@code-yeongyu/senpi-tui 2026.9.12-3 → 2026.9.13-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -221,14 +221,20 @@ interface Component {
221
221
  |--------|-------------|
222
222
  | `render(width)` | Returns an array of strings, one per line. Each line **must not exceed `width`** or the TUI will error. Use `truncateToWidth()` or manual wrapping to ensure this. |
223
223
  | `handleInput?(data)` | Called when the component has focus and receives keyboard input. The `data` string contains raw terminal input (may include ANSI escape sequences). |
224
- | `handleMouse?(event)` | Called by `TuiAltScreen` for normalized pointer input targeted at the component. |
224
+ | `handleMouse?(event)` | Called by the renderer for normalized pointer input targeted at the component; regular-mode clicks require an active mouse-capture lease. |
225
225
  | `invalidate?()` | Called to clear any cached render state. Components should re-render from scratch on the next `render()` call. |
226
226
 
227
227
  The TUI appends a full SGR reset and OSC 8 reset at the end of each rendered line. Styles do not carry across lines. If you emit multi-line text with styling, reapply styles per line or use `wrapTextWithAnsi()` so styles are preserved for each wrapped line.
228
228
 
229
229
  ### Mouse Input
230
230
 
231
- `TuiAltScreen` normalizes SGR mouse input and hit-tests components and overlays. Events contain component-local `x`/`y`, absolute `screenX`/`screenY`, bounds, button, modifiers, click count, and wheel delta. `TuiMainScreen` does not capture mouse input because the terminal owns its scrollback.
231
+ `TuiAltScreen` normalizes SGR mouse input and hit-tests components and overlays. Events contain component-local `x`/`y`, absolute `screenX`/`screenY`, bounds, button, modifiers, click count, and wheel delta.
232
+
233
+ `TuiMainScreen` captures only while a host-owned lease is active: `const release = tui.acquireMouseCapture("pending-question")`; call `release()` when the interactive surface closes. Leases compose and releases are idempotent. A replacement renderer starts with no leases, so the host must reapply its intent after switching modes. Without a lease, native selection and scrollback remain untouched.
234
+
235
+ Regular mode supports unmodified left press/click only. A handler must acknowledge an eligible press with `{ handled: true }` without activating; a same-cell release within 500 ms produces the click. Changed placement or target layout cancels the gesture. Wheel, motion, other buttons, and modified reports are consumed without dispatch, including in-flight reports after capture ends. While capture is active, use the terminal's selection bypass: usually Shift-drag, or Option-drag in iTerm2/Terminal.app. There is no regular-mode app-owned drag selection or wheel scrolling.
236
+
237
+ Clicks fail closed when frame placement is unknown, resized, or image-bearing. Short fresh frames use a private cursor-position query; clearing and viewport-filling frames provide their own anchors. A query timeout leaves keyboard interaction available; a clearing render can recover the anchor. External stdout/stderr invalidates placement, and the next regular-mode render appends a fresh frame before recalibrating without clearing diagnostics or scrollback. Tracking is disabled on non-TTY output, Termux, and Windows consoles without Windows Terminal.
232
238
 
233
239
  ```typescript
234
240
  import type { TuiMouseEvent, TuiMouseEventResult } from "@earendil-works/pi-tui";
@@ -257,7 +263,9 @@ Use `MouseRegion` to add mouse behavior without changing a component's rendering
257
263
 
258
264
  ```typescript
259
265
  const collapsible = new MouseRegion(content, (event) => {
260
- if (event.type !== "click" || event.button !== "left") return undefined;
266
+ if (event.button !== "left") return undefined;
267
+ if (event.type === "press") return { handled: true };
268
+ if (event.type !== "click") return undefined;
261
269
  expanded = !expanded;
262
270
  return { handled: true };
263
271
  });
package/dist/index.d.ts CHANGED
@@ -23,10 +23,11 @@ export { type FuzzyMatch, fuzzyFilter, fuzzyMatch } from "./fuzzy.ts";
23
23
  export { type EditorImageState, formatImageMarker, IMAGE_MARKER_REGEX, IMAGE_MARKER_SINGLE, type ImageMarkerCanonicalization, ImageMarkerRegistry, type ImageMarkerRemoval, imageMarkerId, isImageMarker, } from "./image-markers.ts";
24
24
  export { getKeybindings, type Keybinding, type KeybindingConflict, type KeybindingDefinition, type KeybindingDefinitions, type Keybindings, type KeybindingsConfig, KeybindingsManager, setKeybindings, TUI_KEYBINDINGS, } from "./keybindings.ts";
25
25
  export { decodeKittyPrintable, isKeyRelease, isKeyRepeat, isKittyProtocolActive, Key, type KeyEventType, type KeyId, matchesKey, parseKey, setKittyProtocolActive, } from "./keys.ts";
26
+ export { decodeMouseButton, isMouseSequence, MOUSE_TRACKING, MouseClickSynthesizer, parseSgrMouseEvent, parseWheelEvent, type SgrMouseEvent, toTuiMouseEvent, type WheelEvent, } from "./mouse-input.ts";
26
27
  export { getNativeClipboard, type NativeClipboard } from "./native-platform.ts";
27
28
  export { type EditorPasteState, expandPasteMarkers } from "./paste-markers.ts";
28
29
  export { StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions } from "./stdin-buffer.ts";
29
- export { ProcessTerminal, type ProcessTerminalOptions, type Terminal } from "./terminal.ts";
30
+ export { type CursorPosition, ProcessTerminal, type ProcessTerminalOptions, type Terminal } from "./terminal.ts";
30
31
  export { parseOsc11BackgroundColor, parseTerminalColorSchemeReport, type RgbColor, type TerminalColorScheme, } from "./terminal-colors.ts";
31
32
  export declare function calculateImageRows(imageDimensions: ImageDimensions, targetWidthCells: number, cellDimensions?: CellDimensions): number;
32
33
  export { allocateImageId, buildKittyPlaceholderRow, type CellDimensions, deleteAllKittyImages, deleteKittyImage, detectCapabilities, encodeITerm2, encodeKitty, getCapabilities, getCellDimensions, getGifDimensions, getImageDimensions, getJpegDimensions, getPngDimensions, getWebpDimensions, hyperlink, type ImageDimensions, type ImageProtocol, type ImageRenderOptions, imageFallback, KITTY_PLACEHOLDER_MAX, outerKittyGraphicsMode, renderImage, resetCapabilitiesCache, setCapabilities, setCapabilityOverrides, setCellDimensions, type TerminalCapabilities, type TmuxPassthroughState, wrapTmuxPassthrough, } from "./terminal-image.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3E,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EACN,wBAAwB,EACxB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,O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eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACN,KAAK,SAAS,EACd,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,KAAK,SAAS,EACd,WAAW,EACX,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,GAAG,EACH,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,WAAW,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEpF,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAChB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ export { formatImageMarker, IMAGE_MARKER_REGEX, IMAGE_MARKER_SINGLE, ImageMarker
30
30
  export { getKeybindings, KeybindingsManager, setKeybindings, TUI_KEYBINDINGS, } from "./keybindings.js";
31
31
  // Keyboard input handling
32
32
  export { decodeKittyPrintable, isKeyRelease, isKeyRepeat, isKittyProtocolActive, Key, matchesKey, parseKey, setKittyProtocolActive, } from "./keys.js";
33
+ export { decodeMouseButton, isMouseSequence, MOUSE_TRACKING, MouseClickSynthesizer, parseSgrMouseEvent, parseWheelEvent, toTuiMouseEvent, } from "./mouse-input.js";
33
34
  // Native platform integration
34
35
  export { getNativeClipboard } from "./native-platform.js";
35
36
  export { expandPasteMarkers } from "./paste-markers.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAA2B,MAAM,QAAQ,CAAC;AACzD,+BAA+B;AAC/B,OAAO,EACN,wBAAwB,EAGxB,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,wBAAwB,CAAC;AAChC,uBAAuB;AACvB,OAAO,EAIN,4BAA4B,GAE5B,MAAM,mBAAmB,CAAC;AAC3B,aAAa;AACb,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EACN,MAAM,GAGN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAsC,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAA+B,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACN,gBAAgB,EAEhB,6BAA6B,EAC7B,QAAQ,EAGR,+BAA+B,GAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAA2B,MAAM,8BAA8B,CAAC;AACpF,OAAO,EACN,UAAU,GAIV,MAAM,6BAA6B,CAAC;AACrC,OAA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AE,EAAE;IAE7D,OAAO,sBAAsB,CAAC,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC;AAClG,CAAC;AACD,OAAO,EACN,eAAe,EACf,wBAAwB,EAExB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EAIT,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EAGjB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAEN,SAAS,EACT,aAAa,EACb,gBAAgB,EAEhB,WAAW,EACX,aAAa,EAQb,GAAG,GAUH,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAA4B,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAiC,MAAM,sBAAsB,CAAC;AACpF,YAAY;AACZ,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAChB,MAAM,YAAY,CAAC","sourcesContent":["// Core TUI interfaces and classes\n\nimport type { CellDimensions, ImageDimensions } from \"./terminal-image.ts\";\nimport { calculateImageCellSize } from \"./terminal-image.ts\";\n\nexport { Marked, type Token, type Tokens } from \"marked\";\n// Fullscreen transcript search\nexport {\n\tAltScreenSearchComponent,\n\ttype AltScreenSearchMatch,\n\ttype AltScreenSearchSegment,\n\tfindAltScreenSearchMatches,\n\tgetAltScreenSearchMatchKey,\n} from \"./alt-screen-search.ts\";\n// Autocomplete support\nexport {\n\ttype AutocompleteItem,\n\ttype AutocompleteProvider,\n\ttype AutocompleteSuggestions,\n\tCombinedAutocompleteProvider,\n\ttype SlashCommand,\n} from \"./autocomplete.ts\";\n// Components\nexport { Box } from \"./components/box.ts\";\nexport { CancellableLoader } from \"./components/cancellable-loader.ts\";\nexport {\n\tEditor,\n\ttype EditorOptions,\n\ttype EditorTheme,\n} from \"./components/editor.ts\";\nexport { HStack } from \"./components/h-stack.ts\";\nexport { Image, type ImageOptions, type ImageTheme } from \"./components/image.ts\";\nexport { Input } from \"./components/input.ts\";\nexport { Loader, type LoaderIndicatorOptions } from \"./components/loader.ts\";\nexport {\n\tclearRenderCache,\n\ttype DefaultTextStyle,\n\tgetMarkdownHighlightCallCount,\n\tMarkdown,\n\ttype MarkdownOptions,\n\ttype MarkdownTheme,\n\tresetMarkdownHighlightCallCount,\n} from \"./components/markdown.ts\";\nexport { MouseRegion, type MouseRegionHandler } from \"./components/mouse-region.ts\";\nexport {\n\tScrollView,\n\ttype ScrollViewOptions,\n\ttype ScrollViewScrollbar,\n\ttype ScrollViewScrollToOptions,\n} from \"./components/scroll-view.ts\";\nexport {\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SelectListRenderRow,\n\ttype SelectListRowParts,\n\ttype SelectListTheme,\n\ttype SelectListTruncatePrimaryContext,\n} from \"./components/select-list.ts\";\nexport { type SettingItem, SettingsList, type SettingsListTheme } from \"./components/settings-list.ts\";\nexport { Spacer } from \"./components/spacer.ts\";\nexport { Text } from \"./components/text.ts\";\nexport { TruncatedText } from \"./components/truncated-text.ts\";\nexport {\n\ttype StackChild,\n\ttype StackEntry,\n\ttype StackEntryOptions,\n\ttype StackOptions,\n\tVStack,\n} from \"./components/v-stack.ts\";\n// Editor component interface (for custom editors)\nexport type { EditorComponent } from \"./editor-component.ts\";\n// Fuzzy matching\nexport { type FuzzyMatch, fuzzyFilter, fuzzyMatch } from \"./fuzzy.ts\";\n// Atomic image markers (ids only - never image bytes)\nexport {\n\ttype EditorImageState,\n\tformatImageMarker,\n\tIMAGE_MARKER_REGEX,\n\tIMAGE_MARKER_SINGLE,\n\ttype ImageMarkerCanonicalization,\n\tImageMarkerRegistry,\n\ttype ImageMarkerRemoval,\n\timageMarkerId,\n\tisImageMarker,\n} from \"./image-markers.ts\";\n// Keybindings\nexport {\n\tgetKeybindings,\n\ttype Keybinding,\n\ttype KeybindingConflict,\n\ttype KeybindingDefinition,\n\ttype KeybindingDefinitions,\n\ttype Keybindings,\n\ttype KeybindingsConfig,\n\tKeybindingsManager,\n\tsetKeybindings,\n\tTUI_KEYBINDINGS,\n} from \"./keybindings.ts\";\n// Keyboard input handling\nexport {\n\tdecodeKittyPrintable,\n\tisKeyRelease,\n\tisKeyRepeat,\n\tisKittyProtocolActive,\n\tKey,\n\ttype KeyEventType,\n\ttype KeyId,\n\tmatchesKey,\n\tparseKey,\n\tsetKittyProtocolActive,\n} from \"./keys.ts\";\n// Native platform integration\nexport { getNativeClipboard, type NativeClipboard } from \"./native-platform.ts\";\nexport { type EditorPasteState, expandPasteMarkers } from \"./paste-markers.ts\";\n// Input buffering for batch splitting\nexport { StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions } from \"./stdin-buffer.ts\";\n// Terminal interface and implementations\nexport { ProcessTerminal, type ProcessTerminalOptions, type Terminal } from \"./terminal.ts\";\n// Terminal colors\nexport {\n\tparseOsc11BackgroundColor,\n\tparseTerminalColorSchemeReport,\n\ttype RgbColor,\n\ttype TerminalColorScheme,\n} from \"./terminal-colors.ts\";\n// Terminal image support\nexport function calculateImageRows(\n\timageDimensions: ImageDimensions,\n\ttargetWidthCells: number,\n\tcellDimensions: CellDimensions = { widthPx: 9, heightPx: 18 },\n): number {\n\treturn calculateImageCellSize(imageDimensions, targetWidthCells, undefined, cellDimensions).rows;\n}\nexport {\n\tallocateImageId,\n\tbuildKittyPlaceholderRow,\n\ttype CellDimensions,\n\tdeleteAllKittyImages,\n\tdeleteKittyImage,\n\tdetectCapabilities,\n\tencodeITerm2,\n\tencodeKitty,\n\tgetCapabilities,\n\tgetCellDimensions,\n\tgetGifDimensions,\n\tgetImageDimensions,\n\tgetJpegDimensions,\n\tgetPngDimensions,\n\tgetWebpDimensions,\n\thyperlink,\n\ttype ImageDimensions,\n\ttype ImageProtocol,\n\ttype ImageRenderOptions,\n\timageFallback,\n\tKITTY_PLACEHOLDER_MAX,\n\touterKittyGraphicsMode,\n\trenderImage,\n\tresetCapabilitiesCache,\n\tsetCapabilities,\n\tsetCapabilityOverrides,\n\tsetCellDimensions,\n\ttype TerminalCapabilities,\n\ttype TmuxPassthroughState,\n\twrapTmuxPassthrough,\n} from \"./terminal-image.ts\";\nexport { sanitizeTerminalLabel, shortenImagePath } from \"./terminal-text.ts\";\nexport {\n\ttype Component,\n\tContainer,\n\tCURSOR_MARKER,\n\tcompositeTuiLine,\n\ttype Focusable,\n\tisFocusable,\n\tisViewportTUI,\n\ttype OverlayAnchor,\n\ttype OverlayBounds,\n\ttype OverlayHandle,\n\ttype OverlayMargin,\n\ttype OverlayOptions,\n\ttype OverlayUnfocusOptions,\n\ttype SizeValue,\n\tTUI,\n\ttype TuiInputListener,\n\ttype TuiInputListenerResult,\n\ttype TuiMode,\n\ttype TuiMouseButton,\n\ttype TuiMouseEvent,\n\ttype TuiMouseEventResult,\n\ttype TuiMouseEventType,\n\ttype TuiStopOptions,\n\ttype ViewportTUI,\n} from \"./tui.ts\";\nexport { TuiAltScreen, type TuiAltScreenOptions } from \"./tui-alt-screen.ts\";\nexport { TuiMainScreen, type TuiMainScreenRenderState } from \"./tui-main-screen.ts\";\n// Utilities\nexport {\n\tgetGraphemeSegmenter,\n\tgetOsc8LinkAtColumn,\n\tgetWordSegmenter,\n\tsliceByColumn,\n\tstripTerminalSequences,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n} from \"./utils.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;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,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EAIT,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EAGjB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAEN,SAAS,EACT,aAAa,EACb,gBAAgB,EAEhB,WAAW,EACX,aAAa,EAQb,GAAG,GAUH,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAA4B,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAiC,MAAM,sBAAsB,CAAC;AACpF,YAAY;AACZ,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAChB,MAAM,YAAY,CAAC","sourcesContent":["// Core TUI interfaces and classes\n\nimport type { CellDimensions, ImageDimensions } from \"./terminal-image.ts\";\nimport { calculateImageCellSize } from \"./terminal-image.ts\";\n\nexport { Marked, type Token, type Tokens } from \"marked\";\n// Fullscreen transcript search\nexport {\n\tAltScreenSearchComponent,\n\ttype AltScreenSearchMatch,\n\ttype AltScreenSearchSegment,\n\tfindAltScreenSearchMatches,\n\tgetAltScreenSearchMatchKey,\n} from \"./alt-screen-search.ts\";\n// Autocomplete support\nexport {\n\ttype AutocompleteItem,\n\ttype AutocompleteProvider,\n\ttype AutocompleteSuggestions,\n\tCombinedAutocompleteProvider,\n\ttype SlashCommand,\n} from \"./autocomplete.ts\";\n// Components\nexport { Box } from \"./components/box.ts\";\nexport { CancellableLoader } from \"./components/cancellable-loader.ts\";\nexport {\n\tEditor,\n\ttype EditorOptions,\n\ttype EditorTheme,\n} from \"./components/editor.ts\";\nexport { HStack } from \"./components/h-stack.ts\";\nexport { Image, type ImageOptions, type ImageTheme } from \"./components/image.ts\";\nexport { Input } from \"./components/input.ts\";\nexport { Loader, type LoaderIndicatorOptions } from \"./components/loader.ts\";\nexport {\n\tclearRenderCache,\n\ttype DefaultTextStyle,\n\tgetMarkdownHighlightCallCount,\n\tMarkdown,\n\ttype MarkdownOptions,\n\ttype MarkdownTheme,\n\tresetMarkdownHighlightCallCount,\n} from \"./components/markdown.ts\";\nexport { MouseRegion, type MouseRegionHandler } from \"./components/mouse-region.ts\";\nexport {\n\tScrollView,\n\ttype ScrollViewOptions,\n\ttype ScrollViewScrollbar,\n\ttype ScrollViewScrollToOptions,\n} from \"./components/scroll-view.ts\";\nexport {\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SelectListRenderRow,\n\ttype SelectListRowParts,\n\ttype SelectListTheme,\n\ttype SelectListTruncatePrimaryContext,\n} from \"./components/select-list.ts\";\nexport { type SettingItem, SettingsList, type SettingsListTheme } from \"./components/settings-list.ts\";\nexport { Spacer } from \"./components/spacer.ts\";\nexport { Text } from \"./components/text.ts\";\nexport { TruncatedText } from \"./components/truncated-text.ts\";\nexport {\n\ttype StackChild,\n\ttype StackEntry,\n\ttype StackEntryOptions,\n\ttype StackOptions,\n\tVStack,\n} from \"./components/v-stack.ts\";\n// Editor component interface (for custom editors)\nexport type { EditorComponent } from \"./editor-component.ts\";\n// Fuzzy matching\nexport { type FuzzyMatch, fuzzyFilter, fuzzyMatch } from \"./fuzzy.ts\";\n// Atomic image markers (ids only - never image bytes)\nexport {\n\ttype EditorImageState,\n\tformatImageMarker,\n\tIMAGE_MARKER_REGEX,\n\tIMAGE_MARKER_SINGLE,\n\ttype ImageMarkerCanonicalization,\n\tImageMarkerRegistry,\n\ttype ImageMarkerRemoval,\n\timageMarkerId,\n\tisImageMarker,\n} from \"./image-markers.ts\";\n// Keybindings\nexport {\n\tgetKeybindings,\n\ttype Keybinding,\n\ttype KeybindingConflict,\n\ttype KeybindingDefinition,\n\ttype KeybindingDefinitions,\n\ttype Keybindings,\n\ttype KeybindingsConfig,\n\tKeybindingsManager,\n\tsetKeybindings,\n\tTUI_KEYBINDINGS,\n} from \"./keybindings.ts\";\n// Keyboard input handling\nexport {\n\tdecodeKittyPrintable,\n\tisKeyRelease,\n\tisKeyRepeat,\n\tisKittyProtocolActive,\n\tKey,\n\ttype KeyEventType,\n\ttype KeyId,\n\tmatchesKey,\n\tparseKey,\n\tsetKittyProtocolActive,\n} from \"./keys.ts\";\nexport {\n\tdecodeMouseButton,\n\tisMouseSequence,\n\tMOUSE_TRACKING,\n\tMouseClickSynthesizer,\n\tparseSgrMouseEvent,\n\tparseWheelEvent,\n\ttype SgrMouseEvent,\n\ttoTuiMouseEvent,\n\ttype WheelEvent,\n} from \"./mouse-input.ts\";\n// Native platform integration\nexport { getNativeClipboard, type NativeClipboard } from \"./native-platform.ts\";\nexport { type EditorPasteState, expandPasteMarkers } from \"./paste-markers.ts\";\n// Input buffering for batch splitting\nexport { StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions } from \"./stdin-buffer.ts\";\n// Terminal interface and implementations\nexport { type CursorPosition, ProcessTerminal, type ProcessTerminalOptions, type Terminal } from \"./terminal.ts\";\n// Terminal colors\nexport {\n\tparseOsc11BackgroundColor,\n\tparseTerminalColorSchemeReport,\n\ttype RgbColor,\n\ttype TerminalColorScheme,\n} from \"./terminal-colors.ts\";\n// Terminal image support\nexport function calculateImageRows(\n\timageDimensions: ImageDimensions,\n\ttargetWidthCells: number,\n\tcellDimensions: CellDimensions = { widthPx: 9, heightPx: 18 },\n): number {\n\treturn calculateImageCellSize(imageDimensions, targetWidthCells, undefined, cellDimensions).rows;\n}\nexport {\n\tallocateImageId,\n\tbuildKittyPlaceholderRow,\n\ttype CellDimensions,\n\tdeleteAllKittyImages,\n\tdeleteKittyImage,\n\tdetectCapabilities,\n\tencodeITerm2,\n\tencodeKitty,\n\tgetCapabilities,\n\tgetCellDimensions,\n\tgetGifDimensions,\n\tgetImageDimensions,\n\tgetJpegDimensions,\n\tgetPngDimensions,\n\tgetWebpDimensions,\n\thyperlink,\n\ttype ImageDimensions,\n\ttype ImageProtocol,\n\ttype ImageRenderOptions,\n\timageFallback,\n\tKITTY_PLACEHOLDER_MAX,\n\touterKittyGraphicsMode,\n\trenderImage,\n\tresetCapabilitiesCache,\n\tsetCapabilities,\n\tsetCapabilityOverrides,\n\tsetCellDimensions,\n\ttype TerminalCapabilities,\n\ttype TmuxPassthroughState,\n\twrapTmuxPassthrough,\n} from \"./terminal-image.ts\";\nexport { sanitizeTerminalLabel, shortenImagePath } from \"./terminal-text.ts\";\nexport {\n\ttype Component,\n\tContainer,\n\tCURSOR_MARKER,\n\tcompositeTuiLine,\n\ttype Focusable,\n\tisFocusable,\n\tisViewportTUI,\n\ttype OverlayAnchor,\n\ttype OverlayBounds,\n\ttype OverlayHandle,\n\ttype OverlayMargin,\n\ttype OverlayOptions,\n\ttype OverlayUnfocusOptions,\n\ttype SizeValue,\n\tTUI,\n\ttype TuiInputListener,\n\ttype TuiInputListenerResult,\n\ttype TuiMode,\n\ttype TuiMouseButton,\n\ttype TuiMouseEvent,\n\ttype TuiMouseEventResult,\n\ttype TuiMouseEventType,\n\ttype TuiStopOptions,\n\ttype ViewportTUI,\n} from \"./tui.ts\";\nexport { TuiAltScreen, type TuiAltScreenOptions } from \"./tui-alt-screen.ts\";\nexport { TuiMainScreen, type TuiMainScreenRenderState } from \"./tui-main-screen.ts\";\n// Utilities\nexport {\n\tgetGraphemeSegmenter,\n\tgetOsc8LinkAtColumn,\n\tgetWordSegmenter,\n\tsliceByColumn,\n\tstripTerminalSequences,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n} from \"./utils.ts\";\n"]}
@@ -0,0 +1,37 @@
1
+ import type { TuiMouseButton, TuiMouseEvent } from "./tui.ts";
2
+ export interface SgrMouseEvent {
3
+ button: number;
4
+ x: number;
5
+ y: number;
6
+ release: boolean;
7
+ }
8
+ export interface WheelEvent {
9
+ direction: -1 | 1;
10
+ x: number;
11
+ y: number;
12
+ button: number;
13
+ }
14
+ export declare const MOUSE_TRACKING: {
15
+ buttonMotion: string;
16
+ allMotion: string;
17
+ inline: string;
18
+ disable: string;
19
+ };
20
+ /** Decode SGR's one-based wire coordinates into zero-based cells. */
21
+ export declare function parseSgrMouseEvent(data: string): SgrMouseEvent | undefined;
22
+ export declare function parseWheelEvent(data: string): WheelEvent | undefined;
23
+ export declare function isMouseSequence(data: string): boolean;
24
+ export declare function decodeMouseButton(button: number): TuiMouseButton;
25
+ export declare function toTuiMouseEvent(type: TuiMouseEvent["type"], raw: SgrMouseEvent, size: {
26
+ columns: number;
27
+ rows: number;
28
+ }, extra?: Partial<Pick<TuiMouseEvent, "wheelDelta" | "clickCount">>): TuiMouseEvent;
29
+ /** Gesture state uses explicit timestamps so callers/tests need no timers. */
30
+ export declare class MouseClickSynthesizer {
31
+ private pressed?;
32
+ private last?;
33
+ press(raw: SgrMouseEvent, target: object, epoch: number, now?: number): void;
34
+ release(raw: SgrMouseEvent, target: object, epoch: number, now?: number): number | undefined;
35
+ cancel(): void;
36
+ }
37
+ //# sourceMappingURL=mouse-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mouse-input.d.ts","sourceRoot":"","sources":["../src/mouse-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,OAAO,CAAC;CACjB;AACD,MAAM,WAAW,UAAU;IAC1B,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CACf;AACD,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1b[?1006h\x1b[?1000h",
5
+ disable: "\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l",
6
+ };
7
+ /** Decode SGR's one-based wire coordinates into zero-based cells. */
8
+ export function parseSgrMouseEvent(data) {
9
+ const match = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/.exec(data);
10
+ if (!match)
11
+ return undefined;
12
+ const button = Number(match[1]);
13
+ const x = Number(match[2]) - 1;
14
+ const y = Number(match[3]) - 1;
15
+ if (button > 255 || !Number.isSafeInteger(x) || !Number.isSafeInteger(y) || x < 0 || y < 0)
16
+ return undefined;
17
+ return { button, x, y, release: match[4] === "m" };
18
+ }
19
+ export function parseWheelEvent(data) {
20
+ const raw = parseSgrMouseEvent(data) ??
21
+ (data.length === 6 && data.startsWith("\x1b[M")
22
+ ? { button: data.charCodeAt(3) - 32, x: data.charCodeAt(4) - 33, y: data.charCodeAt(5) - 33 }
23
+ : undefined);
24
+ if (!raw || raw.button < 0 || raw.button > 255 || (raw.button & 64) === 0)
25
+ return undefined;
26
+ const direction = raw.button & 3;
27
+ if (direction !== 0 && direction !== 1)
28
+ return undefined;
29
+ return { direction: direction === 0 ? -1 : 1, x: raw.x, y: raw.y, button: raw.button };
30
+ }
31
+ export function isMouseSequence(data) {
32
+ return data.startsWith("\x1b[<") || data.startsWith("\x1b[M");
33
+ }
34
+ export function decodeMouseButton(button) {
35
+ switch (button & 3) {
36
+ case 0:
37
+ return "left";
38
+ case 1:
39
+ return "middle";
40
+ case 2:
41
+ return "right";
42
+ default:
43
+ return "none";
44
+ }
45
+ }
46
+ export function toTuiMouseEvent(type, raw, size, extra = {}) {
47
+ return {
48
+ type,
49
+ button: type === "wheel" ? "none" : decodeMouseButton(raw.button),
50
+ x: raw.x,
51
+ y: raw.y,
52
+ screenX: raw.x,
53
+ screenY: raw.y,
54
+ width: Math.max(1, size.columns),
55
+ height: Math.max(1, size.rows),
56
+ shift: (raw.button & 4) !== 0,
57
+ alt: (raw.button & 8) !== 0,
58
+ ctrl: (raw.button & 16) !== 0,
59
+ ...extra,
60
+ };
61
+ }
62
+ /** Gesture state uses explicit timestamps so callers/tests need no timers. */
63
+ export class MouseClickSynthesizer {
64
+ press(raw, target, epoch, now = Date.now()) {
65
+ this.pressed = { x: raw.x, y: raw.y, target, epoch, time: now };
66
+ }
67
+ release(raw, target, epoch, now = Date.now()) {
68
+ const press = this.pressed;
69
+ this.pressed = undefined;
70
+ if (!press ||
71
+ press.x !== raw.x ||
72
+ press.y !== raw.y ||
73
+ press.target !== target ||
74
+ press.epoch !== epoch ||
75
+ now - press.time > 500 ||
76
+ now < press.time) {
77
+ this.last = undefined;
78
+ return undefined;
79
+ }
80
+ const last = this.last;
81
+ const count = last &&
82
+ last.x === raw.x &&
83
+ last.y === raw.y &&
84
+ last.target === target &&
85
+ last.epoch === epoch &&
86
+ now - last.time <= 500
87
+ ? (last.count % 3) + 1
88
+ : 1;
89
+ this.last = { ...press, time: now, count };
90
+ return count;
91
+ }
92
+ cancel() {
93
+ this.pressed = undefined;
94
+ this.last = undefined;
95
+ }
96
+ }
97
+ //# sourceMappingURL=mouse-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mouse-input.js","sourceRoot":"","sources":["../src/mouse-input.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,YAAY,EAAE,8CAA8C;IAC5D,SAAS,EAAE,yDAAyD;IACpE,MAAM,EAAE,wBAAwB;IAChC,OAAO,EAAE,8CAA8C;CACvD,CAAC;AAEF,qEAAqE;AACrE,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC9C,MAAM,KAAK,GAAG,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAA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IAAI,CAAC,KAAK,KAAK,KAAK;YACpB,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,GAAG;YACrB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC;YACtB,CAAC,CAAC,CAAC,CAAC;QACN,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM;QACL,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACvB,CAAC;CACD","sourcesContent":["import type { TuiMouseButton, TuiMouseEvent } from \"./tui.ts\";\n\nexport interface SgrMouseEvent {\n\tbutton: number;\n\tx: number;\n\ty: number;\n\trelease: boolean;\n}\nexport interface WheelEvent {\n\tdirection: -1 | 1;\n\tx: number;\n\ty: number;\n\tbutton: number;\n}\nexport const MOUSE_TRACKING = {\n\tbuttonMotion: \"\\x1b[?1000h\\x1b[?1002h\\x1b[?1004h\\x1b[?1006h\",\n\tallMotion: \"\\x1b[?1000h\\x1b[?1002h\\x1b[?1003h\\x1b[?1004h\\x1b[?1006h\",\n\tinline: \"\\x1b[?1006h\\x1b[?1000h\",\n\tdisable: \"\\x1b[?1000l\\x1b[?1002l\\x1b[?1003l\\x1b[?1006l\",\n};\n\n/** Decode SGR's one-based wire coordinates into zero-based cells. */\nexport function parseSgrMouseEvent(data: string): SgrMouseEvent | undefined {\n\tconst match = /^\\x1b\\[<(\\d+);(\\d+);(\\d+)([Mm])$/.exec(data);\n\tif (!match) return undefined;\n\tconst button = Number(match[1]);\n\tconst x = Number(match[2]) - 1;\n\tconst y = Number(match[3]) - 1;\n\tif (button > 255 || !Number.isSafeInteger(x) || !Number.isSafeInteger(y) || x < 0 || y < 0) return undefined;\n\treturn { button, x, y, release: match[4] === \"m\" };\n}\n\nexport function parseWheelEvent(data: string): WheelEvent | undefined {\n\tconst raw =\n\t\tparseSgrMouseEvent(data) ??\n\t\t(data.length === 6 && data.startsWith(\"\\x1b[M\")\n\t\t\t? { button: data.charCodeAt(3) - 32, x: data.charCodeAt(4) - 33, y: data.charCodeAt(5) - 33 }\n\t\t\t: undefined);\n\tif (!raw || raw.button < 0 || raw.button > 255 || (raw.button & 64) === 0) return undefined;\n\tconst direction = raw.button & 3;\n\tif (direction !== 0 && direction !== 1) return undefined;\n\treturn { direction: direction === 0 ? -1 : 1, x: raw.x, y: raw.y, button: raw.button };\n}\n\nexport function isMouseSequence(data: string): boolean {\n\treturn data.startsWith(\"\\x1b[<\") || data.startsWith(\"\\x1b[M\");\n}\n\nexport function decodeMouseButton(button: number): TuiMouseButton {\n\tswitch (button & 3) {\n\t\tcase 0:\n\t\t\treturn \"left\";\n\t\tcase 1:\n\t\t\treturn \"middle\";\n\t\tcase 2:\n\t\t\treturn \"right\";\n\t\tdefault:\n\t\t\treturn \"none\";\n\t}\n}\n\nexport function toTuiMouseEvent(\n\ttype: TuiMouseEvent[\"type\"],\n\traw: SgrMouseEvent,\n\tsize: { columns: number; rows: number },\n\textra: Partial<Pick<TuiMouseEvent, \"wheelDelta\" | \"clickCount\">> = {},\n): TuiMouseEvent {\n\treturn {\n\t\ttype,\n\t\tbutton: type === \"wheel\" ? \"none\" : decodeMouseButton(raw.button),\n\t\tx: raw.x,\n\t\ty: raw.y,\n\t\tscreenX: raw.x,\n\t\tscreenY: raw.y,\n\t\twidth: Math.max(1, size.columns),\n\t\theight: Math.max(1, size.rows),\n\t\tshift: (raw.button & 4) !== 0,\n\t\talt: (raw.button & 8) !== 0,\n\t\tctrl: (raw.button & 16) !== 0,\n\t\t...extra,\n\t};\n}\n\ninterface ClickPoint {\n\tx: number;\n\ty: number;\n\ttarget: object;\n\tepoch: number;\n\ttime: number;\n}\n\n/** Gesture state uses explicit timestamps so callers/tests need no timers. */\nexport class MouseClickSynthesizer {\n\tprivate pressed?: ClickPoint;\n\tprivate last?: ClickPoint & { count: number };\n\n\tpress(raw: SgrMouseEvent, target: object, epoch: number, now = Date.now()): void {\n\t\tthis.pressed = { x: raw.x, y: raw.y, target, epoch, time: now };\n\t}\n\n\trelease(raw: SgrMouseEvent, target: object, epoch: number, now = Date.now()): number | undefined {\n\t\tconst press = this.pressed;\n\t\tthis.pressed = undefined;\n\t\tif (\n\t\t\t!press ||\n\t\t\tpress.x !== raw.x ||\n\t\t\tpress.y !== raw.y ||\n\t\t\tpress.target !== target ||\n\t\t\tpress.epoch !== epoch ||\n\t\t\tnow - press.time > 500 ||\n\t\t\tnow < press.time\n\t\t) {\n\t\t\tthis.last = undefined;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst last = this.last;\n\t\tconst count =\n\t\t\tlast &&\n\t\t\tlast.x === raw.x &&\n\t\t\tlast.y === raw.y &&\n\t\t\tlast.target === target &&\n\t\t\tlast.epoch === epoch &&\n\t\t\tnow - last.time <= 500\n\t\t\t\t? (last.count % 3) + 1\n\t\t\t\t: 1;\n\t\tthis.last = { ...press, time: now, count };\n\t\treturn count;\n\t}\n\n\tcancel(): void {\n\t\tthis.pressed = undefined;\n\t\tthis.last = undefined;\n\t}\n}\n"]}
@@ -42,6 +42,8 @@ export declare class StdinBuffer extends EventEmitter<StdinBufferEventMap> {
42
42
  private timeout;
43
43
  private readonly timeoutMs;
44
44
  private readonly escapeTimeoutMs;
45
+ private mouseFragmentStartedAt?;
46
+ private discardingMouseFragment;
45
47
  private pasteMode;
46
48
  private pasteBuffer;
47
49
  private pendingKittyPrintableCodepoint;
@@ -1 +1 @@
1
- {"version":3,"file":"stdin-buffer.d.ts","sourceRoot":"","sources":["../src/stdin-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAoPtC,MAAM,MAAM,kBAAkB,GAAG;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;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F;;;GAGG;AACH,qBAAa,WAAY,SAAQ,YAAY,CAAC,mBAAmB,CAAC;IACjE,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAA8C;IAC7D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,sBAAsB,CAAC,CAAS;IACxC,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,8BAA8B,CAAqB;IAC3D,OAAO,CAAC,OAAO,CAAoD;IAEnE,YAAY,OAAO,GAAE,kBAAuB,EAI3C;IAEM,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4H1C;IAED,OAAO,CAAC,gBAAgB;IAWxB,KAAK,IAAI,MAAM,EAAE,CA0BhB;IAED,KAAK,IAAI,IAAI,CAYZ;IAED,SAAS,IAAI,MAAM,CAElB;IAED,OAAO,IAAI,IAAI,CAEd;CACD"}
@@ -232,6 +232,7 @@ export class StdinBuffer extends EventEmitter {
232
232
  super();
233
233
  this.buffer = "";
234
234
  this.timeout = null;
235
+ this.discardingMouseFragment = false;
235
236
  this.pasteMode = false;
236
237
  this.pasteBuffer = "";
237
238
  this.decoder = new StringDecoder("utf8");
@@ -266,6 +267,19 @@ export class StdinBuffer extends EventEmitter {
266
267
  }
267
268
  return;
268
269
  }
270
+ if (this.discardingMouseFragment) {
271
+ const terminator = str.search(/[\x40-\x7e]/);
272
+ const escapeIndex = str.indexOf(ESC);
273
+ if (escapeIndex !== -1 && (terminator === -1 || escapeIndex < terminator)) {
274
+ str = str.slice(escapeIndex);
275
+ }
276
+ else {
277
+ if (terminator === -1)
278
+ return;
279
+ str = str.slice(terminator + 1);
280
+ }
281
+ this.discardingMouseFragment = false;
282
+ }
269
283
  this.buffer += str;
270
284
  if (this.pasteMode) {
271
285
  this.pasteBuffer += this.buffer;
@@ -314,6 +328,16 @@ export class StdinBuffer extends EventEmitter {
314
328
  }
315
329
  const result = extractCompleteSequences(this.buffer);
316
330
  this.buffer = result.remainder;
331
+ if (this.buffer.startsWith("\x1b[<")) {
332
+ this.mouseFragmentStartedAt ??= Date.now();
333
+ if (this.buffer.length > 64) {
334
+ this.buffer = "";
335
+ this.discardingMouseFragment = true;
336
+ }
337
+ }
338
+ else {
339
+ this.mouseFragmentStartedAt = undefined;
340
+ }
317
341
  for (const sequence of result.sequences) {
318
342
  this.emitDataSequence(sequence);
319
343
  }
@@ -344,6 +368,18 @@ export class StdinBuffer extends EventEmitter {
344
368
  if (this.buffer.length === 0) {
345
369
  return [];
346
370
  }
371
+ if (this.buffer.startsWith("\x1b[<")) {
372
+ const remaining = 750 - (Date.now() - (this.mouseFragmentStartedAt ?? Date.now()));
373
+ if (remaining > 0 && this.buffer.length <= 64) {
374
+ this.timeout = setTimeout(() => this.flush(), remaining);
375
+ }
376
+ else {
377
+ this.buffer = "";
378
+ this.mouseFragmentStartedAt = undefined;
379
+ this.discardingMouseFragment = true;
380
+ }
381
+ return [];
382
+ }
347
383
  const sequences = [this.buffer];
348
384
  this.buffer = "";
349
385
  this.pendingKittyPrintableCodepoint = undefined;
@@ -357,6 +393,8 @@ export class StdinBuffer extends EventEmitter {
357
393
  this.buffer = "";
358
394
  this.pasteMode = false;
359
395
  this.pasteBuffer = "";
396
+ this.mouseFragmentStartedAt = undefined;
397
+ this.discardingMouseFragment = false;
360
398
  this.pendingKittyPrintableCodepoint = undefined;
361
399
  this.decoder = new StringDecoder("utf8");
362
400
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stdin-buffer.js","sourceRoot":"","sources":["../src/stdin-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC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emits complete sequences.\n *\n * This is necessary because stdin data events can arrive in partial chunks,\n * especially for escape sequences like mouse events. Without buffering,\n * partial sequences can be misinterpreted as regular keypresses.\n *\n * For example, the mouse SGR sequence `\\x1b[<35;20;5m` might arrive as:\n * - Event 1: `\\x1b`\n * - Event 2: `[<35`\n * - Event 3: `;20;5m`\n *\n * The buffer accumulates these until a complete sequence is detected.\n * Call the `process()` method to feed input data.\n *\n * Based on code from OpenTUI (https://github.com/anomalyco/opentui)\n * MIT License - Copyright (c) 2025 opentui\n */\n\nimport { StringDecoder } from \"node:string_decoder\";\nimport { EventEmitter } from \"events\";\n\nconst ESC = \"\\x1b\";\nconst DEFAULT_SEQUENCE_TIMEOUT_MS = 50;\nconst DEFAULT_ESCAPE_TIMEOUT_MS = 10;\nconst BRACKETED_PASTE_START = \"\\x1b[200~\";\nconst BRACKETED_PASTE_END = \"\\x1b[201~\";\n\ntype StatefulStringDecoder = StringDecoder & {\n\treadonly lastNeed?: number;\n};\n\n/**\n * Check if a string is a complete escape sequence or needs more data\n */\nfunction isCompleteSequence(data: string): \"complete\" | \"incomplete\" | \"not-escape\" {\n\tif (!data.startsWith(ESC)) {\n\t\treturn \"not-escape\";\n\t}\n\n\tif (data.length === 1) {\n\t\treturn \"incomplete\";\n\t}\n\n\tconst afterEsc = data.slice(1);\n\n\t// CSI sequences: ESC [\n\tif (afterEsc.startsWith(\"[\")) {\n\t\t// Check for old-style mouse sequence: ESC[M + 3 bytes\n\t\tif (afterEsc.startsWith(\"[M\")) {\n\t\t\t// Old-style mouse needs ESC[M + 3 bytes = 6 total\n\t\t\treturn data.length >= 6 ? \"complete\" : \"incomplete\";\n\t\t}\n\t\treturn isCompleteCsiSequence(data);\n\t}\n\n\t// OSC sequences: ESC ]\n\tif (afterEsc.startsWith(\"]\")) {\n\t\treturn isCompleteOscSequence(data);\n\t}\n\n\t// DCS sequences: ESC P ... ESC \\ (includes XTVersion responses)\n\tif (afterEsc.startsWith(\"P\")) {\n\t\treturn isCompleteDcsSequence(data);\n\t}\n\n\t// APC sequences: ESC _ ... ESC \\ (includes Kitty graphics responses)\n\tif (afterEsc.startsWith(\"_\")) {\n\t\treturn isCompleteApcSequence(data);\n\t}\n\n\t// SS3 sequences: ESC O\n\tif (afterEsc.startsWith(\"O\")) {\n\t\t// ESC O followed by a single character\n\t\treturn afterEsc.length >= 2 ? \"complete\" : \"incomplete\";\n\t}\n\n\t// Meta key sequences: ESC followed by a single character\n\tif (afterEsc.length === 1) {\n\t\treturn \"complete\";\n\t}\n\n\t// Unknown escape sequence - treat as complete\n\treturn \"complete\";\n}\n\n/**\n * Check if CSI sequence is complete\n * CSI sequences: ESC [ ... followed by a final byte (0x40-0x7E)\n */\nfunction isCompleteCsiSequence(data: string): \"complete\" | \"incomplete\" {\n\tif (!data.startsWith(`${ESC}[`)) {\n\t\treturn \"complete\";\n\t}\n\n\t// Need at least ESC [ and one more character\n\tif (data.length < 3) {\n\t\treturn \"incomplete\";\n\t}\n\n\tconst payload = data.slice(2);\n\n\t// CSI sequences end with a byte in the range 0x40-0x7E (@-~)\n\t// This includes all letters and several special characters\n\tconst lastChar = payload[payload.length - 1];\n\tconst lastCharCode = lastChar.charCodeAt(0);\n\n\tif (lastCharCode >= 0x40 && lastCharCode <= 0x7e) {\n\t\t// Special handling for SGR mouse sequences\n\t\t// Format: ESC[<B;X;Ym or ESC[<B;X;YM\n\t\tif (payload.startsWith(\"<\")) {\n\t\t\t// Must have format: <digits;digits;digits[Mm]\n\t\t\tconst mouseMatch = /^<\\d+;\\d+;\\d+[Mm]$/.test(payload);\n\t\t\tif (mouseMatch) {\n\t\t\t\treturn \"complete\";\n\t\t\t}\n\t\t\t// If it ends with M or m but doesn't match the pattern, still incomplete\n\t\t\tif (lastChar === \"M\" || lastChar === \"m\") {\n\t\t\t\t// Check if we have the right structure\n\t\t\t\tconst parts = payload.slice(1, -1).split(\";\");\n\t\t\t\tif (parts.length === 3 && parts.every((p) => /^\\d+$/.test(p))) {\n\t\t\t\t\treturn \"complete\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn \"incomplete\";\n\t\t}\n\n\t\treturn \"complete\";\n\t}\n\n\treturn \"incomplete\";\n}\n\n/**\n * Check if OSC sequence is complete\n * OSC sequences: ESC ] ... ST (where ST is ESC \\ or BEL)\n */\nfunction isCompleteOscSequence(data: string): \"complete\" | \"incomplete\" {\n\tif (!data.startsWith(`${ESC}]`)) {\n\t\treturn \"complete\";\n\t}\n\n\t// OSC sequences end with ST (ESC \\) or BEL (\\x07)\n\tif (data.endsWith(`${ESC}\\\\`) || data.endsWith(\"\\x07\")) {\n\t\treturn \"complete\";\n\t}\n\n\treturn \"incomplete\";\n}\n\n/**\n * Check if DCS (Device Control String) sequence is complete\n * DCS sequences: ESC P ... ST (where ST is ESC \\)\n * Used for XTVersion responses like ESC P >| ... ESC \\\n */\nfunction isCompleteDcsSequence(data: string): \"complete\" | \"incomplete\" {\n\tif (!data.startsWith(`${ESC}P`)) {\n\t\treturn \"complete\";\n\t}\n\n\t// DCS sequences end with ST (ESC \\)\n\tif (data.endsWith(`${ESC}\\\\`)) {\n\t\treturn \"complete\";\n\t}\n\n\treturn \"incomplete\";\n}\n\n/**\n * Check if APC (Application Program Command) sequence is complete\n * APC sequences: ESC _ ... ST (where ST is ESC \\)\n * Used for Kitty graphics responses like ESC _ G ... ESC \\\n */\nfunction isCompleteApcSequence(data: string): \"complete\" | \"incomplete\" {\n\tif (!data.startsWith(`${ESC}_`)) {\n\t\treturn \"complete\";\n\t}\n\n\t// APC sequences end with ST (ESC \\)\n\tif (data.endsWith(`${ESC}\\\\`)) {\n\t\treturn \"complete\";\n\t}\n\n\treturn \"incomplete\";\n}\n\n/**\n * Split accumulated buffer into complete sequences\n */\nfunction parseUnmodifiedKittyPrintableCodepoint(sequence: string): number | undefined {\n\tconst match = sequence.match(/^\\x1b\\[(\\d+)(?::\\d*)?(?::\\d+)?u$/);\n\tif (!match) return undefined;\n\n\tconst codepoint = parseInt(match[1]!, 10);\n\treturn codepoint >= 32 ? codepoint : undefined;\n}\n\nfunction extractCompleteSequences(buffer: string): { sequences: string[]; remainder: string } {\n\tconst sequences: string[] = [];\n\tlet pos = 0;\n\n\twhile (pos < buffer.length) {\n\t\tconst remaining = buffer.slice(pos);\n\n\t\t// Try to extract a sequence starting at this position\n\t\tif (remaining.startsWith(ESC)) {\n\t\t\t// Find the end of this escape sequence\n\t\t\tlet seqEnd = 1;\n\t\t\twhile (seqEnd <= remaining.length) {\n\t\t\t\tconst candidate = remaining.slice(0, seqEnd);\n\t\t\t\tconst status = isCompleteSequence(candidate);\n\n\t\t\t\tif (status === \"complete\") {\n\t\t\t\t\t// WezTerm with enable_kitty_keyboard sends the Escape key press as a\n\t\t\t\t\t// raw '\\x1b' byte (simple text path in encode_kitty, ignoring\n\t\t\t\t\t// DISAMBIGUATE_ESCAPE_CODES) and the release as a full Kitty CSI-u\n\t\t\t\t\t// sequence. These arrive concatenated as '\\x1b\\x1b[27;...u'.\n\t\t\t\t\t// The buffer would normally treat '\\x1b\\x1b' as a complete meta-key\n\t\t\t\t\t// sequence (ESC + single char), leaving '[27;...u' to be typed as\n\t\t\t\t\t// plain text. If the character immediately following '\\x1b\\x1b'\n\t\t\t\t\t// would begin a new escape sequence, emit only the first ESC and\n\t\t\t\t\t// restart from the second.\n\t\t\t\t\tif (candidate === \"\\x1b\\x1b\") {\n\t\t\t\t\t\tconst nextChar = remaining[seqEnd];\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnextChar === \"[\" || // CSI\n\t\t\t\t\t\t\tnextChar === \"]\" || // OSC\n\t\t\t\t\t\t\tnextChar === \"O\" || // SS3\n\t\t\t\t\t\t\tnextChar === \"P\" || // DCS\n\t\t\t\t\t\t\tnextChar === \"_\" // APC\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsequences.push(ESC);\n\t\t\t\t\t\t\tpos += 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsequences.push(candidate);\n\t\t\t\t\tpos += seqEnd;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (status === \"incomplete\") {\n\t\t\t\t\tseqEnd++;\n\t\t\t\t} else {\n\t\t\t\t\t// Should not happen when starting with ESC\n\t\t\t\t\tsequences.push(candidate);\n\t\t\t\t\tpos += seqEnd;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (seqEnd > remaining.length) {\n\t\t\t\treturn { sequences, remainder: remaining };\n\t\t\t}\n\t\t} else {\n\t\t\tconst codepoint = remaining.codePointAt(0)!;\n\t\t\tconst character = String.fromCodePoint(codepoint);\n\t\t\tsequences.push(character);\n\t\t\tpos += character.length;\n\t\t}\n\t}\n\n\treturn { sequences, remainder: \"\" };\n}\n\nexport type StdinBufferOptions = {\n\t/**\n\t * Maximum time to wait for an incomplete sequence such as CSI or mouse\n\t * (default: 50ms).\n\t */\n\ttimeout?: number;\n\t/**\n\t * Maximum time to wait after a lone ESC before treating it as Escape\n\t * (default: 10ms). Increase for high-latency Alt+key input (SSH).\n\t */\n\tescapeTimeout?: number;\n};\n\nexport type StdinBufferEventMap = {\n\tdata: [string];\n\tpaste: [string];\n};\n\n/**\n * Buffers stdin input and emits complete sequences via the 'data' event.\n * Handles partial escape sequences that arrive across multiple chunks.\n */\nexport class StdinBuffer extends EventEmitter<StdinBufferEventMap> {\n\tprivate buffer: string = \"\";\n\tprivate timeout: ReturnType<typeof setTimeout> | null = null;\n\tprivate readonly timeoutMs: number;\n\tprivate readonly escapeTimeoutMs: number;\n\tprivate pasteMode: boolean = false;\n\tprivate pasteBuffer: string = \"\";\n\tprivate pendingKittyPrintableCodepoint: number | undefined;\n\tprivate decoder: StatefulStringDecoder = new StringDecoder(\"utf8\");\n\n\tconstructor(options: StdinBufferOptions = {}) {\n\t\tsuper();\n\t\tthis.timeoutMs = options.timeout ?? DEFAULT_SEQUENCE_TIMEOUT_MS;\n\t\tthis.escapeTimeoutMs = options.escapeTimeout ?? DEFAULT_ESCAPE_TIMEOUT_MS;\n\t}\n\n\tpublic process(data: string | Buffer): void {\n\t\t// Clear any pending timeout\n\t\tif (this.timeout) {\n\t\t\tclearTimeout(this.timeout);\n\t\t\tthis.timeout = null;\n\t\t}\n\n\t\tlet str: string;\n\t\tlet decodedFromBuffer = false;\n\t\tif (Buffer.isBuffer(data)) {\n\t\t\tconst hasPendingUtf8Bytes = (this.decoder.lastNeed ?? 0) > 0;\n\t\t\tif (!hasPendingUtf8Bytes && data.length === 1 && data[0]! >= 0x80 && data[0]! < 0xc2) {\n\t\t\t\tconst byte = data[0]! - 128;\n\t\t\t\tstr = `\\x1b${String.fromCharCode(byte)}`;\n\t\t\t} else {\n\t\t\t\tstr = this.decoder.write(data);\n\t\t\t\tdecodedFromBuffer = true;\n\t\t\t}\n\t\t} else {\n\t\t\tstr = data;\n\t\t}\n\n\t\tif (str.length === 0 && this.buffer.length === 0) {\n\t\t\tif (!decodedFromBuffer) {\n\t\t\t\tthis.emitDataSequence(\"\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis.buffer += str;\n\n\t\tif (this.pasteMode) {\n\t\t\tthis.pasteBuffer += this.buffer;\n\t\t\tthis.buffer = \"\";\n\n\t\t\tconst endIndex = this.pasteBuffer.indexOf(BRACKETED_PASTE_END);\n\t\t\tif (endIndex !== -1) {\n\t\t\t\tconst pastedContent = this.pasteBuffer.slice(0, endIndex);\n\t\t\t\tconst remaining = this.pasteBuffer.slice(endIndex + BRACKETED_PASTE_END.length);\n\n\t\t\t\tthis.pasteMode = false;\n\t\t\t\tthis.pasteBuffer = \"\";\n\t\t\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\n\t\t\t\tthis.emit(\"paste\", pastedContent);\n\n\t\t\t\tif (remaining.length > 0) {\n\t\t\t\t\tthis.process(remaining);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst startIndex = this.buffer.indexOf(BRACKETED_PASTE_START);\n\t\tif (startIndex !== -1) {\n\t\t\tif (startIndex > 0) {\n\t\t\t\tconst beforePaste = this.buffer.slice(0, startIndex);\n\t\t\t\tconst result = extractCompleteSequences(beforePaste);\n\t\t\t\tfor (const sequence of result.sequences) {\n\t\t\t\t\tthis.emitDataSequence(sequence);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\t\t\tthis.buffer = this.buffer.slice(startIndex + BRACKETED_PASTE_START.length);\n\t\t\tthis.pasteMode = true;\n\t\t\tthis.pasteBuffer = this.buffer;\n\t\t\tthis.buffer = \"\";\n\n\t\t\tconst endIndex = this.pasteBuffer.indexOf(BRACKETED_PASTE_END);\n\t\t\tif (endIndex !== -1) {\n\t\t\t\tconst pastedContent = this.pasteBuffer.slice(0, endIndex);\n\t\t\t\tconst remaining = this.pasteBuffer.slice(endIndex + BRACKETED_PASTE_END.length);\n\n\t\t\t\tthis.pasteMode = false;\n\t\t\t\tthis.pasteBuffer = \"\";\n\t\t\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\n\t\t\t\tthis.emit(\"paste\", pastedContent);\n\n\t\t\t\tif (remaining.length > 0) {\n\t\t\t\t\tthis.process(remaining);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst result = extractCompleteSequences(this.buffer);\n\t\tthis.buffer = result.remainder;\n\n\t\tfor (const sequence of result.sequences) {\n\t\t\tthis.emitDataSequence(sequence);\n\t\t}\n\n\t\tif (this.buffer.length > 0) {\n\t\t\tconst timeoutMs = this.buffer === ESC ? this.escapeTimeoutMs : this.timeoutMs;\n\t\t\tthis.timeout = setTimeout(() => {\n\t\t\t\tconst flushed = this.flush();\n\n\t\t\t\tfor (const sequence of flushed) {\n\t\t\t\t\tthis.emitDataSequence(sequence);\n\t\t\t\t}\n\t\t\t}, timeoutMs);\n\t\t}\n\t}\n\n\tprivate emitDataSequence(sequence: string): void {\n\t\tconst rawCodepoint = sequence.length === 1 ? sequence.codePointAt(0) : undefined;\n\t\tif (rawCodepoint !== undefined && rawCodepoint === this.pendingKittyPrintableCodepoint) {\n\t\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pendingKittyPrintableCodepoint = parseUnmodifiedKittyPrintableCodepoint(sequence);\n\t\tthis.emit(\"data\", sequence);\n\t}\n\n\tflush(): string[] {\n\t\tif (this.timeout) {\n\t\t\tclearTimeout(this.timeout);\n\t\t\tthis.timeout = null;\n\t\t}\n\n\t\tif (this.buffer.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst sequences = [this.buffer];\n\t\tthis.buffer = \"\";\n\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\t\treturn sequences;\n\t}\n\n\tclear(): void {\n\t\tif (this.timeout) {\n\t\t\tclearTimeout(this.timeout);\n\t\t\tthis.timeout = null;\n\t\t}\n\t\tthis.buffer = \"\";\n\t\tthis.pasteMode = false;\n\t\tthis.pasteBuffer = \"\";\n\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\t\tthis.decoder = new StringDecoder(\"utf8\");\n\t}\n\n\tgetBuffer(): string {\n\t\treturn this.buffer;\n\t}\n\n\tdestroy(): void {\n\t\tthis.clear();\n\t}\n}\n"]}
1
+ {"version":3,"file":"stdin-buffer.js","sourceRoot":"","sources":["../src/stdin-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,GAAG,GAAG,MAAM,CAAC;AACnB,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AACrC,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAC1C,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAMxC;;GAEG;AACH,SAAS,kBAAkB,CAAC,IAAY;IAC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CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED,SAAS;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,OAAO;QACN,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;CACD","sourcesContent":["/**\n * StdinBuffer buffers input and emits complete sequences.\n *\n * This is necessary because stdin data events can arrive in partial chunks,\n * especially for escape sequences like mouse events. Without buffering,\n * partial sequences can be misinterpreted as regular keypresses.\n *\n * For example, the mouse SGR sequence `\\x1b[<35;20;5m` might arrive as:\n * - Event 1: `\\x1b`\n * - Event 2: `[<35`\n * - Event 3: `;20;5m`\n *\n * The buffer accumulates these until a complete sequence is detected.\n * Call the `process()` method to feed input data.\n *\n * Based on code from OpenTUI (https://github.com/anomalyco/opentui)\n * MIT License - Copyright (c) 2025 opentui\n */\n\nimport { StringDecoder } from \"node:string_decoder\";\nimport { EventEmitter } from \"events\";\n\nconst ESC = \"\\x1b\";\nconst DEFAULT_SEQUENCE_TIMEOUT_MS = 50;\nconst DEFAULT_ESCAPE_TIMEOUT_MS = 10;\nconst BRACKETED_PASTE_START = \"\\x1b[200~\";\nconst BRACKETED_PASTE_END = \"\\x1b[201~\";\n\ntype StatefulStringDecoder = StringDecoder & {\n\treadonly lastNeed?: number;\n};\n\n/**\n * Check if a string is a complete escape sequence or needs more data\n */\nfunction isCompleteSequence(data: string): \"complete\" | \"incomplete\" | \"not-escape\" {\n\tif (!data.startsWith(ESC)) {\n\t\treturn \"not-escape\";\n\t}\n\n\tif (data.length === 1) {\n\t\treturn \"incomplete\";\n\t}\n\n\tconst afterEsc = data.slice(1);\n\n\t// CSI sequences: ESC [\n\tif (afterEsc.startsWith(\"[\")) {\n\t\t// Check for old-style mouse sequence: ESC[M + 3 bytes\n\t\tif (afterEsc.startsWith(\"[M\")) {\n\t\t\t// Old-style mouse needs ESC[M + 3 bytes = 6 total\n\t\t\treturn data.length >= 6 ? \"complete\" : \"incomplete\";\n\t\t}\n\t\treturn isCompleteCsiSequence(data);\n\t}\n\n\t// OSC sequences: ESC ]\n\tif (afterEsc.startsWith(\"]\")) {\n\t\treturn isCompleteOscSequence(data);\n\t}\n\n\t// DCS sequences: ESC P ... ESC \\ (includes XTVersion responses)\n\tif (afterEsc.startsWith(\"P\")) {\n\t\treturn isCompleteDcsSequence(data);\n\t}\n\n\t// APC sequences: ESC _ ... ESC \\ (includes Kitty graphics responses)\n\tif (afterEsc.startsWith(\"_\")) {\n\t\treturn isCompleteApcSequence(data);\n\t}\n\n\t// SS3 sequences: ESC O\n\tif (afterEsc.startsWith(\"O\")) {\n\t\t// ESC O followed by a single character\n\t\treturn afterEsc.length >= 2 ? \"complete\" : \"incomplete\";\n\t}\n\n\t// Meta key sequences: ESC followed by a single character\n\tif (afterEsc.length === 1) {\n\t\treturn \"complete\";\n\t}\n\n\t// Unknown escape sequence - treat as complete\n\treturn \"complete\";\n}\n\n/**\n * Check if CSI sequence is complete\n * CSI sequences: ESC [ ... followed by a final byte (0x40-0x7E)\n */\nfunction isCompleteCsiSequence(data: string): \"complete\" | \"incomplete\" {\n\tif (!data.startsWith(`${ESC}[`)) {\n\t\treturn \"complete\";\n\t}\n\n\t// Need at least ESC [ and one more character\n\tif (data.length < 3) {\n\t\treturn \"incomplete\";\n\t}\n\n\tconst payload = data.slice(2);\n\n\t// CSI sequences end with a byte in the range 0x40-0x7E (@-~)\n\t// This includes all letters and several special characters\n\tconst lastChar = payload[payload.length - 1];\n\tconst lastCharCode = lastChar.charCodeAt(0);\n\n\tif (lastCharCode >= 0x40 && lastCharCode <= 0x7e) {\n\t\t// Special handling for SGR mouse sequences\n\t\t// Format: ESC[<B;X;Ym or ESC[<B;X;YM\n\t\tif (payload.startsWith(\"<\")) {\n\t\t\t// Must have format: <digits;digits;digits[Mm]\n\t\t\tconst mouseMatch = /^<\\d+;\\d+;\\d+[Mm]$/.test(payload);\n\t\t\tif (mouseMatch) {\n\t\t\t\treturn \"complete\";\n\t\t\t}\n\t\t\t// If it ends with M or m but doesn't match the pattern, still incomplete\n\t\t\tif (lastChar === \"M\" || lastChar === \"m\") {\n\t\t\t\t// Check if we have the right structure\n\t\t\t\tconst parts = payload.slice(1, -1).split(\";\");\n\t\t\t\tif (parts.length === 3 && parts.every((p) => /^\\d+$/.test(p))) {\n\t\t\t\t\treturn \"complete\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn \"incomplete\";\n\t\t}\n\n\t\treturn \"complete\";\n\t}\n\n\treturn \"incomplete\";\n}\n\n/**\n * Check if OSC sequence is complete\n * OSC sequences: ESC ] ... ST (where ST is ESC \\ or BEL)\n */\nfunction isCompleteOscSequence(data: string): \"complete\" | \"incomplete\" {\n\tif (!data.startsWith(`${ESC}]`)) {\n\t\treturn \"complete\";\n\t}\n\n\t// OSC sequences end with ST (ESC \\) or BEL (\\x07)\n\tif (data.endsWith(`${ESC}\\\\`) || data.endsWith(\"\\x07\")) {\n\t\treturn \"complete\";\n\t}\n\n\treturn \"incomplete\";\n}\n\n/**\n * Check if DCS (Device Control String) sequence is complete\n * DCS sequences: ESC P ... ST (where ST is ESC \\)\n * Used for XTVersion responses like ESC P >| ... ESC \\\n */\nfunction isCompleteDcsSequence(data: string): \"complete\" | \"incomplete\" {\n\tif (!data.startsWith(`${ESC}P`)) {\n\t\treturn \"complete\";\n\t}\n\n\t// DCS sequences end with ST (ESC \\)\n\tif (data.endsWith(`${ESC}\\\\`)) {\n\t\treturn \"complete\";\n\t}\n\n\treturn \"incomplete\";\n}\n\n/**\n * Check if APC (Application Program Command) sequence is complete\n * APC sequences: ESC _ ... ST (where ST is ESC \\)\n * Used for Kitty graphics responses like ESC _ G ... ESC \\\n */\nfunction isCompleteApcSequence(data: string): \"complete\" | \"incomplete\" {\n\tif (!data.startsWith(`${ESC}_`)) {\n\t\treturn \"complete\";\n\t}\n\n\t// APC sequences end with ST (ESC \\)\n\tif (data.endsWith(`${ESC}\\\\`)) {\n\t\treturn \"complete\";\n\t}\n\n\treturn \"incomplete\";\n}\n\n/**\n * Split accumulated buffer into complete sequences\n */\nfunction parseUnmodifiedKittyPrintableCodepoint(sequence: string): number | undefined {\n\tconst match = sequence.match(/^\\x1b\\[(\\d+)(?::\\d*)?(?::\\d+)?u$/);\n\tif (!match) return undefined;\n\n\tconst codepoint = parseInt(match[1]!, 10);\n\treturn codepoint >= 32 ? codepoint : undefined;\n}\n\nfunction extractCompleteSequences(buffer: string): { sequences: string[]; remainder: string } {\n\tconst sequences: string[] = [];\n\tlet pos = 0;\n\n\twhile (pos < buffer.length) {\n\t\tconst remaining = buffer.slice(pos);\n\n\t\t// Try to extract a sequence starting at this position\n\t\tif (remaining.startsWith(ESC)) {\n\t\t\t// Find the end of this escape sequence\n\t\t\tlet seqEnd = 1;\n\t\t\twhile (seqEnd <= remaining.length) {\n\t\t\t\tconst candidate = remaining.slice(0, seqEnd);\n\t\t\t\tconst status = isCompleteSequence(candidate);\n\n\t\t\t\tif (status === \"complete\") {\n\t\t\t\t\t// WezTerm with enable_kitty_keyboard sends the Escape key press as a\n\t\t\t\t\t// raw '\\x1b' byte (simple text path in encode_kitty, ignoring\n\t\t\t\t\t// DISAMBIGUATE_ESCAPE_CODES) and the release as a full Kitty CSI-u\n\t\t\t\t\t// sequence. These arrive concatenated as '\\x1b\\x1b[27;...u'.\n\t\t\t\t\t// The buffer would normally treat '\\x1b\\x1b' as a complete meta-key\n\t\t\t\t\t// sequence (ESC + single char), leaving '[27;...u' to be typed as\n\t\t\t\t\t// plain text. If the character immediately following '\\x1b\\x1b'\n\t\t\t\t\t// would begin a new escape sequence, emit only the first ESC and\n\t\t\t\t\t// restart from the second.\n\t\t\t\t\tif (candidate === \"\\x1b\\x1b\") {\n\t\t\t\t\t\tconst nextChar = remaining[seqEnd];\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnextChar === \"[\" || // CSI\n\t\t\t\t\t\t\tnextChar === \"]\" || // OSC\n\t\t\t\t\t\t\tnextChar === \"O\" || // SS3\n\t\t\t\t\t\t\tnextChar === \"P\" || // DCS\n\t\t\t\t\t\t\tnextChar === \"_\" // APC\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsequences.push(ESC);\n\t\t\t\t\t\t\tpos += 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsequences.push(candidate);\n\t\t\t\t\tpos += seqEnd;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (status === \"incomplete\") {\n\t\t\t\t\tseqEnd++;\n\t\t\t\t} else {\n\t\t\t\t\t// Should not happen when starting with ESC\n\t\t\t\t\tsequences.push(candidate);\n\t\t\t\t\tpos += seqEnd;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (seqEnd > remaining.length) {\n\t\t\t\treturn { sequences, remainder: remaining };\n\t\t\t}\n\t\t} else {\n\t\t\tconst codepoint = remaining.codePointAt(0)!;\n\t\t\tconst character = String.fromCodePoint(codepoint);\n\t\t\tsequences.push(character);\n\t\t\tpos += character.length;\n\t\t}\n\t}\n\n\treturn { sequences, remainder: \"\" };\n}\n\nexport type StdinBufferOptions = {\n\t/**\n\t * Maximum time to wait for an incomplete sequence such as CSI or mouse\n\t * (default: 50ms).\n\t */\n\ttimeout?: number;\n\t/**\n\t * Maximum time to wait after a lone ESC before treating it as Escape\n\t * (default: 10ms). Increase for high-latency Alt+key input (SSH).\n\t */\n\tescapeTimeout?: number;\n};\n\nexport type StdinBufferEventMap = {\n\tdata: [string];\n\tpaste: [string];\n};\n\n/**\n * Buffers stdin input and emits complete sequences via the 'data' event.\n * Handles partial escape sequences that arrive across multiple chunks.\n */\nexport class StdinBuffer extends EventEmitter<StdinBufferEventMap> {\n\tprivate buffer: string = \"\";\n\tprivate timeout: ReturnType<typeof setTimeout> | null = null;\n\tprivate readonly timeoutMs: number;\n\tprivate readonly escapeTimeoutMs: number;\n\tprivate mouseFragmentStartedAt?: number;\n\tprivate discardingMouseFragment = false;\n\tprivate pasteMode: boolean = false;\n\tprivate pasteBuffer: string = \"\";\n\tprivate pendingKittyPrintableCodepoint: number | undefined;\n\tprivate decoder: StatefulStringDecoder = new StringDecoder(\"utf8\");\n\n\tconstructor(options: StdinBufferOptions = {}) {\n\t\tsuper();\n\t\tthis.timeoutMs = options.timeout ?? DEFAULT_SEQUENCE_TIMEOUT_MS;\n\t\tthis.escapeTimeoutMs = options.escapeTimeout ?? DEFAULT_ESCAPE_TIMEOUT_MS;\n\t}\n\n\tpublic process(data: string | Buffer): void {\n\t\t// Clear any pending timeout\n\t\tif (this.timeout) {\n\t\t\tclearTimeout(this.timeout);\n\t\t\tthis.timeout = null;\n\t\t}\n\n\t\tlet str: string;\n\t\tlet decodedFromBuffer = false;\n\t\tif (Buffer.isBuffer(data)) {\n\t\t\tconst hasPendingUtf8Bytes = (this.decoder.lastNeed ?? 0) > 0;\n\t\t\tif (!hasPendingUtf8Bytes && data.length === 1 && data[0]! >= 0x80 && data[0]! < 0xc2) {\n\t\t\t\tconst byte = data[0]! - 128;\n\t\t\t\tstr = `\\x1b${String.fromCharCode(byte)}`;\n\t\t\t} else {\n\t\t\t\tstr = this.decoder.write(data);\n\t\t\t\tdecodedFromBuffer = true;\n\t\t\t}\n\t\t} else {\n\t\t\tstr = data;\n\t\t}\n\n\t\tif (str.length === 0 && this.buffer.length === 0) {\n\t\t\tif (!decodedFromBuffer) {\n\t\t\t\tthis.emitDataSequence(\"\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.discardingMouseFragment) {\n\t\t\tconst terminator = str.search(/[\\x40-\\x7e]/);\n\t\t\tconst escapeIndex = str.indexOf(ESC);\n\t\t\tif (escapeIndex !== -1 && (terminator === -1 || escapeIndex < terminator)) {\n\t\t\t\tstr = str.slice(escapeIndex);\n\t\t\t} else {\n\t\t\t\tif (terminator === -1) return;\n\t\t\t\tstr = str.slice(terminator + 1);\n\t\t\t}\n\t\t\tthis.discardingMouseFragment = false;\n\t\t}\n\t\tthis.buffer += str;\n\n\t\tif (this.pasteMode) {\n\t\t\tthis.pasteBuffer += this.buffer;\n\t\t\tthis.buffer = \"\";\n\n\t\t\tconst endIndex = this.pasteBuffer.indexOf(BRACKETED_PASTE_END);\n\t\t\tif (endIndex !== -1) {\n\t\t\t\tconst pastedContent = this.pasteBuffer.slice(0, endIndex);\n\t\t\t\tconst remaining = this.pasteBuffer.slice(endIndex + BRACKETED_PASTE_END.length);\n\n\t\t\t\tthis.pasteMode = false;\n\t\t\t\tthis.pasteBuffer = \"\";\n\t\t\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\n\t\t\t\tthis.emit(\"paste\", pastedContent);\n\n\t\t\t\tif (remaining.length > 0) {\n\t\t\t\t\tthis.process(remaining);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst startIndex = this.buffer.indexOf(BRACKETED_PASTE_START);\n\t\tif (startIndex !== -1) {\n\t\t\tif (startIndex > 0) {\n\t\t\t\tconst beforePaste = this.buffer.slice(0, startIndex);\n\t\t\t\tconst result = extractCompleteSequences(beforePaste);\n\t\t\t\tfor (const sequence of result.sequences) {\n\t\t\t\t\tthis.emitDataSequence(sequence);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\t\t\tthis.buffer = this.buffer.slice(startIndex + BRACKETED_PASTE_START.length);\n\t\t\tthis.pasteMode = true;\n\t\t\tthis.pasteBuffer = this.buffer;\n\t\t\tthis.buffer = \"\";\n\n\t\t\tconst endIndex = this.pasteBuffer.indexOf(BRACKETED_PASTE_END);\n\t\t\tif (endIndex !== -1) {\n\t\t\t\tconst pastedContent = this.pasteBuffer.slice(0, endIndex);\n\t\t\t\tconst remaining = this.pasteBuffer.slice(endIndex + BRACKETED_PASTE_END.length);\n\n\t\t\t\tthis.pasteMode = false;\n\t\t\t\tthis.pasteBuffer = \"\";\n\t\t\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\n\t\t\t\tthis.emit(\"paste\", pastedContent);\n\n\t\t\t\tif (remaining.length > 0) {\n\t\t\t\t\tthis.process(remaining);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst result = extractCompleteSequences(this.buffer);\n\t\tthis.buffer = result.remainder;\n\t\tif (this.buffer.startsWith(\"\\x1b[<\")) {\n\t\t\tthis.mouseFragmentStartedAt ??= Date.now();\n\t\t\tif (this.buffer.length > 64) {\n\t\t\t\tthis.buffer = \"\";\n\t\t\t\tthis.discardingMouseFragment = true;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.mouseFragmentStartedAt = undefined;\n\t\t}\n\n\t\tfor (const sequence of result.sequences) {\n\t\t\tthis.emitDataSequence(sequence);\n\t\t}\n\n\t\tif (this.buffer.length > 0) {\n\t\t\tconst timeoutMs = this.buffer === ESC ? this.escapeTimeoutMs : this.timeoutMs;\n\t\t\tthis.timeout = setTimeout(() => {\n\t\t\t\tconst flushed = this.flush();\n\n\t\t\t\tfor (const sequence of flushed) {\n\t\t\t\t\tthis.emitDataSequence(sequence);\n\t\t\t\t}\n\t\t\t}, timeoutMs);\n\t\t}\n\t}\n\n\tprivate emitDataSequence(sequence: string): void {\n\t\tconst rawCodepoint = sequence.length === 1 ? sequence.codePointAt(0) : undefined;\n\t\tif (rawCodepoint !== undefined && rawCodepoint === this.pendingKittyPrintableCodepoint) {\n\t\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pendingKittyPrintableCodepoint = parseUnmodifiedKittyPrintableCodepoint(sequence);\n\t\tthis.emit(\"data\", sequence);\n\t}\n\n\tflush(): string[] {\n\t\tif (this.timeout) {\n\t\t\tclearTimeout(this.timeout);\n\t\t\tthis.timeout = null;\n\t\t}\n\n\t\tif (this.buffer.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (this.buffer.startsWith(\"\\x1b[<\")) {\n\t\t\tconst remaining = 750 - (Date.now() - (this.mouseFragmentStartedAt ?? Date.now()));\n\t\t\tif (remaining > 0 && this.buffer.length <= 64) {\n\t\t\t\tthis.timeout = setTimeout(() => this.flush(), remaining);\n\t\t\t} else {\n\t\t\t\tthis.buffer = \"\";\n\t\t\t\tthis.mouseFragmentStartedAt = undefined;\n\t\t\t\tthis.discardingMouseFragment = true;\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst sequences = [this.buffer];\n\t\tthis.buffer = \"\";\n\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\t\treturn sequences;\n\t}\n\n\tclear(): void {\n\t\tif (this.timeout) {\n\t\t\tclearTimeout(this.timeout);\n\t\t\tthis.timeout = null;\n\t\t}\n\t\tthis.buffer = \"\";\n\t\tthis.pasteMode = false;\n\t\tthis.pasteBuffer = \"\";\n\t\tthis.mouseFragmentStartedAt = undefined;\n\t\tthis.discardingMouseFragment = false;\n\t\tthis.pendingKittyPrintableCodepoint = undefined;\n\t\tthis.decoder = new StringDecoder(\"utf8\");\n\t}\n\n\tgetBuffer(): string {\n\t\treturn this.buffer;\n\t}\n\n\tdestroy(): void {\n\t\tthis.clear();\n\t}\n}\n"]}
@@ -1,9 +1,17 @@
1
+ export interface CursorPosition {
2
+ row: number;
3
+ column: number;
4
+ page?: number;
5
+ }
6
+ export declare function parseCursorPositionResponse(sequence: string): CursorPosition | undefined;
1
7
  export type KeyboardProtocolNegotiationSequence = {
2
8
  type: "kitty-flags";
3
9
  flags: number;
4
10
  } | {
5
11
  type: "device-attributes";
6
- };
12
+ } | ({
13
+ type: "cursor-position";
14
+ } & CursorPosition);
7
15
  export declare function parseKeyboardProtocolNegotiationSequence(sequence: string): KeyboardProtocolNegotiationSequence | undefined;
8
16
  export declare function isAppleTerminalSession(): boolean;
9
17
  /**
@@ -31,6 +39,10 @@ export interface Terminal {
31
39
  * @param idleMs - Exit early if no input arrives within this time (default: 50ms)
32
40
  */
33
41
  drainInput(maxMs?: number, idleMs?: number): Promise<void>;
42
+ /** Optional for virtual/custom terminals that cannot answer private DECXCPR. */
43
+ queryCursorPosition?(): Promise<CursorPosition | undefined>;
44
+ /** Observe external writes without changing their output policy. */
45
+ observeExternalWrites?(listener: () => void): () => void;
34
46
  write(data: string): void;
35
47
  get columns(): number;
36
48
  get rows(): number;
@@ -67,6 +79,11 @@ export declare class ProcessTerminal implements Terminal {
67
79
  private onExternalStdoutWrite?;
68
80
  private originalStdoutWrite?;
69
81
  private rawStdoutWrite?;
82
+ private originalStderrWrite?;
83
+ private readonly externalWriteObservers;
84
+ private keyboardNegotiationSettled;
85
+ private cursorQueryTimedOut;
86
+ private cursorQuery?;
70
87
  private forwardingExternalWrite;
71
88
  private inputHandler?;
72
89
  private resizeHandler?;
@@ -74,6 +91,7 @@ export declare class ProcessTerminal implements Terminal {
74
91
  private _modifyOtherKeysActive;
75
92
  private keyboardProtocolPushed;
76
93
  private keyboardProtocolNegotiationBuffer;
94
+ private discardingPrivateResponse;
77
95
  private keyboardProtocolBufferFlushTimer?;
78
96
  private stdinBuffer?;
79
97
  private stdinDataHandler?;
@@ -83,6 +101,12 @@ export declare class ProcessTerminal implements Terminal {
83
101
  private writeLogPath;
84
102
  constructor(options?: ProcessTerminalOptions);
85
103
  get kittyProtocolActive(): boolean;
104
+ queryCursorPosition(): Promise<CursorPosition | undefined>;
105
+ private issueCursorQuery;
106
+ private settleCursorQuery;
107
+ observeExternalWrites(listener: () => void): () => void;
108
+ private noteExternalWrite;
109
+ private installExternalStderrObserver;
86
110
  private rawWrite;
87
111
  private installExternalStdoutGuard;
88
112
  private removeExternalStdoutGuard;
@@ -1 +1 @@
1
- {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,mCAAmC,GAC5C;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEjC,wBA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