From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#31690: 26.1; term.el doesn't move cursor down into last row Date: Sat, 02 Jun 2018 17:03:56 -0400 Message-ID: <87k1rgaojn.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1527973389 31266 195.159.176.226 (2 Jun 2018 21:03:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 2 Jun 2018 21:03:09 +0000 (UTC) To: 31690@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 02 23:03:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPDg0-00081x-TI for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Jun 2018 23:03:05 +0200 Original-Received: from localhost ([::1]:32792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPDi8-00050Y-2k for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Jun 2018 17:05:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPDhx-00050S-KL for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 17:05:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPDhu-00034V-Ez for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 17:05:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51702) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPDhu-00034R-9r for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 17:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fPDht-0005Rv-VV for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 17:05:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Jun 2018 21:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31690 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.152797345220882 (code B ref -1); Sat, 02 Jun 2018 21:05:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Jun 2018 21:04:12 +0000 Original-Received: from localhost ([127.0.0.1]:59599 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPDh6-0005Qj-Bw for submit@debbugs.gnu.org; Sat, 02 Jun 2018 17:04:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPDh4-0005QV-NM for submit@debbugs.gnu.org; Sat, 02 Jun 2018 17:04:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPDgy-0002ik-9C for submit@debbugs.gnu.org; Sat, 02 Jun 2018 17:04:05 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:48286) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fPDgy-0002ie-5X for submit@debbugs.gnu.org; Sat, 02 Jun 2018 17:04:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPDgw-0004pp-Qn for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 17:04:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPDgt-0002hm-NW for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 17:04:02 -0400 Original-Received: from mail-io0-x233.google.com ([2607:f8b0:4001:c06::233]:44537) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPDgt-0002hZ-GU for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 17:03:59 -0400 Original-Received: by mail-io0-x233.google.com with SMTP id g7-v6so9845600ioh.11 for ; Sat, 02 Jun 2018 14:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=/KIvEUj/lu+9aE+Qvu1Q45Du432gThyp/+IpUaQJZ9Q=; b=GVKts2jeCLjLHEdOlCAPRfpSXMCHHlFxAWAHNOZpcdFZQDEUwFXYzuNsCqOLk9iGzf jIvsBL5xPO5aLGDHf9UcFPV3yOcK3aONrnYF3WsIFMk5DBUKFaxLv5ly/JQvdUkjhdf8 kdVihSGIxlcKgRzYOuCUoyIsTGEieEzrrSLHu1bXcIEJPMfhfd6oP0TgNW1iblCXAEJs VdWsfDzN1t+ZWkWaCdNMF5K5I+YitKIwQGfxx4YeI3RWL0/v7jE+TjxtOZTmqM7gNk1L hu6gSGWnL30OKpfM9HmNpDk0mIE2+OkPAthnUT59uGqvP3xGwnEIICR5x+fjP9PiGpAb B1Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=/KIvEUj/lu+9aE+Qvu1Q45Du432gThyp/+IpUaQJZ9Q=; b=MgemiZJwHq1ggqFDs82JpZniL3LMxdm+OJBGkp1jMYgeLGhzq59baTfkusg+n1WBWY JVeO9zfQhlCvrb73FRWN4H9KEEdFW4v3r1lY6qXy2Q0j+pHvSnSgqnQKZ52pZ4qOXpoC ubLClXl7KCp2Mg/3Tslfoey6Kbwif9KEgtQL/2W0R67dWBcJazgoxcVJt3xIhNCmQYPd SGCXTC+7BOD9oqPPoH19wcgJ3WLl3miY9nz3N6DNNKDYlA6uv/bkihkMc8f67e4hYDnA ZTEm3Mk6J9bNGXApLMZLLal6AbqO8tSI66MEMZi4h/+rV9BWZsiNYwyQI0p7w28oC4qk g6uw== X-Gm-Message-State: ALKqPwcnpRT95js6oTqfg6/VT2FNncCnw/oHKYswIW0LjrjDvfWotPPy KDBb3pRloC+V67+bT5TV/8ZJ8w== X-Google-Smtp-Source: ADUXVKLzjTsQOegxN/jvl6mXh2sH42h/mlZlb8ps4AFaZDgjHDcRsctugHnYy8kYE8P+dy/JciEPbA== X-Received: by 2002:a6b:882a:: with SMTP id k42-v6mr15684701iod.137.1527973438729; Sat, 02 Jun 2018 14:03:58 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id o137-v6sm3190473ioe.3.2018.06.02.14.03.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 02 Jun 2018 14:03:57 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:146878 Archived-At: --=-=-= Content-Type: text/plain 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-term.el-cursor-movement-at-bottom-margin.patch Content-Description: patch >From a7c394806d3b97f65c4b3687ee67908d8a1eb7a9 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-= Content-Type: text/plain [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) --=-=-=--