@gloom-sh/terminal 0.20.10 → 0.20.12
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/package.json +2 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
- package/src/api-client/awards.ts +16 -0
- package/src/api-client/central-bank-rates.ts +5 -0
- package/src/api-client/data.ts +55 -2
- package/src/api-client/index.ts +18 -1
- package/src/api-client/request.ts +86 -3
- package/src/api-client/socket-connection.ts +366 -0
- package/src/api-client/socket-features.ts +75 -0
- package/src/api-client/socket-frames.ts +161 -0
- package/src/api-client/socket-listeners.ts +207 -0
- package/src/api-client/socket-quotes.ts +332 -0
- package/src/api-client/socket.ts +168 -983
- package/src/api-client/supply-chain-graph.ts +4 -2
- package/src/api-client/supply-chain.ts +8 -0
- package/src/api-client/types/econ.ts +10 -7
- package/src/api-client/types/filings-and-calls.ts +8 -0
- package/src/app/global-shortcuts.ts +2 -1
- package/src/app/keybindings/actions.ts +19 -0
- package/src/app/pane-runtime/index.tsx +18 -3
- package/src/app/pane-runtime/layout-placement.ts +63 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +10 -2
- package/src/brokers/signed-in/adapter.ts +19 -5
- package/src/brokers/signed-in/client.ts +13 -1
- package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
- package/src/capabilities/chart-series.ts +4 -1
- package/src/cli/board-coins.ts +10 -1
- package/src/cli/commands/crypto-hints.ts +3 -2
- package/src/cli/commands/fred-series.ts +0 -54
- package/src/cli/commands/market.ts +209 -31
- package/src/cli/commands/overview.ts +47 -14
- package/src/cli/commands/search.ts +37 -8
- package/src/cli/commands/ticker.ts +15 -4
- package/src/cli/desktop-pane-shot.ts +27 -2
- package/src/cli/fx-quote-rate.ts +1 -1
- package/src/cli/glossary.ts +14 -5
- package/src/cli/history-catalog-series.ts +85 -0
- package/src/cli/index.ts +1 -1
- package/src/cli/list-progress.ts +45 -0
- package/src/cli/listing-arg.ts +71 -7
- package/src/cli/name-entries.ts +8 -4
- package/src/cli/not-a-ticker.ts +2 -2
- package/src/cli/pane-functions/freshness.ts +50 -3
- package/src/cli/pane-functions/index.ts +7 -4
- package/src/cli/pane-functions/market-session.ts +66 -14
- package/src/cli/pane-functions/options.ts +5 -0
- package/src/cli/pane-functions/resolver.ts +9 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +28 -3
- package/src/cli/pane-functions/screenshot-types.ts +6 -0
- package/src/cli/quote-answer.ts +49 -10
- package/src/cli/quote-list-reads.ts +87 -0
- package/src/cli/report-tables.ts +70 -13
- package/src/cli/result.ts +24 -2
- package/src/cli/symbol-list.ts +31 -4
- package/src/cli/terminal-code-hints.ts +83 -0
- package/src/cli/ticker-resolution.ts +2 -1
- package/src/cli/treasury-yields.ts +5 -0
- package/src/components/chart/native/kitty/manager.ts +2 -0
- package/src/components/chart/native/surface/manager.ts +211 -11
- package/src/components/command-bar/action-runtime.ts +2 -0
- package/src/components/command-bar/panel/index.tsx +2 -13
- package/src/components/command-bar/panel/layout.ts +1 -7
- package/src/components/command-bar/panel/runtime.ts +0 -1
- package/src/components/command-bar/panel/types.ts +0 -2
- package/src/components/command-bar/routing/launch-request.ts +2 -1
- package/src/components/command-bar/routing/navigation-state.ts +4 -2
- package/src/components/command-bar/workflow/types.ts +6 -0
- package/src/components/data-table/column-menu.tsx +89 -0
- package/src/components/data-table/sort-menu.tsx +9 -2
- package/src/components/data-table/view.tsx +33 -6
- package/src/components/form-modal/content.tsx +10 -0
- package/src/components/index.ts +1 -1
- package/src/components/layout/detached-pane-shell.tsx +3 -0
- package/src/components/layout/double-escape-close.ts +34 -3
- package/src/components/layout/floating-pane.tsx +10 -4
- package/src/components/layout/pane/cycle-order.ts +66 -2
- package/src/components/layout/pane/footer/index.tsx +25 -11
- package/src/components/layout/pane/footer/model.ts +62 -20
- package/src/components/layout/pane/header.tsx +140 -31
- package/src/components/layout/pane/sidebar.tsx +138 -20
- package/src/components/layout/pane/status-footer.ts +3 -1
- package/src/components/layout/shell/active-drag.ts +18 -13
- package/src/components/layout/shell/drag/magnets.ts +34 -18
- package/src/components/layout/shell/drag/runtime.ts +5 -0
- package/src/components/layout/shell/index.tsx +25 -0
- package/src/components/layout/shell/menu.ts +9 -0
- package/src/components/layout/shell/pane/actions.ts +36 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +27 -3
- package/src/components/layout/shell/pane-occlusion.ts +40 -0
- package/src/components/layout/shell/shortcuts.ts +17 -1
- package/src/components/layout/shell/terminal-pointer-runtime.ts +39 -6
- package/src/components/layout/shell/window-mode/index.ts +5 -16
- package/src/components/layout/shell/window-mode/overlays.tsx +3 -1
- package/src/components/market-board/index.tsx +14 -5
- package/src/components/metric-treemap/index.tsx +3 -1
- package/src/components/ticker/list-table-view.tsx +5 -0
- package/src/components/ui/button.tsx +48 -4
- package/src/components/ui/data-table/column-order.ts +180 -0
- package/src/components/ui/data-table/index.tsx +12 -1
- package/src/components/ui/data-table/opentui/index.tsx +291 -32
- package/src/components/ui/data-table/opentui/model.ts +43 -4
- package/src/components/ui/data-table/types.ts +56 -0
- package/src/components/ui/data-table/use-column-order.ts +135 -0
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/inline-quick-add.tsx +19 -3
- package/src/components/ui/list-view.tsx +11 -5
- package/src/components/ui/query-bar.tsx +16 -1
- package/src/components/ui/selection-fill.ts +39 -0
- package/src/components/ui/table-layout.ts +120 -0
- package/src/core/state/app/layout-reducer.ts +2 -1
- package/src/core/state/app/pane-choices.ts +68 -0
- package/src/core/state/app/state.ts +14 -6
- package/src/core/state/app/types.ts +8 -0
- package/src/docs/snapshot.json +3 -2
- package/src/i18n/es.ts +2 -0
- package/src/i18n/ja.ts +2 -0
- package/src/i18n/ko.ts +2 -0
- package/src/i18n/zh-cn.ts +2 -0
- package/src/i18n/zh-tw.ts +2 -0
- package/src/layout/pane-manager/dock-tree.ts +19 -0
- package/src/layout/pane-manager/index.ts +3 -0
- package/src/market-data/coordinator/index.ts +4 -3
- package/src/market-data/coordinator/quotes.ts +12 -4
- package/src/market-data/market/freshness.ts +33 -0
- package/src/market-data/market/status.ts +5 -1
- package/src/market-data/quotes/contributions.ts +10 -0
- package/src/market-data/quotes/freshness.ts +31 -0
- package/src/market-data/quotes/live-valuation.ts +32 -5
- package/src/market-data/quotes/regular-session-valuation.ts +1 -1
- package/src/market-data/quotes/resolution.ts +4 -0
- package/src/market-data/quotes/time.ts +0 -14
- package/src/plugins/builtin/account-management/index.tsx +1 -0
- package/src/plugins/builtin/awards/detail.tsx +12 -4
- package/src/plugins/builtin/awards/headless.ts +29 -8
- package/src/plugins/builtin/awards/model.ts +36 -2
- package/src/plugins/builtin/awards/pane.tsx +7 -4
- package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
- package/src/plugins/builtin/broker-manager/index.tsx +7 -6
- package/src/plugins/builtin/broker-manager/model.ts +15 -6
- package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
- package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
- package/src/plugins/builtin/broker-manager/table.ts +10 -4
- package/src/plugins/builtin/broker-trading/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/headless.ts +6 -6
- package/src/plugins/builtin/central-bank-rates/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +21 -3
- package/src/plugins/builtin/central-bank-rates/pane.tsx +15 -5
- package/src/plugins/builtin/chart-composer/headless.ts +5 -1
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
- package/src/plugins/builtin/chat/content/handle-prompt.tsx +4 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +17 -1
- package/src/plugins/builtin/chat/message/terminal.tsx +4 -1
- package/src/plugins/builtin/chat/sidebar.tsx +35 -19
- package/src/plugins/builtin/cloud/askg/pane.tsx +4 -0
- package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
- package/src/plugins/builtin/cloud/plugin.tsx +1 -0
- package/src/plugins/builtin/cloud/team/module.tsx +1 -0
- package/src/plugins/builtin/cloud/thesis/detail.tsx +9 -4
- package/src/plugins/builtin/commodity-balances/pane.tsx +13 -5
- package/src/plugins/builtin/company-kpis/model.ts +3 -3
- package/src/plugins/builtin/connections/index.ts +1 -0
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +9 -5
- package/src/plugins/builtin/credit-boards/client.ts +5 -0
- package/src/plugins/builtin/credit-boards/headless.ts +1 -6
- package/src/plugins/builtin/credit-boards/model.ts +0 -6
- package/src/plugins/builtin/credit-boards/series.ts +19 -8
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +9 -5
- package/src/plugins/builtin/crypto-etf-flows/headless.ts +23 -13
- package/src/plugins/builtin/crypto-etf-flows/pane.tsx +8 -3
- package/src/plugins/builtin/debt-maturities/headless.ts +16 -7
- package/src/plugins/builtin/debt-maturities/model.ts +9 -15
- package/src/plugins/builtin/debt-maturities/pane.tsx +9 -10
- package/src/plugins/builtin/earnings/board-model.ts +33 -4
- package/src/plugins/builtin/earnings/board.tsx +15 -3
- package/src/plugins/builtin/earnings/calendar.tsx +10 -6
- package/src/plugins/builtin/earnings/client.ts +0 -9
- package/src/plugins/builtin/earnings/headless.ts +10 -7
- package/src/plugins/builtin/earnings/history.tsx +21 -14
- package/src/plugins/builtin/earnings-calls/data.ts +24 -4
- package/src/plugins/builtin/earnings-calls/format.ts +23 -5
- package/src/plugins/builtin/earnings-calls/headless.ts +23 -3
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/earnings-calls/model.ts +11 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -5
- package/src/plugins/builtin/econ/calendar-model.ts +27 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -0
- package/src/plugins/builtin/econ/index.tsx +9 -2
- package/src/plugins/builtin/econ-statistics/headless.ts +3 -1
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -1
- package/src/plugins/builtin/equity-screener/live.ts +74 -18
- package/src/plugins/builtin/equity-screener/model.ts +19 -4
- package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
- package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
- package/src/plugins/builtin/equity-screener/results.ts +22 -2
- package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
- package/src/plugins/builtin/fear-greed/headless.ts +16 -13
- package/src/plugins/builtin/fear-greed/pane.tsx +12 -4
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/futures/index.tsx +15 -1
- package/src/plugins/builtin/futures/table.tsx +1 -1
- package/src/plugins/builtin/fx-matrix/index.tsx +32 -19
- package/src/plugins/builtin/holders/pane.tsx +30 -20
- package/src/plugins/builtin/insider/table.tsx +10 -7
- package/src/plugins/builtin/insider/tickers.tsx +1 -1
- package/src/plugins/builtin/iv-history/events.ts +5 -0
- package/src/plugins/builtin/iv-history/headless.ts +15 -9
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
- package/src/plugins/builtin/macro-day/headless.ts +15 -6
- package/src/plugins/builtin/macro-day/model.ts +1 -1
- package/src/plugins/builtin/macro-day/releases.ts +25 -16
- package/src/plugins/builtin/market-movers/index.tsx +20 -8
- package/src/plugins/builtin/market-movers/model.ts +5 -0
- package/src/plugins/builtin/market-movers/session-body.tsx +2 -1
- package/src/plugins/builtin/money-markets/headless.ts +12 -2
- package/src/plugins/builtin/money-markets/pane.tsx +10 -1
- package/src/plugins/builtin/options/view.tsx +3 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -31
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +19 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +22 -8
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +6 -8
- package/src/plugins/builtin/portfolio-list/table.tsx +15 -1
- package/src/plugins/builtin/rate-path/pane.tsx +2 -0
- package/src/plugins/builtin/realized-vol/headless.ts +28 -2
- package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
- package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/seasonality/pane.tsx +2 -1
- package/src/plugins/builtin/shared/source-footer.ts +70 -0
- package/src/plugins/builtin/short-interest/publications-pane.tsx +5 -1
- package/src/plugins/builtin/short-volume/pane.tsx +5 -1
- package/src/plugins/builtin/social-mentions/outliers.tsx +10 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +7 -0
- package/src/plugins/builtin/supply-chain/client.ts +3 -1
- package/src/plugins/builtin/supply-chain/flow.tsx +25 -8
- package/src/plugins/builtin/supply-chain/graph-client.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-model.ts +12 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +9 -8
- package/src/plugins/builtin/supply-chain/graph.tsx +12 -6
- package/src/plugins/builtin/supply-chain/headless.ts +13 -7
- package/src/plugins/builtin/supply-chain/model.ts +68 -11
- package/src/plugins/builtin/supply-chain/pane.tsx +9 -6
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +5 -5
- package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +14 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +48 -24
- package/src/plugins/builtin/ticker-detail/quote-footer.ts +5 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +6 -3
- package/src/plugins/builtin/treasury-auctions/after.ts +50 -23
- package/src/plugins/builtin/treasury-auctions/cache.ts +23 -5
- package/src/plugins/builtin/treasury-auctions/headless.ts +226 -37
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +11 -5
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +27 -25
- package/src/plugins/builtin/treasury-auctions/hk.ts +60 -8
- package/src/plugins/builtin/treasury-auctions/index.tsx +3 -0
- package/src/plugins/builtin/treasury-auctions/keys.ts +27 -0
- package/src/plugins/builtin/treasury-auctions/like.ts +137 -0
- package/src/plugins/builtin/treasury-auctions/model.ts +100 -22
- package/src/plugins/builtin/treasury-auctions/pane.tsx +39 -11
- package/src/plugins/builtin/vol-surface/heat-grid.tsx +6 -3
- package/src/plugins/builtin/vol-surface/pane.tsx +7 -3
- package/src/plugins/builtin/world-indices/index.tsx +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +2 -1
- package/src/plugins/runtime/index.tsx +1 -0
- package/src/plugins/runtime/state.ts +20 -0
- package/src/portfolio/column-values.ts +8 -2
- package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
- package/src/public/react.ts +7 -0
- package/src/react/auto-refresh.ts +29 -0
- package/src/renderers/browser/deeplink-bridge.ts +24 -3
- package/src/renderers/dom/data-table/column-drag.ts +147 -0
- package/src/renderers/dom/data-table/index.tsx +22 -0
- package/src/renderers/dom/data-table/row.tsx +27 -5
- package/src/renderers/dom/desktop/query-bar.tsx +229 -60
- package/src/renderers/dom/host/overflow-fade-px.ts +2 -0
- package/src/renderers/dom/host/overflow-fade.ts +1 -2
- package/src/renderers/dom/styles.css +47 -5
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -1
- package/src/renderers/opentui/chart-surface.tsx +1 -0
- package/src/renderers/opentui/frame-hits.ts +33 -0
- package/src/renderers/opentui/host.tsx +2 -0
- package/src/renderers/opentui/native-surface.ts +14 -21
- package/src/renderers/opentui/test-utils.tsx +3 -0
- package/src/series/types.ts +2 -0
- package/src/sources/gloomberb-cloud/fred-attribution.ts +86 -0
- package/src/sources/gloomberb-cloud/index.ts +25 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +22 -3
- package/src/sources/provider-errors.ts +64 -1
- package/src/sources/provider-router/batches.ts +19 -0
- package/src/sources/provider-router/index.ts +7 -1
- package/src/state/app/context/index.tsx +46 -1
- package/src/state/pane-unsent-work.ts +47 -0
- package/src/test-support/app-store.ts +24 -1
- package/src/test-support/shell-pane-keys.tsx +5 -0
- package/src/test-support/telemetry-guard.ts +83 -0
- package/src/test-support/test-env.ts +12 -0
- package/src/theme/colors.ts +17 -1
- package/src/theme/ui-tokens.ts +50 -1
- package/src/tickers/listing-venues.ts +11 -1
- package/src/tickers/search/japanese-names.json +1 -0
- package/src/tickers/search/japanese-names.ts +152 -0
- package/src/tickers/terminal-codes.ts +55 -6
- package/src/time-series/base-series.ts +3 -0
- package/src/time-series/live-quotes.ts +3 -9
- package/src/types/data-provider.ts +6 -0
- package/src/types/financials.ts +11 -0
- package/src/types/plugin-contributions.ts +7 -0
- package/src/types/plugin-panes.ts +7 -0
- package/src/ui/host.tsx +24 -0
- package/src/ui/pointer-drag.ts +11 -2
- package/src/utils/double-escape-close.ts +42 -0
- package/src/utils/fundamentals.ts +14 -3
- package/src/utils/fx-status.ts +30 -7
- package/src/utils/network-failure.ts +23 -0
- package/src/utils/share-multiples.cases.json +780 -2
- package/src/utils/share-multiples.ts +154 -24
|
@@ -48,19 +48,86 @@ export interface PaneHeaderStack {
|
|
|
48
48
|
onTabMouseDown?: (id: string, event: any) => void;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/** Terminal: the least a tab that is not shown keeps when a stack is cut to fit: a letter and the ellipsis. */
|
|
52
|
+
const STACK_TAB_MIN_WIDTH = 4;
|
|
53
|
+
/** Terminal: between the last tab named and the count of those left out. */
|
|
54
|
+
const STACK_TAB_MORE_GAP = " ";
|
|
55
|
+
|
|
56
|
+
/** Terminal: one tab of a stack as its header lays it out (`stackTabSpans`). */
|
|
57
|
+
export interface StackTabSpan {
|
|
58
|
+
/** The tab's place in the stack; for the `more` count, the tab a press on it shows. */
|
|
59
|
+
index: number;
|
|
60
|
+
/** Cells from where the title starts (after the grip). */
|
|
61
|
+
start: number;
|
|
62
|
+
text: string;
|
|
63
|
+
/** The count of the tabs left out (`+2`), which a press steps through. */
|
|
64
|
+
more?: true;
|
|
65
|
+
}
|
|
66
|
+
|
|
51
67
|
/**
|
|
52
|
-
* Terminal:
|
|
53
|
-
* in cells from where the title starts (after the
|
|
54
|
-
*
|
|
68
|
+
* Terminal: the tabs of a stack its header shows in `width` cells, as text
|
|
69
|
+
* and where each starts, in cells from where the title starts (after the
|
|
70
|
+
* grip); `index` is the tab's place in the stack. Every tab shows when they
|
|
71
|
+
* fit. When they do not, the tab shown (`activeIndex`) keeps its name, as
|
|
72
|
+
* many others as keep a letter each share what is left, in tab order, and a
|
|
73
|
+
* dim `+n` after them counts the rest. A press on the count shows the first
|
|
74
|
+
* tab left out after the one shown, so pressing it again steps through them.
|
|
75
|
+
* The header always names what the pane shows; the count goes first when
|
|
76
|
+
* there is no room for it beside a letter of that name. The pointer runtime
|
|
77
|
+
* finds the tab under a press with the same spans.
|
|
55
78
|
*/
|
|
56
|
-
export function stackTabSpans(
|
|
79
|
+
export function stackTabSpans(
|
|
80
|
+
titles: readonly string[],
|
|
81
|
+
activeIndex = -1,
|
|
82
|
+
width = Number.POSITIVE_INFINITY,
|
|
83
|
+
): StackTabSpan[] {
|
|
84
|
+
const labels = titles.map((title) => truncateToDisplayWidth(title, STACK_TAB_MAX_WIDTH));
|
|
85
|
+
const separator = STACK_TAB_SEPARATOR.length;
|
|
86
|
+
const natural = labels.reduce((sum, label) => sum + displayWidth(label), 0) + separator * Math.max(0, labels.length - 1);
|
|
87
|
+
let texts: Array<string | null> = labels;
|
|
88
|
+
let more: { index: number; text: string } | null = null;
|
|
89
|
+
if (natural > width && activeIndex >= 0 && activeIndex < labels.length) {
|
|
90
|
+
const shownLabel = labels[activeIndex]!;
|
|
91
|
+
const others = labels.map((_, index) => index).filter((index) => index !== activeIndex);
|
|
92
|
+
const moreWidth = (count: number) => (count > 0 ? STACK_TAB_MORE_GAP.length + `+${count}`.length : 0);
|
|
93
|
+
let kept: number[] = [];
|
|
94
|
+
let share = 0;
|
|
95
|
+
for (let keep = others.length; keep >= 1; keep -= 1) {
|
|
96
|
+
const room = width - displayWidth(shownLabel) - separator * keep - moreWidth(others.length - keep);
|
|
97
|
+
if (Math.floor(room / keep) >= STACK_TAB_MIN_WIDTH) {
|
|
98
|
+
kept = others.slice(0, keep);
|
|
99
|
+
share = Math.floor(room / keep);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const left = others.filter((index) => !kept.includes(index));
|
|
104
|
+
const count = left.length > 0 ? `+${left.length}` : null;
|
|
105
|
+
let shown = shownLabel;
|
|
106
|
+
if (kept.length === 0) {
|
|
107
|
+
const room = width - moreWidth(left.length);
|
|
108
|
+
shown = truncateToDisplayWidth(shownLabel, room >= Math.min(STACK_TAB_MIN_WIDTH, displayWidth(shownLabel)) ? room : width);
|
|
109
|
+
}
|
|
110
|
+
texts = labels.map((label, index) => (
|
|
111
|
+
index === activeIndex ? shown : kept.includes(index) ? truncateToDisplayWidth(label, share) : null
|
|
112
|
+
));
|
|
113
|
+
const used = texts.reduce<number>((sum, text) => sum + (text === null ? 0 : displayWidth(text)), 0)
|
|
114
|
+
+ separator * kept.length;
|
|
115
|
+
if (count && used + moreWidth(left.length) <= width) {
|
|
116
|
+
more = { index: left.find((index) => index > activeIndex) ?? left[0]!, text: count };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
57
119
|
let start = 0;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
start
|
|
62
|
-
|
|
120
|
+
const spans: StackTabSpan[] = [];
|
|
121
|
+
texts.forEach((text, index) => {
|
|
122
|
+
if (text === null) return;
|
|
123
|
+
spans.push({ index, start, text });
|
|
124
|
+
start += displayWidth(text) + separator;
|
|
63
125
|
});
|
|
126
|
+
if (more) {
|
|
127
|
+
const last = spans.at(-1);
|
|
128
|
+
spans.push({ index: more.index, start: last ? last.start + displayWidth(last.text) + STACK_TAB_MORE_GAP.length : 0, text: more.text, more: true });
|
|
129
|
+
}
|
|
130
|
+
return spans;
|
|
64
131
|
}
|
|
65
132
|
|
|
66
133
|
/** Terminal: the cells before a header's title: the grip, after the corner a focused or floating pane draws. */
|
|
@@ -68,21 +135,52 @@ export function paneHeaderTitleStart(framed: boolean): number {
|
|
|
68
135
|
return (framed ? 2 : 0) + PANE_HEADER_GRIP.length;
|
|
69
136
|
}
|
|
70
137
|
|
|
71
|
-
/** Terminal:
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
138
|
+
/** Terminal: what a header's quick settings, lock and `?` take after its title. */
|
|
139
|
+
export function terminalHeaderTrailingWidth(
|
|
140
|
+
quickSettings: ReadonlyArray<Pick<PaneHeaderQuickSetting, "icon">>,
|
|
141
|
+
locked: boolean,
|
|
142
|
+
help: boolean,
|
|
143
|
+
): number {
|
|
144
|
+
return quickSettings.reduce((total, setting) => total + displayWidth(quickSettingText(setting)), 0)
|
|
145
|
+
+ (locked ? displayWidth(PANE_HEADER_LOCK) : 0)
|
|
146
|
+
+ (help ? PANE_HEADER_HELP.length : 0);
|
|
75
147
|
}
|
|
76
148
|
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Terminal: the cells a header leaves its title (or a stack's tabs): its
|
|
151
|
+
* width less the frame a focused, floating or fullscreen pane draws, the
|
|
152
|
+
* grip, what follows the title (`trailing`), the menu and the corner mark a
|
|
153
|
+
* floating or fullscreen pane has.
|
|
154
|
+
*/
|
|
155
|
+
export function terminalHeaderTitleWidth(
|
|
156
|
+
width: number,
|
|
157
|
+
{ framed, corner, trailing }: { framed: boolean; corner: boolean; trailing: number },
|
|
158
|
+
): number {
|
|
159
|
+
const frame = framed ? 4 : 0;
|
|
160
|
+
const cornerWidth = corner ? PANE_HEADER_CLOSE.length : 0;
|
|
161
|
+
return Math.max(0, width - frame - PANE_HEADER_GRIP.length - trailing - PANE_HEADER_ACTION.length - cornerWidth);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Terminal: a stack's tabs as `stackTabSpans` lays them out, the shown one in `activeFg`, the rest dim, padded to `width` with `pad`. */
|
|
165
|
+
function TerminalStackTabs({ stack, spans, width, activeFg, pad }: {
|
|
166
|
+
stack: PaneHeaderStack;
|
|
167
|
+
spans: ReturnType<typeof stackTabSpans>;
|
|
168
|
+
width: number;
|
|
169
|
+
activeFg: string;
|
|
170
|
+
pad: boolean;
|
|
171
|
+
}) {
|
|
172
|
+
let left = width;
|
|
80
173
|
const parts: Array<{ key: string; text: string; fg: string }> = [];
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
174
|
+
spans.forEach((span, position) => {
|
|
175
|
+
if (span.more) {
|
|
176
|
+
parts.push({ key: "more-gap", text: STACK_TAB_MORE_GAP, fg: colors.textDim });
|
|
177
|
+
parts.push({ key: "more", text: span.text, fg: colors.textDim });
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const tab = stack.tabs[span.index]!;
|
|
181
|
+
if (position > 0) parts.push({ key: `sep:${tab.id}`, text: STACK_TAB_SEPARATOR, fg: colors.border });
|
|
182
|
+
parts.push({ key: tab.id, text: span.text, fg: tab.id === stack.active ? activeFg : colors.textDim });
|
|
84
183
|
});
|
|
85
|
-
let left = width;
|
|
86
184
|
return (
|
|
87
185
|
<>
|
|
88
186
|
{parts.map((part) => {
|
|
@@ -95,6 +193,17 @@ function TerminalStackTabs({ stack, width, activeFg, pad }: { stack: PaneHeaderS
|
|
|
95
193
|
);
|
|
96
194
|
}
|
|
97
195
|
|
|
196
|
+
/** The place of the tab a stack shows among its tabs. */
|
|
197
|
+
function stackActiveIndex(stack: PaneHeaderStack): number {
|
|
198
|
+
return stack.tabs.findIndex((tab) => tab.id === stack.active);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Terminal: how wide a stack's tabs are as laid out. */
|
|
202
|
+
function stackSpansWidth(spans: ReturnType<typeof stackTabSpans>): number {
|
|
203
|
+
const last = spans.at(-1);
|
|
204
|
+
return last ? last.start + displayWidth(last.text) : 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
98
207
|
interface PaneHeaderProps {
|
|
99
208
|
title: string;
|
|
100
209
|
/**
|
|
@@ -296,8 +405,7 @@ export function PaneHeader({
|
|
|
296
405
|
const closeText = fullscreen ? PANE_HEADER_RESTORE : floating ? PANE_HEADER_CLOSE : "";
|
|
297
406
|
const onCornerMouseDown = fullscreen ? onRestoreMouseDown : onCloseMouseDown;
|
|
298
407
|
const lockText = locked ? PANE_HEADER_LOCK : "";
|
|
299
|
-
const terminalQuickSettingsWidth = quickSettings
|
|
300
|
-
+ displayWidth(lockText) + helpText.length;
|
|
408
|
+
const terminalQuickSettingsWidth = terminalHeaderTrailingWidth(quickSettings, locked, !!onHelpMouseDown);
|
|
301
409
|
const textColor = paneTitleText(visuallyFocused, floating);
|
|
302
410
|
const tickerAt = titleTicker ? findTitleTicker(title, titleTicker) : null;
|
|
303
411
|
const topInset = topRule ? 1 : 0;
|
|
@@ -551,10 +659,10 @@ export function PaneHeader({
|
|
|
551
659
|
// Fullscreen draws "-" in that corner. Reserve 2 for the frame.
|
|
552
660
|
const borderColor = visuallyFocused ? colors.borderFocused : colors.border;
|
|
553
661
|
const innerWidth = Math.max(0, width - 4);
|
|
554
|
-
const
|
|
555
|
-
const titleWidth = Math.max(0, innerWidth - contentWidth);
|
|
662
|
+
const titleWidth = terminalHeaderTitleWidth(width, { framed: true, corner: closeText.length > 0, trailing: terminalQuickSettingsWidth });
|
|
556
663
|
const clippedTitle = truncateToDisplayWidth(title, titleWidth);
|
|
557
|
-
const
|
|
664
|
+
const spans = stack ? stackTabSpans(stack.tabs.map((tab) => tab.title), stackActiveIndex(stack), titleWidth) : null;
|
|
665
|
+
const fillLen = Math.max(0, innerWidth - PANE_HEADER_GRIP.length - (spans ? Math.min(titleWidth, stackSpansWidth(spans)) : displayWidth(clippedTitle)) - terminalQuickSettingsWidth - actionText.length - closeText.length);
|
|
558
666
|
const fill = "─".repeat(fillLen);
|
|
559
667
|
|
|
560
668
|
return (
|
|
@@ -570,10 +678,10 @@ export function PaneHeader({
|
|
|
570
678
|
onMouseDragEnd={onHeaderMouseDragEnd}
|
|
571
679
|
>
|
|
572
680
|
<Text fg={borderColor} selectable={false}>{"┌─"}</Text>
|
|
573
|
-
{stack ? (
|
|
681
|
+
{stack && spans ? (
|
|
574
682
|
<>
|
|
575
683
|
<Text fg={textColor} selectable={false}>{PANE_HEADER_GRIP}</Text>
|
|
576
|
-
<TerminalStackTabs stack={stack} width={titleWidth} activeFg={textColor} pad={false} />
|
|
684
|
+
<TerminalStackTabs stack={stack} spans={spans} width={titleWidth} activeFg={textColor} pad={false} />
|
|
577
685
|
</>
|
|
578
686
|
) : (
|
|
579
687
|
<Text fg={textColor} selectable={false}>{`${PANE_HEADER_GRIP}${clippedTitle}`}</Text>
|
|
@@ -587,7 +695,7 @@ export function PaneHeader({
|
|
|
587
695
|
onMouseDown={setting.onMouseDown}
|
|
588
696
|
/>
|
|
589
697
|
))}
|
|
590
|
-
<Text fg={borderColor} selectable={false}>{fill}</Text>
|
|
698
|
+
{fill && <Text fg={borderColor} selectable={false}>{fill}</Text>}
|
|
591
699
|
{locked && (
|
|
592
700
|
<TerminalPaneButton text={lockText} fg={colors.textMuted} role="pane-lock" />
|
|
593
701
|
)}
|
|
@@ -613,8 +721,9 @@ export function PaneHeader({
|
|
|
613
721
|
);
|
|
614
722
|
}
|
|
615
723
|
|
|
616
|
-
const titleWidth =
|
|
724
|
+
const titleWidth = terminalHeaderTitleWidth(width, { framed: false, corner: closeText.length > 0, trailing: terminalQuickSettingsWidth });
|
|
617
725
|
const clippedTitle = truncateToDisplayWidth(title, titleWidth);
|
|
726
|
+
const spans = stack ? stackTabSpans(stack.tabs.map((tab) => tab.title), stackActiveIndex(stack), titleWidth) : null;
|
|
618
727
|
const padding = " ".repeat(Math.max(0, titleWidth - displayWidth(clippedTitle)));
|
|
619
728
|
|
|
620
729
|
return (
|
|
@@ -629,10 +738,10 @@ export function PaneHeader({
|
|
|
629
738
|
onMouseDrag={onHeaderMouseDrag}
|
|
630
739
|
onMouseDragEnd={onHeaderMouseDragEnd}
|
|
631
740
|
>
|
|
632
|
-
{stack ? (
|
|
741
|
+
{stack && spans ? (
|
|
633
742
|
<>
|
|
634
743
|
<Text fg={textColor} selectable={false}>{PANE_HEADER_GRIP}</Text>
|
|
635
|
-
<TerminalStackTabs stack={stack} width={titleWidth} activeFg={textColor} pad />
|
|
744
|
+
<TerminalStackTabs stack={stack} spans={spans} width={titleWidth} activeFg={textColor} pad />
|
|
636
745
|
</>
|
|
637
746
|
) : (
|
|
638
747
|
<Text fg={textColor} selectable={false}>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { createContext, startTransition, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
|
|
2
|
-
import { Box, Text, useNativeRenderer, useUiCapabilities, type BoxRenderable } from "../../../ui";
|
|
1
|
+
import { createContext, startTransition, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";
|
|
2
|
+
import { Box, Text, useNativeRenderer, useUiCapabilities, useUiHost, type BoxRenderable, type ScrollBoxRenderable } from "../../../ui";
|
|
3
|
+
import { afterLayout, revealInScrollBox } from "../../ui/reveal-in-scroll-box";
|
|
4
|
+
import { observeScrollBoxContentSize, observeScrollBoxViewportSize } from "../../../renderers/opentui/scrollbox-layout";
|
|
3
5
|
import { beginLiveResize, createCatchUp, type CatchUp } from "../../../ui/live-resize";
|
|
4
6
|
import { capturePointerDrag } from "../../../ui/pointer-drag";
|
|
5
|
-
import { blendHex, colors, hoverBg } from "../../../theme/colors";
|
|
7
|
+
import { blendHex, colors, hoverBg, inactiveSelectedBg } from "../../../theme/colors";
|
|
6
8
|
import { t } from "../../../i18n";
|
|
7
9
|
import { usePaneFooter } from "./footer/registration";
|
|
8
10
|
|
|
@@ -26,10 +28,15 @@ const WIDEN_KEY = ">";
|
|
|
26
28
|
export interface PaneSidebarRenderState {
|
|
27
29
|
backgroundColor: string;
|
|
28
30
|
listWidth: number;
|
|
31
|
+
/**
|
|
32
|
+
* The fill of the row the sidebar shows as chosen, the one its `PaneSidebarRow`s
|
|
33
|
+
* draw: lit while the sidebar has the keys, the inactive selection otherwise.
|
|
34
|
+
* A row a sidebar draws itself (a section heading under the cursor) takes it too.
|
|
35
|
+
*/
|
|
36
|
+
activeBackgroundColor: string;
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
interface PaneSidebarContextValue extends PaneSidebarRenderState {
|
|
32
|
-
activeBackgroundColor: string;
|
|
33
40
|
keyboardFocused: boolean;
|
|
34
41
|
}
|
|
35
42
|
|
|
@@ -37,7 +44,7 @@ const PaneSidebarContext = createContext<PaneSidebarContextValue | null>(null);
|
|
|
37
44
|
|
|
38
45
|
function usePaneSidebarContext(): PaneSidebarContextValue {
|
|
39
46
|
const context = useContext(PaneSidebarContext);
|
|
40
|
-
if (!context) throw new Error("PaneSidebarRow and PaneSidebarAction must be rendered inside PaneSidebar.");
|
|
47
|
+
if (!context) throw new Error("PaneSidebarList, PaneSidebarRow and PaneSidebarAction must be rendered inside PaneSidebar.");
|
|
41
48
|
return context;
|
|
42
49
|
}
|
|
43
50
|
|
|
@@ -217,12 +224,15 @@ export function PaneSidebar({
|
|
|
217
224
|
const backgroundColor = keyboardFocused
|
|
218
225
|
? blendHex(colors.panel, colors.borderFocused, 0.18)
|
|
219
226
|
: colors.panel;
|
|
227
|
+
// Without the keys, the terminal's inactive selection, as every list there
|
|
228
|
+
// has; the desktop keeps the light tint its sidebars always had (its lists
|
|
229
|
+
// keep the full selection, see useSelectionFill).
|
|
220
230
|
const activeBackgroundColor = keyboardFocused
|
|
221
231
|
? blendHex(colors.selected, colors.borderFocused, 0.32)
|
|
222
|
-
: blendHex(colors.panel, colors.selected, 0.35);
|
|
232
|
+
: nativePaneChrome ? blendHex(colors.panel, colors.selected, 0.35) : inactiveSelectedBg(colors);
|
|
223
233
|
const sidebarLayoutHeight = nativePaneChrome ? "100%" : height;
|
|
224
234
|
const nativeFillStyle = nativePaneChrome ? { minHeight: 0 } : undefined;
|
|
225
|
-
const renderState = { backgroundColor, listWidth };
|
|
235
|
+
const renderState = { backgroundColor, listWidth, activeBackgroundColor };
|
|
226
236
|
const dividerActive = resizing || dividerHovered;
|
|
227
237
|
const resizeHandlers = resize && {
|
|
228
238
|
onMouseDown: beginResize,
|
|
@@ -233,7 +243,7 @@ export function PaneSidebar({
|
|
|
233
243
|
};
|
|
234
244
|
|
|
235
245
|
return (
|
|
236
|
-
<PaneSidebarContext.Provider value={{ ...renderState,
|
|
246
|
+
<PaneSidebarContext.Provider value={{ ...renderState, keyboardFocused }}>
|
|
237
247
|
<Box
|
|
238
248
|
ref={sidebarRef}
|
|
239
249
|
width={width}
|
|
@@ -309,20 +319,125 @@ export function PaneSidebar({
|
|
|
309
319
|
);
|
|
310
320
|
}
|
|
311
321
|
|
|
312
|
-
|
|
322
|
+
interface PaneSidebarListContextValue {
|
|
323
|
+
/** Marks `node` as the row the list keeps in view, and brings it there. */
|
|
324
|
+
setCurrent: (node: BoxRenderable | null) => void;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const PaneSidebarListContext = createContext<PaneSidebarListContextValue | null>(null);
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Keeps the row `ref` is on in view while it is `current`: the row the
|
|
331
|
+
* keyboard is on, or the open item. Rows outside a PaneSidebarList, and the
|
|
332
|
+
* desktop list, which scrolls by CSS, ignore it.
|
|
333
|
+
*/
|
|
334
|
+
export function usePaneSidebarReveal(ref: RefObject<BoxRenderable | null>, current: boolean): void {
|
|
335
|
+
const list = useContext(PaneSidebarListContext);
|
|
336
|
+
useLayoutEffect(() => {
|
|
337
|
+
if (!list || !current) return;
|
|
338
|
+
list.setCurrent(ref.current);
|
|
339
|
+
return () => list.setCurrent(null);
|
|
340
|
+
}, [current, list, ref]);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface PaneSidebarListRenderState {
|
|
344
|
+
/** The width a row has beside the list's scrollbar, while it shows one. */
|
|
345
|
+
listWidth: number;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* The scrolling part of a sidebar. The wheel scrolls it, a scrollbar shows
|
|
350
|
+
* while it holds more rows than fit, and the row a `PaneSidebarRow` marks
|
|
351
|
+
* `active` (or `usePaneSidebarReveal` marks current) stays in view as the
|
|
352
|
+
* keyboard moves it.
|
|
353
|
+
*/
|
|
354
|
+
export function PaneSidebarList({ children }: { children: ReactNode | ((state: PaneSidebarListRenderState) => ReactNode) }) {
|
|
313
355
|
const { nativePaneChrome } = useUiCapabilities();
|
|
356
|
+
const sidebar = usePaneSidebarContext();
|
|
357
|
+
if (nativePaneChrome) {
|
|
358
|
+
return (
|
|
359
|
+
<Box
|
|
360
|
+
flexGrow={1}
|
|
361
|
+
flexShrink={1}
|
|
362
|
+
flexBasis={0}
|
|
363
|
+
minHeight={0}
|
|
364
|
+
data-gloom-role="pane-sidebar-list"
|
|
365
|
+
style={{ minHeight: 0, overflowX: "hidden", overflowY: "auto" }}
|
|
366
|
+
>
|
|
367
|
+
{typeof children === "function" ? children({ listWidth: sidebar.listWidth }) : children}
|
|
368
|
+
</Box>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
return <TerminalPaneSidebarList sidebar={sidebar}>{children}</TerminalPaneSidebarList>;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function TerminalPaneSidebarList({ sidebar, children }: {
|
|
375
|
+
sidebar: PaneSidebarContextValue;
|
|
376
|
+
children: ReactNode | ((state: PaneSidebarListRenderState) => ReactNode);
|
|
377
|
+
}) {
|
|
378
|
+
// The host's own ScrollBox, which the pane scroll keys do not drive: the
|
|
379
|
+
// list's keys move its cursor, and the pane's bring the cursor into view.
|
|
380
|
+
const { ScrollBox } = useUiHost();
|
|
381
|
+
const scrollRef = useRef<ScrollBoxRenderable | null>(null);
|
|
382
|
+
const currentRef = useRef<BoxRenderable | null>(null);
|
|
383
|
+
const [scrollbar, setScrollbar] = useState(false);
|
|
384
|
+
const reveal = useCallback(() => afterLayout(() => revealInScrollBox(scrollRef.current, currentRef.current)), []);
|
|
385
|
+
const list = useMemo<PaneSidebarListContextValue>(() => ({
|
|
386
|
+
setCurrent: (node) => {
|
|
387
|
+
currentRef.current = node;
|
|
388
|
+
if (node) reveal();
|
|
389
|
+
},
|
|
390
|
+
}), [reveal]);
|
|
391
|
+
// The scrollbar shows once the rows outgrow the list, and takes a column
|
|
392
|
+
// from them. Read once the whole pass is laid out: the content is at least
|
|
393
|
+
// as tall as the viewport, and is not yet sized to it when the viewport
|
|
394
|
+
// reports.
|
|
395
|
+
const syncScrollbar = useCallback(() => afterLayout(() => {
|
|
396
|
+
const scrollBox = scrollRef.current;
|
|
397
|
+
if (!scrollBox) return;
|
|
398
|
+
const viewportHeight = scrollBox.viewport?.height ?? 0;
|
|
399
|
+
setScrollbar(viewportHeight > 0 && scrollBox.scrollHeight > viewportHeight);
|
|
400
|
+
}), []);
|
|
401
|
+
// A list that opens, or is made shorter or taller, brings the row under the
|
|
402
|
+
// cursor back into view. Rows coming and going, and the scrollbar taking a
|
|
403
|
+
// column, leave the scroll where the wheel put it.
|
|
404
|
+
const viewportHeightRef = useRef(0);
|
|
405
|
+
const syncViewport = useCallback(() => {
|
|
406
|
+
syncScrollbar();
|
|
407
|
+
const height = scrollRef.current?.viewport?.height ?? 0;
|
|
408
|
+
if (height === viewportHeightRef.current) return;
|
|
409
|
+
viewportHeightRef.current = height;
|
|
410
|
+
reveal();
|
|
411
|
+
}, [reveal, syncScrollbar]);
|
|
412
|
+
useEffect(() => observeScrollBoxViewportSize(scrollRef.current, syncViewport), [syncViewport]);
|
|
413
|
+
useEffect(() => observeScrollBoxContentSize(scrollRef.current, syncScrollbar), [syncScrollbar]);
|
|
414
|
+
// In the same frame as the rows narrow or widen for it.
|
|
415
|
+
useLayoutEffect(() => {
|
|
416
|
+
const bar = scrollRef.current?.verticalScrollBar;
|
|
417
|
+
if (bar) bar.visible = scrollbar;
|
|
418
|
+
}, [scrollbar]);
|
|
419
|
+
const listWidth = Math.max(1, sidebar.listWidth - (scrollbar ? 1 : 0));
|
|
420
|
+
const context = useMemo(() => ({ ...sidebar, listWidth }), [sidebar, listWidth]);
|
|
421
|
+
|
|
314
422
|
return (
|
|
315
|
-
<
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
423
|
+
<PaneSidebarContext.Provider value={context}>
|
|
424
|
+
<PaneSidebarListContext.Provider value={list}>
|
|
425
|
+
<ScrollBox
|
|
426
|
+
ref={scrollRef}
|
|
427
|
+
flexGrow={1}
|
|
428
|
+
flexShrink={1}
|
|
429
|
+
flexBasis={0}
|
|
430
|
+
minHeight={0}
|
|
431
|
+
scrollY
|
|
432
|
+
focusable={false}
|
|
433
|
+
verticalScrollbarOptions={{ visible: false }}
|
|
434
|
+
horizontalScrollbarOptions={{ visible: false }}
|
|
435
|
+
data-gloom-role="pane-sidebar-list"
|
|
436
|
+
>
|
|
437
|
+
{typeof children === "function" ? children({ listWidth }) : children}
|
|
438
|
+
</ScrollBox>
|
|
439
|
+
</PaneSidebarListContext.Provider>
|
|
440
|
+
</PaneSidebarContext.Provider>
|
|
326
441
|
);
|
|
327
442
|
}
|
|
328
443
|
|
|
@@ -349,6 +464,8 @@ export function PaneSidebarRow({
|
|
|
349
464
|
}) {
|
|
350
465
|
const { activeBackgroundColor, backgroundColor, keyboardFocused, listWidth } = usePaneSidebarContext();
|
|
351
466
|
const [hovered, setHovered] = useState(false);
|
|
467
|
+
const rowRef = useRef<BoxRenderable>(null);
|
|
468
|
+
usePaneSidebarReveal(rowRef, active);
|
|
352
469
|
const foregroundColor = active
|
|
353
470
|
? colors.selectedText
|
|
354
471
|
: keyboardFocused
|
|
@@ -369,6 +486,7 @@ export function PaneSidebarRow({
|
|
|
369
486
|
|
|
370
487
|
return (
|
|
371
488
|
<Box
|
|
489
|
+
ref={rowRef}
|
|
372
490
|
height={height}
|
|
373
491
|
width={listWidth}
|
|
374
492
|
flexDirection="row"
|
|
@@ -28,7 +28,9 @@ function buildPaneStatusInfo({
|
|
|
28
28
|
stale = false,
|
|
29
29
|
info = EMPTY_STATUS_INFO,
|
|
30
30
|
}: PaneStatusInfoOptions): PaneFooterSegment[] {
|
|
31
|
-
|
|
31
|
+
// A source line that already says its data is stale (`stale (23 days old)`) is not followed by a second `stale`.
|
|
32
|
+
const saysStale = info.some((segment) => segment.asOf && /\bstale\b/.test(segment.parts.map((part) => part.text).join("")));
|
|
33
|
+
return [...info, ...(stale && !saysStale ? [STALE_SEGMENT] : []), ...loadingErrorFooterInfo(loading, error)];
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/**
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
NO_LATCH,
|
|
40
40
|
snapMovedRect,
|
|
41
41
|
snapResizedRect,
|
|
42
|
+
TERMINAL_MAGNET_REST_MS,
|
|
42
43
|
type MagnetDistances,
|
|
43
44
|
type MagnetGlide,
|
|
44
45
|
type MagnetLatch,
|
|
@@ -203,15 +204,16 @@ export function useShellActiveDrag({
|
|
|
203
204
|
return { rect, partners: rects };
|
|
204
205
|
};
|
|
205
206
|
const magnetArea = { x: 0, y: 0, width, height: contentHeight };
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
//
|
|
207
|
+
// The move run again once the pointer rests. A release lands where the
|
|
208
|
+
// pane is drawn: no catch after it.
|
|
209
|
+
const runAgain = event.type === "drag" ? () => { if (dragRef.current === drag) handleRef.current(event); } : undefined;
|
|
210
|
+
// Past the travel speed a release lands the pane where the pointer puts
|
|
211
|
+
// it, its magnets left out (the rest check runs the last move again once
|
|
212
|
+
// the pointer has stopped, so a release then catches). What they hold to
|
|
213
|
+
// still follows every move, so it rests where it would have.
|
|
210
214
|
const travelling = () => {
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
const rest = event.type === "drag" ? () => { if (dragRef.current === drag) handleRef.current(event); } : undefined;
|
|
214
|
-
return memo.pace.travelling({ t: performance.now(), x: preciseX, y: preciseShellY }, magnetDistances, rest);
|
|
215
|
+
if (drag.type !== "pane-drag") return false;
|
|
216
|
+
return memo.pace.travelling({ t: performance.now(), x: preciseX, y: preciseShellY }, magnetDistances, runAgain);
|
|
215
217
|
};
|
|
216
218
|
// Where a move lands the pane (`rect`), and where its magnets hold it as
|
|
217
219
|
// the pointer slows down (`snapped`).
|
|
@@ -224,13 +226,16 @@ export function useShellActiveDrag({
|
|
|
224
226
|
memo.latch = snapped.latch;
|
|
225
227
|
return { rect: travelling() ? rect : snapped.rect, snapped: snapped.rect };
|
|
226
228
|
};
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
//
|
|
230
|
-
// glide on)
|
|
229
|
+
// The moving pane is drawn under the pointer while it moves, and where
|
|
230
|
+
// its magnets hold it once the pointer slows down to place it. The
|
|
231
|
+
// desktop glides between the two (the frames after the pointer stops
|
|
232
|
+
// carry the glide on); the terminal steps onto the magnets, on the move
|
|
233
|
+
// run again once the pointer rests.
|
|
231
234
|
const drawMove = (paneId: string, free: FloatingRect, moved: { rect: FloatingRect; snapped: FloatingRect }) => {
|
|
232
235
|
if (!nativePaneChrome) {
|
|
233
|
-
|
|
236
|
+
const placing = memo.pace.placing(performance.now(), magnetDistances);
|
|
237
|
+
updateDragFloatingRect({ paneId, rect: placing ? moved.snapped : free });
|
|
238
|
+
if (!placing && runAgain) memo.pace.rest(runAgain, TERMINAL_MAGNET_REST_MS);
|
|
234
239
|
return;
|
|
235
240
|
}
|
|
236
241
|
const { snapped } = moved;
|
|
@@ -37,16 +37,17 @@ const MAGNET_RELEASE_PX = 12;
|
|
|
37
37
|
const TERMINAL_MAGNETS: MagnetDistances = { catchX: 1, catchY: 1, releaseX: 2, releaseY: 2 };
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
* a release lands the pane where the
|
|
40
|
+
* Past this pointer speed, in catch distances a second (300 px/s on the
|
|
41
|
+
* desktop, 37.5 cells in the terminal), a release lands the pane where the
|
|
42
|
+
* pointer puts it, its magnets left out.
|
|
42
43
|
*/
|
|
43
44
|
const MAGNET_TRAVEL_SPEED = 300 / MAGNET_CATCH_PX;
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* read as a drag that lags and stutters.
|
|
46
|
+
* Below this pointer speed (60 px/s, about a px a frame) the pointer is
|
|
47
|
+
* placing the pane, and it is drawn where its magnets hold it; faster, it is
|
|
48
|
+
* drawn under the pointer. Drawing the magnets at a hand's usual speed held
|
|
49
|
+
* the pane on each line it crossed, then jumped it up to 18 px (three cells
|
|
50
|
+
* in the terminal), which read as a drag that lags and stutters.
|
|
50
51
|
*/
|
|
51
52
|
const MAGNET_PLACE_SPEED = 60 / MAGNET_CATCH_PX;
|
|
52
53
|
/**
|
|
@@ -59,6 +60,12 @@ const GLIDE_RATE = 35;
|
|
|
59
60
|
const SPEED_WINDOW_MS = 64;
|
|
60
61
|
/** How long the pointer rests before the magnets catch where it stopped, ms. */
|
|
61
62
|
export const MAGNET_REST_MS = 80;
|
|
63
|
+
/**
|
|
64
|
+
* The same in the terminal, which hears from the pointer only as it enters
|
|
65
|
+
* another cell: a hand placing a window there crosses five or so a second, so
|
|
66
|
+
* a pause shorter than that is still a drag.
|
|
67
|
+
*/
|
|
68
|
+
export const TERMINAL_MAGNET_REST_MS = 200;
|
|
62
69
|
|
|
63
70
|
/** Where the pointer was during a move, in cells, and when (ms). */
|
|
64
71
|
interface PointerSample {
|
|
@@ -75,7 +82,7 @@ function trackPointer(track: PointerSample[], sample: PointerSample): void {
|
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
/**
|
|
78
|
-
*
|
|
85
|
+
* When a moving pane's magnets act, over one drag. `travelling`
|
|
79
86
|
* takes each move and says whether the pointer is on its way somewhere; while
|
|
80
87
|
* it is, a release lands the pane where the pointer puts it, and `rest` (the
|
|
81
88
|
* move run again) is set to run once the pointer has stopped for
|
|
@@ -90,6 +97,12 @@ export interface MagnetPace {
|
|
|
90
97
|
travelling(sample: PointerSample, distances: MagnetDistances, rest?: () => void): boolean;
|
|
91
98
|
/** Whether the pointer, as of `now`, moves slowly enough to be placing the pane: its magnets are drawn. */
|
|
92
99
|
placing(now: number, distances: MagnetDistances): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Runs `onRest` once the pointer has stopped for `ms`, unless another event
|
|
102
|
+
* of the drag comes first: the terminal, which draws only when an event
|
|
103
|
+
* comes, draws the magnets that catch where it stopped.
|
|
104
|
+
*/
|
|
105
|
+
rest(onRest: () => void, ms: number): void;
|
|
93
106
|
/** Drops the rest check: another event of the drag came first. */
|
|
94
107
|
cancel(): void;
|
|
95
108
|
/** Forgets the pointer's path, for a new drag. */
|
|
@@ -106,6 +119,17 @@ export function createMagnetPace(): MagnetPace {
|
|
|
106
119
|
rest = null;
|
|
107
120
|
frame = null;
|
|
108
121
|
};
|
|
122
|
+
const restThen = (onRest: () => void, ms = MAGNET_REST_MS) => {
|
|
123
|
+
cancel();
|
|
124
|
+
rest = setTimeout(() => {
|
|
125
|
+
rest = null;
|
|
126
|
+
if (typeof requestAnimationFrame !== "function") return onRest();
|
|
127
|
+
frame = requestAnimationFrame(() => {
|
|
128
|
+
frame = null;
|
|
129
|
+
onRest();
|
|
130
|
+
});
|
|
131
|
+
}, ms);
|
|
132
|
+
};
|
|
109
133
|
return {
|
|
110
134
|
travelling(sample, distances, onRest) {
|
|
111
135
|
cancel();
|
|
@@ -113,19 +137,11 @@ export function createMagnetPace(): MagnetPace {
|
|
|
113
137
|
// The same place again (a rest check, a repeated event) is not a move.
|
|
114
138
|
if (!last || last.x !== sample.x || last.y !== sample.y) trackPointer(track, sample);
|
|
115
139
|
if (pointerSpeed(track, sample.t, distances) <= MAGNET_TRAVEL_SPEED) return false;
|
|
116
|
-
if (onRest)
|
|
117
|
-
rest = setTimeout(() => {
|
|
118
|
-
rest = null;
|
|
119
|
-
if (typeof requestAnimationFrame !== "function") return onRest();
|
|
120
|
-
frame = requestAnimationFrame(() => {
|
|
121
|
-
frame = null;
|
|
122
|
-
onRest();
|
|
123
|
-
});
|
|
124
|
-
}, MAGNET_REST_MS);
|
|
125
|
-
}
|
|
140
|
+
if (onRest) restThen(onRest);
|
|
126
141
|
return true;
|
|
127
142
|
},
|
|
128
143
|
placing: (now, distances) => pointerSpeed(track, now, distances) < MAGNET_PLACE_SPEED,
|
|
144
|
+
rest: restThen,
|
|
129
145
|
cancel,
|
|
130
146
|
reset() {
|
|
131
147
|
cancel();
|