mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-19 01:30:42 -07:00
Add setting to support OSC 52 paste (#15336)
This commit is contained in:
committed by
GitHub
parent
2cb33b2f76
commit
384fb6a465
@@ -317,12 +317,56 @@ function* emitKeys(
|
||||
}
|
||||
}
|
||||
|
||||
if (escaped && (ch === 'O' || ch === '[')) {
|
||||
if (escaped && (ch === 'O' || ch === '[' || ch === ']')) {
|
||||
// ANSI escape sequence
|
||||
code = ch;
|
||||
let modifier = 0;
|
||||
|
||||
if (ch === 'O') {
|
||||
if (ch === ']') {
|
||||
// OSC sequence
|
||||
// ESC ] <params> ; <data> BEL
|
||||
// ESC ] <params> ; <data> ESC \
|
||||
let buffer = '';
|
||||
|
||||
// Read until BEL, `ESC \`, or timeout (empty string)
|
||||
while (true) {
|
||||
const next = yield;
|
||||
if (next === '' || next === '\u0007') {
|
||||
break;
|
||||
} else if (next === ESC) {
|
||||
const afterEsc = yield;
|
||||
if (afterEsc === '' || afterEsc === '\\') {
|
||||
break;
|
||||
}
|
||||
buffer += next + afterEsc;
|
||||
continue;
|
||||
}
|
||||
buffer += next;
|
||||
}
|
||||
|
||||
// Check for OSC 52 (Clipboard) response
|
||||
// Format: 52;c;<base64> or 52;p;<base64>
|
||||
const match = /^52;[cp];(.*)$/.exec(buffer);
|
||||
if (match) {
|
||||
try {
|
||||
const base64Data = match[1];
|
||||
const decoded = Buffer.from(base64Data, 'base64').toString('utf-8');
|
||||
keypressHandler({
|
||||
name: 'paste',
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
shift: false,
|
||||
paste: true,
|
||||
insertable: true,
|
||||
sequence: decoded,
|
||||
});
|
||||
} catch (_e) {
|
||||
debugLogger.log('Failed to decode OSC 52 clipboard data');
|
||||
}
|
||||
}
|
||||
|
||||
continue; // resume main loop
|
||||
} else if (ch === 'O') {
|
||||
// ESC O letter
|
||||
// ESC O modifier letter
|
||||
ch = yield;
|
||||
|
||||
Reference in New Issue
Block a user