@linxiraos/pi-tui 1.1.26 → 1.2.0
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/CHANGELOG.md +51 -491
- package/README.md +13 -7
- package/dist/types/active-terminal.d.ts +30 -0
- package/dist/types/app-keybindings.d.ts +7 -2
- package/dist/types/apps/cleanse-board.d.ts +1 -1
- package/dist/types/apps/debug/log-viewer.d.ts +4 -0
- package/dist/types/apps/debug/raw-sse-buffer.d.ts +2 -0
- package/dist/types/apps/git/git-tui.d.ts +5 -4
- package/dist/types/apps/git/help.d.ts +3 -1
- package/dist/types/apps/if-bench-board.d.ts +2 -2
- package/dist/types/apps/setup-model-picker.d.ts +1 -1
- package/dist/types/autocomplete.d.ts +5 -2
- package/dist/types/charts/chart-plan.d.ts +674 -0
- package/dist/types/charts/chart-svg.d.ts +59 -0
- package/dist/types/charts/table-data.d.ts +175 -0
- package/dist/types/chat/assistant-message.d.ts +11 -1
- package/dist/types/chat/chat-transcript-builder.d.ts +3 -0
- package/dist/types/chat/compaction-summary-message.d.ts +1 -0
- package/dist/types/chat/execution-shared.d.ts +6 -5
- package/dist/types/chat/fence-figure.d.ts +42 -0
- package/dist/types/chat/figure-markdown.d.ts +42 -0
- package/dist/types/chat/messages.d.ts +1 -1
- package/dist/types/chat/svg-figure.d.ts +33 -0
- package/dist/types/chat/svg-source.d.ts +49 -0
- package/dist/types/chat/table-chart.d.ts +89 -0
- package/dist/types/chat/tool-execution.d.ts +2 -0
- package/dist/types/chat/user-message.d.ts +17 -4
- package/dist/types/chrome/shared.d.ts +9 -0
- package/dist/types/chrome/status-notice.d.ts +15 -3
- package/dist/types/chrome/transcript-container.d.ts +6 -0
- package/dist/types/components/box.d.ts +1 -0
- package/dist/types/components/disclosure.d.ts +1 -0
- package/dist/types/components/editor.d.ts +23 -5
- package/dist/types/components/form.d.ts +1 -0
- package/dist/types/components/image.d.ts +26 -44
- package/dist/types/components/input.d.ts +2 -1
- package/dist/types/components/key-value-list.d.ts +1 -0
- package/dist/types/components/layout/row.d.ts +1 -0
- package/dist/types/components/layout/stack.d.ts +1 -0
- package/dist/types/components/loader.d.ts +5 -6
- package/dist/types/components/markdown.d.ts +47 -5
- package/dist/types/components/scroll-view.d.ts +1 -0
- package/dist/types/components/section.d.ts +1 -0
- package/dist/types/components/table.d.ts +1 -0
- package/dist/types/components/text.d.ts +1 -0
- package/dist/types/components/tree-view.d.ts +7 -0
- package/dist/types/components/truncated-text.d.ts +1 -0
- package/dist/types/fuzzy.d.ts +29 -1
- package/dist/types/key-hint-format.d.ts +9 -1
- package/dist/types/keybinding-matchers.d.ts +3 -0
- package/dist/types/keybindings.d.ts +1 -1
- package/dist/types/kitty-graphics.d.ts +2 -2
- package/dist/types/loop-watchdog.d.ts +8 -7
- package/dist/types/multiplexers/cmux.d.ts +16 -0
- package/dist/types/multiplexers/herdr.d.ts +26 -0
- package/dist/types/multiplexers/notify.d.ts +13 -0
- package/dist/types/multiplexers/orca.d.ts +12 -0
- package/dist/types/multiplexers/screen.d.ts +9 -0
- package/dist/types/multiplexers/tmux.d.ts +29 -0
- package/dist/types/multiplexers/types.d.ts +100 -0
- package/dist/types/multiplexers/wmux.d.ts +12 -0
- package/dist/types/multiplexers/zellij.d.ts +12 -0
- package/dist/types/native/apply.d.ts +4 -3
- package/dist/types/native/backend.d.ts +5 -4
- package/dist/types/native/blobs.d.ts +7 -3
- package/dist/types/native/encode.d.ts +8 -6
- package/dist/types/native/node.d.ts +36 -5
- package/dist/types/native/overlay.d.ts +8 -3
- package/dist/types/native/settle.d.ts +4 -3
- package/dist/types/overlays/agent-hub-projection.d.ts +6 -5
- package/dist/types/overlays/agent-hub-types.d.ts +9 -0
- package/dist/types/overlays/agent-hub.d.ts +3 -0
- package/dist/types/overlays/agent-transcript-viewer.d.ts +12 -2
- package/dist/types/overlays/agents-hub.d.ts +9 -0
- package/dist/types/overlays/annotation-overlay.d.ts +19 -2
- package/dist/types/overlays/annotation-types.d.ts +2 -0
- package/dist/types/overlays/ask-dialog.d.ts +5 -2
- package/dist/types/overlays/btw-history-panel.d.ts +13 -1
- package/dist/types/overlays/copy-selector.d.ts +1 -0
- package/dist/types/overlays/history-search.d.ts +10 -0
- package/dist/types/overlays/hook-selector.d.ts +9 -4
- package/dist/types/overlays/hub-frame.d.ts +4 -1
- package/dist/types/overlays/jobs-panel.d.ts +1 -7
- package/dist/types/overlays/model-browser.d.ts +54 -7
- package/dist/types/overlays/model-hub.d.ts +37 -0
- package/dist/types/overlays/oauth-selector.d.ts +0 -1
- package/dist/types/overlays/plan-review-overlay.d.ts +3 -2
- package/dist/types/overlays/report-panel.d.ts +68 -0
- package/dist/types/overlays/rewind-selector.d.ts +1 -0
- package/dist/types/overlays/session-observer-registry.d.ts +2 -0
- package/dist/types/overlays/session-selector.d.ts +6 -2
- package/dist/types/overlays/settings-defs.d.ts +1 -0
- package/dist/types/overlays/thinking-selector.d.ts +2 -2
- package/dist/types/overlays/usage-dashboard.d.ts +12 -8
- package/dist/types/overlays/usage-display.d.ts +3 -1
- package/dist/types/prompt/composer-cache.d.ts +0 -16
- package/dist/types/prompt/composer.d.ts +18 -3
- package/dist/types/prompt/custom-editor.d.ts +25 -13
- package/dist/types/prompt/image-source.d.ts +2 -1
- package/dist/types/prompt/interactive-context-helpers.d.ts +5 -1
- package/dist/types/prompt/model-mention-autocomplete.d.ts +1 -1
- package/dist/types/prompt/welcome.d.ts +7 -2
- package/dist/types/render/composite.d.ts +2 -0
- package/dist/types/render/output-pane.d.ts +1 -0
- package/dist/types/render/render-utils.d.ts +1 -0
- package/dist/types/render/tool-card.d.ts +6 -0
- package/dist/types/render/width-aware-text.d.ts +2 -0
- package/dist/types/setup/scenes/types.d.ts +1 -0
- package/dist/types/space-hold.d.ts +40 -25
- package/dist/types/status-line/component.d.ts +3 -0
- package/dist/types/status-line/context-usage.d.ts +7 -5
- package/dist/types/status-line/host.d.ts +4 -1
- package/dist/types/status-line/segments.d.ts +2 -0
- package/dist/types/status-line/types.d.ts +14 -3
- package/dist/types/terminal-capabilities.d.ts +41 -36
- package/dist/types/terminal-multiplexer.d.ts +127 -14
- package/dist/types/terminal.d.ts +23 -16
- package/dist/types/theme/active-symbols.d.ts +1 -1
- package/dist/types/theme/schema.d.ts +11 -2
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme-class.d.ts +7 -0
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +3 -0
- package/dist/types/thinking.d.ts +1 -1
- package/dist/types/tmux.d.ts +11 -4
- package/dist/types/tools/bash.d.ts +7 -2
- package/dist/types/tools/daemon.d.ts +1 -1
- package/dist/types/tools/eval.d.ts +22 -3
- package/dist/types/tools/glob.d.ts +4 -0
- package/dist/types/tools/native-view.d.ts +47 -0
- package/dist/types/tools/output-meta.d.ts +11 -1
- package/dist/types/tools/renderer.d.ts +37 -2
- package/dist/types/tools/streaming-output.d.ts +20 -1
- package/dist/types/tools/task.d.ts +2 -3
- package/dist/types/tools/write.d.ts +9 -2
- package/dist/types/tools/yield.d.ts +22 -0
- package/dist/types/tui.d.ts +36 -0
- package/dist/types/utils.d.ts +6 -0
- package/dist/types/vim.d.ts +19 -5
- package/dist/types/windows-input-mode.d.ts +33 -1
- package/package.json +13 -9
- package/src/active-terminal.d.ts +30 -0
- package/src/active-terminal.ts +80 -0
- package/src/app-keybindings.d.ts +7 -2
- package/src/app-keybindings.ts +7 -2
- package/src/apps/autoresearch-dashboard.ts +7 -3
- package/src/apps/cleanse-board.ts +2 -2
- package/src/apps/cleanse-picker.ts +1 -1
- package/src/apps/debug/log-viewer.ts +188 -72
- package/src/apps/debug/raw-sse-buffer.ts +8 -0
- package/src/apps/debug/raw-sse.ts +39 -5
- package/src/apps/git/diff-pane.ts +96 -23
- package/src/apps/git/git-tui.ts +23 -16
- package/src/apps/git/help.ts +29 -20
- package/src/apps/git/sidebar.ts +8 -3
- package/src/apps/if-bench-board.ts +2 -2
- package/src/apps/ps-top.ts +2 -2
- package/src/apps/setup-model-picker.ts +1 -1
- package/src/autocomplete.d.ts +5 -2
- package/src/autocomplete.ts +67 -43
- package/src/bracketed-paste.ts +10 -3
- package/src/charts/chart-plan.d.ts +674 -0
- package/src/charts/chart-plan.ts +5081 -0
- package/src/charts/chart-svg.d.ts +59 -0
- package/src/charts/chart-svg.ts +4657 -0
- package/src/charts/table-data.d.ts +175 -0
- package/src/charts/table-data.ts +1478 -0
- package/src/chat/advisor-message.ts +11 -0
- package/src/chat/assistant-message.d.ts +11 -1
- package/src/chat/assistant-message.ts +245 -54
- package/src/chat/chat-transcript-builder.d.ts +3 -0
- package/src/chat/chat-transcript-builder.ts +9 -3
- package/src/chat/compaction-summary-message.d.ts +1 -0
- package/src/chat/compaction-summary-message.ts +8 -0
- package/src/chat/execution-shared.d.ts +6 -5
- package/src/chat/execution-shared.ts +42 -25
- package/src/chat/fence-figure.d.ts +42 -0
- package/src/chat/fence-figure.ts +80 -0
- package/src/chat/figure-markdown.d.ts +42 -0
- package/src/chat/figure-markdown.ts +174 -0
- package/src/chat/messages.d.ts +1 -1
- package/src/chat/messages.ts +1 -1
- package/src/chat/read-tool-group.ts +6 -4
- package/src/chat/skill-message.ts +6 -0
- package/src/chat/svg-figure.d.ts +33 -0
- package/src/chat/svg-figure.ts +399 -0
- package/src/chat/svg-source.d.ts +49 -0
- package/src/chat/svg-source.ts +188 -0
- package/src/chat/table-chart.d.ts +89 -0
- package/src/chat/table-chart.ts +294 -0
- package/src/chat/tool-execution.d.ts +2 -0
- package/src/chat/tool-execution.ts +86 -7
- package/src/chat/user-message.d.ts +17 -4
- package/src/chat/user-message.ts +71 -8
- package/src/chrome/shared.ts +53 -0
- package/src/chrome/status-notice.ts +25 -7
- package/src/chrome/transcript-container.d.ts +6 -0
- package/src/chrome/transcript-container.ts +162 -19
- package/src/components/box.d.ts +1 -0
- package/src/components/box.ts +5 -0
- package/src/components/disclosure.d.ts +1 -0
- package/src/components/disclosure.ts +8 -0
- package/src/components/editor.d.ts +23 -5
- package/src/components/editor.ts +316 -47
- package/src/components/form.d.ts +1 -0
- package/src/components/form.ts +8 -0
- package/src/components/image.d.ts +26 -44
- package/src/components/image.ts +115 -152
- package/src/components/input.d.ts +2 -1
- package/src/components/input.ts +17 -7
- package/src/components/key-value-list.d.ts +1 -0
- package/src/components/key-value-list.ts +4 -0
- package/src/components/layout/row.d.ts +1 -0
- package/src/components/layout/row.ts +7 -0
- package/src/components/layout/stack.d.ts +1 -0
- package/src/components/layout/stack.ts +7 -0
- package/src/components/loader.d.ts +5 -6
- package/src/components/loader.ts +10 -17
- package/src/components/markdown.d.ts +47 -5
- package/src/components/markdown.ts +786 -303
- package/src/components/scroll-view.d.ts +1 -0
- package/src/components/scroll-view.ts +5 -0
- package/src/components/section.d.ts +1 -0
- package/src/components/section.ts +5 -0
- package/src/components/settings-list.ts +2 -0
- package/src/components/table.d.ts +1 -0
- package/src/components/table.ts +4 -0
- package/src/components/text.d.ts +1 -0
- package/src/components/text.ts +7 -0
- package/src/components/tree-view.d.ts +7 -0
- package/src/components/tree-view.ts +38 -8
- package/src/components/truncated-text.d.ts +1 -0
- package/src/components/truncated-text.ts +5 -0
- package/src/desktop-notify.ts +3 -2
- package/src/fuzzy.d.ts +29 -1
- package/src/fuzzy.ts +115 -30
- package/src/hotkeys-markdown.ts +9 -2
- package/src/key-hint-format.d.ts +9 -1
- package/src/key-hint-format.ts +26 -11
- package/src/keybinding-matchers.d.ts +3 -0
- package/src/keybinding-matchers.ts +6 -2
- package/src/keybindings.d.ts +1 -1
- package/src/keybindings.ts +1 -1
- package/src/kitty-graphics.d.ts +2 -2
- package/src/kitty-graphics.ts +11 -5
- package/src/loop-watchdog.d.ts +8 -7
- package/src/loop-watchdog.ts +18 -13
- package/src/multiplexers/cmux.d.ts +16 -0
- package/src/multiplexers/cmux.ts +29 -0
- package/src/multiplexers/herdr.d.ts +26 -0
- package/src/multiplexers/herdr.ts +64 -0
- package/src/multiplexers/notify.d.ts +13 -0
- package/src/multiplexers/notify.ts +24 -0
- package/src/multiplexers/orca.d.ts +12 -0
- package/src/multiplexers/orca.ts +16 -0
- package/src/multiplexers/screen.d.ts +9 -0
- package/src/multiplexers/screen.ts +15 -0
- package/src/multiplexers/tmux.d.ts +29 -0
- package/src/multiplexers/tmux.ts +40 -0
- package/src/multiplexers/types.d.ts +100 -0
- package/src/multiplexers/types.ts +110 -0
- package/src/multiplexers/wmux.d.ts +12 -0
- package/src/multiplexers/wmux.ts +16 -0
- package/src/multiplexers/zellij.d.ts +12 -0
- package/src/multiplexers/zellij.ts +24 -0
- package/src/native/apply.d.ts +4 -3
- package/src/native/apply.ts +4 -3
- package/src/native/backend.d.ts +5 -4
- package/src/native/backend.ts +199 -22
- package/src/native/blobs.d.ts +7 -3
- package/src/native/blobs.ts +47 -12
- package/src/native/encode.d.ts +8 -6
- package/src/native/encode.ts +76 -34
- package/src/native/node.d.ts +36 -5
- package/src/native/node.ts +31 -5
- package/src/native/overlay.d.ts +8 -3
- package/src/native/overlay.ts +17 -4
- package/src/native/reconcile.ts +16 -4
- package/src/native/settle.d.ts +4 -3
- package/src/native/settle.ts +4 -3
- package/src/overlays/agent-hub-projection.d.ts +6 -5
- package/src/overlays/agent-hub-projection.ts +124 -13
- package/src/overlays/agent-hub-types.d.ts +9 -0
- package/src/overlays/agent-hub-types.ts +6 -0
- package/src/overlays/agent-hub.ts +48 -29
- package/src/overlays/agent-transcript-viewer.ts +93 -23
- package/src/overlays/agents-hub.ts +28 -8
- package/src/overlays/annotation-overlay.ts +293 -90
- package/src/overlays/annotation-types.ts +2 -0
- package/src/overlays/ask-dialog.ts +10 -17
- package/src/overlays/btw-history-panel.ts +136 -39
- package/src/overlays/copy-selector.d.ts +1 -0
- package/src/overlays/copy-selector.ts +32 -8
- package/src/overlays/extensions/extension-dashboard.ts +4 -4
- package/src/overlays/extensions/state-manager.ts +52 -12
- package/src/overlays/history-search.ts +100 -7
- package/src/overlays/hook-selector.ts +12 -5
- package/src/overlays/hub-frame.ts +19 -1
- package/src/overlays/jobs-panel.ts +33 -52
- package/src/overlays/model-browser.ts +367 -122
- package/src/overlays/model-hub.ts +435 -59
- package/src/overlays/move-overlay.ts +28 -14
- package/src/overlays/oauth-selector.ts +54 -70
- package/src/overlays/pause-screen.ts +2 -2
- package/src/overlays/plan-review-overlay.ts +208 -70
- package/src/overlays/plugin-settings.ts +3 -3
- package/src/overlays/report-panel.ts +191 -0
- package/src/overlays/rewind-selector.ts +88 -17
- package/src/overlays/session-observer-registry.d.ts +2 -0
- package/src/overlays/session-observer-registry.ts +10 -2
- package/src/overlays/session-selector.ts +64 -26
- package/src/overlays/settings-defs.ts +5 -4
- package/src/overlays/settings-selector.ts +33 -8
- package/src/overlays/snapcompact-shape-preview.ts +2 -3
- package/src/overlays/stats-notice.ts +1 -1
- package/src/overlays/thinking-selector.ts +11 -10
- package/src/overlays/tree-selector.ts +41 -20
- package/src/overlays/usage-dashboard.ts +117 -58
- package/src/overlays/usage-display.ts +10 -4
- package/src/overlays/usage-row.ts +22 -8
- package/src/prompt/attachment-chips.ts +15 -11
- package/src/prompt/composer-attachments.ts +6 -4
- package/src/prompt/composer-cache.ts +7 -86
- package/src/prompt/composer.ts +37 -26
- package/src/prompt/custom-editor.ts +282 -105
- package/src/prompt/image-source.ts +2 -1
- package/src/prompt/interactive-context-helpers.ts +32 -18
- package/src/prompt/macos-spelling.ts +7 -0
- package/src/prompt/magic-keywords.ts +11 -2
- package/src/prompt/model-mention-autocomplete.ts +14 -14
- package/src/prompt/queued-messages.ts +6 -4
- package/src/prompt/tips.txt +13 -9
- package/src/prompt/welcome.ts +64 -46
- package/src/prompt/word-completion.ts +38 -5
- package/src/render/composite.d.ts +2 -0
- package/src/render/composite.ts +64 -0
- package/src/render/output-pane.d.ts +1 -0
- package/src/render/output-pane.ts +6 -0
- package/src/render/render-utils.d.ts +1 -0
- package/src/render/render-utils.ts +16 -1
- package/src/render/tool-card.d.ts +6 -0
- package/src/render/tool-card.ts +15 -0
- package/src/render/width-aware-text.d.ts +2 -0
- package/src/render/width-aware-text.ts +5 -0
- package/src/setup/scenes/model.ts +2 -1
- package/src/setup/scenes/types.ts +1 -0
- package/src/space-hold.d.ts +40 -25
- package/src/space-hold.ts +156 -52
- package/src/status-line/component.ts +292 -78
- package/src/status-line/context-usage.ts +21 -46
- package/src/status-line/host.ts +4 -1
- package/src/status-line/segments.ts +40 -22
- package/src/status-line/types.ts +15 -3
- package/src/terminal-capabilities.d.ts +41 -36
- package/src/terminal-capabilities.ts +137 -213
- package/src/terminal-multiplexer.d.ts +127 -14
- package/src/terminal-multiplexer.ts +112 -33
- package/src/terminal.d.ts +23 -16
- package/src/terminal.ts +203 -99
- package/src/theme/active-symbols.d.ts +1 -1
- package/src/theme/active-symbols.ts +1 -1
- package/src/theme/schema-validation.ts +1 -0
- package/src/theme/schema.d.ts +11 -2
- package/src/theme/schema.ts +14 -1
- package/src/theme/session-color.ts +1 -7
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +11 -4
- package/src/theme/theme-class.d.ts +7 -0
- package/src/theme/theme-class.ts +26 -1
- package/src/theme/theme-schema.json +5 -1
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +8 -4
- package/src/theme/tui-adapters.d.ts +3 -0
- package/src/theme/tui-adapters.ts +68 -0
- package/src/thinking.d.ts +1 -1
- package/src/thinking.ts +1 -1
- package/src/tmux.d.ts +11 -4
- package/src/tmux.ts +47 -11
- package/src/tools/ast-edit.ts +59 -35
- package/src/tools/ast-grep.ts +35 -16
- package/src/tools/bash.d.ts +7 -2
- package/src/tools/bash.ts +116 -47
- package/src/tools/daemon.d.ts +1 -1
- package/src/tools/daemon.ts +1 -1
- package/src/tools/default-renderer.ts +35 -19
- package/src/tools/edit.ts +142 -120
- package/src/tools/eval-format/index.ts +28 -2
- package/src/tools/eval-format/javascript.ts +7 -5
- package/src/tools/eval.d.ts +22 -3
- package/src/tools/eval.ts +364 -208
- package/src/tools/fetch.ts +5 -6
- package/src/tools/glob.d.ts +4 -0
- package/src/tools/glob.ts +33 -65
- package/src/tools/grep.ts +81 -48
- package/src/tools/index.ts +2 -0
- package/src/tools/lsp.ts +81 -59
- package/src/tools/mcp.ts +111 -68
- package/src/tools/native-view.d.ts +47 -0
- package/src/tools/native-view.ts +102 -1
- package/src/tools/output-meta.d.ts +11 -1
- package/src/tools/output-meta.ts +23 -3
- package/src/tools/read.ts +7 -5
- package/src/tools/renderer.d.ts +37 -2
- package/src/tools/renderer.ts +42 -2
- package/src/tools/streaming-output.d.ts +20 -1
- package/src/tools/streaming-output.ts +154 -50
- package/src/tools/task.d.ts +2 -3
- package/src/tools/task.ts +115 -62
- package/src/tools/todo.ts +119 -30
- package/src/tools/wait.ts +34 -24
- package/src/tools/web-search.ts +1 -1
- package/src/tools/write.d.ts +9 -2
- package/src/tools/write.ts +147 -95
- package/src/tools/yield.d.ts +22 -0
- package/src/tools/yield.ts +225 -0
- package/src/tui.d.ts +36 -0
- package/src/tui.ts +666 -217
- package/src/utils.d.ts +6 -0
- package/src/utils.ts +19 -0
- package/src/vim.d.ts +19 -5
- package/src/vim.ts +333 -18
- package/src/windows-input-mode.d.ts +33 -1
- package/src/windows-input-mode.ts +212 -6
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
* terminal sends; chords legacy encoding loses (modified Enter/Tab/Escape,
|
|
17
17
|
* Ctrl+Shift+letter, …) translate to kitty CSI-u, which key matching already
|
|
18
18
|
* parses.
|
|
19
|
+
*
|
|
20
|
+
* A host terminal that writes VT instead of key records (any ConPTY host
|
|
21
|
+
* besides Windows Terminal's native path) reaches us as one `Vk = 0` text
|
|
22
|
+
* record per byte: Alt+Up arrives as `ESC`, `[`, `1`, `;`, `3`, `A`. Those
|
|
23
|
+
* bytes are reassembled into the escape sequence they spell; delivering them
|
|
24
|
+
* one at a time turns every such key into a bare Escape plus typed garbage.
|
|
19
25
|
*/
|
|
20
26
|
|
|
21
27
|
const W32IM_PATTERN = /^\x1b\[([\d;]*)_$/;
|
|
@@ -35,6 +41,9 @@ const VK_ESCAPE = 0x1b;
|
|
|
35
41
|
const VK_SPACE = 0x20;
|
|
36
42
|
const VK_PACKET = 0xe7;
|
|
37
43
|
|
|
44
|
+
/** Keys encoded as fixed bytes that can still carry text a pending dead key composed. */
|
|
45
|
+
const COMPOSABLE_FIXED_VKS = new Set([VK_BACK, VK_TAB, VK_RETURN, VK_ESCAPE, VK_SPACE]);
|
|
46
|
+
|
|
38
47
|
/** Modifier and lock keys: their own presses produce no input. */
|
|
39
48
|
const MODIFIER_VKS = new Set([
|
|
40
49
|
0x10, // VK_SHIFT
|
|
@@ -111,6 +120,31 @@ function baseCodepointForVk(vk: number): number {
|
|
|
111
120
|
return 0;
|
|
112
121
|
}
|
|
113
122
|
|
|
123
|
+
/** `split`: the leading ESC is a standalone Escape and the rest starts a new sequence. */
|
|
124
|
+
type VtState = "partial" | "complete" | "invalid" | "split";
|
|
125
|
+
|
|
126
|
+
/** Classify relayed VT text that starts with ESC. */
|
|
127
|
+
function vtState(text: string): VtState {
|
|
128
|
+
if (text.length === 1) return "partial";
|
|
129
|
+
const introducer = text[1]!;
|
|
130
|
+
if (introducer === "\x1b") {
|
|
131
|
+
if (text.length === 2) return "partial";
|
|
132
|
+
// Only meta-CSI/SS3 (legacy Alt+Up is `ESC ESC [ A`) stays grouped; `ESC ESC d`
|
|
133
|
+
// is Escape followed by Alt+d, matching StdinBuffer.
|
|
134
|
+
return text[2] === "[" || text[2] === "O" ? vtState(text.slice(1)) : "split";
|
|
135
|
+
}
|
|
136
|
+
if (introducer === "[") {
|
|
137
|
+
if (/^\x1b\[[0-?]*[ -/]*[@-~]$/.test(text)) return "complete";
|
|
138
|
+
return /^\x1b\[[0-?]*[ -/]*$/.test(text) ? "partial" : "invalid";
|
|
139
|
+
}
|
|
140
|
+
if (introducer === "O") return text.length === 2 ? "partial" : text.length === 3 ? "complete" : "invalid";
|
|
141
|
+
if (introducer === "]" || introducer === "P" || introducer === "_") {
|
|
142
|
+
return text.endsWith("\x07") || (text.length > 3 && text.endsWith("\x1b\\")) ? "complete" : "partial";
|
|
143
|
+
}
|
|
144
|
+
// ESC + one character: Alt+character.
|
|
145
|
+
return text.length === 2 ? "complete" : "invalid";
|
|
146
|
+
}
|
|
147
|
+
|
|
114
148
|
function encodeKey(record: KeyRecord): string | null {
|
|
115
149
|
const { vk, uc, state } = record;
|
|
116
150
|
const shift = (state & SHIFT_PRESSED) !== 0;
|
|
@@ -119,6 +153,11 @@ function encodeKey(record: KeyRecord): string | null {
|
|
|
119
153
|
const mod = 1 + (shift ? 1 : 0) + (alt ? 2 : 0) + (ctrl ? 4 : 0);
|
|
120
154
|
const text = uc === 0 ? "" : String.fromCharCode(uc);
|
|
121
155
|
|
|
156
|
+
// A pending dead key composes onto the next key: on US-International, `'` then
|
|
157
|
+
// Space arrives as a Space record carrying `'`, and `'` then Enter as an Enter
|
|
158
|
+
// record carrying `'` followed by one carrying `\r`. The carried text is the input.
|
|
159
|
+
if (!ctrl && !alt && uc > 0x20 && uc !== 0x7f && COMPOSABLE_FIXED_VKS.has(vk)) return text;
|
|
160
|
+
|
|
122
161
|
switch (vk) {
|
|
123
162
|
case VK_RETURN:
|
|
124
163
|
return mod === 1 ? "\r" : `\x1b[13;${mod}u`;
|
|
@@ -165,9 +204,30 @@ function encodeKey(record: KeyRecord): string | null {
|
|
|
165
204
|
return uc === 0 ? null : text;
|
|
166
205
|
}
|
|
167
206
|
|
|
168
|
-
/**
|
|
207
|
+
/**
|
|
208
|
+
* Stateful decoder: joins UTF-16 surrogate halves that arrive as separate
|
|
209
|
+
* records, and reassembles VT escape sequences relayed as text records.
|
|
210
|
+
*/
|
|
169
211
|
export class Win32InputModeDecoder {
|
|
170
212
|
#pendingHighSurrogate = 0;
|
|
213
|
+
/** Relayed VT text that starts with ESC and has not completed a sequence yet. */
|
|
214
|
+
#pendingVt = "";
|
|
215
|
+
|
|
216
|
+
/** Whether relayed VT text is held waiting for the rest of its sequence. */
|
|
217
|
+
get hasPendingSequence(): boolean {
|
|
218
|
+
return this.#pendingVt.length > 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Release held VT text as-is. The caller invokes this once no further bytes
|
|
223
|
+
* arrived in time, so a lone relayed ESC still acts as the Escape key.
|
|
224
|
+
*/
|
|
225
|
+
flushPendingSequence(): string[] {
|
|
226
|
+
if (this.#pendingVt.length === 0) return [];
|
|
227
|
+
const pending = this.#pendingVt;
|
|
228
|
+
this.#pendingVt = "";
|
|
229
|
+
return [pending];
|
|
230
|
+
}
|
|
171
231
|
|
|
172
232
|
/**
|
|
173
233
|
* Translate one stdin sequence. Returns `undefined` when `data` is not a
|
|
@@ -180,17 +240,42 @@ export class Win32InputModeDecoder {
|
|
|
180
240
|
|
|
181
241
|
if (!record.down) {
|
|
182
242
|
// Alt+Numpad composition delivers its character on the Alt release.
|
|
183
|
-
if (record.vk === VK_MENU && record.uc !== 0) return this.#emitText(record.uc);
|
|
243
|
+
if (record.vk === VK_MENU && record.uc !== 0) return this.#assembleVt(this.#emitText(record.uc));
|
|
184
244
|
return [];
|
|
185
245
|
}
|
|
186
246
|
if (MODIFIER_VKS.has(record.vk)) return [];
|
|
187
|
-
if (record.vk === 0 || record.vk === VK_PACKET) return this.#emitText(record.uc, record.repeat);
|
|
188
|
-
if (record.uc >= 0xd800 && record.uc <= 0xdfff) return this.#emitText(record.uc);
|
|
247
|
+
if (record.vk === 0 || record.vk === VK_PACKET) return this.#assembleVt(this.#emitText(record.uc, record.repeat));
|
|
248
|
+
if (record.uc >= 0xd800 && record.uc <= 0xdfff) return this.#assembleVt(this.#emitText(record.uc));
|
|
189
249
|
|
|
190
250
|
this.#pendingHighSurrogate = 0;
|
|
191
251
|
const encoded = encodeKey(record);
|
|
192
|
-
|
|
193
|
-
|
|
252
|
+
// A real key ends whatever relayed text was still incomplete.
|
|
253
|
+
const flushed = this.flushPendingSequence();
|
|
254
|
+
if (encoded === null) return flushed;
|
|
255
|
+
for (let i = 0; i < record.repeat; i++) flushed.push(encoded);
|
|
256
|
+
return flushed;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Group relayed text into whole escape sequences; other text passes through per character. */
|
|
260
|
+
#assembleVt(texts: string[]): string[] {
|
|
261
|
+
const out: string[] = [];
|
|
262
|
+
for (const text of texts) {
|
|
263
|
+
if (this.#pendingVt.length === 0 && text !== "\x1b") {
|
|
264
|
+
out.push(text);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
this.#pendingVt += text;
|
|
268
|
+
let state = vtState(this.#pendingVt);
|
|
269
|
+
while (state === "split") {
|
|
270
|
+
out.push("\x1b");
|
|
271
|
+
this.#pendingVt = this.#pendingVt.slice(1);
|
|
272
|
+
state = vtState(this.#pendingVt);
|
|
273
|
+
}
|
|
274
|
+
if (state === "partial") continue;
|
|
275
|
+
out.push(this.#pendingVt);
|
|
276
|
+
this.#pendingVt = "";
|
|
277
|
+
}
|
|
278
|
+
return out;
|
|
194
279
|
}
|
|
195
280
|
|
|
196
281
|
/**
|
|
@@ -228,3 +313,124 @@ export class Win32InputModeDecoder {
|
|
|
228
313
|
return Array.from({ length: repeat }, () => text);
|
|
229
314
|
}
|
|
230
315
|
}
|
|
316
|
+
|
|
317
|
+
const RECORD_AT_START = /^\x1b\[[\d;]*_/;
|
|
318
|
+
const RECORD_PREFIX = /^\x1b\[[\d;]*$/;
|
|
319
|
+
const MAX_RECORD_LENGTH = 64;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Restores paste delimiters that a Windows console host emitted as individual
|
|
323
|
+
* win32-input-mode key records before StdinBuffer searches for the delimiters.
|
|
324
|
+
* Non-matching records remain untouched for normal key and paste decoding.
|
|
325
|
+
*/
|
|
326
|
+
export class Win32PasteMarkerNormalizer {
|
|
327
|
+
#pending = "";
|
|
328
|
+
#candidate = "";
|
|
329
|
+
#index = 0;
|
|
330
|
+
#marker = "";
|
|
331
|
+
#timer?: NodeJS.Timeout;
|
|
332
|
+
readonly #onInput: (data: string) => void;
|
|
333
|
+
readonly #onExpired?: () => void;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* `onExpired` runs after held records are released because their wait timed
|
|
337
|
+
* out, so a downstream holder can treat the same wait as already elapsed.
|
|
338
|
+
*/
|
|
339
|
+
constructor(onInput: (data: string) => void, onExpired?: () => void) {
|
|
340
|
+
this.#onInput = onInput;
|
|
341
|
+
this.#onExpired = onExpired;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
process(data: string): void {
|
|
345
|
+
if (!this.#pending && !this.#candidate && !data.includes("\x1b")) {
|
|
346
|
+
this.#onInput(data);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
clearTimeout(this.#timer);
|
|
350
|
+
this.#timer = undefined;
|
|
351
|
+
this.#pending += data;
|
|
352
|
+
let output = "";
|
|
353
|
+
|
|
354
|
+
while (this.#pending.length > 0) {
|
|
355
|
+
const escape = this.#pending.indexOf("\x1b");
|
|
356
|
+
if (escape > 0) {
|
|
357
|
+
output += this.#candidate + this.#pending.slice(0, escape);
|
|
358
|
+
this.#candidate = "";
|
|
359
|
+
this.#index = 0;
|
|
360
|
+
this.#pending = this.#pending.slice(escape);
|
|
361
|
+
} else if (escape === -1) {
|
|
362
|
+
output += this.#candidate + this.#pending;
|
|
363
|
+
this.#candidate = "";
|
|
364
|
+
this.#index = 0;
|
|
365
|
+
this.#pending = "";
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (this.#pending.length === 1) break;
|
|
370
|
+
if (this.#pending[1] !== "[") {
|
|
371
|
+
output += this.#candidate + this.#pending[0];
|
|
372
|
+
this.#candidate = "";
|
|
373
|
+
this.#index = 0;
|
|
374
|
+
this.#pending = this.#pending.slice(1);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
const record = RECORD_AT_START.exec(this.#pending)?.[0];
|
|
378
|
+
if (!record) {
|
|
379
|
+
if (this.#pending.length <= MAX_RECORD_LENGTH && RECORD_PREFIX.test(this.#pending)) break;
|
|
380
|
+
output += this.#candidate + this.#pending[0];
|
|
381
|
+
this.#candidate = "";
|
|
382
|
+
this.#index = 0;
|
|
383
|
+
this.#pending = this.#pending.slice(1);
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
this.#pending = this.#pending.slice(record.length);
|
|
388
|
+
const key = parseRecord(record);
|
|
389
|
+
if (this.#candidate && key && !key.down) {
|
|
390
|
+
this.#candidate += record;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
if (key?.down && key.state === 0 && key.repeat === 1) {
|
|
394
|
+
const expected = this.#index === 0 ? 27 : "[200~".charCodeAt(this.#index - 1);
|
|
395
|
+
if (key.uc === expected || (this.#index === 4 && key.uc === 49)) {
|
|
396
|
+
if (this.#index === 4) this.#marker = String.fromCharCode(key.uc);
|
|
397
|
+
this.#candidate += record;
|
|
398
|
+
if (++this.#index === 6) {
|
|
399
|
+
output += `\x1b[20${this.#marker}~`;
|
|
400
|
+
this.#candidate = "";
|
|
401
|
+
this.#index = 0;
|
|
402
|
+
}
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
output += this.#candidate;
|
|
407
|
+
this.#candidate = "";
|
|
408
|
+
this.#index = 0;
|
|
409
|
+
if (key?.down && key.state === 0 && key.repeat === 1 && key.uc === 27) {
|
|
410
|
+
this.#candidate = record;
|
|
411
|
+
this.#index = 1;
|
|
412
|
+
} else {
|
|
413
|
+
output += record;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (output) this.#onInput(output);
|
|
418
|
+
if (this.#candidate || this.#pending) {
|
|
419
|
+
this.#timer = setTimeout(() => {
|
|
420
|
+
this.flush();
|
|
421
|
+
this.#onExpired?.();
|
|
422
|
+
}, 75);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Release an incomplete marker as its original key records. */
|
|
427
|
+
flush(): void {
|
|
428
|
+
clearTimeout(this.#timer);
|
|
429
|
+
this.#timer = undefined;
|
|
430
|
+
const raw = this.#candidate + this.#pending;
|
|
431
|
+
this.#candidate = "";
|
|
432
|
+
this.#pending = "";
|
|
433
|
+
this.#index = 0;
|
|
434
|
+
if (raw) this.#onInput(raw);
|
|
435
|
+
}
|
|
436
|
+
}
|