From 0882ddb896bcf35a0a1d238fe9502468c6f700ec Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sun, 28 Dec 2014 11:40:48 -0500 Subject: [PATCH] Repair line-clearing bug. --- rmacs/TODO | 6 ------ rmacs/display.rkt | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/rmacs/TODO b/rmacs/TODO index 2f9955c..43dce02 100644 --- a/rmacs/TODO +++ b/rmacs/TODO @@ -1,11 +1,5 @@ Make it reloadable -The status line isn't cleared away when you C-x 0. - - CLUE: also happens when the window is very narrow and a large jump - would clear entire lines, but the lines to be cleared span the - entire window. For example, M-> in xterm_controls.txt when the - window is ~20 chars wide. - Preserve column on up/down better. Catch and handle SIGWINCH. diff --git a/rmacs/display.rkt b/rmacs/display.rkt index 0614b0c..c6b088e 100644 --- a/rmacs/display.rkt +++ b/rmacs/display.rkt @@ -315,12 +315,17 @@ (not (equal? (vector-ref old-line i) (vector-ref new-line i))))) (define (repair-span! tty old new-line row first-col cell-count) - (for ((column (in-range first-col (+ first-col cell-count)))) - (match-define (cons new-pen new-ch) (vector-ref new-line column)) - (when (non-empty? new-ch) - (set-pen tty new-pen) - (output tty (goto-if-needed old row column) new-ch) - (advance-cursor! tty old)))) + (define trailing-empty-count + (for/fold [(empty-count 0)] [(column (in-range first-col (+ first-col cell-count)))] + (match-define (cons new-pen new-ch) (vector-ref new-line column)) + (if (non-empty? new-ch) + (begin (set-pen tty new-pen) + (output tty (goto-if-needed old row column) new-ch) + (advance-cursor! tty old) + 0) + (+ empty-count 1)))) + (when (and (positive? trailing-empty-count) (= (+ first-col cell-count) (tty-columns tty))) + (output tty (ansi:clear-to-eol)))) (define (repair-line! tty old new row) (define columns (screen-columns new)) @@ -343,8 +348,7 @@ columns)) (insert-columns tty cols-to-insert)) (repair-span! tty old new-line row first-col cell-count)))) - (begin (repair-span! tty old new-line row 0 columns) - (output tty (ansi:clear-to-eol))))) + (repair-span! tty old new-line row 0 columns))) (define (tty-flush tty) (define old (tty-displayed-screen tty))