@bigpixelrocket/uiok 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -1
- package/README.md +1 -1
- package/dist/activity/ActivityBar.d.ts +21 -8
- package/dist/activity/ActivityBar.js +15 -5
- package/dist/activity/activity.css +53 -6
- package/dist/button/Button.d.ts +10 -6
- package/dist/button/Button.js +6 -1
- package/dist/button/button.css +201 -33
- package/dist/charts/Line.logic.d.ts +6 -0
- package/dist/charts/Line.logic.js +9 -0
- package/dist/charts/LineChart.js +11 -4
- package/dist/charts/Pie.logic.d.ts +89 -1
- package/dist/charts/Pie.logic.js +272 -2
- package/dist/charts/PieChart.d.ts +2 -1
- package/dist/charts/PieChart.js +12 -5
- package/dist/charts/PieFill.d.ts +15 -0
- package/dist/charts/PieFill.js +33 -0
- package/dist/charts/ResultChart.d.ts +2 -2
- package/dist/charts/ResultChart.js +173 -47
- package/dist/charts/ResultChart.logic.d.ts +60 -4
- package/dist/charts/ResultChart.logic.js +105 -6
- package/dist/charts/Scatter.logic.d.ts +18 -4
- package/dist/charts/Scatter.logic.js +98 -22
- package/dist/charts/ScatterChart.js +19 -5
- package/dist/charts/charts.css +233 -116
- package/dist/charts/seriesColour.d.ts +2 -0
- package/dist/charts/seriesColour.js +1 -1
- package/dist/datetime/DateTimePicker.d.ts +12 -2
- package/dist/datetime/DateTimePicker.js +61 -16
- package/dist/datetime/DateTimePicker.logic.d.ts +29 -0
- package/dist/datetime/DateTimePicker.logic.js +25 -0
- package/dist/datetime/datetime.css +89 -49
- package/dist/dialog/ConfirmDialog.d.ts +69 -20
- package/dist/dialog/ConfirmDialog.js +39 -12
- package/dist/dialog/DialogLayer.d.ts +25 -0
- package/dist/dialog/DialogLayer.js +24 -0
- package/dist/dialog/DialogLegend.d.ts +2 -1
- package/dist/dialog/DialogLegend.js +10 -5
- package/dist/dialog/DialogLegend.logic.d.ts +15 -3
- package/dist/dialog/DialogLegend.logic.js +8 -4
- package/dist/dialog/DialogLists.d.ts +157 -0
- package/dist/dialog/DialogLists.js +137 -0
- package/dist/dialog/ModalDialog.d.ts +20 -15
- package/dist/dialog/ModalDialog.js +22 -7
- package/dist/dialog/dialog.css +570 -127
- package/dist/dialog/index.d.ts +7 -1
- package/dist/dialog/index.js +7 -1
- package/dist/field/Check.d.ts +15 -0
- package/dist/field/Check.js +23 -0
- package/dist/field/field.css +812 -0
- package/dist/field/index.d.ts +10 -0
- package/dist/field/index.js +10 -0
- package/dist/field/labelHelp.d.ts +33 -0
- package/dist/field/labelHelp.js +22 -0
- package/dist/filter/FilterIcon.js +2 -1
- package/dist/filter/filter.css +72 -20
- package/dist/grid/DataGrid.d.ts +8 -1
- package/dist/grid/DataGrid.js +115 -40
- package/dist/grid/DataGrid.logic.d.ts +15 -3
- package/dist/grid/DataGrid.logic.js +18 -5
- package/dist/grid/grid.css +481 -56
- package/dist/icon/Spinner.d.ts +16 -0
- package/dist/icon/Spinner.js +13 -0
- package/dist/icon/index.d.ts +5 -0
- package/dist/icon/index.js +5 -0
- package/dist/icon/sizes.d.ts +19 -0
- package/dist/icon/sizes.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/keychord/KeyChord.d.ts +12 -1
- package/dist/keychord/KeyChord.js +2 -2
- package/dist/keychord/index.d.ts +1 -1
- package/dist/keychord/keychord.css +87 -9
- package/dist/labels/dialog.d.ts +12 -1
- package/dist/labels/dialog.js +3 -1
- package/dist/labels/selectAll.d.ts +4 -4
- package/dist/labels/selectAll.js +1 -1
- package/dist/legend/KeyLegendStrip.js +1 -1
- package/dist/legend/legend.css +82 -57
- package/dist/listing/Listing.d.ts +17 -10
- package/dist/listing/Listing.js +33 -26
- package/dist/listing/listing.css +1665 -237
- package/dist/menu/menu.css +227 -67
- package/dist/menu/useBellBeat.js +2 -2
- package/dist/namecut/NameCut.d.ts +3 -1
- package/dist/namecut/NameCut.js +152 -5
- package/dist/namecut/NameCut.logic.d.ts +5 -3
- package/dist/namecut/NameCut.logic.js +20 -5
- package/dist/namecut/namecut.css +27 -7
- package/dist/pager/Pager.d.ts +12 -4
- package/dist/pager/Pager.js +21 -7
- package/dist/pager/pager.css +41 -30
- package/dist/palette/Palette.js +2 -1
- package/dist/palette/palette.css +121 -60
- package/dist/pane/PaneActions.d.ts +56 -14
- package/dist/pane/PaneActions.js +64 -16
- package/dist/pane/PaneFrame.d.ts +37 -5
- package/dist/pane/PaneFrame.js +246 -11
- package/dist/pane/index.d.ts +4 -2
- package/dist/pane/index.js +4 -2
- package/dist/pane/toolWords.d.ts +14 -0
- package/dist/pane/toolWords.js +26 -0
- package/dist/pane/useToolbarFit.d.ts +25 -0
- package/dist/pane/useToolbarFit.js +95 -0
- package/dist/run/RunHeader.d.ts +5 -3
- package/dist/run/RunHeader.js +11 -8
- package/dist/run/run.css +64 -79
- package/dist/segmented/SegmentedChoice.d.ts +18 -2
- package/dist/segmented/SegmentedChoice.js +18 -7
- package/dist/segmented/segmented.css +62 -22
- package/dist/selectall/SelectAllBar.d.ts +4 -3
- package/dist/selectall/SelectAllBar.js +4 -3
- package/dist/selectall/selectall.css +17 -12
- package/dist/shell/shell.css +1073 -0
- package/dist/styles.css +620 -22
- package/dist/surface/surface.css +154 -0
- package/dist/tabs/PageTabs.d.ts +10 -5
- package/dist/tabs/PageTabs.js +126 -37
- package/dist/tabs/tabs.css +131 -51
- package/dist/terminal/Terminal.js +3 -1
- package/dist/terminal/Terminal.logic.d.ts +5 -4
- package/dist/terminal/Terminal.logic.js +9 -4
- package/dist/terminal/TerminalMenu.d.ts +4 -1
- package/dist/terminal/TerminalMenu.js +12 -5
- package/dist/terminal/ghostty/contrast.logic.d.ts +45 -0
- package/dist/terminal/ghostty/contrast.logic.js +130 -0
- package/dist/terminal/ghostty/core.d.ts +6 -0
- package/dist/terminal/ghostty/renderer.d.ts +9 -2
- package/dist/terminal/ghostty/renderer.js +91 -14
- package/dist/terminal/ghostty/surface.d.ts +8 -0
- package/dist/terminal/ghostty/surface.js +27 -1
- package/dist/terminal/terminal.css +87 -61
- package/dist/text/text.css +16 -7
- package/dist/themes/catalog.js +4 -3
- package/dist/themes/themes.generated.css +1307 -264
- package/dist/themes/tokens.d.ts +69 -14
- package/dist/themes/tokens.js +920 -97
- package/dist/tokens.css +239 -0
- package/dist/tooltip/Tooltip.d.ts +6 -0
- package/dist/tooltip/Tooltip.js +48 -6
- package/dist/tooltip/Tooltip.logic.d.ts +89 -12
- package/dist/tooltip/Tooltip.logic.js +142 -20
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tooltip/index.js +1 -1
- package/dist/tooltip/tooltip.css +39 -9
- package/package.json +9 -3
|
@@ -26,7 +26,8 @@ export declare function parseCssColor(value: string): GhosttyColor | null;
|
|
|
26
26
|
* The theme the stylesheet's terminal tokens describe. `read` returns a
|
|
27
27
|
* token's value; `parse` resolves a value to a color, or null. Missing
|
|
28
28
|
* defaults fall back to Catppuccin Mocha (`FALLBACK_TERMINAL_THEME`); missing ANSI colors leave Ghostty's
|
|
29
|
-
* own palette in place
|
|
29
|
+
* own palette in place, and a missing selection ink leaves selected cells
|
|
30
|
+
* their own colours (floored on the selection all the same).
|
|
30
31
|
*/
|
|
31
32
|
export declare function terminalThemeFromTokens(read: (token: string) => string, parse?: (value: string) => GhosttyColor | null): GhosttyTheme;
|
|
32
33
|
/**
|
|
@@ -37,10 +38,10 @@ export declare function terminalThemeFromTokens(read: (token: string) => string,
|
|
|
37
38
|
export declare function terminalFontFamilyFromCss(value: string): string | undefined;
|
|
38
39
|
/**
|
|
39
40
|
* 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.
|
|
41
|
-
* fades over the same
|
|
41
|
+
* static edge tint that takes its place under reduced motion. terminal.css
|
|
42
|
+
* fades over `--duration-slow`, the same 280 ms.
|
|
42
43
|
*/
|
|
43
|
-
export declare const BELL_FLASH_MS =
|
|
44
|
+
export declare const BELL_FLASH_MS = 280;
|
|
44
45
|
/**
|
|
45
46
|
* The shortest time between two flashes of the visual bell, in milliseconds.
|
|
46
47
|
* Bells inside it fold into the flash that opened it, so a program ringing
|
|
@@ -25,6 +25,8 @@ const TERMINAL_THEME_TOKENS = {
|
|
|
25
25
|
foreground: '--terminal-fg',
|
|
26
26
|
cursor: '--terminal-cursor',
|
|
27
27
|
selection: '--terminal-selection',
|
|
28
|
+
/** The one ink of selected text, floored again per cell by the renderer. */
|
|
29
|
+
selectionText: '--terminal-selection-text',
|
|
28
30
|
/** `--terminal-ansi-0` through `--terminal-ansi-15`: SGR 30-37, then 90-97. */
|
|
29
31
|
ansiPrefix: '--terminal-ansi-'
|
|
30
32
|
};
|
|
@@ -92,18 +94,21 @@ function terminalPalette(ansi) {
|
|
|
92
94
|
* The theme the stylesheet's terminal tokens describe. `read` returns a
|
|
93
95
|
* token's value; `parse` resolves a value to a color, or null. Missing
|
|
94
96
|
* defaults fall back to Catppuccin Mocha (`FALLBACK_TERMINAL_THEME`); missing ANSI colors leave Ghostty's
|
|
95
|
-
* own palette in place
|
|
97
|
+
* own palette in place, and a missing selection ink leaves selected cells
|
|
98
|
+
* their own colours (floored on the selection all the same).
|
|
96
99
|
*/
|
|
97
100
|
export function terminalThemeFromTokens(read, parse = parseCssColor) {
|
|
98
101
|
const color = (token, fallback) => parse(read(token)) ?? fallback;
|
|
99
102
|
const selection = read(TERMINAL_THEME_TOKENS.selection).trim();
|
|
100
103
|
const ansi = Array.from({ length: ANSI_COLOR_COUNT }, (_, index) => parse(read(`${TERMINAL_THEME_TOKENS.ansiPrefix}${index}`)));
|
|
101
104
|
const complete = ansi.every((entry) => entry !== null);
|
|
105
|
+
const selectionText = parse(read(TERMINAL_THEME_TOKENS.selectionText));
|
|
102
106
|
return {
|
|
103
107
|
background: color(TERMINAL_THEME_TOKENS.background, FALLBACK_TERMINAL_THEME.background),
|
|
104
108
|
foreground: color(TERMINAL_THEME_TOKENS.foreground, FALLBACK_TERMINAL_THEME.foreground),
|
|
105
109
|
cursor: color(TERMINAL_THEME_TOKENS.cursor, FALLBACK_TERMINAL_THEME.cursor),
|
|
106
110
|
selectionBackground: selection.length > 0 ? selection : (FALLBACK_TERMINAL_THEME.selectionBackground ?? ''),
|
|
111
|
+
...(selectionText !== null ? { selectionForeground: selectionText } : {}),
|
|
107
112
|
...(complete ? { palette: terminalPalette(ansi) } : {})
|
|
108
113
|
};
|
|
109
114
|
}
|
|
@@ -121,10 +126,10 @@ export function terminalFontFamilyFromCss(value) {
|
|
|
121
126
|
}
|
|
122
127
|
/**
|
|
123
128
|
* How long the visual bell shows, in milliseconds: the flash's fade, or the
|
|
124
|
-
* static edge tint that takes its place under reduced motion.
|
|
125
|
-
* fades over the same
|
|
129
|
+
* static edge tint that takes its place under reduced motion. terminal.css
|
|
130
|
+
* fades over `--duration-slow`, the same 280 ms.
|
|
126
131
|
*/
|
|
127
|
-
export const BELL_FLASH_MS =
|
|
132
|
+
export const BELL_FLASH_MS = 280;
|
|
128
133
|
/**
|
|
129
134
|
* The shortest time between two flashes of the visual bell, in milliseconds.
|
|
130
135
|
* Bells inside it fold into the flash that opened it, so a program ringing
|
|
@@ -24,7 +24,10 @@ export interface TerminalMenuProps {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* The terminal's menu: Copy and Paste with their chords, in the menu look,
|
|
27
|
-
* opened at the point a secondary click landed.
|
|
27
|
+
* opened at the point a secondary click landed. It is the menu look
|
|
28
|
+
* (`.folder-menu`, `.folder-menu-option`) drawn through a portal on the
|
|
29
|
+
* document's body (or the element shown full screen), so no scrolling pane
|
|
30
|
+
* or dialog clips it; React still carries its events to the terminal.
|
|
28
31
|
*
|
|
29
32
|
* It holds the keys while open (↑ ↓, Return and Space, Escape;
|
|
30
33
|
* `terminalMenuKeyAction`), which travel no further, so neither a dialog
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ClipboardPaste, Copy } from 'lucide-react';
|
|
3
3
|
import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { ICON_MD } from '../icon/index.js';
|
|
4
6
|
import { KeyChord } from '../keychord/KeyChord.js';
|
|
5
7
|
import { movedPickableCursor, pickableCursor } from '../menu/MenuQuery.logic.js';
|
|
6
8
|
import { placeTerminalMenu, terminalMenuKeyAction } from './TerminalMenu.logic.js';
|
|
@@ -11,7 +13,10 @@ const ICONS = {
|
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
13
15
|
* The terminal's menu: Copy and Paste with their chords, in the menu look,
|
|
14
|
-
* opened at the point a secondary click landed.
|
|
16
|
+
* opened at the point a secondary click landed. It is the menu look
|
|
17
|
+
* (`.folder-menu`, `.folder-menu-option`) drawn through a portal on the
|
|
18
|
+
* document's body (or the element shown full screen), so no scrolling pane
|
|
19
|
+
* or dialog clips it; React still carries its events to the terminal.
|
|
15
20
|
*
|
|
16
21
|
* It holds the keys while open (↑ ↓, Return and Space, Escape;
|
|
17
22
|
* `terminalMenuKeyAction`), which travel no further, so neither a dialog
|
|
@@ -55,7 +60,7 @@ export function TerminalMenu({ at, within, items, label, onRun, onClose }) {
|
|
|
55
60
|
if (item?.enabled === true)
|
|
56
61
|
onRun(item.verb);
|
|
57
62
|
};
|
|
58
|
-
return (_jsx("div", { "aria-activedescendant": cursor === null ? undefined : `${itemId}-${cursor}`, "aria-label": label, className: "terminal-menu", "data-native-keyboard": true, "data-overlay": true,
|
|
63
|
+
return createPortal(_jsx("div", { "aria-activedescendant": cursor === null ? undefined : `${itemId}-${cursor}`, "aria-label": label, className: "folder-menu terminal-menu", "data-native-keyboard": true, "data-overlay": true,
|
|
59
64
|
// The focus left for somewhere else: another control, or another window.
|
|
60
65
|
onBlur: (event) => {
|
|
61
66
|
if (!(event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))) {
|
|
@@ -79,9 +84,11 @@ export function TerminalMenu({ at, within, items, label, onRun, onClose }) {
|
|
|
79
84
|
// A press on an item must not take the focus from the menu, which holds the keys.
|
|
80
85
|
onMouseDown: (event) => event.preventDefault(), ref: rootRef, role: "menu", tabIndex: -1, children: items.map((item, index) => {
|
|
81
86
|
const Icon = ICONS[item.verb];
|
|
82
|
-
return (_jsxs("div", { "aria-disabled": !item.enabled, className: index === cursor
|
|
87
|
+
return (_jsxs("div", { "aria-disabled": !item.enabled, className: index === cursor
|
|
88
|
+
? 'folder-menu-option terminal-menu-item cursor'
|
|
89
|
+
: 'folder-menu-option terminal-menu-item', id: `${itemId}-${index}`, onClick: () => run(item), onMouseMove: () => {
|
|
83
90
|
if (item.enabled)
|
|
84
91
|
setPointed(item.verb);
|
|
85
|
-
}, role: "menuitem", children: [_jsx("span", { className: "terminal-menu-icon", children: _jsx(Icon, { "aria-hidden": true, size:
|
|
86
|
-
}) }));
|
|
92
|
+
}, role: "menuitem", children: [_jsx("span", { className: "terminal-menu-icon", children: _jsx(Icon, { "aria-hidden": true, size: ICON_MD }) }), _jsx("span", { className: "terminal-menu-label", children: item.label }), _jsx(KeyChord, { chord: item.chord })] }, item.verb));
|
|
93
|
+
}) }), document.fullscreenElement ?? document.body);
|
|
87
94
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { GhosttyColor } from './core.js';
|
|
2
|
+
/** The contrast ratio a cell's text keeps against its background: WCAG's body-text floor. */
|
|
3
|
+
export declare const TERMINAL_MIN_CONTRAST = 4.5;
|
|
4
|
+
/** The WCAG contrast ratio between two colours, from 1 to 21. */
|
|
5
|
+
export declare function terminalContrast(left: GhosttyColor, right: GhosttyColor): number;
|
|
6
|
+
/**
|
|
7
|
+
* The colour a cell's text is drawn in on `background`: `foreground` itself
|
|
8
|
+
* when it keeps `TERMINAL_MIN_CONTRAST` there, else the least mix of it
|
|
9
|
+
* toward white or black, whichever stands further from the background. A
|
|
10
|
+
* mix toward white or black keeps the hue the program asked for (a red
|
|
11
|
+
* error stays red, only lighter or darker), where a mix toward the
|
|
12
|
+
* terminal's grey text colour would wash it out. The result is a new
|
|
13
|
+
* object only when it differs from `foreground`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function legibleForeground(foreground: GhosttyColor, background: GhosttyColor): GhosttyColor;
|
|
16
|
+
/** The contrast ratio a mark (the cursor, an outline) keeps against the ground it sits on. */
|
|
17
|
+
export declare const TERMINAL_MARK_CONTRAST = 3;
|
|
18
|
+
/**
|
|
19
|
+
* A quiet mark's colour on `background`: `foreground` mixed `share` of the
|
|
20
|
+
* way in from the background, or, where that stands less than
|
|
21
|
+
* `TERMINAL_MARK_CONTRAST` from it, the least stronger mix that does (at
|
|
22
|
+
* most `foreground` itself). An unfocused terminal's hollow cursor is drawn
|
|
23
|
+
* in it, so it stays quieter than text without fading out of sight.
|
|
24
|
+
*/
|
|
25
|
+
export declare function quietMark(foreground: GhosttyColor, background: GhosttyColor, share?: number): GhosttyColor;
|
|
26
|
+
/** A colour over whatever lies under it, at `alpha` (0 to 1). */
|
|
27
|
+
export interface TranslucentColor {
|
|
28
|
+
readonly color: GhosttyColor;
|
|
29
|
+
readonly alpha: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reads the CSS colour forms the selection fill takes: `#rrggbb`, and
|
|
33
|
+
* `rgb()`/`rgba()` in comma or space syntax with an optional alpha as a
|
|
34
|
+
* number or a percentage. Null for anything else.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseTranslucentColor(value: string): TranslucentColor | null;
|
|
37
|
+
/**
|
|
38
|
+
* The colour a selected cell's text is drawn in. Selected text takes the
|
|
39
|
+
* theme's selection ink (`selectionText`) where it has one, else its own
|
|
40
|
+
* foreground, floored at the minimum contrast against what the reader sees
|
|
41
|
+
* behind it: the selection fill laid over the cell's own background. So a
|
|
42
|
+
* dim or coloured word stays readable while selected, as unselected text
|
|
43
|
+
* does on its own background.
|
|
44
|
+
*/
|
|
45
|
+
export declare function selectedForeground(foreground: GhosttyColor, background: GhosttyColor, selection: TranslucentColor | null, selectionText?: GhosttyColor): GhosttyColor;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The terminal's minimum contrast: a cell's text against that cell's own
|
|
3
|
+
* background, as terminals with a "minimum contrast" setting enforce it. A
|
|
4
|
+
* program may paint any background it likes; only the text colour on it
|
|
5
|
+
* moves, and only as far as it must.
|
|
6
|
+
*/
|
|
7
|
+
/** The contrast ratio a cell's text keeps against its background: WCAG's body-text floor. */
|
|
8
|
+
export const TERMINAL_MIN_CONTRAST = 4.5;
|
|
9
|
+
const BLACK = { r: 0, g: 0, b: 0 };
|
|
10
|
+
const WHITE = { r: 255, g: 255, b: 255 };
|
|
11
|
+
const channel = (value) => {
|
|
12
|
+
const unit = value / 255;
|
|
13
|
+
return unit <= 0.04045 ? unit / 12.92 : ((unit + 0.055) / 1.055) ** 2.4;
|
|
14
|
+
};
|
|
15
|
+
/** A colour's relative luminance (WCAG 2). */
|
|
16
|
+
const luminance = (color) => 0.2126 * channel(color.r) + 0.7152 * channel(color.g) + 0.0722 * channel(color.b);
|
|
17
|
+
/** The WCAG contrast ratio between two colours, from 1 to 21. */
|
|
18
|
+
export function terminalContrast(left, right) {
|
|
19
|
+
const a = luminance(left);
|
|
20
|
+
const b = luminance(right);
|
|
21
|
+
return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
|
|
22
|
+
}
|
|
23
|
+
/** `from` moved `amount` (0 to 1) of the way to `to`, in whole sRGB channels. */
|
|
24
|
+
const mixed = (from, to, amount) => ({
|
|
25
|
+
r: Math.round(from.r + (to.r - from.r) * amount),
|
|
26
|
+
g: Math.round(from.g + (to.g - from.g) * amount),
|
|
27
|
+
b: Math.round(from.b + (to.b - from.b) * amount)
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* The colour a cell's text is drawn in on `background`: `foreground` itself
|
|
31
|
+
* when it keeps `TERMINAL_MIN_CONTRAST` there, else the least mix of it
|
|
32
|
+
* toward white or black, whichever stands further from the background. A
|
|
33
|
+
* mix toward white or black keeps the hue the program asked for (a red
|
|
34
|
+
* error stays red, only lighter or darker), where a mix toward the
|
|
35
|
+
* terminal's grey text colour would wash it out. The result is a new
|
|
36
|
+
* object only when it differs from `foreground`.
|
|
37
|
+
*/
|
|
38
|
+
export function legibleForeground(foreground, background) {
|
|
39
|
+
if (terminalContrast(foreground, background) >= TERMINAL_MIN_CONTRAST)
|
|
40
|
+
return foreground;
|
|
41
|
+
const target = terminalContrast(WHITE, background) >= terminalContrast(BLACK, background) ? WHITE : BLACK;
|
|
42
|
+
let low = 0;
|
|
43
|
+
let high = 1;
|
|
44
|
+
// Twelve halvings settle the mix finer than one channel step.
|
|
45
|
+
for (let step = 0; step < 12; step += 1) {
|
|
46
|
+
const middle = (low + high) / 2;
|
|
47
|
+
if (terminalContrast(mixed(foreground, target, middle), background) >= TERMINAL_MIN_CONTRAST) {
|
|
48
|
+
high = middle;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
low = middle;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return mixed(foreground, target, high);
|
|
55
|
+
}
|
|
56
|
+
/** The contrast ratio a mark (the cursor, an outline) keeps against the ground it sits on. */
|
|
57
|
+
export const TERMINAL_MARK_CONTRAST = 3;
|
|
58
|
+
/**
|
|
59
|
+
* A quiet mark's colour on `background`: `foreground` mixed `share` of the
|
|
60
|
+
* way in from the background, or, where that stands less than
|
|
61
|
+
* `TERMINAL_MARK_CONTRAST` from it, the least stronger mix that does (at
|
|
62
|
+
* most `foreground` itself). An unfocused terminal's hollow cursor is drawn
|
|
63
|
+
* in it, so it stays quieter than text without fading out of sight.
|
|
64
|
+
*/
|
|
65
|
+
export function quietMark(foreground, background, share = 0.5) {
|
|
66
|
+
const at = (amount) => mixed(background, foreground, amount);
|
|
67
|
+
if (terminalContrast(at(share), background) >= TERMINAL_MARK_CONTRAST)
|
|
68
|
+
return at(share);
|
|
69
|
+
if (terminalContrast(foreground, background) < TERMINAL_MARK_CONTRAST)
|
|
70
|
+
return foreground;
|
|
71
|
+
let low = share;
|
|
72
|
+
let high = 1;
|
|
73
|
+
for (let step = 0; step < 12; step += 1) {
|
|
74
|
+
const middle = (low + high) / 2;
|
|
75
|
+
if (terminalContrast(at(middle), background) >= TERMINAL_MARK_CONTRAST)
|
|
76
|
+
high = middle;
|
|
77
|
+
else
|
|
78
|
+
low = middle;
|
|
79
|
+
}
|
|
80
|
+
return at(high);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Reads the CSS colour forms the selection fill takes: `#rrggbb`, and
|
|
84
|
+
* `rgb()`/`rgba()` in comma or space syntax with an optional alpha as a
|
|
85
|
+
* number or a percentage. Null for anything else.
|
|
86
|
+
*/
|
|
87
|
+
export function parseTranslucentColor(value) {
|
|
88
|
+
const text = value.trim().toLowerCase();
|
|
89
|
+
const hex = /^#([0-9a-f]{6})$/.exec(text)?.[1];
|
|
90
|
+
if (hex !== undefined) {
|
|
91
|
+
return {
|
|
92
|
+
color: {
|
|
93
|
+
r: Number.parseInt(hex.slice(0, 2), 16),
|
|
94
|
+
g: Number.parseInt(hex.slice(2, 4), 16),
|
|
95
|
+
b: Number.parseInt(hex.slice(4, 6), 16)
|
|
96
|
+
},
|
|
97
|
+
alpha: 1
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const functional = /^rgba?\(([^)]*)\)$/.exec(text)?.[1];
|
|
101
|
+
if (functional === undefined)
|
|
102
|
+
return null;
|
|
103
|
+
const parts = functional.split(/[\s,/]+/).filter((part) => part.length > 0);
|
|
104
|
+
if (parts.length !== 3 && parts.length !== 4)
|
|
105
|
+
return null;
|
|
106
|
+
const [r, g, b] = parts.slice(0, 3).map((part) => Number.parseFloat(part));
|
|
107
|
+
const alphaText = parts[3] ?? '1';
|
|
108
|
+
const alpha = alphaText.endsWith('%')
|
|
109
|
+
? Number.parseFloat(alphaText) / 100
|
|
110
|
+
: Number.parseFloat(alphaText);
|
|
111
|
+
if (![r, g, b, alpha].every((number) => Number.isFinite(number)))
|
|
112
|
+
return null;
|
|
113
|
+
const clamp = (number) => Math.round(Math.max(0, Math.min(255, number)));
|
|
114
|
+
return {
|
|
115
|
+
color: { r: clamp(r), g: clamp(g), b: clamp(b) },
|
|
116
|
+
alpha: Math.max(0, Math.min(1, alpha))
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The colour a selected cell's text is drawn in. Selected text takes the
|
|
121
|
+
* theme's selection ink (`selectionText`) where it has one, else its own
|
|
122
|
+
* foreground, floored at the minimum contrast against what the reader sees
|
|
123
|
+
* behind it: the selection fill laid over the cell's own background. So a
|
|
124
|
+
* dim or coloured word stays readable while selected, as unselected text
|
|
125
|
+
* does on its own background.
|
|
126
|
+
*/
|
|
127
|
+
export function selectedForeground(foreground, background, selection, selectionText) {
|
|
128
|
+
const under = selection === null ? background : mixed(background, selection.color, selection.alpha);
|
|
129
|
+
return legibleForeground(selectionText ?? foreground, under);
|
|
130
|
+
}
|
|
@@ -30,6 +30,12 @@ export interface GhosttyTheme {
|
|
|
30
30
|
readonly cursor: GhosttyColor;
|
|
31
31
|
/** CSS color the renderer overlays on selected cells; not sent to Ghostty. */
|
|
32
32
|
readonly selectionBackground?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The one colour selected text is drawn in, floored by the renderer against
|
|
35
|
+
* the selection over each cell; each cell's own foreground when absent. Not
|
|
36
|
+
* sent to Ghostty.
|
|
37
|
+
*/
|
|
38
|
+
readonly selectionForeground?: GhosttyColor;
|
|
33
39
|
/** The full 256-color palette (16 ANSI colors, color cube, gray ramp); Ghostty's own when absent. */
|
|
34
40
|
readonly palette?: readonly GhosttyColor[];
|
|
35
41
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canvas 2D drawing of a Ghostty render snapshot: backgrounds and selection
|
|
3
|
-
* in runs, text in same-style runs clipped to their cells
|
|
3
|
+
* in runs, text in same-style runs clipped to their cells and drawn at the
|
|
4
|
+
* terminal's minimum contrast against each cell's own background, block elements and
|
|
4
5
|
* box drawing as shapes snapped to device pixels, decorations, and the cursor.
|
|
5
6
|
* Only dirty rows are repainted unless a full frame is forced.
|
|
6
7
|
*/
|
|
7
|
-
import { type GhosttyCell, type GhosttySnapshot } from './core.js';
|
|
8
|
+
import { type GhosttyCell, type GhosttyColor, type GhosttySnapshot } from './core.js';
|
|
8
9
|
/** One cell's size in CSS pixels and its text baseline offset. */
|
|
9
10
|
export interface GhosttyCellMetrics {
|
|
10
11
|
readonly width: number;
|
|
@@ -85,6 +86,12 @@ export declare function renderGhosttySnapshot(options: {
|
|
|
85
86
|
readonly previousCursorY?: number | null;
|
|
86
87
|
readonly focused?: boolean;
|
|
87
88
|
readonly selectionBackground?: string;
|
|
89
|
+
/**
|
|
90
|
+
* The one ink of selected text (the theme's selection foreground); each
|
|
91
|
+
* selected cell's own foreground when omitted. Either way it is floored
|
|
92
|
+
* against the selection over the cell's background.
|
|
93
|
+
*/
|
|
94
|
+
readonly selectionForeground?: GhosttyColor;
|
|
88
95
|
readonly hoveredLinkRange?: GhosttyCellRange | null;
|
|
89
96
|
/** The device pixels per CSS pixel the context's transform scales by; 1 when omitted. */
|
|
90
97
|
readonly pixelRatio?: number;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canvas 2D drawing of a Ghostty render snapshot: backgrounds and selection
|
|
3
|
-
* in runs, text in same-style runs clipped to their cells
|
|
3
|
+
* in runs, text in same-style runs clipped to their cells and drawn at the
|
|
4
|
+
* terminal's minimum contrast against each cell's own background, block elements and
|
|
4
5
|
* box drawing as shapes snapped to device pixels, decorations, and the cursor.
|
|
5
6
|
* Only dirty rows are repainted unless a full frame is forced.
|
|
6
7
|
*/
|
|
7
8
|
import { GHOSTTY_CELL_WIDE, ghosttyColorsEqual } from './core.js';
|
|
9
|
+
import { legibleForeground, parseTranslucentColor, quietMark, selectedForeground } from './contrast.logic.js';
|
|
8
10
|
import { DEFAULT_SELECTION_BACKGROUND } from './fallbackColors.js';
|
|
9
11
|
import { ghosttySpriteCodepoint, ghosttySpriteGlyph, ghosttySpriteThickness } from './spriteGlyphs.logic.js';
|
|
10
12
|
// The engine hands out one object per color, so its CSS text is built once.
|
|
@@ -17,10 +19,54 @@ function cssColor(color) {
|
|
|
17
19
|
}
|
|
18
20
|
return text;
|
|
19
21
|
}
|
|
22
|
+
// By a cell's background, then its foreground: the colour its text is
|
|
23
|
+
// drawn in. The engine hands out one object per color, so each pair is
|
|
24
|
+
// floored once and keeps one CSS text.
|
|
25
|
+
const inks = new WeakMap();
|
|
26
|
+
/**
|
|
27
|
+
* The colour a cell's text is drawn in: its foreground, moved only as far
|
|
28
|
+
* as the terminal's minimum contrast against the cell's own background
|
|
29
|
+
* needs (`legibleForeground`). A background stays as the program asked.
|
|
30
|
+
*/
|
|
31
|
+
function cellInk(cell) {
|
|
32
|
+
let byForeground = inks.get(cell.background);
|
|
33
|
+
if (byForeground === undefined) {
|
|
34
|
+
byForeground = new WeakMap();
|
|
35
|
+
inks.set(cell.background, byForeground);
|
|
36
|
+
}
|
|
37
|
+
let ink = byForeground.get(cell.foreground);
|
|
38
|
+
if (ink === undefined) {
|
|
39
|
+
ink = legibleForeground(cell.foreground, cell.background);
|
|
40
|
+
byForeground.set(cell.foreground, ink);
|
|
41
|
+
}
|
|
42
|
+
return ink;
|
|
43
|
+
}
|
|
44
|
+
// Selected cells' inks, by selection fill, selection ink, background, and
|
|
45
|
+
// foreground, so each combination is floored once and keeps one object (and
|
|
46
|
+
// so one CSS text). Dropped wholesale if a run of themes ever fills it.
|
|
47
|
+
const SELECTED_INK_LIMIT = 4096;
|
|
48
|
+
const selectedInks = new Map();
|
|
49
|
+
const colorKey = (color) => color === undefined ? '' : `${color.r},${color.g},${color.b}`;
|
|
50
|
+
/**
|
|
51
|
+
* The colour a selected cell's text is drawn in (`selectedForeground`): the
|
|
52
|
+
* selection ink, or the cell's own foreground, at the minimum contrast on
|
|
53
|
+
* the selection fill over the cell's background.
|
|
54
|
+
*/
|
|
55
|
+
function selectedCellInk(cell, selectionBackground, selection, selectionText) {
|
|
56
|
+
const key = `${selectionBackground}|${colorKey(selectionText)}|${colorKey(cell.background)}|${colorKey(cell.foreground)}`;
|
|
57
|
+
let ink = selectedInks.get(key);
|
|
58
|
+
if (ink === undefined) {
|
|
59
|
+
ink = selectedForeground(cell.foreground, cell.background, selection, selectionText);
|
|
60
|
+
if (selectedInks.size >= SELECTED_INK_LIMIT)
|
|
61
|
+
selectedInks.clear();
|
|
62
|
+
selectedInks.set(key, ink);
|
|
63
|
+
}
|
|
64
|
+
return ink;
|
|
65
|
+
}
|
|
20
66
|
function sameTextStyle(left, right) {
|
|
21
|
-
// Selection
|
|
22
|
-
//
|
|
23
|
-
//
|
|
67
|
+
// Selection does not participate: it tints the background overlay, and a
|
|
68
|
+
// run splits at a selection boundary only where the selected text takes
|
|
69
|
+
// another ink (the run's ink is compared beside this).
|
|
24
70
|
return (ghosttyColorsEqual(left.foreground, right.foreground) &&
|
|
25
71
|
left.bold === right.bold &&
|
|
26
72
|
left.italic === right.italic &&
|
|
@@ -218,11 +264,23 @@ export function terminalGridSize(width, height, metrics, padding) {
|
|
|
218
264
|
rows: Math.max(1, Math.floor((height - padding * 2) / metrics.height))
|
|
219
265
|
};
|
|
220
266
|
}
|
|
267
|
+
/** How strongly an unfocused terminal's hollow cursor is drawn: the text colour at half strength, at least 3:1 on the ground. */
|
|
268
|
+
const UNFOCUSED_CURSOR_SHARE = 0.5;
|
|
269
|
+
/** Whether no cell of the snapshot's screen shows a glyph. */
|
|
270
|
+
function screenIsBlank(snapshot) {
|
|
271
|
+
return snapshot.rowData.every((row) => row.cells.every((cell) => cell.text === '' || cell.text === ' '));
|
|
272
|
+
}
|
|
221
273
|
/** Paints a snapshot onto the canvas context. */
|
|
222
274
|
export function renderGhosttySnapshot(options) {
|
|
223
275
|
const { context, snapshot, metrics, fontSize, fontFamily, padding, forceFull, cursorOn, previousCursorY } = options;
|
|
224
276
|
const focused = options.focused ?? true;
|
|
225
277
|
const selectionBackground = options.selectionBackground ?? DEFAULT_SELECTION_BACKGROUND;
|
|
278
|
+
const selectionFill = parseTranslucentColor(selectionBackground);
|
|
279
|
+
const selectionForeground = options.selectionForeground;
|
|
280
|
+
// A cell's text colour: on the selection, the selection's ink against it.
|
|
281
|
+
const inkOf = (cell) => cell.selected
|
|
282
|
+
? selectedCellInk(cell, selectionBackground, selectionFill, selectionForeground)
|
|
283
|
+
: cellInk(cell);
|
|
226
284
|
const hoveredLinkRange = options.hoveredLinkRange ?? null;
|
|
227
285
|
const pixelRatio = options.pixelRatio ?? 1;
|
|
228
286
|
// A clip of several rectangles turns Chromium's GPU canvas to multisampling
|
|
@@ -322,6 +380,8 @@ export function renderGhosttySnapshot(options) {
|
|
|
322
380
|
break;
|
|
323
381
|
runEnd += 1;
|
|
324
382
|
}
|
|
383
|
+
// Block and box shapes keep the program's colour: they draw a
|
|
384
|
+
// picture or a frame, whose colour is the point, not text to read.
|
|
325
385
|
if (!first.invisible) {
|
|
326
386
|
const color = cssColor(first.foreground);
|
|
327
387
|
context.fillStyle = color;
|
|
@@ -332,7 +392,12 @@ export function renderGhosttySnapshot(options) {
|
|
|
332
392
|
runStart = runEnd;
|
|
333
393
|
continue;
|
|
334
394
|
}
|
|
335
|
-
const
|
|
395
|
+
const firstInk = inkOf(first);
|
|
396
|
+
// A run splits where the floor draws its text in another colour, so
|
|
397
|
+
// each cell's text keeps the contrast of its own background.
|
|
398
|
+
const runEnd = ghosttyTextRunEnd(row.cells, runStart, (cell) => ghosttySpriteCodepoint(cell.text) < 0 &&
|
|
399
|
+
sameTextStyle(cell, first) &&
|
|
400
|
+
ghosttyColorsEqual(inkOf(cell), firstInk));
|
|
336
401
|
const text = runEnd === runStart + 1
|
|
337
402
|
? first.text
|
|
338
403
|
: row.cells
|
|
@@ -341,7 +406,7 @@ export function renderGhosttySnapshot(options) {
|
|
|
341
406
|
.join('');
|
|
342
407
|
if (!first.invisible && text.trim().length > 0) {
|
|
343
408
|
const font = fonts[(first.bold ? 2 : 0) + (first.italic ? 1 : 0)];
|
|
344
|
-
const color = cssColor(
|
|
409
|
+
const color = cssColor(firstInk);
|
|
345
410
|
const x = padding + runStart * metrics.width;
|
|
346
411
|
const y = top + metrics.baseline;
|
|
347
412
|
const maxWidth = (runEnd - runStart) * metrics.width;
|
|
@@ -421,7 +486,7 @@ export function renderGhosttySnapshot(options) {
|
|
|
421
486
|
if (!cell || (!cell.underline && !cell.strikethrough && !cell.overline && !hoveredLink)) {
|
|
422
487
|
continue;
|
|
423
488
|
}
|
|
424
|
-
context.fillStyle = cssColor(cell
|
|
489
|
+
context.fillStyle = cssColor(inkOf(cell));
|
|
425
490
|
// Decorations span the cell's device edges so a decorated run is unbroken.
|
|
426
491
|
const left = columnEdge(column) / pixelRatio;
|
|
427
492
|
const width = (columnEdge(column + 1) - columnEdge(column)) / pixelRatio;
|
|
@@ -435,7 +500,13 @@ export function renderGhosttySnapshot(options) {
|
|
|
435
500
|
context.fillRect(left, top + 1, width, 1);
|
|
436
501
|
}
|
|
437
502
|
}
|
|
438
|
-
if (cursorOn &&
|
|
503
|
+
if (cursorOn &&
|
|
504
|
+
snapshot.cursorVisible &&
|
|
505
|
+
snapshot.cursorX >= 0 &&
|
|
506
|
+
snapshot.cursorY >= 0 &&
|
|
507
|
+
// An unfocused screen with nothing on it shows no cursor: a lone box in
|
|
508
|
+
// an empty output well reads as an error mark, not as a place to type.
|
|
509
|
+
(focused || !screenIsBlank(snapshot))) {
|
|
439
510
|
const left = padding + snapshot.cursorX * metrics.width;
|
|
440
511
|
const top = padding + snapshot.cursorY * metrics.height;
|
|
441
512
|
const deviceLeft = deviceGridEdge(snapshot.cursorX, metrics.width, padding, pixelRatio);
|
|
@@ -444,8 +515,11 @@ export function renderGhosttySnapshot(options) {
|
|
|
444
515
|
const deviceBottom = deviceGridEdge(snapshot.cursorY + 1, metrics.height, padding, pixelRatio);
|
|
445
516
|
context.fillStyle = cssColor(snapshot.cursor);
|
|
446
517
|
if (!focused) {
|
|
447
|
-
// An unfocused terminal draws a hollow cursor
|
|
448
|
-
|
|
518
|
+
// An unfocused terminal draws a quiet hollow cursor, a 1px outline in
|
|
519
|
+
// the text colour at half strength, so the active pane is obvious and
|
|
520
|
+
// the resting one keeps its place without the cursor colour's alarm;
|
|
521
|
+
// never fainter than a mark's 3:1 on the ground.
|
|
522
|
+
context.strokeStyle = cssColor(quietMark(snapshot.foreground, snapshot.background, UNFOCUSED_CURSOR_SHARE));
|
|
449
523
|
context.strokeRect(left + 0.5, top + 0.5, metrics.width - 1, metrics.height - 1);
|
|
450
524
|
}
|
|
451
525
|
else if (snapshot.cursorStyle === 0) {
|
|
@@ -466,14 +540,17 @@ export function renderGhosttySnapshot(options) {
|
|
|
466
540
|
const cell = snapshot.rowData[snapshot.cursorY]?.cells[snapshot.cursorX];
|
|
467
541
|
const shown = cell !== undefined && !cell.invisible;
|
|
468
542
|
const spriteCodepoint = shown ? ghosttySpriteCodepoint(cell.text) : -1;
|
|
543
|
+
// The cell under the block is drawn in the ground's colour, floored at
|
|
544
|
+
// the per-cell text contrast against the block, which as a mark only
|
|
545
|
+
// keeps 3:1 from the ground.
|
|
546
|
+
const ink = cssColor(legibleForeground(snapshot.background, snapshot.cursor));
|
|
469
547
|
if (spriteCodepoint >= 0) {
|
|
470
|
-
|
|
471
|
-
context.
|
|
472
|
-
paintSpriteCell(context, spriteCodepoint, snapshot.cursorX, deviceTop, deviceBottom, padding, metrics.width, pixelRatio, spriteThickness, background);
|
|
548
|
+
context.fillStyle = ink;
|
|
549
|
+
paintSpriteCell(context, spriteCodepoint, snapshot.cursorX, deviceTop, deviceBottom, padding, metrics.width, pixelRatio, spriteThickness, ink);
|
|
473
550
|
}
|
|
474
551
|
else if (shown && cell.text) {
|
|
475
552
|
context.font = fontForCell(cell, fontSize, fontFamily);
|
|
476
|
-
context.fillStyle =
|
|
553
|
+
context.fillStyle = ink;
|
|
477
554
|
context.fillText(cell.text, left, top + metrics.baseline, metrics.width);
|
|
478
555
|
}
|
|
479
556
|
}
|
|
@@ -121,6 +121,7 @@ export declare class GhosttyTerminalSurface {
|
|
|
121
121
|
private selectionMode;
|
|
122
122
|
private selectionBase;
|
|
123
123
|
private selectionScrollTimer;
|
|
124
|
+
private scrollbarShowTimer;
|
|
124
125
|
private selectionScrollDelta;
|
|
125
126
|
private selectionPointer;
|
|
126
127
|
private mouseReportingPointerId;
|
|
@@ -259,6 +260,13 @@ export declare class GhosttyTerminalSurface {
|
|
|
259
260
|
private installEvents;
|
|
260
261
|
private removeEvents;
|
|
261
262
|
private scrollViewport;
|
|
263
|
+
/**
|
|
264
|
+
* The thumb rests hidden, as the platform's overlay scroll bar does, and
|
|
265
|
+
* shows while the user moves the scrollback and for a moment after
|
|
266
|
+
* (`data-scrolling`, which terminal.css reads). Output that arrives on its
|
|
267
|
+
* own never shows it.
|
|
268
|
+
*/
|
|
269
|
+
private showScrollbarWhileScrolling;
|
|
262
270
|
private scrollbarToPointer;
|
|
263
271
|
private updateScrollbar;
|
|
264
272
|
private readScrollbarState;
|
|
@@ -46,6 +46,8 @@ const QUEUED_OUTPUT_DEADLINE_MS = 50;
|
|
|
46
46
|
* and painted instead of freezing the last frame.
|
|
47
47
|
*/
|
|
48
48
|
const SYNCHRONIZED_OUTPUT_RENDER_TIMEOUT_MS = 500;
|
|
49
|
+
/** How long the overlay scroll thumb stays after the scrollback stops moving. */
|
|
50
|
+
const SCROLLBAR_LINGER_MS = 1000;
|
|
49
51
|
const TERMINAL_FONT_LOAD_TEXT = 'iMW0@# .';
|
|
50
52
|
const TERMINAL_FONT_LOAD_VARIANTS = [
|
|
51
53
|
'normal 400',
|
|
@@ -177,6 +179,7 @@ export class GhosttyTerminalSurface {
|
|
|
177
179
|
// shift the origin of a drag selection.
|
|
178
180
|
selectionBase = null;
|
|
179
181
|
selectionScrollTimer = null;
|
|
182
|
+
scrollbarShowTimer = null;
|
|
180
183
|
selectionScrollDelta = 0;
|
|
181
184
|
selectionPointer = null;
|
|
182
185
|
mouseReportingPointerId = null;
|
|
@@ -579,6 +582,8 @@ export class GhosttyTerminalSurface {
|
|
|
579
582
|
this.reducedMotionMedia?.removeEventListener('change', this.onReducedMotionChange);
|
|
580
583
|
if (this.selectionScrollTimer !== null)
|
|
581
584
|
window.clearInterval(this.selectionScrollTimer);
|
|
585
|
+
if (this.scrollbarShowTimer !== null)
|
|
586
|
+
window.clearTimeout(this.scrollbarShowTimer);
|
|
582
587
|
if (this.resizeNotifyTimer !== null) {
|
|
583
588
|
window.clearTimeout(this.resizeNotifyTimer);
|
|
584
589
|
this.resizeNotifyTimer = null;
|
|
@@ -1014,7 +1019,9 @@ export class GhosttyTerminalSurface {
|
|
|
1014
1019
|
setHoveredLink(link) {
|
|
1015
1020
|
const previous = this.hoveredLink;
|
|
1016
1021
|
const unchanged = previous === null ? link === null : link !== null && isSameTerminalLink(previous, link);
|
|
1017
|
-
|
|
1022
|
+
// The I-beam stays over a link, as everywhere on the canvas: a desktop
|
|
1023
|
+
// terminal shows a link by its underline, never by the hand.
|
|
1024
|
+
this.canvas.style.cursor = '';
|
|
1018
1025
|
if (unchanged)
|
|
1019
1026
|
return;
|
|
1020
1027
|
this.hoveredLink = link;
|
|
@@ -1251,8 +1258,24 @@ export class GhosttyTerminalSurface {
|
|
|
1251
1258
|
this.core.scroll(delta);
|
|
1252
1259
|
this.forceFullRender = true;
|
|
1253
1260
|
this.scrollbarDirty = true;
|
|
1261
|
+
this.showScrollbarWhileScrolling();
|
|
1254
1262
|
this.requestRender();
|
|
1255
1263
|
}
|
|
1264
|
+
/**
|
|
1265
|
+
* The thumb rests hidden, as the platform's overlay scroll bar does, and
|
|
1266
|
+
* shows while the user moves the scrollback and for a moment after
|
|
1267
|
+
* (`data-scrolling`, which terminal.css reads). Output that arrives on its
|
|
1268
|
+
* own never shows it.
|
|
1269
|
+
*/
|
|
1270
|
+
showScrollbarWhileScrolling() {
|
|
1271
|
+
this.scrollbar.dataset['scrolling'] = '';
|
|
1272
|
+
if (this.scrollbarShowTimer !== null)
|
|
1273
|
+
window.clearTimeout(this.scrollbarShowTimer);
|
|
1274
|
+
this.scrollbarShowTimer = window.setTimeout(() => {
|
|
1275
|
+
this.scrollbarShowTimer = null;
|
|
1276
|
+
delete this.scrollbar.dataset['scrolling'];
|
|
1277
|
+
}, SCROLLBAR_LINGER_MS);
|
|
1278
|
+
}
|
|
1256
1279
|
scrollbarToPointer(clientY, bounds) {
|
|
1257
1280
|
const state = this.scrollbarState;
|
|
1258
1281
|
if (state === null)
|
|
@@ -1400,6 +1423,9 @@ export class GhosttyTerminalSurface {
|
|
|
1400
1423
|
textInk: this.textInk,
|
|
1401
1424
|
...(this.theme.selectionBackground !== undefined
|
|
1402
1425
|
? { selectionBackground: this.theme.selectionBackground }
|
|
1426
|
+
: {}),
|
|
1427
|
+
...(this.theme.selectionForeground !== undefined
|
|
1428
|
+
? { selectionForeground: this.theme.selectionForeground }
|
|
1403
1429
|
: {})
|
|
1404
1430
|
});
|
|
1405
1431
|
this.positionInput();
|