mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 12:40:44 +00:00
feat: support for pasting image
This commit is contained in:
parent
2aa681f610
commit
9a3e0bb72b
7 changed files with 833 additions and 161 deletions
|
|
@ -35,6 +35,7 @@ import {
|
|||
MODIFIER_ALT_BIT,
|
||||
MODIFIER_CTRL_BIT,
|
||||
} from '../utils/platformConstants.js';
|
||||
import { clipboardHasImage } from '../utils/clipboardUtils.js';
|
||||
|
||||
import { FOCUS_IN, FOCUS_OUT } from '../hooks/useFocus.js';
|
||||
|
||||
|
|
@ -53,6 +54,7 @@ export interface Key {
|
|||
paste: boolean;
|
||||
sequence: string;
|
||||
kittyProtocol?: boolean;
|
||||
pasteImage?: boolean;
|
||||
}
|
||||
|
||||
export type KeypressHandler = (key: Key) => void;
|
||||
|
|
@ -387,7 +389,7 @@ export function KeypressProvider({
|
|||
}
|
||||
};
|
||||
|
||||
const handleKeypress = (_: unknown, key: Key) => {
|
||||
const handleKeypress = async (_: unknown, key: Key) => {
|
||||
if (key.sequence === FOCUS_IN || key.sequence === FOCUS_OUT) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -397,14 +399,28 @@ export function KeypressProvider({
|
|||
}
|
||||
if (key.name === 'paste-end') {
|
||||
isPaste = false;
|
||||
broadcast({
|
||||
name: '',
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
shift: false,
|
||||
paste: true,
|
||||
sequence: pasteBuffer.toString(),
|
||||
});
|
||||
if (pasteBuffer.toString().length > 0) {
|
||||
broadcast({
|
||||
name: '',
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
shift: false,
|
||||
paste: true,
|
||||
sequence: pasteBuffer.toString(),
|
||||
});
|
||||
} else {
|
||||
const hasImage = await clipboardHasImage();
|
||||
broadcast({
|
||||
name: '',
|
||||
ctrl: false,
|
||||
meta: false,
|
||||
shift: false,
|
||||
paste: true,
|
||||
pasteImage: hasImage,
|
||||
sequence: pasteBuffer.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
pasteBuffer = Buffer.alloc(0);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue