From: John Shahid <jvshahid@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Few enhancements to ansi-term
Date: Tue, 30 Apr 2019 13:23:52 -0400 [thread overview]
Message-ID: <87v9yvz9sn.fsf@gmail.com> (raw)
In-Reply-To: <87wojbz9x9.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 84 bytes --]
Apologies, I forgot to attach the patches I am using locally to fix
those issues.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-setting-and-unsetting-scroll-with-delete.patch --]
[-- Type: text/x-patch, Size: 4337 bytes --]
From 174673f0d98b1042ef10a3307bc3956c17b41100 Mon Sep 17 00:00:00 2001
From: John Shahid <jvshahid@gmail.com>
Date: Mon, 29 Apr 2019 13:53:38 -0400
Subject: [PATCH] Fix setting and unsetting scroll-with-delete
* lisp/term.el (term-set-scroll-region): Do not set
term-scroll-with-delete when the region is set to the height of the
terminal.
* lisp/term.el (term-reset-terminal): Reset term-scroll-with-delete.
* test/lisp/term-tests.el (term-scrolling-region): Add more tests to
term mode handle scroll region properly.
---
lisp/term.el | 5 +--
test/lisp/term-tests.el | 78 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 80 insertions(+), 3 deletions(-)
diff --git a/lisp/term.el b/lisp/term.el
index d69ab94b7a..1fe27da181 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -1174,7 +1174,7 @@ term-reset-size
(setq term-start-line-column nil)
(setq term-current-row nil)
(setq term-current-column nil)
- (term-set-scroll-region 0 height)
+ (term-set-scroll-region 0 (1- height))
;; `term-set-scroll-region' causes these to be set, we have to
;; clear them again since we're changing point (Bug#30544).
(setq term-start-line-column nil)
@@ -3215,6 +3215,7 @@ term-reset-terminal
(setq term-current-column 1)
(setq term-scroll-start 0)
(setq term-scroll-end term-height)
+ (setq term-scroll-with-delete nil)
(setq term-insert-mode nil)
;; FIXME: No idea why this is here, it looks wrong. --Stef
(setq term-ansi-face-already-done nil))
@@ -3439,7 +3440,7 @@ term-set-scroll-region
(setq term-scroll-with-delete
(or (term-using-alternate-sub-buffer)
(not (and (= term-scroll-start 0)
- (= term-scroll-end term-height)))))
+ (= term-scroll-end (1- term-height))))))
(term-move-columns (- (term-current-column)))
(term-goto 0 0))
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index 9f5dcd559e..b0b9a11974 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -119,7 +119,83 @@ term-test-screen-from-input
line4\r
line5\r
line6\r
-"))))
+")))
+
+ ;; test reverse scrolling
+ (should (equal "line1
+line7
+line6
+line2
+line5"
+ (term-test-screen-from-input 40 5
+ '("\e[0;0H"
+ "\e[J"
+ "line1\r
+line2\r
+line3\r
+line4\r
+line5"
+ "\e[2;4r"
+ "\e[2;0H"
+ "\e[2;0H"
+ "\eMline6"
+ "\e[2;0H"
+ "\eMline7"))))
+
+ ;; test scrolling down
+ (should (equal "line1
+line3
+line4
+line7
+line5"
+ (term-test-screen-from-input 40 5
+ '("\e[0;0H"
+ "\e[J"
+ "line1\r
+line2\r
+line3\r
+line4\r
+line5"
+ "\e[2;4r"
+ "\e[2;0H"
+ "\e[4;5H"
+ "\n\rline7"))))
+
+ ;; setting the scroll region to the entire height should not turn on
+ ;; term-scroll-with-delete
+ (should (equal "line1
+line2
+line3
+line4
+line5
+line6"
+ (term-test-screen-from-input 40 5
+ '("\e[1;5r"
+ "line1\r
+line2\r
+line3\r
+line4\r
+line5\r
+line6"))))
+
+ ;; reset should reset term-scroll-with-delete
+ (should (equal "line1
+line2
+line3
+line4
+line5
+line6
+line7"
+ (term-test-screen-from-input 40 5
+ '("\e[2;5r" ;set the region
+ "\ec" ;reset
+ "line1\r
+line2\r
+line3\r
+line4\r
+line5\r
+line6\r
+line7")))))
(ert-deftest term-set-directory ()
(let ((term-ansi-at-user (user-real-login-name)))
--
2.21.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-Prevent-accidental-edits-in-the-ansi-term-buffer-fro.patch --]
[-- Type: text/x-patch, Size: 1592 bytes --]
From 6b490f9419e59adb7287b175c2bfca16acc8eb77 Mon Sep 17 00:00:00 2001
From: John Shahid <jvshahid@gmail.com>
Date: Sun, 28 Apr 2019 15:59:50 -0400
Subject: [PATCH] Prevent accidental edits in the ansi-term buffer from
breaking resizing
* lisp/term.el (term-unwrap-line, term-emulate-terminal): Add
rear-nonsticky text property to the newlines used for line wrapping.
---
lisp/term.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lisp/term.el b/lisp/term.el
index b5949c4600..d69ab94b7a 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -2935,7 +2935,8 @@ term-emulate-terminal
(delete-region (point) (line-end-position))
(term-down 1 t)
(term-move-columns (- (term-current-column)))
- (put-text-property (1- (point)) (point) 'term-line-wrap t)
+ (add-text-properties (1- (point)) (point)
+ '(term-line-wrap t rear-nonsticky t))
(setq decoded-substring
(substring decoded-substring (- term-width old-column)))
(setq old-column 0)))
@@ -3754,7 +3755,8 @@ term-unwrap-line
(when (not (bolp))
(let ((old-point (point)))
(insert-before-markers ?\n)
- (put-text-property old-point (point) 'term-line-wrap t))))
+ (add-text-properties old-point (point)
+ '(term-line-wrap t rear-nonsticky t)))))
(defun term-erase-in-line (kind)
(when (= kind 1) ;; erase left of point
--
2.21.0
next prev parent reply other threads:[~2019-04-30 17:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 17:21 Few enhancements to ansi-term John Shahid
2019-04-30 17:23 ` John Shahid [this message]
2019-04-30 18:34 ` Stefan Monnier
2019-04-30 21:50 ` John Shahid
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v9yvz9sn.fsf@gmail.com \
--to=jvshahid@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.