This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository terminology.

View the commit online.

commit 65319e01c42b6c35d3db45407014ba258ecffc6a
Author: Boris Faure <[email protected]>
AuthorDate: Sun Nov 29 15:15:19 2026 +0000

    termptyesc: let DECSET 1007 turn off alternate scroll
    
    DECSET 1007 (alternate scroll, ctlseqs.txt:982-983) asks that on the
    alternate screen, with no mouse reporting, the wheel send cursor up/down
    instead of scrolling the history. Terminology has always done that, but
    had no mode bit for it, so CSI ? 1007 h/l fell through to the unhandled
    branch and Codex printed the sequence on stdout at every start and exit.
    
    Add alternate_scroll to Term_State, on in termpty_reset_state() so RIS
    keeps today's behaviour (DECSTR leaves the application's setting, as in
    foot and xterm), set/reset by case 1007, reported to DECRQM, and
    honoured in termio_internal_mouse_wheel(): when off, the wheel on the
    alternate screen falls through to the history scroll, which has no
    history there, so nothing moves, as in xterm.
    
    Default on, not off as in xterm: it is what Terminology has always done,
    and foot (alternate-scroll-mode) and ghostty (mouse_alternate_scroll)
    default it on too.
---
 src/bin/termiointernals.c |  2 +-
 src/bin/termpty.h         |  1 +
 src/bin/termptyesc.c      |  8 ++++++++
 src/bin/termptyops.c      |  3 +++
 tests/decset-1007.sh      | 18 ++++++++++++++++++
 tests/tests.results       |  1 +
 6 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/bin/termiointernals.c b/src/bin/termiointernals.c
index ec8191bd..748fc92e 100644
--- a/src/bin/termiointernals.c
+++ b/src/bin/termiointernals.c
@@ -2167,7 +2167,7 @@ termio_internal_mouse_wheel(Termio *sd,
 
    if (sd->pty->mouse_mode == MOUSE_OFF)
      {
-        if (sd->pty->altbuf)
+        if (sd->pty->altbuf && sd->pty->termstate.alternate_scroll)
           {
              /* Emulate cursors */
              buf[0] = 0x1b;
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 4a5326ec..c1dd8a1c 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -158,6 +158,7 @@ typedef struct tag_Term_State {
     unsigned int  numlock_mode : 1;
     unsigned int  insert : 1;
     unsigned int  appcursor : 1;
+    unsigned int  alternate_scroll : 1;
     unsigned int  wrap : 1;
     unsigned int  crlf : 1;
     unsigned int  send_bs : 1;
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 24b5e15a..f6f40014 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -677,6 +677,12 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b,
                    else ty->mouse_ext = MOUSE_EXT_NONE;
                    DBG("set mouse (xterm sgr style) %i", mode);
                    break;
+                case 1007: /* alternate scroll: on the alternate screen with
+                            * no mouse reporting, the wheel sends cursor
+                            * keys instead of scrolling the history */
+                   DBG("alternate scroll mode %i", mode);
+                   ty->termstate.alternate_scroll = mode;
+                   break;
                 case 1010: // ignore
                    WRN("TODO: set home on tty output %i", mode);
                    ty->decoding_error = EINA_TRUE;
@@ -897,6 +903,8 @@ _dec_private_mode_status(const Termpty *ty, int mode)
          return _decrpm_from_bool(ty->mouse_ext == MOUSE_EXT_UTF8);
       case 1006:
          return _decrpm_from_bool(ty->mouse_ext == MOUSE_EXT_SGR);
+      case 1007: /* alternate scroll */
+         return _decrpm_from_bool(ty->termstate.alternate_scroll);
       case 1015:
          return _decrpm_from_bool(ty->mouse_ext == MOUSE_EXT_URXVT);
       case 1016: /* SGR with pixel coordinates, not implemented */
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index db48c1d5..9f6f136e 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -854,6 +854,9 @@ void
 termpty_reset_state(Termpty *ty)
 {
    termpty_soft_reset_state(ty);
+   /* RIS restores the built-in default: alternate scroll on, as it has
+    * always been. DECSTR (soft reset) leaves the application's setting. */
+   ty->termstate.alternate_scroll = 1;
    ty->color_scheme_reporting = 0;
    ty->cursor_state.cx = 0;
    ty->cursor_state.cy = 0;
diff --git a/tests/decset-1007.sh b/tests/decset-1007.sh
new file mode 100755
index 00000000..b0719d43
--- /dev/null
+++ b/tests/decset-1007.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# shellcheck source=tests/utils.sh
+. "$(dirname "$0")/utils.sh"
+
+printf '\033[?1049h'
+printf '\033[?1007\044p'
+# default: the wheel sends cursor keys
+printf '\033}tw;10;10;1;1;0\0'
+printf '\033}tw;10;10;0;1;0\0'
+printf '\033[?1h'
+printf '\033}tw;10;10;1;1;0\0'
+printf '\033[?1l'
+# off: no cursor keys
+printf '\033[?1007l'
+printf '\033[?1007\044p'
+printf '\033}tw;10;10;1;1;0\0'
+printf '\033[?1007h'
+printf '\033[?1007\044p'
diff --git a/tests/tests.results b/tests/tests.results
index dd9a5141..c1851e5f 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -210,6 +210,7 @@ osc52_long.sh e9a6f4e0ea7bb6fbdaba74988d88b67c
 osc-can.sh 74530a1ced8bc249989e9175c8d29e99
 dsr-color-scheme.sh 68f86326864cc9988c84dc20babe4156
 decset-2027.sh 0a1c82f8293b216ac59148326b539079
+decset-1007.sh 91cf48d5620608640de90759c8bb958f
 decset-2031.sh 60c4f2ca88a2a4dbae8f7453c633d074
 ascii_run_prefix.sh 5413bed756d01dc51d09609c8512b8ec
 xtgettcap.sh 300a0521bca0f2bf50bc00161f8fc195

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to