From b4a9f5445d2a5d66f3f209dce4d9b657ee8f7e75 Mon Sep 17 00:00:00 2001 From: Thomas Ulmer Date: Sat, 20 Dec 2025 15:19:13 -0800 Subject: st: scrollback with Shift+Pg{up,down} and mouse, keyboard select --- st/st-0.9.3/x.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'st/st-0.9.3/x.c') diff --git a/st/st-0.9.3/x.c b/st/st-0.9.3/x.c index 1e4bdf5..da3d8ac 100644 --- a/st/st-0.9.3/x.c +++ b/st/st-0.9.3/x.c @@ -34,6 +34,7 @@ typedef struct { void (*func)(const Arg *); const Arg arg; uint release; + int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */ } MouseShortcut; typedef struct { @@ -59,8 +60,6 @@ static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); static void ttysend(const Arg *); -void kscrollup(const Arg *); -void kscrolldown(const Arg *); /* config.h for applying patches and the configuration. */ #include "config.h" @@ -457,6 +456,7 @@ mouseaction(XEvent *e, uint release) for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { if (ms->release == release && ms->button == e->xbutton.button && + (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) && (match(ms->mod, state) || /* exact or forced */ match(ms->mod, state & ~forcemousemod))) { ms->func(&(ms->arg)); @@ -1861,6 +1861,14 @@ kpress(XEvent *ev) } else { len = XLookupString(e, buf, sizeof buf, &ksym, NULL); } + + if ( IS_SET(MODE_KBDSELECT) ) { + if ( match(XK_NO_MOD, e->state) || + (XK_Shift_L | XK_Shift_R) & e->state ) + win.mode ^= trt_kbdselect(ksym, buf, len); + return; + } + /* 1. shortcuts */ for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { if (ksym == bp->keysym && match(bp->mod, e->state)) { @@ -2038,6 +2046,14 @@ usage(void) " [stty_args ...]\n", argv0, argv0); } +void toggle_winmode(int flag) { + win.mode ^= flag; +} + +void keyboard_select(const Arg *dummy) { + win.mode ^= trt_kbdselect(-1, NULL, 0); +} + int main(int argc, char *argv[]) { -- cgit v1.2.3