nastech-tui 0.0.1
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/.prettierrc +11 -0
- package/README.md +346 -0
- package/eslint.config.mjs +111 -0
- package/package.json +51 -0
- package/packages/nastech-ink/ambient.d.ts +83 -0
- package/packages/nastech-ink/index.d.ts +40 -0
- package/packages/nastech-ink/index.js +1 -0
- package/packages/nastech-ink/nastech-ink/ambient.d.ts +83 -0
- package/packages/nastech-ink/nastech-ink/index.d.ts +40 -0
- package/packages/nastech-ink/nastech-ink/index.js +1 -0
- package/packages/nastech-ink/nastech-ink/package.json +54 -0
- package/packages/nastech-ink/nastech-ink/src/bootstrap/state.ts +9 -0
- package/packages/nastech-ink/nastech-ink/src/entry-exports.ts +32 -0
- package/packages/nastech-ink/nastech-ink/src/hooks/use-stderr.ts +15 -0
- package/packages/nastech-ink/nastech-ink/src/hooks/use-stdout.ts +15 -0
- package/packages/nastech-ink/nastech-ink/src/ink/Ansi.tsx +435 -0
- package/packages/nastech-ink/nastech-ink/src/ink/app-mouse.test.ts +123 -0
- package/packages/nastech-ink/nastech-ink/src/ink/bidi.ts +145 -0
- package/packages/nastech-ink/nastech-ink/src/ink/cache-eviction.ts +45 -0
- package/packages/nastech-ink/nastech-ink/src/ink/clearTerminal.ts +68 -0
- package/packages/nastech-ink/nastech-ink/src/ink/colorize.test.ts +60 -0
- package/packages/nastech-ink/nastech-ink/src/ink/colorize.ts +277 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/AlternateScreen.tsx +133 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/App.tsx +830 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/AppContext.ts +20 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Box.tsx +294 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Button.tsx +236 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/ClockContext.tsx +133 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/CursorAdvanceContext.ts +35 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/CursorDeclarationContext.ts +28 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/ErrorOverview.tsx +130 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Link.tsx +38 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Newline.tsx +43 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/NoSelect.tsx +73 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/RawAnsi.tsx +61 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/ScrollBox.tsx +290 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Spacer.tsx +23 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/StdinContext.ts +25 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/TerminalFocusContext.tsx +63 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/TerminalSizeContext.tsx +7 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Text.test.ts +38 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Text.tsx +336 -0
- package/packages/nastech-ink/nastech-ink/src/ink/constants.ts +6 -0
- package/packages/nastech-ink/nastech-ink/src/ink/cursor.ts +5 -0
- package/packages/nastech-ink/nastech-ink/src/ink/devtools.ts +2 -0
- package/packages/nastech-ink/nastech-ink/src/ink/dom.ts +495 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/click-event.ts +38 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/cmd-shortcuts.test.ts +65 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/dispatcher.ts +242 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/emitter.ts +40 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/event-handlers.ts +84 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/event.ts +11 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/focus-event.ts +18 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/input-event.ts +176 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/keyboard-event.ts +57 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/mouse-event.ts +18 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/paste-event.ts +10 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/resize-event.ts +12 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/terminal-event.ts +107 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/terminal-focus-event.ts +19 -0
- package/packages/nastech-ink/nastech-ink/src/ink/focus.ts +219 -0
- package/packages/nastech-ink/nastech-ink/src/ink/frame.ts +124 -0
- package/packages/nastech-ink/nastech-ink/src/ink/get-max-width.ts +27 -0
- package/packages/nastech-ink/nastech-ink/src/ink/global.d.ts +1 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hit-test.test.ts +38 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hit-test.ts +224 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-animation-frame.ts +62 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-app.ts +9 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-cursor-advance.ts +33 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-declared-cursor.ts +75 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-external-process.ts +27 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-input.ts +95 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-interval.ts +71 -0
- package/packages/nastech-ink/package.json +57 -0
- package/packages/nastech-ink/src/bootstrap/state.ts +9 -0
- package/packages/nastech-ink/src/entry-exports.ts +32 -0
- package/packages/nastech-ink/src/hooks/use-stderr.ts +15 -0
- package/packages/nastech-ink/src/hooks/use-stdout.ts +15 -0
- package/packages/nastech-ink/src/ink/Ansi.tsx +435 -0
- package/packages/nastech-ink/src/ink/app-mouse.test.ts +123 -0
- package/packages/nastech-ink/src/ink/app-rawmode-mouse.test.ts +91 -0
- package/packages/nastech-ink/src/ink/bidi.ts +145 -0
- package/packages/nastech-ink/src/ink/cache-eviction.ts +45 -0
- package/packages/nastech-ink/src/ink/clearTerminal.ts +68 -0
- package/packages/nastech-ink/src/ink/colorize.test.ts +60 -0
- package/packages/nastech-ink/src/ink/colorize.ts +277 -0
- package/packages/nastech-ink/src/ink/components/AlternateScreen.tsx +133 -0
- package/packages/nastech-ink/src/ink/components/App.tsx +855 -0
- package/packages/nastech-ink/src/ink/components/AppContext.ts +20 -0
- package/packages/nastech-ink/src/ink/components/Box.tsx +294 -0
- package/packages/nastech-ink/src/ink/components/Button.tsx +236 -0
- package/packages/nastech-ink/src/ink/components/ClockContext.tsx +133 -0
- package/packages/nastech-ink/src/ink/components/CursorAdvanceContext.ts +35 -0
- package/packages/nastech-ink/src/ink/components/CursorDeclarationContext.ts +28 -0
- package/packages/nastech-ink/src/ink/components/ErrorOverview.tsx +130 -0
- package/packages/nastech-ink/src/ink/components/Link.tsx +38 -0
- package/packages/nastech-ink/src/ink/components/Newline.tsx +43 -0
- package/packages/nastech-ink/src/ink/components/NoSelect.tsx +73 -0
- package/packages/nastech-ink/src/ink/components/RawAnsi.tsx +61 -0
- package/packages/nastech-ink/src/ink/components/ScrollBox.tsx +290 -0
- package/packages/nastech-ink/src/ink/components/Spacer.tsx +23 -0
- package/packages/nastech-ink/src/ink/components/StdinContext.ts +25 -0
- package/packages/nastech-ink/src/ink/components/TerminalFocusContext.tsx +63 -0
- package/packages/nastech-ink/src/ink/components/TerminalSizeContext.tsx +7 -0
- package/packages/nastech-ink/src/ink/components/Text.test.ts +38 -0
- package/packages/nastech-ink/src/ink/components/Text.tsx +336 -0
- package/packages/nastech-ink/src/ink/constants.ts +6 -0
- package/packages/nastech-ink/src/ink/cursor.ts +5 -0
- package/packages/nastech-ink/src/ink/devtools.ts +2 -0
- package/packages/nastech-ink/src/ink/dom.ts +495 -0
- package/packages/nastech-ink/src/ink/events/click-event.ts +38 -0
- package/packages/nastech-ink/src/ink/events/cmd-shortcuts.test.ts +65 -0
- package/packages/nastech-ink/src/ink/events/dispatcher.ts +242 -0
- package/packages/nastech-ink/src/ink/events/emitter.ts +40 -0
- package/packages/nastech-ink/src/ink/events/event-handlers.ts +84 -0
- package/packages/nastech-ink/src/ink/events/event.ts +11 -0
- package/packages/nastech-ink/src/ink/events/focus-event.ts +18 -0
- package/packages/nastech-ink/src/ink/events/input-event.ts +176 -0
- package/packages/nastech-ink/src/ink/events/keyboard-event.ts +57 -0
- package/packages/nastech-ink/src/ink/events/mouse-event.ts +18 -0
- package/packages/nastech-ink/src/ink/events/paste-event.ts +10 -0
- package/packages/nastech-ink/src/ink/events/resize-event.ts +12 -0
- package/packages/nastech-ink/src/ink/events/terminal-event.ts +107 -0
- package/packages/nastech-ink/src/ink/events/terminal-focus-event.ts +19 -0
- package/packages/nastech-ink/src/ink/focus.ts +219 -0
- package/packages/nastech-ink/src/ink/frame.ts +124 -0
- package/packages/nastech-ink/src/ink/get-max-width.ts +27 -0
- package/packages/nastech-ink/src/ink/global.d.ts +1 -0
- package/packages/nastech-ink/src/ink/hit-test.test.ts +38 -0
- package/packages/nastech-ink/src/ink/hit-test.ts +224 -0
- package/packages/nastech-ink/src/ink/hooks/use-animation-frame.ts +62 -0
- package/packages/nastech-ink/src/ink/hooks/use-app.ts +9 -0
- package/packages/nastech-ink/src/ink/hooks/use-cursor-advance.ts +33 -0
- package/packages/nastech-ink/src/ink/hooks/use-declared-cursor.ts +75 -0
- package/packages/nastech-ink/src/ink/hooks/use-external-process.ts +27 -0
- package/packages/nastech-ink/src/ink/hooks/use-input.ts +95 -0
- package/packages/nastech-ink/src/ink/hooks/use-interval.ts +71 -0
- package/packages/nastech-ink/src/ink/hooks/use-search-highlight.ts +56 -0
- package/packages/nastech-ink/src/ink/hooks/use-selection.ts +101 -0
- package/packages/nastech-ink/src/ink/hooks/use-stdin.ts +9 -0
- package/packages/nastech-ink/src/ink/hooks/use-tab-status.ts +71 -0
- package/packages/nastech-ink/src/ink/hooks/use-terminal-focus.ts +18 -0
- package/packages/nastech-ink/src/ink/hooks/use-terminal-title.ts +34 -0
- package/packages/nastech-ink/src/ink/hooks/use-terminal-viewport.ts +100 -0
- package/packages/nastech-ink/src/ink/hyperlinkHover.ts +52 -0
- package/packages/nastech-ink/src/ink/ink-cursor-advance.test.ts +234 -0
- package/packages/nastech-ink/src/ink/ink-resize.test.ts +50 -0
- package/packages/nastech-ink/src/ink/ink.tsx +2705 -0
- package/packages/nastech-ink/src/ink/instances.ts +10 -0
- package/packages/nastech-ink/src/ink/layout/engine.ts +6 -0
- package/packages/nastech-ink/src/ink/layout/geometry.ts +98 -0
- package/packages/nastech-ink/src/ink/layout/node.ts +145 -0
- package/packages/nastech-ink/src/ink/layout/yoga.ts +313 -0
- package/packages/nastech-ink/src/ink/line-width-cache.ts +38 -0
- package/packages/nastech-ink/src/ink/log-update.test.ts +223 -0
- package/packages/nastech-ink/src/ink/log-update.ts +752 -0
- package/packages/nastech-ink/src/ink/lru.ts +14 -0
- package/packages/nastech-ink/src/ink/measure-element.ts +23 -0
- package/packages/nastech-ink/src/ink/measure-text.ts +50 -0
- package/packages/nastech-ink/src/ink/node-cache.ts +53 -0
- package/packages/nastech-ink/src/ink/optimizer.ts +99 -0
- package/packages/nastech-ink/src/ink/output.ts +845 -0
- package/packages/nastech-ink/src/ink/parse-keypress.test.ts +133 -0
- package/packages/nastech-ink/src/ink/parse-keypress.ts +848 -0
- package/packages/nastech-ink/src/ink/reconciler.ts +382 -0
- package/packages/nastech-ink/src/ink/render-border.ts +206 -0
- package/packages/nastech-ink/src/ink/render-node-to-output.ts +1582 -0
- package/packages/nastech-ink/src/ink/render-to-screen.ts +236 -0
- package/packages/nastech-ink/src/ink/renderer.ts +169 -0
- package/packages/nastech-ink/src/ink/root.ts +204 -0
- package/packages/nastech-ink/src/ink/screen.ts +1590 -0
- package/packages/nastech-ink/src/ink/searchHighlight.ts +91 -0
- package/packages/nastech-ink/src/ink/selection.test.ts +82 -0
- package/packages/nastech-ink/src/ink/selection.ts +1143 -0
- package/packages/nastech-ink/src/ink/squash-text-nodes.ts +74 -0
- package/packages/nastech-ink/src/ink/stringWidth.ts +341 -0
- package/packages/nastech-ink/src/ink/styles.ts +750 -0
- package/packages/nastech-ink/src/ink/supports-hyperlinks.ts +51 -0
- package/packages/nastech-ink/src/ink/tabstops.ts +44 -0
- package/packages/nastech-ink/src/ink/terminal-focus-state.ts +52 -0
- package/packages/nastech-ink/src/ink/terminal-querier.ts +222 -0
- package/packages/nastech-ink/src/ink/terminal.test.ts +15 -0
- package/packages/nastech-ink/src/ink/terminal.ts +299 -0
- package/packages/nastech-ink/src/ink/termio/ansi.ts +75 -0
- package/packages/nastech-ink/src/ink/termio/csi.ts +334 -0
- package/packages/nastech-ink/src/ink/termio/dec.ts +99 -0
- package/packages/nastech-ink/src/ink/termio/esc.ts +69 -0
- package/packages/nastech-ink/src/ink/termio/osc.test.ts +191 -0
- package/packages/nastech-ink/src/ink/termio/osc.ts +724 -0
- package/packages/nastech-ink/src/ink/termio/parser.ts +467 -0
- package/packages/nastech-ink/src/ink/termio/sgr.ts +362 -0
- package/packages/nastech-ink/src/ink/termio/tokenize.test.ts +185 -0
- package/packages/nastech-ink/src/ink/termio/tokenize.ts +350 -0
- package/packages/nastech-ink/src/ink/termio/types.ts +230 -0
- package/packages/nastech-ink/src/ink/termio.ts +42 -0
- package/packages/nastech-ink/src/ink/useTerminalNotification.ts +110 -0
- package/packages/nastech-ink/src/ink/warn.ts +15 -0
- package/packages/nastech-ink/src/ink/widest-line.ts +22 -0
- package/packages/nastech-ink/src/ink/wrap-text.test.ts +17 -0
- package/packages/nastech-ink/src/ink/wrap-text.ts +144 -0
- package/packages/nastech-ink/src/ink/wrapAnsi.ts +13 -0
- package/packages/nastech-ink/src/native-ts/yoga-layout/enums.ts +112 -0
- package/packages/nastech-ink/src/native-ts/yoga-layout/index.ts +2326 -0
- package/packages/nastech-ink/src/utils/debug.ts +6 -0
- package/packages/nastech-ink/src/utils/earlyInput.ts +131 -0
- package/packages/nastech-ink/src/utils/env.ts +66 -0
- package/packages/nastech-ink/src/utils/envUtils.ts +13 -0
- package/packages/nastech-ink/src/utils/execFileNoThrow.test.ts +146 -0
- package/packages/nastech-ink/src/utils/execFileNoThrow.ts +115 -0
- package/packages/nastech-ink/src/utils/fullscreen.ts +3 -0
- package/packages/nastech-ink/src/utils/intl.ts +87 -0
- package/packages/nastech-ink/src/utils/log.ts +7 -0
- package/packages/nastech-ink/src/utils/semver.ts +57 -0
- package/packages/nastech-ink/src/utils/sliceAnsi.ts +106 -0
- package/packages/nastech-ink/text-input.d.ts +2 -0
- package/packages/nastech-ink/text-input.js +1 -0
- package/scripts/build.mjs +61 -0
- package/scripts/profile-tui.mjs +121 -0
- package/src/__tests__/activeSessionSwitcher.test.ts +157 -0
- package/src/__tests__/appChromeStatusRule.test.tsx +84 -0
- package/src/__tests__/appChromeStatusRuleDevCredits.test.tsx +73 -0
- package/src/__tests__/approvalAction.test.ts +50 -0
- package/src/__tests__/asCommandDispatch.test.ts +27 -0
- package/src/__tests__/blockLayout.test.ts +122 -0
- package/src/__tests__/clipboard.test.ts +369 -0
- package/src/__tests__/constants.test.ts +53 -0
- package/src/__tests__/createGatewayEventHandler.test.ts +1091 -0
- package/src/__tests__/createSlashHandler.test.ts +822 -0
- package/src/__tests__/creditsCommand.test.ts +144 -0
- package/src/__tests__/cursorDriftRegression.test.ts +114 -0
- package/src/__tests__/details.test.ts +115 -0
- package/src/__tests__/emoji.test.ts +64 -0
- package/src/__tests__/externalLink.test.ts +144 -0
- package/src/__tests__/forceTruecolor.test.ts +191 -0
- package/src/__tests__/gatewayClient.test.ts +394 -0
- package/src/__tests__/gatewayRecovery.test.ts +47 -0
- package/src/__tests__/markdown.test.ts +331 -0
- package/src/__tests__/mathUnicode.test.ts +293 -0
- package/src/__tests__/memoryMonitor.test.ts +102 -0
- package/src/__tests__/messageLine.test.ts +19 -0
- package/src/__tests__/messages.test.ts +92 -0
- package/src/__tests__/orchestratorPromptSession.test.ts +64 -0
- package/src/__tests__/osc52.test.ts +67 -0
- package/src/__tests__/parentLog.test.ts +75 -0
- package/src/__tests__/paths.test.ts +70 -0
- package/src/__tests__/platform.test.ts +556 -0
- package/src/__tests__/precisionWheel.test.ts +44 -0
- package/src/__tests__/prompt.test.ts +31 -0
- package/src/__tests__/providers.test.ts +65 -0
- package/src/__tests__/reasoning.test.ts +76 -0
- package/src/__tests__/rpc.test.ts +27 -0
- package/src/__tests__/scroll.test.ts +99 -0
- package/src/__tests__/slashParity.test.ts +123 -0
- package/src/__tests__/spawnHistoryStore.test.ts +46 -0
- package/src/__tests__/stateIsolation.test.ts +46 -0
- package/src/__tests__/statusBarTicker.test.ts +18 -0
- package/src/__tests__/statusRule.test.ts +32 -0
- package/src/__tests__/streamingMarkdown.test.ts +121 -0
- package/src/__tests__/subagentTree.test.ts +407 -0
- package/src/__tests__/syntax.test.ts +45 -0
- package/src/__tests__/terminalModes.test.ts +39 -0
- package/src/__tests__/terminalParity.test.ts +77 -0
- package/src/__tests__/terminalSetup.test.ts +386 -0
- package/src/__tests__/termux.test.ts +35 -0
- package/src/__tests__/termuxComposerLayout.test.ts +40 -0
- package/src/__tests__/text.test.ts +233 -0
- package/src/__tests__/textInputBurstInput.test.ts +40 -0
- package/src/__tests__/textInputCursorSourceOfTruth.test.ts +50 -0
- package/src/__tests__/textInputFastEcho.test.ts +200 -0
- package/src/__tests__/textInputLineNav.test.ts +55 -0
- package/src/__tests__/textInputPassThrough.test.ts +59 -0
- package/src/__tests__/textInputRightClick.test.ts +48 -0
- package/src/__tests__/textInputWrap.test.ts +151 -0
- package/src/__tests__/theme.test.ts +311 -0
- package/src/__tests__/turnControllerNotice.test.ts +43 -0
- package/src/__tests__/turnStore.test.ts +66 -0
- package/src/__tests__/useCompletion.test.ts +35 -0
- package/src/__tests__/useComposerState.test.ts +59 -0
- package/src/__tests__/useConfigSync.test.ts +460 -0
- package/src/__tests__/useInputHandlers.test.ts +77 -0
- package/src/__tests__/useQueue.test.ts +28 -0
- package/src/__tests__/useSessionLifecycle.test.ts +60 -0
- package/src/__tests__/useVirtualHistoryHeights.test.ts +39 -0
- package/src/__tests__/viewport.test.ts +58 -0
- package/src/__tests__/viewportStore.test.ts +85 -0
- package/src/__tests__/virtualHeights.test.ts +96 -0
- package/src/__tests__/virtualHistoryClamp.test.ts +19 -0
- package/src/__tests__/virtualHistoryOffsetCache.test.ts +282 -0
- package/src/__tests__/wheelAccel.test.ts +138 -0
- package/src/app/createGatewayEventHandler.ts +833 -0
- package/src/app/createSlashHandler.ts +130 -0
- package/src/app/delegationStore.ts +77 -0
- package/src/app/gatewayContext.tsx +19 -0
- package/src/app/gatewayRecovery.ts +35 -0
- package/src/app/inputSelectionStore.ts +15 -0
- package/src/app/interfaces.ts +394 -0
- package/src/app/overlayStore.ts +53 -0
- package/src/app/scroll.ts +71 -0
- package/src/app/setupHandoff.ts +54 -0
- package/src/app/slash/commands/core.ts +648 -0
- package/src/app/slash/commands/credits.ts +57 -0
- package/src/app/slash/commands/debug.ts +48 -0
- package/src/app/slash/commands/ops.ts +717 -0
- package/src/app/slash/commands/session.ts +554 -0
- package/src/app/slash/commands/setup.ts +20 -0
- package/src/app/slash/registry.ts +20 -0
- package/src/app/slash/types.ts +21 -0
- package/src/app/spawnHistoryStore.ts +159 -0
- package/src/app/turnController.ts +866 -0
- package/src/app/turnStore.ts +85 -0
- package/src/app/uiStore.ts +44 -0
- package/src/app/useComposerState.ts +367 -0
- package/src/app/useConfigSync.ts +288 -0
- package/src/app/useInputHandlers.ts +576 -0
- package/src/app/useLongRunToolCharms.ts +69 -0
- package/src/app/useMainApp.ts +1039 -0
- package/src/app/useSessionLifecycle.ts +366 -0
- package/src/app/useSubmission.ts +429 -0
- package/src/app.tsx +25 -0
- package/src/banner.ts +93 -0
- package/src/components/activeSessionSwitcher.tsx +635 -0
- package/src/components/agentsOverlay.tsx +1073 -0
- package/src/components/appChrome.tsx +554 -0
- package/src/components/appLayout.tsx +444 -0
- package/src/components/appOverlays.tsx +254 -0
- package/src/components/branding.tsx +466 -0
- package/src/components/fpsOverlay.tsx +30 -0
- package/src/components/helpHint.tsx +73 -0
- package/src/components/markdown.tsx +1119 -0
- package/src/components/maskedPrompt.tsx +34 -0
- package/src/components/messageLine.tsx +237 -0
- package/src/components/modelPicker.tsx +527 -0
- package/src/components/overlayControls.tsx +50 -0
- package/src/components/pluginsHub.tsx +238 -0
- package/src/components/prompts.tsx +276 -0
- package/src/components/queuedMessages.tsx +64 -0
- package/src/components/sessionPicker.tsx +227 -0
- package/src/components/skillsHub.tsx +308 -0
- package/src/components/streamingAssistant.tsx +110 -0
- package/src/components/streamingMarkdown.tsx +174 -0
- package/src/components/textInput.tsx +1340 -0
- package/src/components/themed.tsx +30 -0
- package/src/components/thinking.tsx +1224 -0
- package/src/components/todoPanel.tsx +93 -0
- package/src/config/env.ts +64 -0
- package/src/config/limits.ts +13 -0
- package/src/config/timing.ts +6 -0
- package/src/content/charms.ts +1 -0
- package/src/content/faces.ts +17 -0
- package/src/content/fortunes.ts +30 -0
- package/src/content/hotkeys.ts +37 -0
- package/src/content/placeholders.ts +13 -0
- package/src/content/setup.ts +17 -0
- package/src/content/verbs.ts +38 -0
- package/src/domain/blockLayout.ts +146 -0
- package/src/domain/details.ts +76 -0
- package/src/domain/messages.ts +91 -0
- package/src/domain/paths.ts +16 -0
- package/src/domain/providers.ts +11 -0
- package/src/domain/roles.ts +9 -0
- package/src/domain/slash.ts +10 -0
- package/src/domain/usage.ts +3 -0
- package/src/domain/viewport.ts +51 -0
- package/src/entry.tsx +104 -0
- package/src/gatewayClient.ts +730 -0
- package/src/gatewayTypes.ts +568 -0
- package/src/hooks/useCompletion.ts +112 -0
- package/src/hooks/useGitBranch.ts +72 -0
- package/src/hooks/useInputHistory.ts +11 -0
- package/src/hooks/useQueue.ts +76 -0
- package/src/hooks/useVirtualHistory.ts +554 -0
- package/src/lib/circularBuffer.ts +48 -0
- package/src/lib/clipboard.ts +182 -0
- package/src/lib/editor.test.ts +74 -0
- package/src/lib/editor.ts +47 -0
- package/src/lib/emoji.ts +55 -0
- package/src/lib/externalCli.ts +16 -0
- package/src/lib/externalLink.ts +435 -0
- package/src/lib/forceTruecolor.ts +60 -0
- package/src/lib/fpsStore.ts +51 -0
- package/src/lib/fuzzy.test.ts +109 -0
- package/src/lib/fuzzy.ts +177 -0
- package/src/lib/gracefulExit.ts +47 -0
- package/src/lib/history.ts +82 -0
- package/src/lib/inputMetrics.ts +203 -0
- package/src/lib/liveProgress.test.ts +116 -0
- package/src/lib/liveProgress.ts +79 -0
- package/src/lib/mathUnicode.ts +770 -0
- package/src/lib/memory.test.ts +155 -0
- package/src/lib/memory.ts +188 -0
- package/src/lib/memoryMonitor.ts +109 -0
- package/src/lib/messages.test.ts +29 -0
- package/src/lib/messages.ts +8 -0
- package/src/lib/openExternalUrl.test.ts +217 -0
- package/src/lib/openExternalUrl.ts +158 -0
- package/src/lib/osc52.ts +73 -0
- package/src/lib/parentLog.ts +57 -0
- package/src/lib/perfPane.tsx +107 -0
- package/src/lib/platform.ts +409 -0
- package/src/lib/precisionWheel.ts +48 -0
- package/src/lib/prompt.ts +35 -0
- package/src/lib/reasoning.ts +55 -0
- package/src/lib/rpc.ts +41 -0
- package/src/lib/subagentTree.ts +355 -0
- package/src/lib/syntax.ts +117 -0
- package/src/lib/terminalModes.ts +51 -0
- package/src/lib/terminalParity.ts +78 -0
- package/src/lib/terminalSetup.ts +444 -0
- package/src/lib/termux.ts +29 -0
- package/src/lib/text.test.ts +18 -0
- package/src/lib/text.ts +339 -0
- package/src/lib/todo.test.ts +21 -0
- package/src/lib/todo.ts +9 -0
- package/src/lib/viewportStore.ts +124 -0
- package/src/lib/virtualHeights.ts +145 -0
- package/src/lib/wheelAccel.ts +190 -0
- package/src/protocol/interpolation.ts +3 -0
- package/src/protocol/paste.ts +1 -0
- package/src/theme.ts +589 -0
- package/src/types/nastech-ink.d.ts +176 -0
- package/src/types.ts +212 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI Parser - Semantic Action Generator
|
|
3
|
+
*
|
|
4
|
+
* A streaming parser for ANSI escape sequences that produces semantic actions.
|
|
5
|
+
* Uses the tokenizer for escape sequence boundary detection, then interprets
|
|
6
|
+
* each sequence to produce structured actions.
|
|
7
|
+
*
|
|
8
|
+
* Key design decisions:
|
|
9
|
+
* - Streaming: can process input incrementally
|
|
10
|
+
* - Semantic output: produces structured actions, not string tokens
|
|
11
|
+
* - Style tracking: maintains current text style state
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { getGraphemeSegmenter } from '../../utils/intl.js'
|
|
15
|
+
|
|
16
|
+
import { C0 } from './ansi.js'
|
|
17
|
+
import { CSI, CURSOR_STYLES, ERASE_DISPLAY, ERASE_LINE_REGION } from './csi.js'
|
|
18
|
+
import { DEC } from './dec.js'
|
|
19
|
+
import { parseEsc } from './esc.js'
|
|
20
|
+
import { parseOSC } from './osc.js'
|
|
21
|
+
import { applySGR } from './sgr.js'
|
|
22
|
+
import { createTokenizer, type Token, type Tokenizer } from './tokenize.js'
|
|
23
|
+
import type { Action, Grapheme, TextStyle } from './types.js'
|
|
24
|
+
import { defaultStyle } from './types.js'
|
|
25
|
+
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Grapheme Utilities
|
|
28
|
+
// =============================================================================
|
|
29
|
+
|
|
30
|
+
function isEmoji(codePoint: number): boolean {
|
|
31
|
+
return (
|
|
32
|
+
(codePoint >= 0x2600 && codePoint <= 0x26ff) ||
|
|
33
|
+
(codePoint >= 0x2700 && codePoint <= 0x27bf) ||
|
|
34
|
+
(codePoint >= 0x1f300 && codePoint <= 0x1f9ff) ||
|
|
35
|
+
(codePoint >= 0x1fa00 && codePoint <= 0x1faff) ||
|
|
36
|
+
(codePoint >= 0x1f1e0 && codePoint <= 0x1f1ff)
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isEastAsianWide(codePoint: number): boolean {
|
|
41
|
+
return (
|
|
42
|
+
(codePoint >= 0x1100 && codePoint <= 0x115f) ||
|
|
43
|
+
(codePoint >= 0x2e80 && codePoint <= 0x9fff) ||
|
|
44
|
+
(codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
|
|
45
|
+
(codePoint >= 0xf900 && codePoint <= 0xfaff) ||
|
|
46
|
+
(codePoint >= 0xfe10 && codePoint <= 0xfe1f) ||
|
|
47
|
+
(codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
|
|
48
|
+
(codePoint >= 0xff00 && codePoint <= 0xff60) ||
|
|
49
|
+
(codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
|
|
50
|
+
(codePoint >= 0x20000 && codePoint <= 0x2fffd) ||
|
|
51
|
+
(codePoint >= 0x30000 && codePoint <= 0x3fffd)
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function hasMultipleCodepoints(str: string): boolean {
|
|
56
|
+
let count = 0
|
|
57
|
+
|
|
58
|
+
for (const _ of str) {
|
|
59
|
+
count++
|
|
60
|
+
|
|
61
|
+
if (count > 1) {
|
|
62
|
+
return true
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function graphemeWidth(grapheme: string): 1 | 2 {
|
|
70
|
+
if (hasMultipleCodepoints(grapheme)) {
|
|
71
|
+
return 2
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const codePoint = grapheme.codePointAt(0)
|
|
75
|
+
|
|
76
|
+
if (codePoint === undefined) {
|
|
77
|
+
return 1
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (isEmoji(codePoint) || isEastAsianWide(codePoint)) {
|
|
81
|
+
return 2
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return 1
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function* segmentGraphemes(str: string): Generator<Grapheme> {
|
|
88
|
+
for (const { segment } of getGraphemeSegmenter().segment(str)) {
|
|
89
|
+
yield { value: segment, width: graphemeWidth(segment) }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// =============================================================================
|
|
94
|
+
// Sequence Parsing
|
|
95
|
+
// =============================================================================
|
|
96
|
+
|
|
97
|
+
function parseCSIParams(paramStr: string): number[] {
|
|
98
|
+
if (paramStr === '') {
|
|
99
|
+
return []
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return paramStr.split(/[;:]/).map(s => (s === '' ? 0 : parseInt(s, 10)))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Parse a raw CSI sequence (e.g., "\x1b[31m") into an action */
|
|
106
|
+
function parseCSI(rawSequence: string): Action | null {
|
|
107
|
+
const inner = rawSequence.slice(2)
|
|
108
|
+
|
|
109
|
+
if (inner.length === 0) {
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const finalByte = inner.charCodeAt(inner.length - 1)
|
|
114
|
+
const beforeFinal = inner.slice(0, -1)
|
|
115
|
+
|
|
116
|
+
let privateMode = ''
|
|
117
|
+
let paramStr = beforeFinal
|
|
118
|
+
let intermediate = ''
|
|
119
|
+
|
|
120
|
+
if (beforeFinal.length > 0 && '?>='.includes(beforeFinal[0]!)) {
|
|
121
|
+
privateMode = beforeFinal[0]!
|
|
122
|
+
paramStr = beforeFinal.slice(1)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const intermediateMatch = paramStr.match(/([^0-9;:]+)$/)
|
|
126
|
+
|
|
127
|
+
if (intermediateMatch) {
|
|
128
|
+
intermediate = intermediateMatch[1]!
|
|
129
|
+
paramStr = paramStr.slice(0, -intermediate.length)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const params = parseCSIParams(paramStr)
|
|
133
|
+
const p0 = params[0] ?? 1
|
|
134
|
+
const p1 = params[1] ?? 1
|
|
135
|
+
|
|
136
|
+
// SGR (Select Graphic Rendition)
|
|
137
|
+
if (finalByte === CSI.SGR && privateMode === '') {
|
|
138
|
+
return { type: 'sgr', params: paramStr }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Cursor movement
|
|
142
|
+
if (finalByte === CSI.CUU) {
|
|
143
|
+
return {
|
|
144
|
+
type: 'cursor',
|
|
145
|
+
action: { type: 'move', direction: 'up', count: p0 }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (finalByte === CSI.CUD) {
|
|
150
|
+
return {
|
|
151
|
+
type: 'cursor',
|
|
152
|
+
action: { type: 'move', direction: 'down', count: p0 }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (finalByte === CSI.CUF) {
|
|
157
|
+
return {
|
|
158
|
+
type: 'cursor',
|
|
159
|
+
action: { type: 'move', direction: 'forward', count: p0 }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (finalByte === CSI.CUB) {
|
|
164
|
+
return {
|
|
165
|
+
type: 'cursor',
|
|
166
|
+
action: { type: 'move', direction: 'back', count: p0 }
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (finalByte === CSI.CNL) {
|
|
171
|
+
return { type: 'cursor', action: { type: 'nextLine', count: p0 } }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (finalByte === CSI.CPL) {
|
|
175
|
+
return { type: 'cursor', action: { type: 'prevLine', count: p0 } }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (finalByte === CSI.CHA) {
|
|
179
|
+
return { type: 'cursor', action: { type: 'column', col: p0 } }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (finalByte === CSI.CUP || finalByte === CSI.HVP) {
|
|
183
|
+
return { type: 'cursor', action: { type: 'position', row: p0, col: p1 } }
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (finalByte === CSI.VPA) {
|
|
187
|
+
return { type: 'cursor', action: { type: 'row', row: p0 } }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Erase
|
|
191
|
+
if (finalByte === CSI.ED) {
|
|
192
|
+
const region = ERASE_DISPLAY[params[0] ?? 0] ?? 'toEnd'
|
|
193
|
+
|
|
194
|
+
return { type: 'erase', action: { type: 'display', region } }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (finalByte === CSI.EL) {
|
|
198
|
+
const region = ERASE_LINE_REGION[params[0] ?? 0] ?? 'toEnd'
|
|
199
|
+
|
|
200
|
+
return { type: 'erase', action: { type: 'line', region } }
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (finalByte === CSI.ECH) {
|
|
204
|
+
return { type: 'erase', action: { type: 'chars', count: p0 } }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Scroll
|
|
208
|
+
if (finalByte === CSI.SU) {
|
|
209
|
+
return { type: 'scroll', action: { type: 'up', count: p0 } }
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (finalByte === CSI.SD) {
|
|
213
|
+
return { type: 'scroll', action: { type: 'down', count: p0 } }
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (finalByte === CSI.DECSTBM) {
|
|
217
|
+
return {
|
|
218
|
+
type: 'scroll',
|
|
219
|
+
action: { type: 'setRegion', top: p0, bottom: p1 }
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Cursor save/restore
|
|
224
|
+
if (finalByte === CSI.SCOSC) {
|
|
225
|
+
return { type: 'cursor', action: { type: 'save' } }
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (finalByte === CSI.SCORC) {
|
|
229
|
+
return { type: 'cursor', action: { type: 'restore' } }
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Cursor style
|
|
233
|
+
if (finalByte === CSI.DECSCUSR && intermediate === ' ') {
|
|
234
|
+
const styleInfo = CURSOR_STYLES[p0] ?? CURSOR_STYLES[0]!
|
|
235
|
+
|
|
236
|
+
return { type: 'cursor', action: { type: 'style', ...styleInfo } }
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Private modes
|
|
240
|
+
if (privateMode === '?' && (finalByte === CSI.SM || finalByte === CSI.RM)) {
|
|
241
|
+
const enabled = finalByte === CSI.SM
|
|
242
|
+
|
|
243
|
+
if (p0 === DEC.CURSOR_VISIBLE) {
|
|
244
|
+
return {
|
|
245
|
+
type: 'cursor',
|
|
246
|
+
action: enabled ? { type: 'show' } : { type: 'hide' }
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (p0 === DEC.ALT_SCREEN_CLEAR || p0 === DEC.ALT_SCREEN) {
|
|
251
|
+
return { type: 'mode', action: { type: 'alternateScreen', enabled } }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (p0 === DEC.BRACKETED_PASTE) {
|
|
255
|
+
return { type: 'mode', action: { type: 'bracketedPaste', enabled } }
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (p0 === DEC.MOUSE_NORMAL) {
|
|
259
|
+
return {
|
|
260
|
+
type: 'mode',
|
|
261
|
+
action: { type: 'mouseTracking', mode: enabled ? 'normal' : 'off' }
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (p0 === DEC.MOUSE_BUTTON) {
|
|
266
|
+
return {
|
|
267
|
+
type: 'mode',
|
|
268
|
+
action: { type: 'mouseTracking', mode: enabled ? 'button' : 'off' }
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (p0 === DEC.MOUSE_ANY) {
|
|
273
|
+
return {
|
|
274
|
+
type: 'mode',
|
|
275
|
+
action: { type: 'mouseTracking', mode: enabled ? 'any' : 'off' }
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (p0 === DEC.FOCUS_EVENTS) {
|
|
280
|
+
return { type: 'mode', action: { type: 'focusEvents', enabled } }
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return { type: 'unknown', sequence: rawSequence }
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Identify the type of escape sequence from its raw form.
|
|
289
|
+
*/
|
|
290
|
+
function identifySequence(seq: string): 'csi' | 'osc' | 'esc' | 'ss3' | 'unknown' {
|
|
291
|
+
if (seq.length < 2) {
|
|
292
|
+
return 'unknown'
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (seq.charCodeAt(0) !== C0.ESC) {
|
|
296
|
+
return 'unknown'
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const second = seq.charCodeAt(1)
|
|
300
|
+
|
|
301
|
+
if (second === 0x5b) {
|
|
302
|
+
return 'csi'
|
|
303
|
+
} // [
|
|
304
|
+
|
|
305
|
+
if (second === 0x5d) {
|
|
306
|
+
return 'osc'
|
|
307
|
+
} // ]
|
|
308
|
+
|
|
309
|
+
if (second === 0x4f) {
|
|
310
|
+
return 'ss3'
|
|
311
|
+
} // O
|
|
312
|
+
|
|
313
|
+
return 'esc'
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// =============================================================================
|
|
317
|
+
// Main Parser
|
|
318
|
+
// =============================================================================
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Parser class - maintains state for streaming/incremental parsing
|
|
322
|
+
*
|
|
323
|
+
* Usage:
|
|
324
|
+
* ```typescript
|
|
325
|
+
* const parser = new Parser()
|
|
326
|
+
* const actions1 = parser.feed('partial\x1b[')
|
|
327
|
+
* const actions2 = parser.feed('31mred') // state maintained internally
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
export class Parser {
|
|
331
|
+
private tokenizer: Tokenizer = createTokenizer()
|
|
332
|
+
|
|
333
|
+
style: TextStyle = defaultStyle()
|
|
334
|
+
inLink = false
|
|
335
|
+
linkUrl: string | undefined
|
|
336
|
+
|
|
337
|
+
reset(): void {
|
|
338
|
+
this.tokenizer.reset()
|
|
339
|
+
this.style = defaultStyle()
|
|
340
|
+
this.inLink = false
|
|
341
|
+
this.linkUrl = undefined
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** Feed input and get resulting actions */
|
|
345
|
+
feed(input: string): Action[] {
|
|
346
|
+
const tokens = this.tokenizer.feed(input)
|
|
347
|
+
const actions: Action[] = []
|
|
348
|
+
|
|
349
|
+
for (const token of tokens) {
|
|
350
|
+
const tokenActions = this.processToken(token)
|
|
351
|
+
actions.push(...tokenActions)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return actions
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
private processToken(token: Token): Action[] {
|
|
358
|
+
switch (token.type) {
|
|
359
|
+
case 'text':
|
|
360
|
+
return this.processText(token.value)
|
|
361
|
+
|
|
362
|
+
case 'sequence':
|
|
363
|
+
return this.processSequence(token.value)
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
private processText(text: string): Action[] {
|
|
368
|
+
// Handle BEL characters embedded in text
|
|
369
|
+
const actions: Action[] = []
|
|
370
|
+
let current = ''
|
|
371
|
+
|
|
372
|
+
for (const char of text) {
|
|
373
|
+
if (char.charCodeAt(0) === C0.BEL) {
|
|
374
|
+
if (current) {
|
|
375
|
+
const graphemes = [...segmentGraphemes(current)]
|
|
376
|
+
|
|
377
|
+
if (graphemes.length > 0) {
|
|
378
|
+
actions.push({ type: 'text', graphemes, style: { ...this.style } })
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
current = ''
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
actions.push({ type: 'bell' })
|
|
385
|
+
} else {
|
|
386
|
+
current += char
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (current) {
|
|
391
|
+
const graphemes = [...segmentGraphemes(current)]
|
|
392
|
+
|
|
393
|
+
if (graphemes.length > 0) {
|
|
394
|
+
actions.push({ type: 'text', graphemes, style: { ...this.style } })
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return actions
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
private processSequence(seq: string): Action[] {
|
|
402
|
+
const seqType = identifySequence(seq)
|
|
403
|
+
|
|
404
|
+
switch (seqType) {
|
|
405
|
+
case 'csi': {
|
|
406
|
+
const action = parseCSI(seq)
|
|
407
|
+
|
|
408
|
+
if (!action) {
|
|
409
|
+
return []
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (action.type === 'sgr') {
|
|
413
|
+
this.style = applySGR(action.params, this.style)
|
|
414
|
+
|
|
415
|
+
return []
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return [action]
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
case 'osc': {
|
|
422
|
+
// Extract OSC content (between ESC ] and terminator)
|
|
423
|
+
let content = seq.slice(2)
|
|
424
|
+
|
|
425
|
+
// Remove terminator (BEL or ESC \)
|
|
426
|
+
if (content.endsWith('\x07')) {
|
|
427
|
+
content = content.slice(0, -1)
|
|
428
|
+
} else if (content.endsWith('\x1b\\')) {
|
|
429
|
+
content = content.slice(0, -2)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const action = parseOSC(content)
|
|
433
|
+
|
|
434
|
+
if (action) {
|
|
435
|
+
if (action.type === 'link') {
|
|
436
|
+
if (action.action.type === 'start') {
|
|
437
|
+
this.inLink = true
|
|
438
|
+
this.linkUrl = action.action.url
|
|
439
|
+
} else {
|
|
440
|
+
this.inLink = false
|
|
441
|
+
this.linkUrl = undefined
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return [action]
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return []
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
case 'esc': {
|
|
452
|
+
const escContent = seq.slice(1)
|
|
453
|
+
const action = parseEsc(escContent)
|
|
454
|
+
|
|
455
|
+
return action ? [action] : []
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
case 'ss3':
|
|
459
|
+
// SS3 sequences are typically cursor keys in application mode
|
|
460
|
+
// For output parsing, treat as unknown
|
|
461
|
+
return [{ type: 'unknown', sequence: seq }]
|
|
462
|
+
|
|
463
|
+
default:
|
|
464
|
+
return [{ type: 'unknown', sequence: seq }]
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|