split PAINT into PAINT and WAIT-FOR-INPUT. Call PRINT-RESULT-BUFFER
to redraw only the result-buffer.
This commit is contained in:
		
							parent
							
								
									c9f6b17692
								
							
						
					
					
						commit
						599021b937
					
				| 
						 | 
				
			
			@ -248,7 +248,8 @@
 | 
			
		|||
			       (set! active-keyboard-interrupt a)))
 | 
			
		||||
      
 | 
			
		||||
      ;;Loop
 | 
			
		||||
      (let loop ((ch (paint)))
 | 
			
		||||
      (paint)
 | 
			
		||||
      (let loop ((ch (wait-for-input)))
 | 
			
		||||
	(cond
 | 
			
		||||
       
 | 
			
		||||
	 ;;The result of pressing these keys is independent of which
 | 
			
		||||
| 
						 | 
				
			
			@ -278,17 +279,20 @@
 | 
			
		|||
						 current-result-object
 | 
			
		||||
						 ch)))
 | 
			
		||||
		  (set! current-result-object (switch key-message))))
 | 
			
		||||
	    (loop (paint))))
 | 
			
		||||
	    (paint)
 | 
			
		||||
	    (loop (wait-for-input))))
 | 
			
		||||
 | 
			
		||||
	 ;; forward in result history
 | 
			
		||||
	 ((= ch key-npage)
 | 
			
		||||
	  (history-forward)
 | 
			
		||||
	  (loop (paint)))
 | 
			
		||||
	  (print-result-buffer result-win)
 | 
			
		||||
	  (loop (wait-for-input)))
 | 
			
		||||
 | 
			
		||||
	 ;; back in result history
 | 
			
		||||
	 ((= ch key-ppage)
 | 
			
		||||
	  (history-back)
 | 
			
		||||
	  (loop (paint)))
 | 
			
		||||
	  (print-result-buffer result-win)
 | 
			
		||||
	  (loop (wait-for-input)))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
       	 ;;if lower window is active a message is sent.
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +313,7 @@
 | 
			
		|||
			  (set! current-result-object (switch key-message))))
 | 
			
		||||
		      (set! active-buffer 1))
 | 
			
		||||
		  (set! c-x-pressed #f)
 | 
			
		||||
		  (loop (paint))))
 | 
			
		||||
		  (loop (wait-for-input))))
 | 
			
		||||
 | 
			
		||||
	       ;;C-x r -> redo
 | 
			
		||||
	       ((= ch 114)
 | 
			
		||||
| 
						 | 
				
			
			@ -330,7 +334,7 @@
 | 
			
		|||
			(run)))
 | 
			
		||||
		    (begin
 | 
			
		||||
		      (set! c-x-pressed #f)
 | 
			
		||||
		      (loop (paint)))))
 | 
			
		||||
		      (loop (wait-for-input)))))
 | 
			
		||||
 | 
			
		||||
	       (else
 | 
			
		||||
		(begin
 | 
			
		||||
| 
						 | 
				
			
			@ -348,7 +352,7 @@
 | 
			
		|||
				 (marked-items (switch message)))
 | 
			
		||||
			    (add-string-to-command-buffer marked-items))))
 | 
			
		||||
		  (set! c-x-pressed #f)
 | 
			
		||||
		  (loop (paint)))))
 | 
			
		||||
		  (loop (wait-for-input)))))
 | 
			
		||||
	      
 | 
			
		||||
	      (if (= active-buffer 2)
 | 
			
		||||
		  (let ((key-message 
 | 
			
		||||
| 
						 | 
				
			
			@ -357,7 +361,7 @@
 | 
			
		|||
						   ch)))
 | 
			
		||||
		    (begin
 | 
			
		||||
		      (set! current-result-object (switch key-message))
 | 
			
		||||
		      (loop (paint))))
 | 
			
		||||
		      (loop (wait-for-input))))
 | 
			
		||||
		  
 | 
			
		||||
		  (cond
 | 
			
		||||
		   
 | 
			
		||||
| 
						 | 
				
			
			@ -431,115 +435,111 @@
 | 
			
		|||
			  (set! command-cols num-cols)
 | 
			
		||||
			  (set! can-write-command can-write)
 | 
			
		||||
			  (set! command-history-pos history-pos)))
 | 
			
		||||
		      (loop (paint)))))))))))))
 | 
			
		||||
       
 | 
			
		||||
		      (paint)
 | 
			
		||||
		      (loop (wait-for-input)))))))))))))
 | 
			
		||||
 | 
			
		||||
