@bigpixelrocket/uiok 0.0.0-stage → 0.1.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 +38 -0
- package/LICENSE +21 -0
- package/NOTICE +569 -0
- package/README.md +44 -2
- package/dist/VisuallyHidden.d.ts +13 -0
- package/dist/VisuallyHidden.js +13 -0
- package/dist/activity/ActivityBar.d.ts +29 -0
- package/dist/activity/ActivityBar.js +21 -0
- package/dist/activity/activity.css +43 -0
- package/dist/activity/index.d.ts +2 -0
- package/dist/activity/index.js +2 -0
- package/dist/button/Button.d.ts +26 -0
- package/dist/button/Button.js +14 -0
- package/dist/button/IconButton.d.ts +18 -0
- package/dist/button/IconButton.js +14 -0
- package/dist/button/button.css +95 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.js +3 -0
- package/dist/charts/Drawing.d.ts +27 -0
- package/dist/charts/Drawing.js +117 -0
- package/dist/charts/Drawing.logic.d.ts +2 -0
- package/dist/charts/Drawing.logic.js +22 -0
- package/dist/charts/Line.logic.d.ts +33 -0
- package/dist/charts/Line.logic.js +72 -0
- package/dist/charts/LineChart.d.ts +34 -0
- package/dist/charts/LineChart.js +100 -0
- package/dist/charts/Pie.logic.d.ts +16 -0
- package/dist/charts/Pie.logic.js +28 -0
- package/dist/charts/PieChart.d.ts +20 -0
- package/dist/charts/PieChart.js +16 -0
- package/dist/charts/ResultChart.d.ts +47 -0
- package/dist/charts/ResultChart.js +175 -0
- package/dist/charts/ResultChart.logic.d.ts +42 -0
- package/dist/charts/ResultChart.logic.js +165 -0
- package/dist/charts/Scatter.logic.d.ts +55 -0
- package/dist/charts/Scatter.logic.js +134 -0
- package/dist/charts/ScatterChart.d.ts +36 -0
- package/dist/charts/ScatterChart.js +99 -0
- package/dist/charts/charts.css +310 -0
- package/dist/charts/index.d.ts +14 -0
- package/dist/charts/index.js +11 -0
- package/dist/charts/seriesColour.d.ts +2 -0
- package/dist/charts/seriesColour.js +8 -0
- package/dist/clock/index.d.ts +2 -0
- package/dist/clock/index.js +2 -0
- package/dist/clock/useClock.d.ts +14 -0
- package/dist/clock/useClock.js +57 -0
- package/dist/datetime/DateTimePicker.d.ts +50 -0
- package/dist/datetime/DateTimePicker.js +98 -0
- package/dist/datetime/DateTimePicker.logic.d.ts +59 -0
- package/dist/datetime/DateTimePicker.logic.js +103 -0
- package/dist/datetime/datetime.css +115 -0
- package/dist/datetime/index.d.ts +7 -0
- package/dist/datetime/index.js +7 -0
- package/dist/dialog/ConfirmDialog.d.ts +73 -0
- package/dist/dialog/ConfirmDialog.js +30 -0
- package/dist/dialog/DialogLegend.d.ts +21 -0
- package/dist/dialog/DialogLegend.js +28 -0
- package/dist/dialog/DialogLegend.logic.d.ts +145 -0
- package/dist/dialog/DialogLegend.logic.js +71 -0
- package/dist/dialog/ModalDialog.d.ts +101 -0
- package/dist/dialog/ModalDialog.js +184 -0
- package/dist/dialog/dialog.css +283 -0
- package/dist/dialog/index.d.ts +8 -0
- package/dist/dialog/index.js +8 -0
- package/dist/filter/FilterEscape.d.ts +16 -0
- package/dist/filter/FilterEscape.js +15 -0
- package/dist/filter/FilterIcon.d.ts +8 -0
- package/dist/filter/FilterIcon.js +11 -0
- package/dist/filter/filter.css +42 -0
- package/dist/filter/index.d.ts +3 -0
- package/dist/filter/index.js +3 -0
- package/dist/grid/DataGrid.d.ts +149 -0
- package/dist/grid/DataGrid.js +373 -0
- package/dist/grid/DataGrid.logic.d.ts +57 -0
- package/dist/grid/DataGrid.logic.js +121 -0
- package/dist/grid/grid.css +206 -0
- package/dist/grid/index.d.ts +7 -0
- package/dist/grid/index.js +7 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/keyboard/BrowserKeys.d.ts +15 -0
- package/dist/keyboard/BrowserKeys.js +28 -0
- package/dist/keyboard/KeyChord.logic.d.ts +25 -0
- package/dist/keyboard/KeyChord.logic.js +50 -0
- package/dist/keyboard/Keyboard.logic.d.ts +84 -0
- package/dist/keyboard/Keyboard.logic.js +137 -0
- package/dist/keyboard/OverlayWatch.d.ts +28 -0
- package/dist/keyboard/OverlayWatch.js +119 -0
- package/dist/keyboard/PageSelectAll.d.ts +14 -0
- package/dist/keyboard/PageSelectAll.js +22 -0
- package/dist/keyboard/index.d.ts +9 -0
- package/dist/keyboard/index.js +9 -0
- package/dist/keychord/KeyChord.d.ts +16 -0
- package/dist/keychord/KeyChord.js +55 -0
- package/dist/keychord/index.d.ts +2 -0
- package/dist/keychord/index.js +2 -0
- package/dist/keychord/keychord.css +41 -0
- package/dist/labels/UiokLabels.d.ts +41 -0
- package/dist/labels/UiokLabels.js +31 -0
- package/dist/labels/UiokProvider.d.ts +44 -0
- package/dist/labels/UiokProvider.js +54 -0
- package/dist/labels/charts.d.ts +34 -0
- package/dist/labels/charts.js +15 -0
- package/dist/labels/dateTime.d.ts +32 -0
- package/dist/labels/dateTime.js +14 -0
- package/dist/labels/dialog.d.ts +18 -0
- package/dist/labels/dialog.js +6 -0
- package/dist/labels/index.d.ts +13 -0
- package/dist/labels/index.js +13 -0
- package/dist/labels/keys.d.ts +28 -0
- package/dist/labels/keys.js +53 -0
- package/dist/labels/legend.d.ts +21 -0
- package/dist/labels/legend.js +7 -0
- package/dist/labels/listing.d.ts +16 -0
- package/dist/labels/listing.js +8 -0
- package/dist/labels/pager.d.ts +32 -0
- package/dist/labels/pager.js +20 -0
- package/dist/labels/palette.d.ts +17 -0
- package/dist/labels/palette.js +6 -0
- package/dist/labels/selectAll.d.ts +15 -0
- package/dist/labels/selectAll.js +6 -0
- package/dist/labels/terminal.d.ts +25 -0
- package/dist/labels/terminal.js +9 -0
- package/dist/legend/KeyLegend.logic.d.ts +84 -0
- package/dist/legend/KeyLegend.logic.js +109 -0
- package/dist/legend/KeyLegendStrip.d.ts +36 -0
- package/dist/legend/KeyLegendStrip.js +82 -0
- package/dist/legend/index.d.ts +3 -0
- package/dist/legend/index.js +3 -0
- package/dist/legend/legend.css +148 -0
- package/dist/listing/CurrentDot.d.ts +15 -0
- package/dist/listing/CurrentDot.js +13 -0
- package/dist/listing/Listing.d.ts +230 -0
- package/dist/listing/Listing.js +265 -0
- package/dist/listing/PathParts.logic.d.ts +17 -0
- package/dist/listing/PathParts.logic.js +18 -0
- package/dist/listing/index.d.ts +10 -0
- package/dist/listing/index.js +10 -0
- package/dist/listing/listing.css +867 -0
- package/dist/menu/MenuQuery.logic.d.ts +69 -0
- package/dist/menu/MenuQuery.logic.js +75 -0
- package/dist/menu/fuzzyMatch.d.ts +31 -0
- package/dist/menu/fuzzyMatch.js +296 -0
- package/dist/menu/index.d.ts +9 -0
- package/dist/menu/index.js +9 -0
- package/dist/menu/menu.css +203 -0
- package/dist/menu/useBellBeat.d.ts +8 -0
- package/dist/menu/useBellBeat.js +26 -0
- package/dist/namecut/NameCut.d.ts +22 -0
- package/dist/namecut/NameCut.js +28 -0
- package/dist/namecut/NameCut.logic.d.ts +51 -0
- package/dist/namecut/NameCut.logic.js +120 -0
- package/dist/namecut/index.d.ts +3 -0
- package/dist/namecut/index.js +3 -0
- package/dist/namecut/namecut.css +67 -0
- package/dist/pager/Pager.d.ts +37 -0
- package/dist/pager/Pager.js +38 -0
- package/dist/pager/Pager.logic.d.ts +13 -0
- package/dist/pager/Pager.logic.js +63 -0
- package/dist/pager/index.d.ts +7 -0
- package/dist/pager/index.js +7 -0
- package/dist/pager/pager.css +62 -0
- package/dist/palette/Palette.d.ts +79 -0
- package/dist/palette/Palette.js +60 -0
- package/dist/palette/index.d.ts +6 -0
- package/dist/palette/index.js +6 -0
- package/dist/palette/palette.css +159 -0
- package/dist/pane/PaneActions.d.ts +104 -0
- package/dist/pane/PaneActions.js +62 -0
- package/dist/pane/PaneFrame.d.ts +51 -0
- package/dist/pane/PaneFrame.js +28 -0
- package/dist/pane/PaneKeys.d.ts +41 -0
- package/dist/pane/PaneKeys.js +104 -0
- package/dist/pane/PaneKeys.logic.d.ts +95 -0
- package/dist/pane/PaneKeys.logic.js +109 -0
- package/dist/pane/index.d.ts +11 -0
- package/dist/pane/index.js +11 -0
- package/dist/pane/usePaneKeys.d.ts +141 -0
- package/dist/pane/usePaneKeys.js +313 -0
- package/dist/run/RunHeader.d.ts +50 -0
- package/dist/run/RunHeader.js +31 -0
- package/dist/run/RunProgress.logic.d.ts +29 -0
- package/dist/run/RunProgress.logic.js +34 -0
- package/dist/run/index.d.ts +3 -0
- package/dist/run/index.js +3 -0
- package/dist/run/run.css +190 -0
- package/dist/segmented/SegmentedChoice.d.ts +22 -0
- package/dist/segmented/SegmentedChoice.js +31 -0
- package/dist/segmented/index.d.ts +2 -0
- package/dist/segmented/index.js +2 -0
- package/dist/segmented/segmented.css +49 -0
- package/dist/selectall/CheckRange.logic.d.ts +8 -0
- package/dist/selectall/CheckRange.logic.js +23 -0
- package/dist/selectall/SelectAllBar.d.ts +25 -0
- package/dist/selectall/SelectAllBar.js +24 -0
- package/dist/selectall/index.d.ts +7 -0
- package/dist/selectall/index.js +7 -0
- package/dist/selectall/selectall.css +31 -0
- package/dist/store/KeepUnchanged.logic.d.ts +19 -0
- package/dist/store/KeepUnchanged.logic.js +33 -0
- package/dist/store/SameProps.d.ts +15 -0
- package/dist/store/SameProps.js +46 -0
- package/dist/store/ValueStore.d.ts +17 -0
- package/dist/store/ValueStore.js +23 -0
- package/dist/store/index.d.ts +8 -0
- package/dist/store/index.js +8 -0
- package/dist/store/useStableHandlers.d.ts +13 -0
- package/dist/store/useStableHandlers.js +22 -0
- package/dist/styles.css +85 -0
- package/dist/tabs/PageTabs.d.ts +38 -0
- package/dist/tabs/PageTabs.js +33 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/tabs.css +64 -0
- package/dist/terminal/Terminal.d.ts +104 -0
- package/dist/terminal/Terminal.js +309 -0
- package/dist/terminal/Terminal.logic.d.ts +66 -0
- package/dist/terminal/Terminal.logic.js +156 -0
- package/dist/terminal/TerminalMenu.d.ts +36 -0
- package/dist/terminal/TerminalMenu.js +87 -0
- package/dist/terminal/TerminalMenu.logic.d.ts +78 -0
- package/dist/terminal/TerminalMenu.logic.js +68 -0
- package/dist/terminal/TerminalScrollback.d.ts +10 -0
- package/dist/terminal/TerminalScrollback.js +11 -0
- package/dist/terminal/ghostty/LICENSE +21 -0
- package/dist/terminal/ghostty/core.d.ts +315 -0
- package/dist/terminal/ghostty/core.js +1189 -0
- package/dist/terminal/ghostty/fallbackColors.d.ts +12 -0
- package/dist/terminal/ghostty/fallbackColors.js +23 -0
- package/dist/terminal/ghostty/fonts/LICENSE +21 -0
- package/dist/terminal/ghostty/fonts/SymbolsNerdFontMono-Regular.woff2 +0 -0
- package/dist/terminal/ghostty/keyCodes.logic.d.ts +20 -0
- package/dist/terminal/ghostty/keyCodes.logic.js +249 -0
- package/dist/terminal/ghostty/links.logic.d.ts +39 -0
- package/dist/terminal/ghostty/links.logic.js +84 -0
- package/dist/terminal/ghostty/renderer.d.ts +98 -0
- package/dist/terminal/ghostty/renderer.js +481 -0
- package/dist/terminal/ghostty/runtime.d.ts +126 -0
- package/dist/terminal/ghostty/runtime.js +346 -0
- package/dist/terminal/ghostty/spriteGlyphs.logic.d.ts +64 -0
- package/dist/terminal/ghostty/spriteGlyphs.logic.js +546 -0
- package/dist/terminal/ghostty/surface.d.ts +285 -0
- package/dist/terminal/ghostty/surface.js +1565 -0
- package/dist/terminal/ghostty/surface.logic.d.ts +181 -0
- package/dist/terminal/ghostty/surface.logic.js +392 -0
- package/dist/terminal/ghostty/vendor/LICENSE +21 -0
- package/dist/terminal/ghostty/vendor/ghostty-effects.wasm +0 -0
- package/dist/terminal/ghostty/vendor/ghostty-vt.wasm +0 -0
- package/dist/terminal/index.d.ts +12 -0
- package/dist/terminal/index.js +12 -0
- package/dist/terminal/terminal.css +169 -0
- package/dist/text/MarkedText.d.ts +14 -0
- package/dist/text/MarkedText.js +11 -0
- package/dist/text/highlightSegments.d.ts +13 -0
- package/dist/text/highlightSegments.js +29 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.js +3 -0
- package/dist/text/text.css +11 -0
- package/dist/themes/attributes.d.ts +21 -0
- package/dist/themes/attributes.js +41 -0
- package/dist/themes/catalog.d.ts +125 -0
- package/dist/themes/catalog.js +940 -0
- package/dist/themes/color.d.ts +29 -0
- package/dist/themes/color.js +52 -0
- package/dist/themes/ids.d.ts +139 -0
- package/dist/themes/ids.js +59 -0
- package/dist/themes/index.d.ts +12 -0
- package/dist/themes/index.js +12 -0
- package/dist/themes/themes.generated.css +1830 -0
- package/dist/themes/tokens.d.ts +189 -0
- package/dist/themes/tokens.js +462 -0
- package/dist/tooltip/Tooltip.d.ts +21 -0
- package/dist/tooltip/Tooltip.js +105 -0
- package/dist/tooltip/Tooltip.logic.d.ts +49 -0
- package/dist/tooltip/Tooltip.logic.js +50 -0
- package/dist/tooltip/index.d.ts +3 -0
- package/dist/tooltip/index.js +3 -0
- package/dist/tooltip/tooltip.css +45 -0
- package/package.json +91 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* ---- Page tabs (PageTabs) ----
|
|
2
|
+
|
|
3
|
+
The level's pages as tabs under a path bar, the current one underlined
|
|
4
|
+
in the accent. */
|
|
5
|
+
.page-tabs {
|
|
6
|
+
flex: none;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: stretch;
|
|
9
|
+
gap: 2px;
|
|
10
|
+
height: 28px;
|
|
11
|
+
padding: 0 6px;
|
|
12
|
+
overflow-x: auto;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
border-bottom: 1px solid var(--border);
|
|
15
|
+
scrollbar-width: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.page-tab {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: 6px;
|
|
22
|
+
padding: 0 10px;
|
|
23
|
+
border: none;
|
|
24
|
+
border-bottom: 2px solid transparent;
|
|
25
|
+
background: transparent;
|
|
26
|
+
color: var(--text-dim);
|
|
27
|
+
font: 12px var(--font-ui);
|
|
28
|
+
white-space: nowrap;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.page-tab:hover:enabled {
|
|
33
|
+
background: var(--hover-wash);
|
|
34
|
+
color: var(--text);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.page-tab[aria-selected='true'] {
|
|
38
|
+
border-bottom-color: var(--accent);
|
|
39
|
+
color: var(--text);
|
|
40
|
+
font-weight: 600;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.page-tab:focus-visible {
|
|
44
|
+
outline: 2px solid var(--accent);
|
|
45
|
+
outline-offset: -2px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* The second strip, a tab's own pages: rounded pills on a shorter row, the current one washed. */
|
|
49
|
+
.page-tabs.pills {
|
|
50
|
+
height: 26px;
|
|
51
|
+
padding: 3px 6px;
|
|
52
|
+
gap: 4px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.page-tabs.pills .page-tab {
|
|
56
|
+
padding: 0 8px;
|
|
57
|
+
border-bottom: none;
|
|
58
|
+
border-radius: 999px;
|
|
59
|
+
font-size: 11px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.page-tabs.pills .page-tab[aria-selected='true'] {
|
|
63
|
+
background: var(--cursor-row-bg);
|
|
64
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A terminal surface: Ghostty's VT engine (libghostty-vt, as WebAssembly)
|
|
3
|
+
* drawn on a canvas by `ghostty/surface`. React mounts it and relays props;
|
|
4
|
+
* parsing, painting, input, and selection run outside React.
|
|
5
|
+
*
|
|
6
|
+
* Output written through the handle is queued, parsed in the next animation
|
|
7
|
+
* frame right before it is painted, and acknowledged through `onConsumed`
|
|
8
|
+
* once parsed. Writes, resets, and focus requests that arrive before the
|
|
9
|
+
* engine has loaded (it loads lazily, once per page) are held and applied
|
|
10
|
+
* when it is ready.
|
|
11
|
+
*
|
|
12
|
+
* The scrollback length comes from `TerminalScrollbackContext`, and the
|
|
13
|
+
* engine follows a change to it while the terminal runs.
|
|
14
|
+
*
|
|
15
|
+
* With `actionForKey`, the host binds chords to the terminal's own actions
|
|
16
|
+
* (`TerminalAction`: clear to start and the macOS line-editing moves): a
|
|
17
|
+
* keystroke it maps to one runs it instead of reaching the program, and
|
|
18
|
+
* every other key is encoded as typed. Without it no chord does.
|
|
19
|
+
*
|
|
20
|
+
* With `onBell`, a bell the program rings flashes the terminal, briefly and
|
|
21
|
+
* at most twice a second however fast it rings (`bellFlashes`); under
|
|
22
|
+
* reduced motion the flash is a still tint at the edges instead.
|
|
23
|
+
*
|
|
24
|
+
* Copy and paste work in every terminal through the document's copy and
|
|
25
|
+
* paste events (⌘C and ⌘V, or an Edit menu's items), and through the menu a
|
|
26
|
+
* secondary click opens (`TerminalMenu`): Copy while text is selected, and
|
|
27
|
+
* Paste, which reads the clipboard with the web Clipboard API and pastes as
|
|
28
|
+
* ⌘V does. There is no Cut, and an Edit menu's Cut does nothing here. The
|
|
29
|
+
* click opens the menu even while a program tracks the mouse, which then
|
|
30
|
+
* never hears the right button.
|
|
31
|
+
*
|
|
32
|
+
* Without `onInput` the terminal is read-only: no input element and no
|
|
33
|
+
* cursor, but selection and copy still work, Paste is offered dimmed and ⌘V
|
|
34
|
+
* does nothing, and the bell never rings. The canvas is hidden from
|
|
35
|
+
* assistive technology either way; a read-only terminal's host is a
|
|
36
|
+
* labelled, focusable group (hosts keep their own text alternative, such as
|
|
37
|
+
* a log mirror), and an interactive terminal's label sits on its input
|
|
38
|
+
* element.
|
|
39
|
+
*/
|
|
40
|
+
import { type ReactElement, type Ref } from 'react';
|
|
41
|
+
import { type TerminalAction, type TerminalKeyStroke } from './Terminal.logic.js';
|
|
42
|
+
import { type TerminalMenuChords } from './TerminalMenu.logic.js';
|
|
43
|
+
/** Imperative control of a mounted terminal. */
|
|
44
|
+
export interface TerminalHandle {
|
|
45
|
+
/** Feeds output (text with VT escape sequences) to the screen. */
|
|
46
|
+
write: (data: string) => void;
|
|
47
|
+
/** Clears the screen and scrollback and resets every terminal mode. */
|
|
48
|
+
reset: () => void;
|
|
49
|
+
/** Moves keyboard focus into the terminal; a read-only terminal takes focus for selection only. */
|
|
50
|
+
focus: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Runs one of the terminal's own actions, as its chord would: a press on a
|
|
53
|
+
* legend's slot. Nothing happens on a read-only terminal or before the
|
|
54
|
+
* engine is ready.
|
|
55
|
+
*/
|
|
56
|
+
perform: (action: TerminalAction) => void;
|
|
57
|
+
}
|
|
58
|
+
/** A terminal's grid in cells. */
|
|
59
|
+
export interface TerminalSize {
|
|
60
|
+
readonly cols: number;
|
|
61
|
+
readonly rows: number;
|
|
62
|
+
}
|
|
63
|
+
/** What the host supplies; omitting `onInput` makes the terminal read-only. */
|
|
64
|
+
export interface TerminalProps {
|
|
65
|
+
/** Accessible name of the terminal region, e.g. "Install log" or "Terminal". */
|
|
66
|
+
readonly ariaLabel: string;
|
|
67
|
+
/**
|
|
68
|
+
* Receives keystrokes, pastes, and the terminal's own replies to queries.
|
|
69
|
+
* Absent means read-only: no cursor, no input, selection and copy only.
|
|
70
|
+
*/
|
|
71
|
+
readonly onInput?: (data: string) => void;
|
|
72
|
+
/** Called after the first layout and on every later change of the grid size. */
|
|
73
|
+
readonly onResize?: (size: TerminalSize) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Called once a written chunk is parsed, with its length in UTF-16 code
|
|
76
|
+
* units, so a session can acknowledge output to the host.
|
|
77
|
+
*/
|
|
78
|
+
readonly onConsumed?: (units: number) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Turns the visual bell on: called for every bell the program rings, once
|
|
81
|
+
* per parse, including those folded into a flash already showing, so a
|
|
82
|
+
* host that marks a hidden terminal never misses one. Absent, a bell
|
|
83
|
+
* neither flashes nor reports; a read-only terminal never rings.
|
|
84
|
+
*/
|
|
85
|
+
readonly onBell?: () => void;
|
|
86
|
+
/**
|
|
87
|
+
* The chords the terminal answers itself: the action a keystroke runs, or
|
|
88
|
+
* null for a key the program gets. Read on every key, so a host's new
|
|
89
|
+
* bindings apply at once; absent, every key is the program's. Ignored by
|
|
90
|
+
* a read-only terminal.
|
|
91
|
+
*/
|
|
92
|
+
readonly actionForKey?: (stroke: TerminalKeyStroke) => TerminalAction | null;
|
|
93
|
+
/**
|
|
94
|
+
* The chords the menu shows beside Copy and Paste, the app's own for those
|
|
95
|
+
* verbs; ⌘C and ⌘V when absent (`DEFAULT_TERMINAL_MENU_CHORDS`).
|
|
96
|
+
*/
|
|
97
|
+
readonly menuChords?: TerminalMenuChords;
|
|
98
|
+
/** Layout class for the host element (size and position only). */
|
|
99
|
+
readonly className?: string;
|
|
100
|
+
/** Receives the imperative handle: write, reset, focus, and perform. */
|
|
101
|
+
readonly ref?: Ref<TerminalHandle>;
|
|
102
|
+
}
|
|
103
|
+
/** A terminal for an interactive shell (with `onInput`) or a read-only log (without). */
|
|
104
|
+
export declare function Terminal({ ariaLabel, onInput, onResize, onConsumed, onBell, actionForKey, menuChords, className, ref }: TerminalProps): ReactElement;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A terminal surface: Ghostty's VT engine (libghostty-vt, as WebAssembly)
|
|
4
|
+
* drawn on a canvas by `ghostty/surface`. React mounts it and relays props;
|
|
5
|
+
* parsing, painting, input, and selection run outside React.
|
|
6
|
+
*
|
|
7
|
+
* Output written through the handle is queued, parsed in the next animation
|
|
8
|
+
* frame right before it is painted, and acknowledged through `onConsumed`
|
|
9
|
+
* once parsed. Writes, resets, and focus requests that arrive before the
|
|
10
|
+
* engine has loaded (it loads lazily, once per page) are held and applied
|
|
11
|
+
* when it is ready.
|
|
12
|
+
*
|
|
13
|
+
* The scrollback length comes from `TerminalScrollbackContext`, and the
|
|
14
|
+
* engine follows a change to it while the terminal runs.
|
|
15
|
+
*
|
|
16
|
+
* With `actionForKey`, the host binds chords to the terminal's own actions
|
|
17
|
+
* (`TerminalAction`: clear to start and the macOS line-editing moves): a
|
|
18
|
+
* keystroke it maps to one runs it instead of reaching the program, and
|
|
19
|
+
* every other key is encoded as typed. Without it no chord does.
|
|
20
|
+
*
|
|
21
|
+
* With `onBell`, a bell the program rings flashes the terminal, briefly and
|
|
22
|
+
* at most twice a second however fast it rings (`bellFlashes`); under
|
|
23
|
+
* reduced motion the flash is a still tint at the edges instead.
|
|
24
|
+
*
|
|
25
|
+
* Copy and paste work in every terminal through the document's copy and
|
|
26
|
+
* paste events (⌘C and ⌘V, or an Edit menu's items), and through the menu a
|
|
27
|
+
* secondary click opens (`TerminalMenu`): Copy while text is selected, and
|
|
28
|
+
* Paste, which reads the clipboard with the web Clipboard API and pastes as
|
|
29
|
+
* ⌘V does. There is no Cut, and an Edit menu's Cut does nothing here. The
|
|
30
|
+
* click opens the menu even while a program tracks the mouse, which then
|
|
31
|
+
* never hears the right button.
|
|
32
|
+
*
|
|
33
|
+
* Without `onInput` the terminal is read-only: no input element and no
|
|
34
|
+
* cursor, but selection and copy still work, Paste is offered dimmed and ⌘V
|
|
35
|
+
* does nothing, and the bell never rings. The canvas is hidden from
|
|
36
|
+
* assistive technology either way; a read-only terminal's host is a
|
|
37
|
+
* labelled, focusable group (hosts keep their own text alternative, such as
|
|
38
|
+
* a log mirror), and an interactive terminal's label sits on its input
|
|
39
|
+
* element.
|
|
40
|
+
*/
|
|
41
|
+
import { useContext, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
|
|
42
|
+
import { useLabels } from '../labels/UiokProvider.js';
|
|
43
|
+
import { subscribeThemeChange } from '../themes/attributes.js';
|
|
44
|
+
import { GhosttyTerminalSurface } from './ghostty/surface.js';
|
|
45
|
+
import { BELL_FLASH_MS, TERMINAL_FONT_SIZE, TERMINAL_LINE_HEIGHT, bellFlashes, parseCssColor, terminalActionInput, terminalFontFamilyFromCss, terminalThemeFromTokens } from './Terminal.logic.js';
|
|
46
|
+
import { TerminalMenu } from './TerminalMenu.js';
|
|
47
|
+
import { DEFAULT_TERMINAL_MENU_CHORDS, terminalMenuItems } from './TerminalMenu.logic.js';
|
|
48
|
+
import { TerminalScrollbackContext } from './TerminalScrollback.js';
|
|
49
|
+
let colorProbe;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves a color the token parser does not read (a named color, `hsl()`,
|
|
52
|
+
* `color-mix()`) by painting it; null where no canvas is available.
|
|
53
|
+
*/
|
|
54
|
+
function probeCssColor(value) {
|
|
55
|
+
const parsed = parseCssColor(value);
|
|
56
|
+
if (parsed !== null || value.trim().length === 0)
|
|
57
|
+
return parsed;
|
|
58
|
+
try {
|
|
59
|
+
if (colorProbe === undefined) {
|
|
60
|
+
const canvas = document.createElement('canvas');
|
|
61
|
+
canvas.width = 1;
|
|
62
|
+
canvas.height = 1;
|
|
63
|
+
colorProbe = canvas.getContext('2d', { willReadFrequently: true });
|
|
64
|
+
}
|
|
65
|
+
if (colorProbe === null)
|
|
66
|
+
return null;
|
|
67
|
+
colorProbe.clearRect(0, 0, 1, 1);
|
|
68
|
+
colorProbe.fillStyle = value;
|
|
69
|
+
colorProbe.fillRect(0, 0, 1, 1);
|
|
70
|
+
const [r = 0, g = 0, b = 0, alpha = 0] = colorProbe.getImageData(0, 0, 1, 1).data;
|
|
71
|
+
return alpha === 0 ? null : { r, g, b };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Clears the screen, or sends an editing action's bytes to the program from the live screen. */
|
|
78
|
+
function performAction(surface, action, send) {
|
|
79
|
+
const input = terminalActionInput(action);
|
|
80
|
+
if (input === null) {
|
|
81
|
+
surface.clearToStart();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
surface.scrollToBottom();
|
|
85
|
+
send?.(input);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Runs a menu verb. Copy writes the selection as plain text, the text ⌘C
|
|
90
|
+
* copies; Paste reads the clipboard's text and pastes it as ⌘V does. Both go
|
|
91
|
+
* through the web Clipboard API, which needs a secure context and, for
|
|
92
|
+
* reading, the page's clipboard permission; a refusal is logged. A
|
|
93
|
+
* clipboard with no text pastes nothing, as ⌘V does.
|
|
94
|
+
*/
|
|
95
|
+
function runMenuVerb(surface, verb) {
|
|
96
|
+
if (verb === 'copy') {
|
|
97
|
+
const text = surface.getSelection();
|
|
98
|
+
if (text.length === 0)
|
|
99
|
+
return;
|
|
100
|
+
navigator.clipboard.writeText(text).catch((error) => {
|
|
101
|
+
console.error('Could not copy the selection', error);
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
navigator.clipboard.readText().then((text) => surface.paste(text), (error) => console.error('Could not read the clipboard', error));
|
|
106
|
+
}
|
|
107
|
+
function readTheme(element) {
|
|
108
|
+
const styles = getComputedStyle(element);
|
|
109
|
+
return terminalThemeFromTokens((token) => styles.getPropertyValue(token), probeCssColor);
|
|
110
|
+
}
|
|
111
|
+
/** A terminal for an interactive shell (with `onInput`) or a read-only log (without). */
|
|
112
|
+
export function Terminal({ ariaLabel, onInput, onResize, onConsumed, onBell, actionForKey, menuChords = DEFAULT_TERMINAL_MENU_CHORDS, className, ref }) {
|
|
113
|
+
const labels = useLabels().terminal;
|
|
114
|
+
const readOnly = onInput === undefined;
|
|
115
|
+
const mountRef = useRef(null);
|
|
116
|
+
const surfaceRef = useRef(null);
|
|
117
|
+
// Output written before the engine is ready, applied in order once it is.
|
|
118
|
+
const pendingRef = useRef([]);
|
|
119
|
+
const failedRef = useRef(false);
|
|
120
|
+
const [failed, setFailed] = useState(false);
|
|
121
|
+
const [menu, setMenu] = useState(null);
|
|
122
|
+
const callbacksRef = useRef({
|
|
123
|
+
onInput,
|
|
124
|
+
onResize,
|
|
125
|
+
onConsumed,
|
|
126
|
+
onBell,
|
|
127
|
+
actionForKey
|
|
128
|
+
});
|
|
129
|
+
const ariaLabelRef = useRef(ariaLabel);
|
|
130
|
+
const scrollbackLabelRef = useRef(labels.scrollback);
|
|
131
|
+
const scrollbackLines = useContext(TerminalScrollbackContext);
|
|
132
|
+
// Read when the engine starts; the effect below hands it later changes.
|
|
133
|
+
const scrollbackLinesRef = useRef(scrollbackLines);
|
|
134
|
+
// Latest-ref pattern: assigned at every commit, in the layout phase, so a
|
|
135
|
+
// parent's layout effect that writes through the handle already sees it.
|
|
136
|
+
useLayoutEffect(() => {
|
|
137
|
+
callbacksRef.current = { onInput, onResize, onConsumed, onBell, actionForKey };
|
|
138
|
+
ariaLabelRef.current = ariaLabel;
|
|
139
|
+
scrollbackLabelRef.current = labels.scrollback;
|
|
140
|
+
scrollbackLinesRef.current = scrollbackLines;
|
|
141
|
+
surfaceRef.current?.input?.setAttribute('aria-label', ariaLabel);
|
|
142
|
+
surfaceRef.current?.scrollbar.setAttribute('aria-label', labels.scrollback);
|
|
143
|
+
});
|
|
144
|
+
// A running engine follows the length; one still loading reads it when ready.
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
surfaceRef.current?.setScrollbackLines(scrollbackLines);
|
|
147
|
+
}, [scrollbackLines]);
|
|
148
|
+
useImperativeHandle(ref, () => ({
|
|
149
|
+
write: (data) => {
|
|
150
|
+
if (data.length === 0)
|
|
151
|
+
return;
|
|
152
|
+
const surface = surfaceRef.current;
|
|
153
|
+
if (surface !== null)
|
|
154
|
+
surface.enqueue(data);
|
|
155
|
+
// An engine that could not start still releases the session's output.
|
|
156
|
+
else if (failedRef.current)
|
|
157
|
+
callbacksRef.current.onConsumed?.(data.length);
|
|
158
|
+
else
|
|
159
|
+
pendingRef.current.push(data);
|
|
160
|
+
},
|
|
161
|
+
reset: () => {
|
|
162
|
+
const surface = surfaceRef.current;
|
|
163
|
+
if (surface !== null) {
|
|
164
|
+
surface.resetAndWrite('');
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const dropped = pendingRef.current;
|
|
168
|
+
pendingRef.current = [];
|
|
169
|
+
for (const chunk of dropped)
|
|
170
|
+
callbacksRef.current.onConsumed?.(chunk.length);
|
|
171
|
+
},
|
|
172
|
+
// Before the engine is ready the host element holds focus, and hands it
|
|
173
|
+
// to the input element once that exists.
|
|
174
|
+
focus: () => (surfaceRef.current ?? mountRef.current)?.focus(),
|
|
175
|
+
perform: (action) => {
|
|
176
|
+
const surface = surfaceRef.current;
|
|
177
|
+
if (surface !== null && !readOnly) {
|
|
178
|
+
performAction(surface, action, callbacksRef.current.onInput);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}), [readOnly]);
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
const mount = mountRef.current;
|
|
184
|
+
if (mount === null)
|
|
185
|
+
return;
|
|
186
|
+
let disposed = false;
|
|
187
|
+
let surface = null;
|
|
188
|
+
// The tokens change with the appearance and with the theme the window wears.
|
|
189
|
+
const stopFollowingTheme = subscribeThemeChange(() => surface?.setTheme(readTheme(mount)));
|
|
190
|
+
const beforeKey = (event) => {
|
|
191
|
+
const action = callbacksRef.current.actionForKey?.(event) ?? null;
|
|
192
|
+
if (action === null)
|
|
193
|
+
return true;
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
event.stopPropagation();
|
|
196
|
+
if (surface !== null)
|
|
197
|
+
performAction(surface, action, callbacksRef.current.onInput);
|
|
198
|
+
return false;
|
|
199
|
+
};
|
|
200
|
+
// The flash is a data attribute the stylesheet draws over the canvas, set
|
|
201
|
+
// here rather than through React, which stays out of the frame loop.
|
|
202
|
+
let lastFlashAt = null;
|
|
203
|
+
let flashTimer = null;
|
|
204
|
+
const endFlash = () => {
|
|
205
|
+
if (flashTimer !== null)
|
|
206
|
+
window.clearTimeout(flashTimer);
|
|
207
|
+
flashTimer = null;
|
|
208
|
+
mount.removeAttribute('data-bell');
|
|
209
|
+
};
|
|
210
|
+
// Only the flash is rate-limited: every bell is reported.
|
|
211
|
+
const ring = () => {
|
|
212
|
+
const report = callbacksRef.current.onBell;
|
|
213
|
+
if (report === undefined)
|
|
214
|
+
return;
|
|
215
|
+
const now = performance.now();
|
|
216
|
+
if (bellFlashes(lastFlashAt, now)) {
|
|
217
|
+
lastFlashAt = now;
|
|
218
|
+
endFlash();
|
|
219
|
+
mount.setAttribute('data-bell', '');
|
|
220
|
+
flashTimer = window.setTimeout(endFlash, BELL_FLASH_MS);
|
|
221
|
+
}
|
|
222
|
+
report();
|
|
223
|
+
};
|
|
224
|
+
const startLines = scrollbackLinesRef.current;
|
|
225
|
+
GhosttyTerminalSurface.create(mount, {
|
|
226
|
+
theme: readTheme(mount),
|
|
227
|
+
font: {
|
|
228
|
+
family: terminalFontFamilyFromCss(getComputedStyle(mount).getPropertyValue('--font-mono')),
|
|
229
|
+
size: TERMINAL_FONT_SIZE,
|
|
230
|
+
lineHeight: TERMINAL_LINE_HEIGHT
|
|
231
|
+
},
|
|
232
|
+
scrollbackLines: startLines,
|
|
233
|
+
readOnly,
|
|
234
|
+
inputLabel: ariaLabelRef.current,
|
|
235
|
+
scrollbackLabel: scrollbackLabelRef.current,
|
|
236
|
+
onData: (data) => callbacksRef.current.onInput?.(data),
|
|
237
|
+
onResize: (cols, rows) => callbacksRef.current.onResize?.({ cols, rows }),
|
|
238
|
+
onParsed: (units) => callbacksRef.current.onConsumed?.(units),
|
|
239
|
+
...(readOnly ? {} : { beforeKey, onBell: ring }),
|
|
240
|
+
// A host that opens web links elsewhere (a desktop shell's default
|
|
241
|
+
// browser) intercepts window.open.
|
|
242
|
+
onLinkActivate: (url) => {
|
|
243
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
244
|
+
},
|
|
245
|
+
onContextMenu: ({ clientX, clientY }) => {
|
|
246
|
+
if (surface === null)
|
|
247
|
+
return;
|
|
248
|
+
const box = mount.getBoundingClientRect();
|
|
249
|
+
setMenu({
|
|
250
|
+
at: { x: clientX, y: clientY },
|
|
251
|
+
within: { left: box.left, top: box.top, right: box.right, bottom: box.bottom },
|
|
252
|
+
state: { readOnly, hasSelection: surface.hasSelection() }
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}).then((created) => {
|
|
256
|
+
if (disposed) {
|
|
257
|
+
created.dispose();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
surface = created;
|
|
261
|
+
surfaceRef.current = created;
|
|
262
|
+
// The appearance, the length, and the labels may have changed while the engine loaded.
|
|
263
|
+
created.setTheme(readTheme(mount));
|
|
264
|
+
created.scrollbar.setAttribute('aria-label', scrollbackLabelRef.current);
|
|
265
|
+
if (scrollbackLinesRef.current !== startLines) {
|
|
266
|
+
created.setScrollbackLines(scrollbackLinesRef.current);
|
|
267
|
+
}
|
|
268
|
+
const pending = pendingRef.current;
|
|
269
|
+
pendingRef.current = [];
|
|
270
|
+
for (const chunk of pending)
|
|
271
|
+
created.enqueue(chunk);
|
|
272
|
+
if (document.activeElement === mount)
|
|
273
|
+
created.focus();
|
|
274
|
+
}, (error) => {
|
|
275
|
+
if (disposed)
|
|
276
|
+
return;
|
|
277
|
+
console.error('Could not start the terminal', error);
|
|
278
|
+
failedRef.current = true;
|
|
279
|
+
const dropped = pendingRef.current;
|
|
280
|
+
pendingRef.current = [];
|
|
281
|
+
for (const chunk of dropped)
|
|
282
|
+
callbacksRef.current.onConsumed?.(chunk.length);
|
|
283
|
+
setFailed(true);
|
|
284
|
+
});
|
|
285
|
+
return () => {
|
|
286
|
+
disposed = true;
|
|
287
|
+
setMenu(null);
|
|
288
|
+
stopFollowingTheme();
|
|
289
|
+
endFlash();
|
|
290
|
+
if (surfaceRef.current === surface)
|
|
291
|
+
surfaceRef.current = null;
|
|
292
|
+
surface?.dispose();
|
|
293
|
+
};
|
|
294
|
+
}, [readOnly]);
|
|
295
|
+
// Titled on every render, so an open menu follows a change of labels.
|
|
296
|
+
const menuItems = menu === null ? null : terminalMenuItems(menu.state, labels, menuChords);
|
|
297
|
+
return (_jsxs("div", { className: className === undefined ? 'terminal' : `terminal ${className}`, children: [_jsx("div", { "aria-label": readOnly ? ariaLabel : undefined, className: "terminal-mount", hidden: failed, ref: mountRef, role: readOnly ? 'group' : undefined, tabIndex: readOnly ? 0 : -1 }), failed && _jsx("p", { className: "terminal-failure", children: labels.startFailed }), menu !== null && (_jsx(TerminalMenu, { at: menu.at, items: menuItems ?? [], label: labels.menu, onClose: (by) => {
|
|
298
|
+
setMenu(null);
|
|
299
|
+
if (by === 'keyboard')
|
|
300
|
+
surfaceRef.current?.focus();
|
|
301
|
+
}, onRun: (verb) => {
|
|
302
|
+
setMenu(null);
|
|
303
|
+
const surface = surfaceRef.current;
|
|
304
|
+
if (surface === null)
|
|
305
|
+
return;
|
|
306
|
+
surface.focus();
|
|
307
|
+
runMenuVerb(surface, verb);
|
|
308
|
+
}, within: menu.within }))] }));
|
|
309
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The terminal component's pure decisions: its theme from the stylesheet's
|
|
3
|
+
* terminal tokens (with the 256-color palette derived from the 16 ANSI
|
|
4
|
+
* colors), its font stack from `--font-mono` and its size and line pitch,
|
|
5
|
+
* the bytes its line-editing actions send, and how often the bell may flash.
|
|
6
|
+
*/
|
|
7
|
+
import type { GhosttyColor, GhosttyTheme } from './ghostty/core.js';
|
|
8
|
+
/**
|
|
9
|
+
* The terminal's text size in CSS pixels: the listing's, so a terminal
|
|
10
|
+
* beside a listing reads at the same size.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TERMINAL_FONT_SIZE = 13;
|
|
13
|
+
/**
|
|
14
|
+
* The terminal's line pitch in CSS pixels: a little roomier than the size
|
|
15
|
+
* alone, and tighter than the listing's 24px rows, which hold one item each
|
|
16
|
+
* rather than running text.
|
|
17
|
+
*/
|
|
18
|
+
export declare const TERMINAL_LINE_HEIGHT = 19;
|
|
19
|
+
/**
|
|
20
|
+
* Parses the color forms the terminal tokens use: `#rgb`, `#rrggbb`, and
|
|
21
|
+
* `rgb()`/`rgba()` in comma or space syntax (alpha ignored). Anything else
|
|
22
|
+
* is null, for the caller to resolve another way.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseCssColor(value: string): GhosttyColor | null;
|
|
25
|
+
/**
|
|
26
|
+
* The theme the stylesheet's terminal tokens describe. `read` returns a
|
|
27
|
+
* token's value; `parse` resolves a value to a color, or null. Missing
|
|
28
|
+
* defaults fall back to Catppuccin Mocha (`FALLBACK_TERMINAL_THEME`); missing ANSI colors leave Ghostty's
|
|
29
|
+
* own palette in place.
|
|
30
|
+
*/
|
|
31
|
+
export declare function terminalThemeFromTokens(read: (token: string) => string, parse?: (value: string) => GhosttyColor | null): GhosttyTheme;
|
|
32
|
+
/**
|
|
33
|
+
* The `--font-mono` stack without the CSS-only generic keywords (such as
|
|
34
|
+
* `ui-monospace` and `system-ui`) that make a canvas font string invalid;
|
|
35
|
+
* undefined when nothing named is left, for the engine's default stack.
|
|
36
|
+
*/
|
|
37
|
+
export declare function terminalFontFamilyFromCss(value: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* How long the visual bell shows, in milliseconds: the flash's fade, or the
|
|
40
|
+
* static edge tint that takes its place under reduced motion. `Terminal.css`
|
|
41
|
+
* fades over the same time.
|
|
42
|
+
*/
|
|
43
|
+
export declare const BELL_FLASH_MS = 250;
|
|
44
|
+
/**
|
|
45
|
+
* The shortest time between two flashes of the visual bell, in milliseconds.
|
|
46
|
+
* Bells inside it fold into the flash that opened it, so a program ringing
|
|
47
|
+
* without pause flashes at most twice a second instead of strobing, and a
|
|
48
|
+
* flash always ends before the next one starts.
|
|
49
|
+
*/
|
|
50
|
+
export declare const BELL_INTERVAL_MS = 500;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a bell at `now` flashes, given when the last flash started (null
|
|
53
|
+
* for none yet): only once the interval since then has passed.
|
|
54
|
+
*/
|
|
55
|
+
export declare function bellFlashes(lastFlashAt: number | null, now: number): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* What a terminal does for a chord its host binds to it, as macOS Terminal
|
|
58
|
+
* does: clear to start (the scrollback and the rows above the cursor), move
|
|
59
|
+
* to the line's start or end, move back or forward a word, or delete to the
|
|
60
|
+
* line's start. The host decides which chords run them (`actionForKey`).
|
|
61
|
+
*/
|
|
62
|
+
export type TerminalAction = 'clear' | 'line-start' | 'line-end' | 'word-back' | 'word-forward' | 'delete-to-line-start';
|
|
63
|
+
/** The fields of a keydown a host reads to pick a terminal action. */
|
|
64
|
+
export type TerminalKeyStroke = Pick<KeyboardEvent, 'altKey' | 'code' | 'ctrlKey' | 'key' | 'metaKey' | 'shiftKey'>;
|
|
65
|
+
/** The bytes an action sends the shell, or null for clear, which only the screen does. */
|
|
66
|
+
export declare function terminalActionInput(action: TerminalAction): string | null;
|