@cplieger/web-terminal-engine 2.3.3 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/mouse.ts +21 -0
package/jsr.json
CHANGED
package/package.json
CHANGED
package/src/mouse.ts
CHANGED
|
@@ -85,6 +85,13 @@ export interface MouseInputHandler {
|
|
|
85
85
|
|
|
86
86
|
let handler: MouseInputHandler | null = null;
|
|
87
87
|
let lastButton = -1;
|
|
88
|
+
// True while a Shift-initiated press is in flight. Shift+click/drag is the
|
|
89
|
+
// xterm convention for "bypass application mouse tracking": the gesture is
|
|
90
|
+
// reserved for the browser's native text selection instead of being reported
|
|
91
|
+
// to (and preventDefault-ed away from) the TUI. Tracked from press to release
|
|
92
|
+
// so the move/up of a bypassed drag stay bypassed even if Shift is lifted
|
|
93
|
+
// mid-drag.
|
|
94
|
+
let shiftBypass = false;
|
|
88
95
|
|
|
89
96
|
/**
|
|
90
97
|
* Initialize the mouse module by attaching pointer/wheel/focus listeners to
|
|
@@ -138,6 +145,12 @@ function onMouseDown(e: MouseEvent): void {
|
|
|
138
145
|
if (mode === 0 || !(isMouseSGR() || isMousePixels()) || !handler) {
|
|
139
146
|
return;
|
|
140
147
|
}
|
|
148
|
+
if (e.shiftKey) {
|
|
149
|
+
// Shift+press: leave the whole gesture to the browser (native selection).
|
|
150
|
+
shiftBypass = true;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
shiftBypass = false;
|
|
141
154
|
const pos = pixelToCell(e);
|
|
142
155
|
if (!pos) {
|
|
143
156
|
return;
|
|
@@ -153,6 +166,11 @@ function onMouseUp(e: MouseEvent): void {
|
|
|
153
166
|
if (mode === 0 || !(isMouseSGR() || isMousePixels()) || !handler) {
|
|
154
167
|
return;
|
|
155
168
|
}
|
|
169
|
+
if (shiftBypass) {
|
|
170
|
+
// Release of a Shift-initiated (native-selection) gesture: report nothing.
|
|
171
|
+
shiftBypass = false;
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
156
174
|
const pos = pixelToCell(e);
|
|
157
175
|
if (!pos) {
|
|
158
176
|
return;
|
|
@@ -169,6 +187,9 @@ function onMouseMove(e: MouseEvent): void {
|
|
|
169
187
|
if (mode === 0 || !(isMouseSGR() || isMousePixels()) || !handler) {
|
|
170
188
|
return;
|
|
171
189
|
}
|
|
190
|
+
if (shiftBypass && e.buttons) {
|
|
191
|
+
return; // a Shift-initiated drag is a native selection; don't report it
|
|
192
|
+
}
|
|
172
193
|
// mode 1000: no motion events
|
|
173
194
|
// mode 1002: motion only while button held (drag)
|
|
174
195
|
// mode 1003: all motion events
|