MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / handleInput

Method handleInput

packages/pi-tui/src/components/input.ts:48–211  ·  view source on GitHub ↗
(data: string)

Source from the content-addressed store, hash-verified

46 }
47
48 handleInput(data: string): void {
49 // Handle bracketed paste mode
50 // Start of paste: \x1b[200~
51 // End of paste: \x1b[201~
52
53 // Check if we're starting a bracketed paste
54 if (data.includes("\x1b[200~")) {
55 this.isInPaste = true;
56 this.pasteBuffer = "";
57 data = data.replace("\x1b[200~", "");
58 }
59
60 // If we're in a paste, buffer the data
61 if (this.isInPaste) {
62 // Check if this chunk contains the end marker
63 this.pasteBuffer += data;
64
65 const endIndex = this.pasteBuffer.indexOf("\x1b[201~");
66 if (endIndex !== -1) {
67 // Extract the pasted content
68 const pasteContent = this.pasteBuffer.substring(0, endIndex);
69
70 // Process the complete paste
71 this.handlePaste(pasteContent);
72
73 // Reset paste state
74 this.isInPaste = false;
75
76 // Handle any remaining input after the paste marker
77 const remaining = this.pasteBuffer.substring(endIndex + 6); // 6 = length of \x1b[201~
78 this.pasteBuffer = "";
79 if (remaining) {
80 this.handleInput(remaining);
81 }
82 }
83 return;
84 }
85
86 const kb = getKeybindings();
87
88 // Escape/Cancel
89 if (kb.matches(data, "tui.select.cancel")) {
90 if (this.onEscape) this.onEscape();
91 return;
92 }
93
94 // Undo
95 if (kb.matches(data, "tui.editor.undo")) {
96 this.undo();
97 return;
98 }
99
100 // Submit
101 if (kb.matches(data, "tui.input.submit") || data === "\n") {
102 if (this.onSubmit) this.onSubmit(this.value);
103 return;
104 }
105

Callers

nothing calls this directly

Calls 15

handlePasteMethod · 0.95
undoMethod · 0.95
handleBackspaceMethod · 0.95
handleForwardDeleteMethod · 0.95
deleteWordBackwardsMethod · 0.95
deleteWordForwardMethod · 0.95
deleteToLineStartMethod · 0.95
deleteToLineEndMethod · 0.95
yankMethod · 0.95
yankPopMethod · 0.95
moveWordBackwardsMethod · 0.95
moveWordForwardsMethod · 0.95

Tested by

no test coverage detected