Fix the "terminal emulation" for ascii codes cr and nl. Don't pass
strings containing cr or nl to ncurses (leads to garbled output).
This commit is contained in:
parent
7d0c566c0b
commit
f5c808e10a
|
@ -1,3 +1,7 @@
|
|||
;; turn off debugging for the moment
|
||||
(define debug-message
|
||||
(lambda args #f))
|
||||
|
||||
(define-record-type terminal-buffer :terminal-buffer
|
||||
(really-make-terminal-buffer width height view-index
|
||||
x y buffer repaint?
|
||||
|
@ -100,18 +104,20 @@
|
|||
(set-terminal-buffer-x! termbuf 0))
|
||||
|
||||
(define (terminal-buffer-add-char termbuf char)
|
||||
(debug-message "add-char " termbuf)
|
||||
(debug-message "add-char " termbuf " '" char "' "
|
||||
(char->ascii char))
|
||||
(cond
|
||||
((not (string=? "" (terminal-buffer-esc-code termbuf)))
|
||||
(read-escape-code termbuf char))
|
||||
((char=? char (ascii->char 27))
|
||||
(set-terminal-buffer-esc-code! termbuf (string char)))
|
||||
((char=? char (ascii->char 13))
|
||||
(goto-beginning-of-line termbuf))
|
||||
((char=? char #\newline)
|
||||
(if (cursor-on-last-line? termbuf)
|
||||
(append-empty-line termbuf))
|
||||
(goto-next-line termbuf)
|
||||
(goto-beginning-of-line termbuf))
|
||||
(else
|
||||
(goto-next-line termbuf))
|
||||
((char-set-contains? char-set:printing char)
|
||||
(add-normal-char termbuf char))))
|
||||
|
||||
(define (add-normal-char termbuf char)
|
||||
|
@ -123,7 +129,10 @@
|
|||
(insert-char termbuf char))
|
||||
(else
|
||||
(insert-char termbuf char)
|
||||
(goto-next-char termbuf))))
|
||||
(goto-next-char termbuf)))
|
||||
(debug-message "add-normal-char "
|
||||
(string-length (line-at-cursor-position termbuf))
|
||||
"'" (line-at-cursor-position termbuf) "'"))
|
||||
|
||||
(define (curses-paint-terminal-buffer termbuf win)
|
||||
(if (terminal-buffer-repaint? termbuf)
|
||||
|
@ -139,6 +148,7 @@
|
|||
(if (zero? i)
|
||||
'blorf
|
||||
(begin
|
||||
(debug-message y ": '" (car lines) "'")
|
||||
(mvwaddstr win y 0 (car lines))
|
||||
(lp (- i 1) (cdr lines) (+ y 1)))))
|
||||
(position-cursor termbuf win))
|
||||
|
|
Loading…
Reference in New Issue