add a command buffer mode indicator
This commit is contained in:
		
							parent
							
								
									73e44b5fbd
								
							
						
					
					
						commit
						75500100b3
					
				| 
						 | 
				
			
			@ -81,9 +81,6 @@
 | 
			
		|||
;;lines to be marked
 | 
			
		||||
(define marked-lines '())
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
;;miscelaneous state
 | 
			
		||||
;;-------------------
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -101,6 +98,21 @@
 | 
			
		|||
(define (focus-result-buffer!)
 | 
			
		||||
  (set! *focus-buffer* 'result-buffer))
 | 
			
		||||
 | 
			
		||||
;; mode of the command buffer
 | 
			
		||||
(define *command-buffer-mode* 'scheme)
 | 
			
		||||
 | 
			
		||||
(define (command-buffer-in-scheme-mode?)
 | 
			
		||||
  (eq? *command-buffer-mode* 'scheme))
 | 
			
		||||
 | 
			
		||||
(define (command-buffer-in-command-mode?)
 | 
			
		||||
  (eq? *command-buffer-mode* 'command))
 | 
			
		||||
 | 
			
		||||
(define (enter-scheme-mode!)
 | 
			
		||||
  (set! *command-buffer-mode* 'scheme))
 | 
			
		||||
 | 
			
		||||
(define (enter-command-mode!)
 | 
			
		||||
  (set! *command-buffer-mode* 'command))
 | 
			
		||||
 | 
			
		||||
;; History
 | 
			
		||||
 | 
			
		||||
(define history-pos 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -211,6 +223,17 @@
 | 
			
		|||
    (move-cursor command-buffer)
 | 
			
		||||
    (refresh-command-window))))
 | 
			
		||||
 | 
			
		||||
(define (toggle-command/scheme-mode)
 | 
			
		||||
  (cond 
 | 
			
		||||
   ((command-buffer-in-command-mode?)
 | 
			
		||||
    (enter-scheme-mode!))
 | 
			
		||||
   ((command-buffer-in-scheme-mode?)
 | 
			
		||||
    (enter-command-mode!)))
 | 
			
		||||
  (paint-command-frame-window)
 | 
			
		||||
  (paint-command-window-contents)
 | 
			
		||||
  (move-cursor command-buffer)
 | 
			
		||||
  (refresh-command-window))
 | 
			
		||||
 | 
			
		||||
;; handle input
 | 
			
		||||
(define (run)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -228,6 +251,11 @@
 | 
			
		|||
     ((= ch key-control-x)
 | 
			
		||||
      (loop (wait-for-input) #t))
 | 
			
		||||
 | 
			
		||||
     ;; F7 toggle scheme-mode / command-mode (FIXME: find a better key)
 | 
			
		||||
     ((= ch key-f7)
 | 
			
		||||
      (toggle-command/scheme-mode)
 | 
			
		||||
      (loop (wait-for-input) #f))
 | 
			
		||||
 | 
			
		||||
     ;; C-x o --- toggle buffer focus
 | 
			
		||||
     ((and c-x-pressed? (= ch key-o))
 | 
			
		||||
      (toggle-buffer-focus)
 | 
			
		||||
| 
						 | 
				
			
			@ -374,9 +402,26 @@
 | 
			
		|||
  (mvwaddstr (app-window-curses-win bar-1) 0 1 "SCSH-NUIT")
 | 
			
		||||
  (wrefresh (app-window-curses-win bar-1)))
 | 
			
		||||
 | 
			
		||||
(define (paint-command-buffer-mode-indicator)
 | 
			
		||||
  (let ((mode-string 
 | 
			
		||||
	 (string-append
 | 
			
		||||
	  "[ "
 | 
			
		||||
	  (if (command-buffer-in-command-mode?)
 | 
			
		||||
	      "Command"
 | 
			
		||||
	      "Scheme")
 | 
			
		||||
	  " ]")))
 | 
			
		||||
    (mvwaddstr 
 | 
			
		||||
     (app-window-curses-win command-frame-window)
 | 
			
		||||
     0 
 | 
			
		||||
     (- (- (app-window-width command-frame-window)
 | 
			
		||||
	   (string-length mode-string)) 
 | 
			
		||||
	2)
 | 
			
		||||
     mode-string)))
 | 
			
		||||
  
 | 
			
		||||
(define (paint-command-frame-window)
 | 
			
		||||
  (box (app-window-curses-win command-frame-window)
 | 
			
		||||
       (ascii->char 0) (ascii->char 0))
 | 
			
		||||
  (paint-command-buffer-mode-indicator)
 | 
			
		||||
  (wrefresh (app-window-curses-win command-frame-window)))
 | 
			
		||||
 | 
			
		||||
(define (paint-command-window-contents)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue