unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#31690: 26.1; term.el doesn't move cursor down into last row
@ 2018-06-02 21:03 Noam Postavsky
  2018-06-08 14:52 ` Eli Zaretskii
  2018-06-10 23:08 ` Noam Postavsky
  0 siblings, 2 replies; 3+ messages in thread
From: Noam Postavsky @ 2018-06-02 21:03 UTC (permalink / raw)
  To: 31690

[-- Attachment #1: Type: text/plain, Size: 208 bytes --]

Tags: patch

GNU nano fails to display the bottom line correctly in M-x term, as
reported in [1].  This is due an off by one error in the handling of the
down cursor escape sequence (\e[B).  Here's a patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2439 bytes --]

From a7c394806d3b97f65c4b3687ee67908d8a1eb7a9 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sat, 2 Jun 2018 15:57:33 -0400
Subject: [PATCH] Fix term.el cursor movement at bottom margin

* 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 75c2779783..c36224566b 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -3386,11 +3386,10 @@ term-handle-ansi-escape
    ;; \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 234dfa1f0d..7fd8d1293d 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -124,6 +124,27 @@ term-test-screen-from-input
                     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
-- 
2.11.0


[-- Attachment #3: Type: text/plain, Size: 403 bytes --]


[1]: https://emacs.stackexchange.com/questions/41796/nano-not-displaying-correctly-in-term-and-ansi-term

In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2018-04-09 built on zebian
Repository revision: 24ba63314f29fdffa9cfe012927e5efd744c138d
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description:	Debian GNU/Linux 9.3 (stretch)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#31690: 26.1; term.el doesn't move cursor down into last row
  2018-06-02 21:03 bug#31690: 26.1; term.el doesn't move cursor down into last row Noam Postavsky
@ 2018-06-08 14:52 ` Eli Zaretskii
  2018-06-10 23:08 ` Noam Postavsky
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2018-06-08 14:52 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 31690

> From: Noam Postavsky <npostavs@gmail.com>
> Date: Sat, 02 Jun 2018 17:03:56 -0400
> 
> GNU nano fails to display the bottom line correctly in M-x term, as
> reported in [1].  This is due an off by one error in the handling of the
> down cursor escape sequence (\e[B).  Here's a patch:

LGTM.  Should this go to emacs-26 or to master?





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#31690: 26.1; term.el doesn't move cursor down into last row
  2018-06-02 21:03 bug#31690: 26.1; term.el doesn't move cursor down into last row Noam Postavsky
  2018-06-08 14:52 ` Eli Zaretskii
@ 2018-06-10 23:08 ` Noam Postavsky
  1 sibling, 0 replies; 3+ messages in thread
From: Noam Postavsky @ 2018-06-10 23:08 UTC (permalink / raw)
  To: 31690

[-- Attachment #1: Type: text/plain, Size: 40 bytes --]

tags 31690 fixed
close 31690 26.2
quit


[-- Attachment #2: Type: message/rfc822, Size: 812 bytes --]

From: Eli Zaretskii <eliz@gnu.org>
To: Noam Postavsky <npostavs@gmail.com>
Subject: Re: bug#31690: 26.1; term.el doesn't move cursor down into last row
Date: Fri, 08 Jun 2018 21:04:30 +0300
Message-ID: <83vaattas1.fsf@gnu.org>

> From: Noam Postavsky <npostavs@gmail.com>
> Date: Fri, 8 Jun 2018 11:05:15 -0400
> Cc: Eli Zaretskii <eliz@gnu.org>
> 
> I think this should go to emacs-26; it's not a regression (afaik) but
> it's a pretty straightforward fix.

OK.

[-- Attachment #3: Type: text/plain, Size: 485 bytes --]



Pushed to emacs-26 [1: 8a1576cc03], and merged to master (it needed some
manual conflict resolution [2: 962547791e]).

[1: 8a1576cc03]: 2018-06-10 17:57:50 -0400
  Fix term.el cursor movement at bottom margin (Bug#31690)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=8a1576cc03963138d62c42bd373226e58f9f17c6

[2: 962547791e]: 2018-06-10 18:47:27 -0400
  Merge from emacs-26
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=962547791e6ea16b18512e6b933a5317c464da26

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-10 23:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-02 21:03 bug#31690: 26.1; term.el doesn't move cursor down into last row Noam Postavsky
2018-06-08 14:52 ` Eli Zaretskii
2018-06-10 23:08 ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).