From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#53485: 29.0.50; [PATCH] Implement alternative sub-buffer support in term.el Date: Sun, 23 Jan 2022 22:00:07 +0100 Message-ID: <87pmoicgmg.fsf@miha-pc> Reply-To: miha@kamnitnik.top Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36296"; mail-complaints-to="usenet@ciao.gmane.io" To: 53485@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 23 21:54:32 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBjsc-000993-QR for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Jan 2022 21:54:31 +0100 Original-Received: from localhost ([::1]:57560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBjsb-0004iS-Op for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Jan 2022 15:54:29 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBjsA-0004fm-FQ for bug-gnu-emacs@gnu.org; Sun, 23 Jan 2022 15:54:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nBjsA-0000V8-5r for bug-gnu-emacs@gnu.org; Sun, 23 Jan 2022 15:54:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nBjsA-0007ut-6Z for bug-gnu-emacs@gnu.org; Sun, 23 Jan 2022 15:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: miha@kamnitnik.top Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Jan 2022 20:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 53485 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.164297123430415 (code B ref -1); Sun, 23 Jan 2022 20:54:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Jan 2022 20:53:54 +0000 Original-Received: from localhost ([127.0.0.1]:41377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nBjs2-0007uU-3E for submit@debbugs.gnu.org; Sun, 23 Jan 2022 15:53:54 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:59550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nBjs0-0007uN-JR for submit@debbugs.gnu.org; Sun, 23 Jan 2022 15:53:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBjs0-0004bn-Bl for bug-gnu-emacs@gnu.org; Sun, 23 Jan 2022 15:53:52 -0500 Original-Received: from kamnitnik.top ([209.250.245.214]:45744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBjry-0000U4-0D for bug-gnu-emacs@gnu.org; Sun, 23 Jan 2022 15:53:52 -0500 Original-Received: from localhost (BSN-77-156-43.static.siol.net [193.77.156.43]) by kamnitnik.top (Postfix) with ESMTPSA id 13F869C713 for ; Sun, 23 Jan 2022 20:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1642971223; bh=Abt7nSImBsGbjLbaM5huzHw1H6La1n2M2WQKBhfgTfk=; h=From:To:Subject:Date:From; b=rSD1IDg8YbuJoHeJ9xop5shd2HZbpTIcv3o4OacS1ZDyiACeIffbrg/6p9nsUEG56 qhGRr/9DC1AZ2o8mmN8dEuJI1TZQ/cu5Vej5//DjfXnFilTP9yHSNBXskWaw9/XwNG gcGO6YPl/fjgeRHn/lygUZUE0pR7jHWEtCut4ZPel3yqpf61KO8aE2yH+cFlJ31tvc 0TnyZFClA5ZZjQ7i9ODa4YGBHGBnKnDXZvQwjQvwGmvYNIpU7pJEekXXc9gWjyIyus 7b84+FM6eMGvbc6jwaxEq3jPDESniPaLqPLaG28fRWIPW9fi1C2PLy7IzdDHMkJx1m /tIdgjRmlCFOQ== Received-SPF: pass client-ip=209.250.245.214; envelope-from=miha@kamnitnik.top; helo=kamnitnik.top X-Spam_score_int: 19 X-Spam_score: 1.9 X-Spam_bar: + X-Spam_report: (1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.479, PDS_OTHER_BAD_TLD=1.997, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:224969 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain In M-x term, try: $ seq 100 $ htop Press 'q' to exit htop. (Instead of 'htop', you could also try with 'emacs -q', 'vi' or any other full-screen TUI program.) Current behaviour: htop overwrites a portion of output from the 'seq' command and htop's contents remain visible on the screen after pressing 'q'. Proposed behaviour (patch attached): avoid overwriting output from the 'seq' command and erase htop's contents after exiting. This is the default behaviour of xterm, st and most other terminal emulators. Best regards. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Implement-alternative-sub-buffer-support-in-term.el.patch Content-Transfer-Encoding: quoted-printable From=2041d2f635612c2ef7e046b8f38bd81d0393a7a730 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Sun, 23 Jan 2022 21:13:24 +0100 Subject: [PATCH] Implement alternative sub-buffer support in term.el * etc/e/eterm-color.ti: Added termcaps for entering and leaving an alternative sub-buffer. * lisp/term.el (term-reset-size): Resize correctly in an alternative sub-buffer is in use. (term-handle-ansi-escape): (term-termcap-format): Handle termcaps for entering and leaving an alternative sub-buffer. (term-switch-to-alternate-sub-buffer): New (used to be commented out) function to enter or leave an alternative sub-buffer. =2D-- etc/e/eterm-color | Bin 1296 -> 1318 bytes etc/e/eterm-color.ti | 5 +-- etc/e/eterm-direct | Bin 1375 -> 1397 bytes lisp/term.el | 80 ++++++++++++++++++++++++------------------- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/etc/e/eterm-color b/etc/e/eterm-color index bf44fa0f36de0f6681fa3172db13a83c414aa42a..fadac25ffcb55b3b3f6812e9c80= f848e94f3dcc3 100644 GIT binary patch delta 283 zcmbQhwTz2fiqV}xl7XKglkwCn)5<@zW&S5BIC4glF4H;!5mNKjYa@GU!W`-RMd!Y&rGEAPxsAO}L z;T*$th6g~wmkgg6egkP1MwodJnit9!0Mf#YVvG_{zBJ?Hi;PxGvLNc@WC2EYCM8Co zk$PO}j7DH3=3D8Qn=3DrNkVd>XA)#1!?kP_Gavw9LOBSY+{}@QmR-kp2Nx0yCMB5yD~t((H^}j66_2KjY+wj8;s7AnGvCEM6ut#>opA^|+)N r)xb)$87Dh3N{N|3)x*pK(Uu@hUd;B4b(5o+qbBcWR^I%C*@+PVcS)1K diff --git a/etc/e/eterm-color.ti b/etc/e/eterm-color.ti index eeb9b0b6e6..84b27aef5d 100644 =2D-- a/etc/e/eterm-color.ti +++ b/etc/e/eterm-color.ti @@ -16,6 +16,7 @@ eterm-color|Emacs term.el terminal emulator term-protocol= -version 0.96, am, mir, msgr, + nrrmc, xenl, bel=3D^G, blink=3D\E[5m, @@ -77,8 +78,8 @@ eterm-color|Emacs term.el terminal emulator term-protocol= -version 0.96, smso=3D\E[7m, u6=3D\E[%i%d;%dR, u7=3D\E[6n, =2D# smcup=3D\E[?47h, =2D# rmcup=3D\E[?47l, + smcup=3D\E[47h, + rmcup=3D\E[47l, # rs2 may need to be added =20 eterm-direct|Emacs term.el with direct-color indexing term-protocol-versio= n 0.96, diff --git a/etc/e/eterm-direct b/etc/e/eterm-direct index c113c3713693b948ae9d52e75df5d89957fd0c77..f4c16621eb185d7d0de14b56fb2= e2b73a57adab8 100644 GIT binary patch delta 259 zcmcc5^_7cTjwz5ql7XKglkww3?nF)o7?_w{>JrZI|9>n)5<@zW&S5BIC4gjv8)YPxGOPl!*8}lph8+xhq4EbACLd%}vOdai zj^R4P1EAnbhEEK?fiw#v%s2?m3*`#{X<gMrG@r42Kv_Gh6`*-DP;j z@E%D2fJ(zmWMqV}Sb#J;BNrnNl+Qm|ky&{11x5`I)2BRfZu?4d| term-home-marker home-marker) + (let ((inhibit-read-only t)) + (delete-region home-marker term-home-marker))))))) =20 ;; Recursive routine used to check if any string in term-kill-echo-list ;; matches part of the buffer before point. @@ -1611,6 +1621,7 @@ term-termcap-format "%s%s:li#%d:co#%d:cl=3D\\E[H\\E[J:cd=3D\\E[J:bs:am:xn:cm=3D\\E[%%i%%d;%%= dH\ :nd=3D\\E[C:up=3D\\E[A:ce=3D\\E[K:ho=3D\\E[H:pt\ :al=3D\\E[L:dl=3D\\E[M:DL=3D\\E[%%dM:AL=3D\\E[%%dL:cs=3D\\E[%%i%%d;%%dr:sf= =3D^J\ +:NR:te=3D\\E[47l:ti=3D\\E[47h\ :dc=3D\\E[P:DC=3D\\E[%%dP:IC=3D\\E[%%d@:im=3D\\E[4h:ei=3D\\E[4l:mi:\ :mb=3D\\E[5m:mh=3D\\E[2m:ZR=3D\\E[23m:ZH=3D\\E[3m\ :so=3D\\E[7m:se=3D\\E[m:us=3D\\E[4m:ue=3D\\E[m:md=3D\\E[1m:mr=3D\\E[7m:me= =3D\\E[m\ @@ -3539,16 +3550,14 @@ term-handle-ansi-escape ((eq char ?h) (cond ((eq (car params) 4) ;; (terminfo: smir) (setq term-insert-mode t)) =2D ;; ((eq (car params) 47) ;; (terminfo: smcup) =2D ;; (term-switch-to-alternate-sub-buffer t)) =2D )) + ((eq (car params) 47) ;; (terminfo: smcup) + (term-switch-to-alternate-sub-buffer t)))) ;; \E[?l - DEC Private Mode Reset ((eq char ?l) (cond ((eq (car params) 4) ;; (terminfo: rmir) (setq term-insert-mode nil)) =2D ;; ((eq (car params) 47) ;; (terminfo: rmcup) =2D ;; (term-switch-to-alternate-sub-buffer nil)) =2D )) + ((eq (car params) 47) ;; (terminfo: rmcup) + (term-switch-to-alternate-sub-buffer nil)))) =20 ;; Modified to allow ansi coloring -mm ;; \E[m - Set/reset modes, set bg/fg @@ -3595,32 +3604,33 @@ term-set-scroll-region (term-move-columns (- (term-current-column))) (term-goto 0 0)) =20 =2D;; (defun term-switch-to-alternate-sub-buffer (set) =2D;; ;; If asked to switch to (from) the alternate sub-buffer, and alrea= dy (not) =2D;; ;; using it, do nothing. This test is needed for some programs (in= cluding =2D;; ;; Emacs) that emit the ti termcap string twice, for unknown reason. =2D;; (term-handle-deferred-scroll) =2D;; (if (eq set (not (term-using-alternate-sub-buffer))) =2D;; (let ((row (term-current-row)) =2D;; (col (term-horizontal-column))) =2D;; (cond (set =2D;; (goto-char (point-max)) =2D;; (if (not (eq (preceding-char) ?\n)) =2D;; (term-insert-char ?\n 1)) =2D;; (setq term-scroll-with-delete t) =2D;; (setq term-saved-home-marker (copy-marker term-home-marker)) =2D;; (set-marker term-home-marker (point))) =2D;; (t =2D;; (setq term-scroll-with-delete =2D;; (not (and (=3D term-scroll-start 0) =2D;; (=3D term-scroll-end term-height)))) =2D;; (set-marker term-home-marker term-saved-home-marker) =2D;; (set-marker term-saved-home-marker nil) =2D;; (setq term-saved-home-marker nil) =2D;; (goto-char term-home-marker))) =2D;; (setq term-current-column nil) =2D;; (setq term-current-row 0) =2D;; (term-goto row col)))) +(defun term-switch-to-alternate-sub-buffer (set) + ;; If asked to switch to (from) the alternate sub-buffer, and already (n= ot) + ;; using it, do nothing. This test is needed for some programs (includi= ng + ;; Emacs) that emit the ti termcap string twice, for unknown reason. + (term-handle-deferred-scroll) + (when (eq set (not (term-using-alternate-sub-buffer))) + (let ((row (term-current-row)) + (col (term-horizontal-column))) + (cond (set + (goto-char (point-max)) + (if (not (eq (preceding-char) ?\n)) + (term-insert-char ?\n 1)) + (setq term-scroll-with-delete t) + (setq term-saved-home-marker (copy-marker term-home-marker)) + (set-marker term-home-marker (point))) + (t + (setq term-scroll-with-delete + (not (and (=3D term-scroll-start 0) + (=3D term-scroll-end (term--last-line))))) + (delete-region term-home-marker (point-max)) + (set-marker term-home-marker term-saved-home-marker) + (set-marker term-saved-home-marker nil) + (setq term-saved-home-marker nil) + (goto-char (point-max)))) + (setq term-current-column nil) + (setq term-current-row nil) + (term-goto row col)))) =20 ;; Default value for the symbol term-command-function. =20 =2D-=20 2.34.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmHtwdcTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP82rD/9b8SxFAYuMjfVG2Vv/uCR2TE4+BChI 8JuM0CxQB8jOVDGKmeOPpSIANKAnxXUI9dEH9PQjMyswBxpEKPplttKpM3qapktA CfvdsI8JqdeKETVNzD17Z5Qua2mhBlao8d/f8AC0tUHytbCj+wg4XKTzA0bCnIQn DRi/58NniANkwrZLnL+raKQ1qtC/kPNN7/9gNVyzMXM8zO4pKjbmdtHQM6dUumGW uAWchgrRnvZngoZrY7/XlEGMLy/Z/AqN0G0Qvy0hmPOvG/Vk70VQmzbbdu5NFnPf OLDVVNXQoWvA4HqS1Lrh+/3pM1nTzw1V4McwA+AHea9lL9AGuyfkROYrl62D8w5d L6N9AeA5UysBo038SBaipVx/t1UOySXXO1t25uL1XTBT7BTMf7x9VAUarBw1AX2t 0MIExpTxF0bgFv/H2CnxRm6VV8Lm8Xv1+1v29CcCiiflZW32I/se8U/JIWCWBX/Z cK9ZTmxX5pbrgChwwf4CC+QmPQoVkcIrKqcD60Ie8veVv743i/pISWekBppVS85R A9D0aX9rEilyn11x2+Hnl91q1SeTpjR4D07TCgSBGOa8b7E6NfeRB/BuXWMQakzm 5/S3TXZ3pqBdnXlXO5zZLyvMomfFmgRrIwlmvWPUYmDcn0h/o1q204DSqhZj/nUO JeUxWXtLy0qq1w== =X5WT -----END PGP SIGNATURE----- --==-=-=--