pinokiod 8.3.11 → 8.3.13
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/kernel/shells.js
CHANGED
|
@@ -772,10 +772,16 @@ class Shells {
|
|
|
772
772
|
session.emit(payload)
|
|
773
773
|
}
|
|
774
774
|
} else if (params.binary) {
|
|
775
|
-
|
|
776
|
-
// mouse
|
|
777
|
-
//
|
|
778
|
-
|
|
775
|
+
const report = Buffer.from(String(params.emit), "binary")
|
|
776
|
+
// Legacy mouse input is ESC [ M followed by button, column and row bytes.
|
|
777
|
+
// Coordinates start at 1 and are encoded as value + 32. From column or
|
|
778
|
+
// row 96, Windows ConPTY's UTF-8 decoding can corrupt the position.
|
|
779
|
+
if (this.kernel.platform === "win32" && report.length === 6 &&
|
|
780
|
+
report[0] === 0x1b && report[1] === 0x5b && report[2] === 0x4d &&
|
|
781
|
+
(report[4] > 127 || report[5] > 127)) {
|
|
782
|
+
return true
|
|
783
|
+
}
|
|
784
|
+
session.emit(report)
|
|
779
785
|
} else {
|
|
780
786
|
session.emit(params.emit)
|
|
781
787
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
(function (global) {
|
|
2
|
+
// xterm sends scrolling as SGR mouse reports or repeated Up/Down keys.
|
|
3
|
+
// Ignore whole chunks of those reports when building the tab preview.
|
|
4
|
+
const scrollInput = /^(?:\x1b\[<\d+;\d+;\d+[Mm]|\x1b(?:\[|O)[AB])+$/
|
|
5
|
+
|
|
2
6
|
function processTerminalInputData(data, handlers) {
|
|
3
|
-
if (!data || typeof data !== 'string' || !handlers) {
|
|
7
|
+
if (!data || typeof data !== 'string' || !handlers || scrollInput.test(data)) {
|
|
4
8
|
return
|
|
5
9
|
}
|
|
6
10
|
const capture = typeof handlers.capture === 'function' ? handlers.capture : function () {}
|
|
@@ -172,6 +172,21 @@ test('a finger drag scrolls a program that tracks the mouse on the normal screen
|
|
|
172
172
|
assert.deepEqual(wheel, [1, 1])
|
|
173
173
|
})
|
|
174
174
|
|
|
175
|
+
test('scrolling before a paste keeps mouse reports and arrow keys out of the tab preview', (t) => {
|
|
176
|
+
const { window } = page(t)
|
|
177
|
+
for (const script of ['terminal_input_utils.js', 'terminal_input_tracker.js']) {
|
|
178
|
+
window.eval(fs.readFileSync(path.resolve(__dirname, '../server/public', script), 'utf8'))
|
|
179
|
+
}
|
|
180
|
+
const tracker = new window.TerminalInputTracker()
|
|
181
|
+
const previews = []
|
|
182
|
+
tracker.submit = (line) => previews.push(line)
|
|
183
|
+
const handlers = { capture: (text) => tracker.capture(text) }
|
|
184
|
+
for (const chunk of ['echo ', '\x1b[<64;12;5M', '\x1b[<0;12;5m', '\x1b[A\x1b[B', '\x1bOA\x1bOB', '[A\r']) {
|
|
185
|
+
window.processTerminalInputData(chunk, handlers)
|
|
186
|
+
}
|
|
187
|
+
assert.deepEqual(previews, ['echo [A'])
|
|
188
|
+
})
|
|
189
|
+
|
|
175
190
|
test('at a shell prompt a finger drag is left to the terminal and sends nothing', (t) => {
|
|
176
191
|
const { wheel, touch, attach, screenSize } = page(t)
|
|
177
192
|
attach()
|
|
@@ -255,19 +270,32 @@ test('nothing is replayed while the connection is not open', (t) => {
|
|
|
255
270
|
assert.deepEqual(wheel, [1])
|
|
256
271
|
})
|
|
257
272
|
|
|
258
|
-
function shellsWith(session) {
|
|
259
|
-
const shells =
|
|
273
|
+
function shellsWith(session, platform = process.platform) {
|
|
274
|
+
const shells = new Shells({ platform })
|
|
260
275
|
shells.get = () => session
|
|
261
276
|
return shells
|
|
262
277
|
}
|
|
263
278
|
|
|
264
|
-
test('
|
|
279
|
+
test('Unix shells receive the original legacy mouse bytes even at wide columns', () => {
|
|
280
|
+
for (const platform of ['darwin', 'linux']) {
|
|
281
|
+
const received = []
|
|
282
|
+
const shells = shellsWith({ emit: (message) => received.push(message) }, platform)
|
|
283
|
+
shells.emit({ id: 'a', emit: OLD_FORMAT_REPORT, binary: true })
|
|
284
|
+
assert.deepEqual(received, [Buffer.from(OLD_FORMAT_BYTES)])
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
test('Windows drops only legacy mouse reports beyond column or row 95', () => {
|
|
265
289
|
const received = []
|
|
266
|
-
const shells = shellsWith({ emit: (message) => received.push(message) })
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
290
|
+
const shells = shellsWith({ emit: (message) => received.push(message) }, 'win32')
|
|
291
|
+
const lastValid = '\x1b[M\x60\x7f\x7f'
|
|
292
|
+
const otherBinary = '\x1b[X\x60\x80\x80'
|
|
293
|
+
for (const emit of [lastValid, '\x1b[M\x60\x80\x7f', '\x1b[M\x60\x7f\x80', otherBinary]) {
|
|
294
|
+
assert.equal(shells.emit({ id: 'a', emit, binary: true }), true)
|
|
295
|
+
}
|
|
296
|
+
const sgr = '\x1b[<64;164;5M'
|
|
297
|
+
shells.emit({ id: 'a', emit: sgr })
|
|
298
|
+
assert.deepEqual(received, [Buffer.from(lastValid, 'binary'), Buffer.from(otherBinary, 'binary'), sgr])
|
|
271
299
|
})
|
|
272
300
|
|
|
273
301
|
test('typed text and pastes are still passed on as text', () => {
|