;;print and wait for input
 | 
			
		||||
(define paint
 | 
			
		||||
  (lambda ()
 | 
			
		||||
  (begin
 | 
			
		||||
    (init-screen)
 | 
			
		||||
    ;(cbreak)
 | 
			
		||||
    (let* ((bar1-y 1)
 | 
			
		||||
	   (bar1-x 1)
 | 
			
		||||
	   (bar1-h 2)
 | 
			
		||||
	   (bar1-w (- (COLS) 2))
 | 
			
		||||
	   (bar2-y (+ (round (/ (LINES) 3)) 2))
 | 
			
		||||
	   (bar2-x 1)
 | 
			
		||||
	   (bar2-h 3)
 | 
			
		||||
	   (bar2-w (- (COLS) 2))
 | 
			
		||||
	   (comwin-y 2)
 | 
			
		||||
	   (comwin-x 1)
 | 
			
		||||
	   (comwin-h (- bar2-y 2))
 | 
			
		||||
	   (comwin-w (- (COLS) 2))
 | 
			
		||||
	   (reswin-y (+ bar2-y 3))
 | 
			
		||||
	   (reswin-x 1)
 | 
			
		||||
	   (reswin-h (- (- (LINES) 6) comwin-h))
 | 
			
		||||
	   (reswin-w (- (COLS) 2)))
 | 
			
		||||
(define (paint)
 | 
			
		||||
  (init-screen)
 | 
			
		||||
  (let* ((bar1-y 1)
 | 
			
		||||
	 (bar1-x 1)
 | 
			
		||||
	 (bar1-h 2)
 | 
			
		||||
	 (bar1-w (- (COLS) 2))
 | 
			
		||||
	 (bar2-y (+ (round (/ (LINES) 3)) 2))
 | 
			
		||||
	 (bar2-x 1)
 | 
			
		||||
	 (bar2-h 3)
 | 
			
		||||
	 (bar2-w (- (COLS) 2))
 | 
			
		||||
	 (comwin-y 2)
 | 
			
		||||
	 (comwin-x 1)
 | 
			
		||||
	 (comwin-h (- bar2-y 2))
 | 
			
		||||
	 (comwin-w (- (COLS) 2))
 | 
			
		||||
	 (reswin-y (+ bar2-y 3))
 | 
			
		||||
	 (reswin-x 1)
 | 
			
		||||
	 (reswin-h (- (- (LINES) 6) comwin-h))
 | 
			
		||||
	 (reswin-w (- (COLS) 2)))
 | 
			
		||||
 | 
			
		||||
      (wclear bar1) 
 | 
			
		||||
      (wclear bar2)
 | 
			
		||||
      (wclear command-win)
 | 
			
		||||
      (wclear result-win)
 | 
			
		||||
      (clear)
 | 
			
		||||
    (wclear bar1) 
 | 
			
		||||
    (wclear bar2)
 | 
			
		||||
    (wclear command-win)
 | 
			
		||||
    (wclear result-win)
 | 
			
		||||
    (clear)
 | 
			
		||||
 | 
			
		||||
      (set! bar1 (newwin bar1-h bar1-w bar1-y bar1-x))
 | 
			
		||||
      (set! bar2 (newwin bar2-h bar2-w bar2-y bar2-x))
 | 
			
		||||
      (set! command-win (newwin  comwin-h comwin-w comwin-y comwin-x))
 | 
			
		||||
      (set! result-win (newwin reswin-h reswin-w reswin-y reswin-x))
 | 
			
		||||
    (set! bar1 (newwin bar1-h bar1-w bar1-y bar1-x))
 | 
			
		||||
    (set! bar2 (newwin bar2-h bar2-w bar2-y bar2-x))
 | 
			
		||||
    (set! command-win (newwin  comwin-h comwin-w comwin-y comwin-x))
 | 
			
		||||
    (set! result-win (newwin reswin-h reswin-w reswin-y reswin-x))
 | 
			
		||||
      
 | 
			
		||||
      ;(box standard-screen (ascii->char 0) (ascii->char 0))
 | 
			
		||||
      ;(refresh)
 | 
			
		||||
      (mvwaddstr bar1  0 1 "SCSH-NUIT")
 | 
			
		||||
      (wrefresh bar1)
 | 
			
		||||
					;(box standard-screen (ascii->char 0) (ascii->char 0))
 | 
			
		||||
					;(refresh)
 | 
			
		||||
    (mvwaddstr bar1  0 1 "SCSH-NUIT")
 | 
			
		||||
    (wrefresh bar1)
 | 
			
		||||
 | 
			
		||||
      (box bar2 (ascii->char 0) (ascii->char 0))
 | 
			
		||||
      (print-active-command-win bar2 bar2-w)
 | 
			
		||||
    (box bar2 (ascii->char 0) (ascii->char 0))
 | 
			
		||||
    (print-active-command-win bar2 bar2-w)
 | 
			
		||||
 | 
			
		||||
      (box command-win (ascii->char 0) (ascii->char 0))
 | 
			
		||||
      (set! command-lines (- comwin-h 2))
 | 
			
		||||
      (set! command-cols (- comwin-w 3))
 | 
			
		||||
    (box command-win (ascii->char 0) (ascii->char 0))
 | 
			
		||||
    (set! command-lines (- comwin-h 2))
 | 
			
		||||
    (set! command-cols (- comwin-w 3))
 | 
			
		||||
      
 | 
			
		||||
      (set! command-buffer (make-buffer text-command 
 | 
			
		||||
					pos-command
 | 
			
		||||
					pos-command-col
 | 
			
		||||
					pos-command-fin-ln
 | 
			
		||||
					command-buffer-pos-y
 | 
			
		||||
					command-buffer-pos-x
 | 
			
		||||
					command-lines
 | 
			
		||||
					command-cols
 | 
			
		||||
					can-write-command
 | 
			
		||||
					command-history-pos))		
 | 
			
		||||
    (set! command-buffer (make-buffer text-command 
 | 
			
		||||
				      pos-command
 | 
			
		||||
				      pos-command-col
 | 
			
		||||
				      pos-command-fin-ln
 | 
			
		||||
				      command-buffer-pos-y
 | 
			
		||||
				      command-buffer-pos-x
 | 
			
		||||
				      command-lines
 | 
			
		||||
				      command-cols
 | 
			
		||||
				      can-write-command
 | 
			
		||||
				      command-history-pos))		
 | 
			
		||||
      
 | 
			
		||||
      (set! command-buffer (print-command-buffer command-win command-buffer))
 | 
			
		||||
    (set! command-buffer (print-command-buffer command-win command-buffer))
 | 
			
		||||
 | 
			
		||||
      (wrefresh command-win)
 | 
			
		||||
      (box result-win (ascii->char 0) (ascii->char 0))
 | 
			
		||||
      (set! result-lines (- reswin-h 2))
 | 
			
		||||
      (set! result-cols (- reswin-w 3))
 | 
			
		||||
      (print-result-buffer result-win)
 | 
			
		||||
      (wrefresh result-win)
 | 
			
		||||
    (wrefresh command-win)
 | 
			
		||||
    (box result-win (ascii->char 0) (ascii->char 0))
 | 
			
		||||
    (set! result-lines (- reswin-h 2))
 | 
			
		||||
    (set! result-cols (- reswin-w 3))
 | 
			
		||||
    (print-result-buffer result-win)
 | 
			
		||||
    (wrefresh result-win)
 | 
			
		||||
 
 | 
			
		||||
      (set! command-buffer (cur-right-pos command-win result-win comwin-h 
 | 
			
		||||
					  reswin-h command-buffer))
 | 
			
		||||
    (set! command-buffer (cur-right-pos command-win result-win comwin-h 
 | 
			
		||||
					reswin-h command-buffer))
 | 
			
		||||
 | 
			
		||||
      (let ((text (buffer-text command-buffer))
 | 
			
		||||
	    (pos-line (buffer-pos-line command-buffer))
 | 
			
		||||
	    (pos-col (buffer-pos-col command-buffer))
 | 
			
		||||
	    (pos-fin-ln (buffer-pos-fin-ln command-buffer))
 | 
			
		||||
	    (pos-y (buffer-pos-y command-buffer))
 | 
			
		||||
	    (pos-x (buffer-pos-x command-buffer))
 | 
			
		||||
	    (num-lines (buffer-num-lines command-buffer))
 | 
			
		||||
	    (num-cols (buffer-num-cols command-buffer))
 | 
			
		||||
	    (can-write (buffer-can-write command-buffer))
 | 
			
		||||
	    (history-pos (buffer-history-pos command-buffer)))
 | 
			
		||||
	(begin
 | 
			
		||||
	  (set! text-command text)
 | 
			
		||||
	  (set! pos-command pos-line)
 | 
			
		||||
	  (set! pos-command-col pos-col)
 | 
			
		||||
	  (set! pos-command-fin-ln pos-fin-ln)
 | 
			
		||||
	  (set! command-buffer-pos-y pos-y)
 | 
			
		||||
	  (set! command-buffer-pos-x pos-x)
 | 
			
		||||
	  (set! command-lines num-lines)
 | 
			
		||||
	  (set! command-cols num-cols)
 | 
			
		||||
	  (set! can-write-command can-write)
 | 
			
		||||
	  (set! command-history-pos history-pos)))
 | 
			
		||||
    (let ((text (buffer-text command-buffer))
 | 
			
		||||
	  (pos-line (buffer-pos-line command-buffer))
 | 
			
		||||
	  (pos-col (buffer-pos-col command-buffer))
 | 
			
		||||
	  (pos-fin-ln (buffer-pos-fin-ln command-buffer))
 | 
			
		||||
	  (pos-y (buffer-pos-y command-buffer))
 | 
			
		||||
	  (pos-x (buffer-pos-x command-buffer))
 | 
			
		||||
	  (num-lines (buffer-num-lines command-buffer))
 | 
			
		||||
	  (num-cols (buffer-num-cols command-buffer))
 | 
			
		||||
	  (can-write (buffer-can-write command-buffer))
 | 
			
		||||
	  (history-pos (buffer-history-pos command-buffer)))
 | 
			
		||||
      (begin
 | 
			
		||||
	(set! text-command text)
 | 
			
		||||
	(set! pos-command pos-line)
 | 
			
		||||
	(set! pos-command-col pos-col)
 | 
			
		||||
	(set! pos-command-fin-ln pos-fin-ln)
 | 
			
		||||
	(set! command-buffer-pos-y pos-y)
 | 
			
		||||
	(set! command-buffer-pos-x pos-x)
 | 
			
		||||
	(set! command-lines num-lines)
 | 
			
		||||
	(set! command-cols num-cols)
 | 
			
		||||
	(set! can-write-command can-write)
 | 
			
		||||
	(set! command-history-pos history-pos)))
 | 
			
		||||
 | 
			
		||||
      ;(refresh)
 | 
			
		||||
      ; (wrefresh command-win)
 | 
			
		||||
					;(refresh)
 | 
			
		||||
					; (wrefresh command-win)
 | 
			
		||||
;       (wrefresh result-win)
 | 
			
		||||
;       (wrefresh bar1)
 | 
			
		||||
;       (wrefresh bar2)
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      (noecho)
 | 
			
		||||
      (keypad bar1 #t)
 | 
			
		||||
      (set! active-keyboard-interrupt #f)
 | 
			
		||||
      (let ((ch (wgetch bar1)))
 | 
			
		||||
	(echo)
 | 
			
		||||
	  ch
 | 
			
		||||
	)))))
 | 
			
		||||
    ))
 | 
			
		||||
 | 
			
		||||
(define (wait-for-input)
 | 
			
		||||
  (noecho)
 | 
			
		||||
  (keypad bar1 #t)
 | 
			
		||||
  (set! active-keyboard-interrupt #f)
 | 
			
		||||
  (let ((ch (wgetch bar1)))
 | 
			
		||||
    (echo)
 | 
			
		||||
    ch))
 | 
			
		||||
 | 
			
		||||
;;If the user presses enter the last line is interpreted as a command
 | 
			
		||||
;;which has to be executed.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue