emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 8a1576c: Fix term.el cursor movement at bottom ma


From: Noam Postavsky
Subject: [Emacs-diffs] emacs-26 8a1576c: Fix term.el cursor movement at bottom margin (Bug#31690)
Date: Sun, 10 Jun 2018 19:03:38 -0400 (EDT)

branch: emacs-26
commit 8a1576cc03963138d62c42bd373226e58f9f17c6
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Fix term.el cursor movement at bottom margin (Bug#31690)
    
    * lisp/term.el (term-handle-ansi-escape) <\E[B cud>: Allow moving the
    cursor to the bottom margin line, rather than stopping one line
    before.
---
 lisp/term.el            |  7 +++----
 test/lisp/term-tests.el | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/lisp/term.el b/lisp/term.el
index 419ddb2..60cd547 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -3387,11 +3387,10 @@ option is enabled.  See `term-set-goto-process-mark'."
    ;; \E[B - cursor down (terminfo: cud)
    ((eq char ?B)
     (let ((tcr (term-current-row)))
-      (unless (= tcr (1- term-scroll-end))
+      (unless (>= tcr term-scroll-end)
        (term-down
-        (if (> (+ tcr term-terminal-parameter) term-scroll-end)
-            (- term-scroll-end 1 tcr)
-          (max 1 term-terminal-parameter)) t))))
+         (min (- term-scroll-end tcr) (max 1 term-terminal-parameter))
+         t))))
    ;; \E[C - cursor right (terminfo: cuf, cuf1)
    ((eq char ?C)
     (term-move-columns
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index 234dfa1..7fd8d12 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -124,6 +124,27 @@ line6\r
                     40 12 (list "\eAnSiTc /f" "oo/\n") 'default-directory)
                    "/foo/"))))
 
+(ert-deftest term-to-margin ()
+  "Test cursor movement at the scroll margin.
+This is a reduced example from GNU nano's initial screen."
+  (let* ((width 10)
+         (x (make-string width ?x))
+         (y (make-string width ?y)))
+    (should (equal (term-test-screen-from-input
+                    width 3
+                    `("\e[1;3r"       ; Setup 3 line scrolling region.
+                      "\e[2;1H"       ; Move to 2nd last line.
+                      ,x              ; Fill with 'x'.
+                      "\r\e[1B"       ; Next line.
+                      ,y))            ; Fill with 'y'.
+                   (concat "\n" x "\n" y)))
+    ;; Same idea, but moving upwards.
+    (should (equal (term-test-screen-from-input
+                    width 3
+                    `("\e[1;3r" "\e[2;1H" ,x "\r\e[1A" ,y))
+                   (concat y "\n" x)))))
+
+
 (provide 'term-tests)
 
 ;;; term-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]