Files
NetMesh/components/terminal/runtime/terminalInterruptInputState.ts

22 lines
494 B
TypeScript
Raw Normal View History

type StringRef = {
current: string;
};
type InterruptInputStateOptions = {
commandBufferRef: StringRef;
serialLineBufferRef?: StringRef;
onAutocompleteInput?: (data: string) => void;
};
export function clearTerminalInputStateForInterrupt({
commandBufferRef,
serialLineBufferRef,
onAutocompleteInput,
}: InterruptInputStateOptions): void {
commandBufferRef.current = "";
if (serialLineBufferRef) {
serialLineBufferRef.current = "";
}
onAutocompleteInput?.("\x03");
}