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

Method start

packages/pi-tui/src/terminal.ts:134–167  ·  view source on GitHub ↗
(onInput: (data: string) => void, onResize: () => void)

Source from the content-addressed store, hash-verified

132 }
133
134 start(onInput: (data: string) => void, onResize: () => void): void {
135 this.inputHandler = onInput;
136 this.resizeHandler = onResize;
137
138 // Save previous state and enable raw mode
139 this.wasRaw = process.stdin.isRaw || false;
140 if (process.stdin.setRawMode) {
141 process.stdin.setRawMode(true);
142 }
143 process.stdin.setEncoding("utf8");
144 process.stdin.resume();
145
146 // Enable bracketed paste mode - terminal will wrap pastes in \x1b[200~ ... \x1b[201~
147 process.stdout.write("\x1b[?2004h");
148
149 // Set up resize handler immediately
150 process.stdout.on("resize", this.resizeHandler);
151
152 // Refresh terminal dimensions - they may be stale after suspend/resume
153 // (SIGWINCH is lost while process is stopped). Unix only.
154 if (process.platform !== "win32") {
155 process.kill(process.pid, "SIGWINCH");
156 }
157
158 // On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends
159 // VT escape sequences (e.g. \x1b[Z for Shift+Tab) instead of raw console
160 // events that lose modifier information. Must run AFTER setRawMode(true)
161 // since that resets console mode flags.
162 this.enableWindowsVTInput();
163
164 // Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.
165 // See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
166 this.queryAndEnableKittyProtocol();
167 }
168
169 /**
170 * Set up StdinBuffer to split batched input into individual sequences.

Callers

nothing calls this directly

Calls 7

enableWindowsVTInputMethod · 0.95
setRawModeMethod · 0.80
writeMethod · 0.65
onMethod · 0.65
killMethod · 0.65
resumeMethod · 0.45

Tested by

no test coverage detected