@simon_he/vue-tui 0.0.8 → 1.0.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/README.md +142 -30
- package/dist/TSelect-BwJJbuTt.js +6089 -0
- package/dist/TTree-DK_DQBYm.js +6480 -0
- package/dist/agent.cjs +39416 -0
- package/dist/agent.d.cts +44 -0
- package/dist/agent.d.ts +44 -0
- package/dist/agent.js +828 -0
- package/dist/ansi-palette-CNXqFciC.js +57 -0
- package/dist/ansi-styles.d.ts +200 -0
- package/dist/block-source-CKUOnkgT.js +1663 -0
- package/dist/cli/headless-renderer.d.ts +29 -0
- package/dist/cli/input.d.ts +49 -0
- package/dist/cli/node-file-writers.d.ts +13 -0
- package/dist/cli/node-module.d.ts +2 -0
- package/dist/cli/parse-kitty.d.ts +2 -0
- package/dist/cli/parse-mouse.d.ts +2 -0
- package/dist/cli/parse-utils.d.ts +14 -0
- package/dist/cli/parse-xterm.d.ts +2 -0
- package/dist/cli/path-provider-types.d.ts +1 -0
- package/dist/cli/path-provider.d.ts +4 -0
- package/dist/cli/path-suggest-core.d.ts +1 -0
- package/dist/cli/path-suggest.d.ts +15 -0
- package/dist/cli/recording.d.ts +4 -0
- package/dist/cli/stdin-buffer.d.ts +33 -0
- package/dist/cli.cjs +11061 -0
- package/dist/cli.d.cts +23 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +9875 -0
- package/dist/core/ansi/capability.d.ts +20 -0
- package/dist/core/ansi/colors.d.ts +41 -0
- package/dist/core/ansi/sgr.d.ts +7 -0
- package/dist/core/ansi/theme.d.ts +6 -0
- package/dist/core/ansi-palette.d.ts +14 -0
- package/dist/core/buffer/buffer.d.ts +54 -0
- package/dist/core/buffer/width.d.ts +4 -0
- package/dist/core/debug-logger.d.ts +18 -0
- package/dist/core/hyperlink.d.ts +9 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/path-provider-types.d.ts +24 -0
- package/dist/core/path-suggest.d.ts +35 -0
- package/dist/core/render-plane.d.ts +3 -0
- package/dist/core/terminal/create-terminal.d.ts +8 -0
- package/dist/core/terminal/emitter.d.ts +7 -0
- package/dist/core/types.d.ts +107 -0
- package/dist/core.cjs +3153 -0
- package/dist/core.d.cts +14 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +424 -0
- package/dist/create-terminal-C2oiWFJU.js +1434 -0
- package/dist/create-terminal-app.d.ts +36 -0
- package/dist/dom-renderer-BqGijQID.js +1173 -0
- package/dist/env-Cl8qmNFN.js +19 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/manager/cli-event-manager.d.ts +22 -0
- package/dist/events/manager/event-manager.d.ts +30 -0
- package/dist/events/manager/selection-suppression.d.ts +3 -0
- package/dist/events/manager/types.d.ts +108 -0
- package/dist/events/recording.d.ts +44 -0
- package/dist/experimental.cjs +4412 -1641
- package/dist/experimental.d.cts +42 -0
- package/dist/experimental.d.ts +42 -825
- package/dist/experimental.js +31 -7392
- package/dist/frame-perf-C6Xfg85O.js +24 -0
- package/dist/hyperlink-Bn02UXJb.js +419 -0
- package/dist/index.cjs +14765 -17582
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -1528
- package/dist/index.js +17 -20026
- package/dist/linkify-D_gzn9Xq.js +562 -0
- package/dist/markdown.cjs +9321 -7623
- package/dist/markdown.d.cts +11 -0
- package/dist/markdown.d.ts +11 -112
- package/dist/markdown.js +36 -1427
- package/dist/observability/cli-latency-node.d.ts +3 -0
- package/dist/observability/cli-latency-types.d.ts +41 -0
- package/dist/observability/cli-latency.d.ts +3 -0
- package/dist/observability/frame-perf-store.d.ts +18 -0
- package/dist/observability/frame-perf.d.ts +40 -0
- package/dist/observability/perf-sink.d.ts +56 -0
- package/dist/observability/trace.d.ts +40 -0
- package/dist/observability/tui-profiler.d.ts +33 -0
- package/dist/observability.cjs +221 -0
- package/dist/observability.d.cts +8 -0
- package/dist/observability.d.ts +8 -0
- package/dist/observability.js +4 -0
- package/dist/path-mnSgEpCm.js +81 -0
- package/dist/path-suggest-BNqcuE3-.js +274 -0
- package/dist/path-suggest-Dk9TRLh5.js +3 -0
- package/dist/{path-suggest-DmrmeueH.js → path-suggest-bvR9SY6Q.js} +86 -18
- package/dist/renderer/capabilities.d.ts +13 -0
- package/dist/renderer/cli/index.d.ts +2 -0
- package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
- package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
- package/dist/renderer/dom/dom-renderer.d.ts +157 -0
- package/dist/renderer/dom/index.d.ts +2 -0
- package/dist/renderer/index.d.ts +2 -0
- package/dist/renderer-dom.cjs +1505 -0
- package/dist/renderer-dom.d.cts +4 -0
- package/dist/renderer-dom.d.ts +4 -0
- package/dist/renderer-dom.js +7 -0
- package/dist/runtime/index.d.ts +36 -0
- package/dist/runtime/osc52.d.ts +9 -0
- package/dist/runtime-rfcZCyJq.js +1197 -0
- package/dist/runtime.cjs +1698 -0
- package/dist/runtime.d.cts +9 -0
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.js +4 -0
- package/dist/selection/terminal-selection.d.ts +123 -0
- package/dist/sgr-BmzxEjAO.js +304 -0
- package/dist/terminal-selection-DBinO6p5.js +330 -0
- package/dist/tlog-theme-qPBt5rge.js +9254 -0
- package/dist/trace-CjzYeIxN.js +182 -0
- package/dist/utils/env.d.ts +3 -0
- package/dist/utils/grapheme.d.ts +5 -0
- package/dist/utils/newlines.d.ts +1 -0
- package/dist/utils/path.d.ts +7 -0
- package/dist/utils/url-safety.d.ts +2 -0
- package/dist/vue/agent/view-models.d.ts +98 -0
- package/dist/vue/components/TAnchor.d.ts +108 -0
- package/dist/vue/components/TBox.d.ts +144 -0
- package/dist/vue/components/TCommandPalette.d.ts +587 -0
- package/dist/vue/components/TDataTable.d.ts +367 -0
- package/dist/vue/components/TDebugOverlay.d.ts +43 -0
- package/dist/vue/components/TDialog.d.ts +255 -0
- package/dist/vue/components/TFeedback.d.ts +635 -0
- package/dist/vue/components/TFlow.d.ts +85 -0
- package/dist/vue/components/TForm.d.ts +1230 -0
- package/dist/vue/components/TInput.d.ts +545 -0
- package/dist/vue/components/TInputBox.d.ts +158 -0
- package/dist/vue/components/TJsonEditor.d.ts +165 -0
- package/dist/vue/components/TLink.d.ts +239 -0
- package/dist/vue/components/TLinkifyText.d.ts +141 -0
- package/dist/vue/components/TList.d.ts +119 -0
- package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
- package/dist/vue/components/TLogMinimap.d.ts +263 -0
- package/dist/vue/components/TLogScrollbar.d.ts +236 -0
- package/dist/vue/components/TLogSearchBar.d.ts +267 -0
- package/dist/vue/components/TLogSearchPager.d.ts +162 -0
- package/dist/vue/components/TLogSearchResults.d.ts +200 -0
- package/dist/vue/components/TLogView.d.ts +536 -0
- package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
- package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
- package/dist/vue/components/TMarkdownText.d.ts +134 -0
- package/dist/vue/components/TMultilineModal.d.ts +62 -0
- package/dist/vue/components/TNavigation.d.ts +324 -0
- package/dist/vue/components/TOverlay.d.ts +366 -0
- package/dist/vue/components/TPanels.d.ts +244 -0
- package/dist/vue/components/TPathPicker.d.ts +213 -0
- package/dist/vue/components/TRenderLayer.d.ts +16 -0
- package/dist/vue/components/TRenderPlane.d.ts +17 -0
- package/dist/vue/components/TSelect.d.ts +335 -0
- package/dist/vue/components/TTable.d.ts +317 -0
- package/dist/vue/components/TText.d.ts +116 -0
- package/dist/vue/components/TThinkingView.d.ts +233 -0
- package/dist/vue/components/TToolCallView.d.ts +384 -0
- package/dist/vue/components/TTranscriptView.d.ts +221 -0
- package/dist/vue/components/TTransition.d.ts +83 -0
- package/dist/vue/components/TTree.d.ts +200 -0
- package/dist/vue/components/TUserMessageView.d.ts +344 -0
- package/dist/vue/components/TView.d.ts +127 -0
- package/dist/vue/components/TVirtualList.d.ts +182 -0
- package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
- package/dist/vue/components/TVirtualRows.d.ts +247 -0
- package/dist/vue/components/TerminalProvider.d.ts +218 -0
- package/dist/vue/components/input/host.d.ts +17 -0
- package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
- package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
- package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
- package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
- package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
- package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
- package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
- package/dist/vue/components/input/plugins/types.d.ts +90 -0
- package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
- package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
- package/dist/vue/components/input/utils/primitives.d.ts +3 -0
- package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
- package/dist/vue/components/link/host.d.ts +15 -0
- package/dist/vue/components/list/list-geometry.d.ts +16 -0
- package/dist/vue/components/list/list-paint.d.ts +1 -0
- package/dist/vue/components/list/scroll-state.d.ts +25 -0
- package/dist/vue/components/list/selection-state.d.ts +6 -0
- package/dist/vue/components/simple-utils.d.ts +5 -0
- package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
- package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
- package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
- package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
- package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
- package/dist/vue/composables/use-layout.d.ts +2 -0
- package/dist/vue/composables/use-render-node.d.ts +19 -0
- package/dist/vue/composables/use-render-stack.d.ts +3 -0
- package/dist/vue/composables/use-runtime.d.ts +5 -0
- package/dist/vue/composables/use-terminal-node.d.ts +14 -0
- package/dist/vue/composables/use-terminal.d.ts +2 -0
- package/dist/vue/composables/use-visibility.d.ts +12 -0
- package/dist/vue/context.d.ts +153 -0
- package/dist/vue/index.d.ts +69 -0
- package/dist/vue/injection-key.d.ts +2 -0
- package/dist/vue/linkify.d.ts +11 -0
- package/dist/vue/log/append-only-log-store.d.ts +2 -0
- package/dist/vue/log/tlog-keymap.d.ts +28 -0
- package/dist/vue/log/tlog-plugins.d.ts +144 -0
- package/dist/vue/log/tlog-session.d.ts +81 -0
- package/dist/vue/log/tlog-theme.d.ts +68 -0
- package/dist/vue/log/types.d.ts +43 -0
- package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
- package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
- package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
- package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
- package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
- package/dist/vue/markdown/ast.d.ts +3 -0
- package/dist/vue/markdown/block-source.d.ts +22 -0
- package/dist/vue/markdown/document.d.ts +20 -0
- package/dist/vue/markdown/layout.d.ts +21 -0
- package/dist/vue/markdown/parser.d.ts +11 -0
- package/dist/vue/markdown/render.d.ts +10 -0
- package/dist/vue/markdown/theme.d.ts +186 -0
- package/dist/vue/markdown/types.d.ts +59 -0
- package/dist/vue/overlay.d.ts +27 -0
- package/dist/vue/render/context.d.ts +3 -0
- package/dist/vue/render/render-manager.d.ts +94 -0
- package/dist/vue/router/RouterView.d.ts +25 -0
- package/dist/vue/router/composables.d.ts +4 -0
- package/dist/vue/router/context.d.ts +4 -0
- package/dist/vue/router/router.d.ts +7 -0
- package/dist/vue/router/types.d.ts +29 -0
- package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
- package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
- package/dist/vue/theme.d.ts +48 -0
- package/dist/vue/transcript/hit-regions.d.ts +2 -0
- package/dist/vue/transcript/layout.d.ts +20 -0
- package/dist/vue/transcript/plain-text.d.ts +2 -0
- package/dist/vue/transcript/types.d.ts +122 -0
- package/dist/vue/utils/frame-task.d.ts +6 -0
- package/dist/vue/utils/rect.d.ts +4 -0
- package/dist/vue/utils/row-scroll.d.ts +25 -0
- package/dist/vue/utils/style-cache.d.ts +3 -0
- package/dist/vue/utils/text.d.ts +27 -0
- package/dist/vue/utils/wheel-scroll.d.ts +18 -0
- package/dist/vue.cjs +23668 -0
- package/dist/vue.d.cts +1 -0
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +3957 -0
- package/dist/{wheel-scroll-CiNsasLf.js → wheel-scroll-vBRaQ7p-.js} +404 -405
- package/package.json +185 -35
- package/dist/path-suggest-BeV6n7m-.js +0 -3
- package/dist/sgr-Tko2EQ0U.js +0 -484
- package/dist/theme-Bsm65g8k.d.ts +0 -32
- package/dist/types-ClIV2h1o.d.ts +0 -103
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { Rect, TerminalBaseEvent, TerminalDebugNode, TerminalEventHandlerMap, TerminalEventType, TerminalInputEvent, TerminalKeyboardEvent, TerminalNode, TerminalPointerEvent, } from "./events/manager/types.js";
|
|
2
|
+
export type { EventManager } from "./events/manager/event-manager.js";
|
|
3
|
+
export { createEventManager } from "./events/manager/event-manager.js";
|
|
4
|
+
export type { TerminalEventRecord } from "./events/recording.js";
|
|
5
|
+
export type { ClipboardApi, RafApi, Runtime, RuntimeEnv, RuntimeOptions, TimerApi, } from "./runtime/index.js";
|
|
6
|
+
export { createRuntime } from "./runtime/index.js";
|
|
7
|
+
export type { CreateTerminalSelectionControllerOptions, SelectionTextProvider, TerminalSelectionConfig, TerminalSelectionController, TerminalSelectionCopyPayload, TerminalSelectionOptions, TerminalSelectionPoint, TerminalSelectionRange, TerminalSelectionRefreshOptions, TerminalSelectionState, } from "./selection/terminal-selection.js";
|
|
8
|
+
export type { SelectedRowSpan } from "./selection/terminal-selection.js";
|
|
9
|
+
export { createTerminalSelectionController, terminalSelectionRowSpans, terminalSelectionVisibleRowSpans, } from "./selection/terminal-selection.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { Rect, TerminalBaseEvent, TerminalDebugNode, TerminalEventHandlerMap, TerminalEventType, TerminalInputEvent, TerminalKeyboardEvent, TerminalNode, TerminalPointerEvent, } from "./events/manager/types.js";
|
|
2
|
+
export type { EventManager } from "./events/manager/event-manager.js";
|
|
3
|
+
export { createEventManager } from "./events/manager/event-manager.js";
|
|
4
|
+
export type { TerminalEventRecord } from "./events/recording.js";
|
|
5
|
+
export type { ClipboardApi, RafApi, Runtime, RuntimeEnv, RuntimeOptions, TimerApi, } from "./runtime/index.js";
|
|
6
|
+
export { createRuntime } from "./runtime/index.js";
|
|
7
|
+
export type { CreateTerminalSelectionControllerOptions, SelectionTextProvider, TerminalSelectionConfig, TerminalSelectionController, TerminalSelectionCopyPayload, TerminalSelectionOptions, TerminalSelectionPoint, TerminalSelectionRange, TerminalSelectionRefreshOptions, TerminalSelectionState, } from "./selection/terminal-selection.js";
|
|
8
|
+
export type { SelectedRowSpan } from "./selection/terminal-selection.js";
|
|
9
|
+
export { createTerminalSelectionController, terminalSelectionRowSpans, terminalSelectionVisibleRowSpans, } from "./selection/terminal-selection.js";
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createEventManager, createRuntime } from "./runtime-rfcZCyJq.js";
|
|
2
|
+
import { createTerminalSelectionController, terminalSelectionRowSpans, terminalSelectionVisibleRowSpans } from "./terminal-selection-DBinO6p5.js";
|
|
3
|
+
|
|
4
|
+
export { createEventManager, createRuntime, createTerminalSelectionController, terminalSelectionRowSpans, terminalSelectionVisibleRowSpans };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { Rect } from "../events/manager/types.js";
|
|
3
|
+
import type { ClipboardApi } from "../runtime/index.js";
|
|
4
|
+
import type { Cell, Style, Terminal } from "../core/types.js";
|
|
5
|
+
export type TerminalSelectionPoint = Readonly<{
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}>;
|
|
9
|
+
export type TerminalSelectionRange = Readonly<{
|
|
10
|
+
anchor: TerminalSelectionPoint;
|
|
11
|
+
focus: TerminalSelectionPoint;
|
|
12
|
+
mode: "linear" | "block";
|
|
13
|
+
}>;
|
|
14
|
+
export type TerminalSelectionState = Readonly<{
|
|
15
|
+
active: boolean;
|
|
16
|
+
anchor: TerminalSelectionPoint | null;
|
|
17
|
+
focus: TerminalSelectionPoint | null;
|
|
18
|
+
text: string;
|
|
19
|
+
hasRange: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
export type TerminalSelectionCopyPayload = Readonly<{
|
|
22
|
+
text: string;
|
|
23
|
+
rows: number;
|
|
24
|
+
chars: number;
|
|
25
|
+
ok: boolean;
|
|
26
|
+
error?: unknown;
|
|
27
|
+
}>;
|
|
28
|
+
export type TerminalSelectionOptions = Readonly<{
|
|
29
|
+
autoCopy?: boolean;
|
|
30
|
+
copyOnMouseUp?: boolean;
|
|
31
|
+
style?: Style;
|
|
32
|
+
}>;
|
|
33
|
+
export type TerminalSelectionConfig = boolean | TerminalSelectionOptions;
|
|
34
|
+
/**
|
|
35
|
+
* A visible overlay span in terminal screen coordinates.
|
|
36
|
+
* Provider-space spans must be translated to screen coordinates before
|
|
37
|
+
* returning from `getVisibleSpans()`.
|
|
38
|
+
*/
|
|
39
|
+
export type SelectedRowSpan = Readonly<{
|
|
40
|
+
/** Terminal screen row y */
|
|
41
|
+
y: number;
|
|
42
|
+
/** Terminal screen column x inclusive */
|
|
43
|
+
x0: number;
|
|
44
|
+
/** Terminal screen column x exclusive */
|
|
45
|
+
x1: number;
|
|
46
|
+
}>;
|
|
47
|
+
export type SelectionTextProvider = Readonly<{
|
|
48
|
+
id: string;
|
|
49
|
+
/**
|
|
50
|
+
* Current provider viewport rect in terminal screen coordinates.
|
|
51
|
+
*/
|
|
52
|
+
rect: Rect;
|
|
53
|
+
/**
|
|
54
|
+
* Receives a terminal screen-space range. Return true when this provider
|
|
55
|
+
* can resolve the range without relying on the terminal buffer fallback.
|
|
56
|
+
*/
|
|
57
|
+
canHandle: (screenRange: TerminalSelectionRange) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Maps a terminal screen-space point to provider-space point.
|
|
60
|
+
*/
|
|
61
|
+
pointForCell?: (screenPoint: TerminalSelectionPoint) => TerminalSelectionPoint | null;
|
|
62
|
+
/**
|
|
63
|
+
* Receives a provider-space range (i.e. after `pointForCell` mapping).
|
|
64
|
+
*/
|
|
65
|
+
getText: (providerRange: TerminalSelectionRange) => string;
|
|
66
|
+
/**
|
|
67
|
+
* Return overlay highlight spans for the portion of the selection that is
|
|
68
|
+
* currently visible in the viewport. Coordinates are terminal screen cells.
|
|
69
|
+
*
|
|
70
|
+
* When a virtual-scrolling provider scrolls during a drag-selection, the
|
|
71
|
+
* selection range may span content that has already scrolled out of view.
|
|
72
|
+
* The default `terminalSelectionRowSpans()` uses screen coordinates and
|
|
73
|
+
* cannot account for this, so the highlight becomes stale after each scroll
|
|
74
|
+
* tick. Providers that support cross-viewport selection should implement
|
|
75
|
+
* this method to return only the spans that intersect the current viewport,
|
|
76
|
+
* mapped back to screen cell coordinates.
|
|
77
|
+
*
|
|
78
|
+
* @param providerRange - The selection range in provider-space coordinates
|
|
79
|
+
* (i.e. after `pointForCell` mapping).
|
|
80
|
+
* @param screenRange - The same selection range in terminal screen
|
|
81
|
+
* coordinates (before `pointForCell` mapping).
|
|
82
|
+
*/
|
|
83
|
+
getVisibleSpans?: (providerRange: TerminalSelectionRange, screenRange: TerminalSelectionRange) => readonly SelectedRowSpan[];
|
|
84
|
+
}>;
|
|
85
|
+
export type TerminalSelectionRefreshOptions = Readonly<{
|
|
86
|
+
/**
|
|
87
|
+
* Re-map the current screen-space focus point through the active provider.
|
|
88
|
+
* Use this for selection-driven auto-scroll after the viewport has moved.
|
|
89
|
+
*/
|
|
90
|
+
remapFocus?: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
export type TerminalSelectionController = Readonly<{
|
|
93
|
+
state: Ref<TerminalSelectionState>;
|
|
94
|
+
start: (point: TerminalSelectionPoint, options?: {
|
|
95
|
+
extend?: boolean;
|
|
96
|
+
}) => void;
|
|
97
|
+
update: (point: TerminalSelectionPoint) => void;
|
|
98
|
+
finish: () => Promise<void>;
|
|
99
|
+
clear: () => void;
|
|
100
|
+
copy: () => Promise<boolean>;
|
|
101
|
+
paint: (dirtyRows?: readonly number[]) => void;
|
|
102
|
+
refresh: (options?: TerminalSelectionRefreshOptions) => void;
|
|
103
|
+
clearProvider: (providerId: string) => void;
|
|
104
|
+
}>;
|
|
105
|
+
type ResolvedSelectionOptions = Readonly<{
|
|
106
|
+
autoCopy: boolean;
|
|
107
|
+
copyOnMouseUp: boolean;
|
|
108
|
+
style: Style;
|
|
109
|
+
}>;
|
|
110
|
+
export type CreateTerminalSelectionControllerOptions = Readonly<{
|
|
111
|
+
terminal: Terminal;
|
|
112
|
+
overlayTerminal: Terminal;
|
|
113
|
+
clipboard: ClipboardApi;
|
|
114
|
+
getRow?: (y: number) => readonly Cell[];
|
|
115
|
+
getOptions?: () => Partial<ResolvedSelectionOptions>;
|
|
116
|
+
getTextProviders?: () => readonly SelectionTextProvider[];
|
|
117
|
+
onDirtyRows?: (rows: readonly number[]) => void;
|
|
118
|
+
onCopy?: (payload: TerminalSelectionCopyPayload) => void;
|
|
119
|
+
}>;
|
|
120
|
+
export declare function terminalSelectionRowSpans(range: TerminalSelectionRange, cols: number, rows: number): SelectedRowSpan[];
|
|
121
|
+
export declare function terminalSelectionVisibleRowSpans(range: TerminalSelectionRange, cols: number, rows: number, visibleStartY: number, visibleEndY: number): SelectedRowSpan[];
|
|
122
|
+
export declare function createTerminalSelectionController(options: CreateTerminalSelectionControllerOptions): TerminalSelectionController;
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
//#region src/core/ansi/sgr.ts
|
|
2
|
+
const ESC = "\x1B";
|
|
3
|
+
function ansi16ToColorName(code) {
|
|
4
|
+
switch (code) {
|
|
5
|
+
case 30: return "black";
|
|
6
|
+
case 31: return "red";
|
|
7
|
+
case 32: return "green";
|
|
8
|
+
case 33: return "yellow";
|
|
9
|
+
case 34: return "blue";
|
|
10
|
+
case 35: return "magenta";
|
|
11
|
+
case 36: return "cyan";
|
|
12
|
+
case 37: return "white";
|
|
13
|
+
case 90: return "blackBright";
|
|
14
|
+
case 91: return "redBright";
|
|
15
|
+
case 92: return "greenBright";
|
|
16
|
+
case 93: return "yellowBright";
|
|
17
|
+
case 94: return "blueBright";
|
|
18
|
+
case 95: return "magentaBright";
|
|
19
|
+
case 96: return "cyanBright";
|
|
20
|
+
case 97: return "whiteBright";
|
|
21
|
+
default: return void 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function ansi16BgToColorName(code) {
|
|
25
|
+
const fgCode = code >= 40 && code <= 47 ? code - 10 : code >= 100 && code <= 107 ? code - 10 : null;
|
|
26
|
+
if (fgCode == null) return void 0;
|
|
27
|
+
return ansi16ToColorName(fgCode);
|
|
28
|
+
}
|
|
29
|
+
const ANSI16_RGB = {
|
|
30
|
+
black: {
|
|
31
|
+
r: 0,
|
|
32
|
+
g: 0,
|
|
33
|
+
b: 0
|
|
34
|
+
},
|
|
35
|
+
red: {
|
|
36
|
+
r: 201,
|
|
37
|
+
g: 27,
|
|
38
|
+
b: 0
|
|
39
|
+
},
|
|
40
|
+
green: {
|
|
41
|
+
r: 0,
|
|
42
|
+
g: 194,
|
|
43
|
+
b: 0
|
|
44
|
+
},
|
|
45
|
+
yellow: {
|
|
46
|
+
r: 199,
|
|
47
|
+
g: 196,
|
|
48
|
+
b: 0
|
|
49
|
+
},
|
|
50
|
+
blue: {
|
|
51
|
+
r: 2,
|
|
52
|
+
g: 37,
|
|
53
|
+
b: 199
|
|
54
|
+
},
|
|
55
|
+
magenta: {
|
|
56
|
+
r: 201,
|
|
57
|
+
g: 48,
|
|
58
|
+
b: 199
|
|
59
|
+
},
|
|
60
|
+
cyan: {
|
|
61
|
+
r: 0,
|
|
62
|
+
g: 197,
|
|
63
|
+
b: 199
|
|
64
|
+
},
|
|
65
|
+
white: {
|
|
66
|
+
r: 199,
|
|
67
|
+
g: 199,
|
|
68
|
+
b: 199
|
|
69
|
+
},
|
|
70
|
+
blackBright: {
|
|
71
|
+
r: 104,
|
|
72
|
+
g: 104,
|
|
73
|
+
b: 104
|
|
74
|
+
},
|
|
75
|
+
redBright: {
|
|
76
|
+
r: 255,
|
|
77
|
+
g: 110,
|
|
78
|
+
b: 103
|
|
79
|
+
},
|
|
80
|
+
greenBright: {
|
|
81
|
+
r: 95,
|
|
82
|
+
g: 250,
|
|
83
|
+
b: 104
|
|
84
|
+
},
|
|
85
|
+
yellowBright: {
|
|
86
|
+
r: 255,
|
|
87
|
+
g: 252,
|
|
88
|
+
b: 103
|
|
89
|
+
},
|
|
90
|
+
blueBright: {
|
|
91
|
+
r: 104,
|
|
92
|
+
g: 113,
|
|
93
|
+
b: 255
|
|
94
|
+
},
|
|
95
|
+
magentaBright: {
|
|
96
|
+
r: 255,
|
|
97
|
+
g: 118,
|
|
98
|
+
b: 255
|
|
99
|
+
},
|
|
100
|
+
cyanBright: {
|
|
101
|
+
r: 95,
|
|
102
|
+
g: 253,
|
|
103
|
+
b: 255
|
|
104
|
+
},
|
|
105
|
+
whiteBright: {
|
|
106
|
+
r: 255,
|
|
107
|
+
g: 255,
|
|
108
|
+
b: 255
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
function nearestAnsi16(r, g, b) {
|
|
112
|
+
let best = "white";
|
|
113
|
+
let bestDist = Number.POSITIVE_INFINITY;
|
|
114
|
+
for (const [name, rgb] of Object.entries(ANSI16_RGB)) {
|
|
115
|
+
const dr = r - rgb.r;
|
|
116
|
+
const dg = g - rgb.g;
|
|
117
|
+
const db = b - rgb.b;
|
|
118
|
+
const d = dr * dr + dg * dg + db * db;
|
|
119
|
+
if (d < bestDist) {
|
|
120
|
+
bestDist = d;
|
|
121
|
+
best = name;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return best;
|
|
125
|
+
}
|
|
126
|
+
function ansi256ToRgb(index) {
|
|
127
|
+
const n = Math.max(0, Math.min(255, Math.trunc(index)));
|
|
128
|
+
if (n < 16) {
|
|
129
|
+
const map = [
|
|
130
|
+
"black",
|
|
131
|
+
"red",
|
|
132
|
+
"green",
|
|
133
|
+
"yellow",
|
|
134
|
+
"blue",
|
|
135
|
+
"magenta",
|
|
136
|
+
"cyan",
|
|
137
|
+
"white",
|
|
138
|
+
"blackBright",
|
|
139
|
+
"redBright",
|
|
140
|
+
"greenBright",
|
|
141
|
+
"yellowBright",
|
|
142
|
+
"blueBright",
|
|
143
|
+
"magentaBright",
|
|
144
|
+
"cyanBright",
|
|
145
|
+
"whiteBright"
|
|
146
|
+
];
|
|
147
|
+
const name = map[n] ?? "white";
|
|
148
|
+
return ANSI16_RGB[name];
|
|
149
|
+
}
|
|
150
|
+
if (n >= 232) {
|
|
151
|
+
const c = 8 + (n - 232) * 10;
|
|
152
|
+
return {
|
|
153
|
+
r: c,
|
|
154
|
+
g: c,
|
|
155
|
+
b: c
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const i = n - 16;
|
|
159
|
+
const rr = Math.floor(i / 36);
|
|
160
|
+
const gg = Math.floor(i % 36 / 6);
|
|
161
|
+
const bb = i % 6;
|
|
162
|
+
const toComponent = (v) => v === 0 ? 0 : 55 + v * 40;
|
|
163
|
+
return {
|
|
164
|
+
r: toComponent(rr),
|
|
165
|
+
g: toComponent(gg),
|
|
166
|
+
b: toComponent(bb)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function applyAnsiSgrStyle(current, codes) {
|
|
170
|
+
let next = { ...current };
|
|
171
|
+
for (let i = 0; i < codes.length; i++) {
|
|
172
|
+
const code = codes[i];
|
|
173
|
+
if (code === 0) {
|
|
174
|
+
next = {};
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (code === 1) next = {
|
|
178
|
+
...next,
|
|
179
|
+
bold: true
|
|
180
|
+
};
|
|
181
|
+
else if (code === 2) next = {
|
|
182
|
+
...next,
|
|
183
|
+
dim: true
|
|
184
|
+
};
|
|
185
|
+
else if (code === 3) next = {
|
|
186
|
+
...next,
|
|
187
|
+
italic: true
|
|
188
|
+
};
|
|
189
|
+
else if (code === 4) next = {
|
|
190
|
+
...next,
|
|
191
|
+
underline: true
|
|
192
|
+
};
|
|
193
|
+
else if (code === 7) next = {
|
|
194
|
+
...next,
|
|
195
|
+
inverse: true
|
|
196
|
+
};
|
|
197
|
+
else if (code === 22) next = {
|
|
198
|
+
...next,
|
|
199
|
+
bold: false,
|
|
200
|
+
dim: false
|
|
201
|
+
};
|
|
202
|
+
else if (code === 23) next = {
|
|
203
|
+
...next,
|
|
204
|
+
italic: false
|
|
205
|
+
};
|
|
206
|
+
else if (code === 24) next = {
|
|
207
|
+
...next,
|
|
208
|
+
underline: false
|
|
209
|
+
};
|
|
210
|
+
else if (code === 27) next = {
|
|
211
|
+
...next,
|
|
212
|
+
inverse: false
|
|
213
|
+
};
|
|
214
|
+
else if (code === 39) next = {
|
|
215
|
+
...next,
|
|
216
|
+
fg: void 0
|
|
217
|
+
};
|
|
218
|
+
else if (code === 49) next = {
|
|
219
|
+
...next,
|
|
220
|
+
bg: void 0
|
|
221
|
+
};
|
|
222
|
+
else if (code >= 30 && code <= 37 || code >= 90 && code <= 97) {
|
|
223
|
+
const fg = ansi16ToColorName(code);
|
|
224
|
+
next = {
|
|
225
|
+
...next,
|
|
226
|
+
fg: fg ?? next.fg
|
|
227
|
+
};
|
|
228
|
+
} else if (code >= 40 && code <= 47 || code >= 100 && code <= 107) {
|
|
229
|
+
const bg = ansi16BgToColorName(code);
|
|
230
|
+
next = {
|
|
231
|
+
...next,
|
|
232
|
+
bg: bg ?? next.bg
|
|
233
|
+
};
|
|
234
|
+
} else if (code === 38 || code === 48) {
|
|
235
|
+
const mode = codes[i + 1];
|
|
236
|
+
if (mode === 5) {
|
|
237
|
+
const idx = codes[i + 2];
|
|
238
|
+
if (idx != null) {
|
|
239
|
+
const { r, g, b } = ansi256ToRgb(idx);
|
|
240
|
+
const name = nearestAnsi16(r, g, b);
|
|
241
|
+
next = code === 38 ? {
|
|
242
|
+
...next,
|
|
243
|
+
fg: name
|
|
244
|
+
} : {
|
|
245
|
+
...next,
|
|
246
|
+
bg: name
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
i += 2;
|
|
250
|
+
} else if (mode === 2) {
|
|
251
|
+
const r = codes[i + 2];
|
|
252
|
+
const g = codes[i + 3];
|
|
253
|
+
const b = codes[i + 4];
|
|
254
|
+
if (r != null && g != null && b != null) {
|
|
255
|
+
const name = nearestAnsi16(r, g, b);
|
|
256
|
+
next = code === 38 ? {
|
|
257
|
+
...next,
|
|
258
|
+
fg: name
|
|
259
|
+
} : {
|
|
260
|
+
...next,
|
|
261
|
+
bg: name
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
i += 4;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return next;
|
|
269
|
+
}
|
|
270
|
+
function parseAnsiSgr(input, baseStyle = {}) {
|
|
271
|
+
const segments = [];
|
|
272
|
+
let style = { ...baseStyle };
|
|
273
|
+
let lastIndex = 0;
|
|
274
|
+
for (let i = 0; i < input.length; i++) {
|
|
275
|
+
if (input[i] !== ESC || input[i + 1] !== "[") continue;
|
|
276
|
+
let j = i + 2;
|
|
277
|
+
while (j < input.length) {
|
|
278
|
+
const c = input.charCodeAt(j);
|
|
279
|
+
if (c >= 48 && c <= 57 || c === 59) {
|
|
280
|
+
j++;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
if (j >= input.length || input[j] !== "m") continue;
|
|
286
|
+
if (i > lastIndex) segments.push({
|
|
287
|
+
text: input.slice(lastIndex, i),
|
|
288
|
+
style
|
|
289
|
+
});
|
|
290
|
+
const body = input.slice(i + 2, j);
|
|
291
|
+
const codes = body.split(";").filter(Boolean).map((n) => Number.parseInt(n, 10)).filter((n) => Number.isFinite(n));
|
|
292
|
+
style = applyAnsiSgrStyle(style, codes.length ? codes : [0]);
|
|
293
|
+
lastIndex = j + 1;
|
|
294
|
+
i = j;
|
|
295
|
+
}
|
|
296
|
+
if (lastIndex < input.length) segments.push({
|
|
297
|
+
text: input.slice(lastIndex),
|
|
298
|
+
style
|
|
299
|
+
});
|
|
300
|
+
return segments;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
//#endregion
|
|
304
|
+
export { applyAnsiSgrStyle, parseAnsiSgr };
|