Subj : uifc/ciolib (curses): keys buffered by ncurses are invisible to kbhit( To : GitLab note in main/sbbs From : Rob Swindell Date : Mon Aug 10 2026 23:04:43 https://gitlab.synchro.net/main/sbbs/-/issues/1223#note_10159 Numbers for the mouse-reporting angle, plus a candidate patch. Posting this as data rather than as a proposal over the top of e4d2b183bb -- that commit fixes the curses-side hole it describes, and this is the other half. ## A/B, both built from e4d2b183bb, same flags, same machine SCFG driven over a pty inside GNU screen, pristine ctrl/ copied per run, comparing rendered screens through a terminal emulator rather than raw bytes. Measurement is: press ESC once from a sub-menu, how long until the rendered screen changes. | build | lone ESC, 4 trials | | --- | --- | | e4d2b183bb as-is | no change in 3.0s on every clean trial; takes effect only when the next key arrives | | same + mouse gated | 0.326s, 0.328s, 0.328s, 0.327s | Outside screen the gated build is unchanged: 0.027s, mouse still enabled. The 326 ms is screen's own 300 ms maptimeout plus ESCDELAY. That is the floor for any application taking a bare ESC through screen -- vi pays it too -- so this makes SCFG as responsive as screen permits, not instant. ## Patch ```diff @@ -904,7 +904,11 @@ int curs_initciolib(int inmode) } mode = inmode; #ifdef NCURSES_VERSION_MAJOR - { + /* GNU screen holds a trailing ESC until the next byte arrives once mouse + * reporting is enabled, leaving us a keystroke behind forever (#1223). + * STY is also inherited by a tmux started from within screen, so it only + * means "under screen" when TMUX is unset. */ + if (getenv("STY") == NULL || getenv("TMUX") != NULL) { mmask_t msk = BUTTON1_PRESSED|BUTTON1_RELEASED|BUTTON2_PRESSED|... #ifdef BUTTON5_PRESSED msk |= BUTTON4_PRESSED|BUTTON5_PRESSED; ``` The TMUX half is not defensive coding. Measured: a tmux started from inside a screen session inherits STY (`STY='2161380.sty' TMUX='/tmp/tmux-1000/default,...'`), so testing STY alone would disable the mouse under tmux, which does not have the bug. ## The cost, which is the part worth arguing about No mouse in scfg, uedit, echocfg, umonitor or the local console when they are run inside GNU screen. That is the whole trade: ESC responds, mouse goes away, and only under screen. Alternatives, in case either is preferred: - leave it, treat it as a screen defect and report it upstream -- the bug is genuinely theirs, and this patch is a workaround for someone else's parser - make it a knob rather than automatic, so a sysop who wants the mouse under screen can keep it I have no stake in which. The measurements are the contribution; the policy call is yours. -- *Authored by Claude (Claude Code), on behalf of @rswindell* --- SBBSecho 3.37-Linux * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705) .