From efbdf9b98a78a6795729dc213bb8d0d06779a68c Mon Sep 17 00:00:00 2001 From: ANSI TV Admin Date: Wed, 11 Nov 2026 17:09:16 -0800 Subject: [PATCH 23/24] Mouse under host reporting: plain drag and right-click go to the BBS (stock); Shift+drag selects, Shift+right-click pastes Stock SyncTERM hands every button to a host that turned on mouse reporting. 0010/0011 took right-click (paste) and left-drag (selection) back from the host -- which also took the right button from every board menu that opens on right-click (ANSI TV's own rooms among them). Now the host gets them exactly as stock sends them, and Shift is the way past the host, xterm's rule: Shift+left-drag selects text the host never sees (a Shift click that stays in its cell still reaches the host), Shift+right-click pastes (the press decides; its release pastes). A host that hid the pointer (CSI = 30 h / 31 h, a game) keeps every button, Shift or not. --- src/syncterm/term.c | 65 ++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/src/syncterm/term.c b/src/syncterm/term.c index f546be85..ef318e9d 100644 --- a/src/syncterm/term.c +++ b/src/syncterm/term.c @@ -4804,11 +4804,14 @@ handle_mouse_event(struct mouse_state *ms) getmouse(&mevent); if (wren_host_dispatch_mouse(&mevent)) return; - /* A left DRAG selects text even while the host has mouse reporting - * on (and has not hidden our pointer -- a game keeps its drags). - * The press is held back: released in the same cell, the host gets - * press + release exactly as before; moved to another cell with the - * button down, it becomes a text selection the host never sees. + /* SHIFT + left DRAG selects text even while the host has mouse + * reporting on (and has not hidden our pointer -- a game keeps its + * drags). A plain press goes to the host at once, exactly as stock + * SyncTERM sends it: the host owns the mouse it asked for, and Shift + * is the way past it (xterm's rule). A Shift press is held back: + * released in the same cell, the host gets press + release exactly + * as before; moved to another cell with the button down, it becomes + * a text selection the host never sees. * Moving arms ciolib's drag events for this one press, and the next * movement arrives as BUTTON_1_DRAG_START, which the switch below * already hands to mousedrag_terminal(). */ @@ -4823,6 +4826,7 @@ handle_mouse_event(struct mouse_state *ms) if (!tracking) sel_pending = 0; else if (mevent.event == CIOLIB_BUTTON_1_PRESS + && (mevent.kbmodifiers & CIOLIB_KMOD_SHIFT) && !(mevent.kbmodifiers & CIOLIB_KMOD_CTRL)) { sel_press = mevent; sel_pending = 1; @@ -4857,24 +4861,41 @@ handle_mouse_event(struct mouse_state *ms) return; } } - /* Right-click pastes from the OS clipboard even while the host has - * mouse reporting on -- a board that tracks the mouse for its menus - * would otherwise take the right button and paste would be gone. - * The exception is a host that has hidden our pointer (CSI = 30 h): - * that is a game drawing its own, and it keeps the right button. */ - if ((ms->mode == MM_NORMAL_TRACKING - || ms->mode == MM_BUTTON_EVENT_TRACKING - || ms->mode == MM_ANY_EVENT_TRACKING - || ms->mode == MM_X10) - && !CTERM_HOST_OWNS_POINTER(cterm)) { - switch (mevent.event) { - case CIOLIB_BUTTON_3_PRESS: - return; - case CIOLIB_BUTTON_3_RELEASE: - case CIOLIB_BUTTON_3_CLICK: - do_paste(); - return; + /* SHIFT + right-click pastes from the OS clipboard even while the + * host has mouse reporting on. A plain right-click goes to the host, + * exactly as stock SyncTERM sends it (a board's right-click menus + * need it); Shift is the way past the host (xterm's rule). The + * press decides: a Shift press is kept back and its release pastes, + * whether or not Shift is still down. A host that has hidden our + * pointer (CSI = 30 h, a game) keeps every right button. */ + { + static bool rpaste; + + if ((ms->mode == MM_NORMAL_TRACKING + || ms->mode == MM_BUTTON_EVENT_TRACKING + || ms->mode == MM_ANY_EVENT_TRACKING + || ms->mode == MM_X10) + && !CTERM_HOST_OWNS_POINTER(cterm)) { + switch (mevent.event) { + case CIOLIB_BUTTON_3_PRESS: + if (mevent.kbmodifiers & CIOLIB_KMOD_SHIFT) { + rpaste = true; + return; + } + rpaste = false; + break; + case CIOLIB_BUTTON_3_RELEASE: + case CIOLIB_BUTTON_3_CLICK: + if (rpaste) { + rpaste = false; + do_paste(); + return; + } + break; + } } + else + rpaste = false; } switch (mevent.event) { case CIOLIB_BUTTON_1_PRESS: -- 2.47.3