@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
|
@@ -467,6 +467,16 @@ export function FormModalContent({
|
|
|
467
467
|
}
|
|
468
468
|
}, [desktop, showsFields]);
|
|
469
469
|
|
|
470
|
+
// A body its fields fit shows no scrollbar. Left to the scroll box, a bar shown while the body was shorter
|
|
471
|
+
// would stay: it takes the text a column, and a line as wide as the body wraps to a row more than it holds.
|
|
472
|
+
const bodyFits = fieldRowsHeight <= availableRows;
|
|
473
|
+
useLayoutEffect(() => {
|
|
474
|
+
const bar = desktop || !showsFields ? null : scrollRef.current?.verticalScrollBar;
|
|
475
|
+
if (!bar) return;
|
|
476
|
+
if (bodyFits) bar.visible = false;
|
|
477
|
+
else bar.resetVisibilityControl?.();
|
|
478
|
+
}, [bodyFits, desktop, showsFields]);
|
|
479
|
+
|
|
470
480
|
// After layout, so a field that dependsOn just revealed is measured, and
|
|
471
481
|
// again when the body's height changes (an error line takes a row from it).
|
|
472
482
|
useEffect(() => {
|
package/src/components/index.ts
CHANGED
|
@@ -147,7 +147,7 @@ export {
|
|
|
147
147
|
export type {
|
|
148
148
|
ActionRowProps, BadgeProps, BulletListProps, ButtonProps, ButtonVariant, CardProps, CheckboxProps, ChoiceDialogChoice, ColumnGridCell,
|
|
149
149
|
ColumnGridColumn, ColumnGridLink, ColumnGridPairProps, ColumnGridProps, ConfirmDialogOptions, CountryFlagProps,
|
|
150
|
-
DataTableCell, DataTableColumn, DataTableProps, DataTableVisibleRange, DetailScrollBodyProps, DialogFrameProps,
|
|
150
|
+
DataTableCell, DataTableColumn, DataTableColumnReorder, DataTableProps, DataTableVisibleRange, DetailScrollBodyProps, DialogFrameProps,
|
|
151
151
|
DisclosureMarkerProps, DividerProps, EmptyStateProps, FieldGridProps, FieldLabelProps, FieldRing, FieldRingOptions,
|
|
152
152
|
FigureListItem, FigureListProps, GridField,
|
|
153
153
|
IconButtonPressEvent, IconButtonProps, IconName, IconProps, InlineQuickAddRowProps,
|
|
@@ -41,6 +41,7 @@ import { paneMenuButtonAnchor, ShellActionMenuOverlay, type ActionMenuState } fr
|
|
|
41
41
|
import { getPaneFooter } from "./pane/footer";
|
|
42
42
|
import { requestPaneDocs } from "../../docs/requests";
|
|
43
43
|
import { DOCS_PANE_TEMPLATE_ID } from "../../docs/content";
|
|
44
|
+
import { paneHoldsUnsentWork } from "../../state/pane-unsent-work";
|
|
44
45
|
|
|
45
46
|
interface DetachedPaneShellProps {
|
|
46
47
|
pluginRegistry: PluginRegistry;
|
|
@@ -130,6 +131,8 @@ export function DetachedPaneShell({ pluginRegistry, desktopWindowBridge }: Detac
|
|
|
130
131
|
overlayOpen: dialogOpen || menuState !== null,
|
|
131
132
|
editing: inputCaptured,
|
|
132
133
|
close: () => {
|
|
134
|
+
// A draft not sent or an answer coming in keeps the window: the Esc goes on to the pane.
|
|
135
|
+
if (paneHoldsUnsentWork(desktopWindowBridge.paneId)) return false;
|
|
133
136
|
if (!locked) fireAndForget(desktopWindowBridge.closeDetachedPane?.(desktopWindowBridge.paneId), "desktop.closeDetachedPane");
|
|
134
137
|
return true;
|
|
135
138
|
},
|
|
@@ -4,9 +4,12 @@ import {
|
|
|
4
4
|
armDoubleEscapeClose,
|
|
5
5
|
createDoubleEscapeCloseState,
|
|
6
6
|
isEscapeKeptFromClosing,
|
|
7
|
+
isHeldEscapePress,
|
|
7
8
|
offerEscapeTowardClose,
|
|
8
9
|
resetDoubleEscapeClose,
|
|
10
|
+
swallowEscapeAfterSingleClose,
|
|
9
11
|
takeDoubleEscapeClose,
|
|
12
|
+
takeSingleEscapeClose,
|
|
10
13
|
} from "../../utils/double-escape-close";
|
|
11
14
|
|
|
12
15
|
function isEscapeKey(event: KeyEventLike): boolean {
|
|
@@ -24,11 +27,19 @@ interface DoubleEscapeCloseOptions {
|
|
|
24
27
|
dragging?: () => boolean;
|
|
25
28
|
/** Closes the target; false when nothing was closed and the Esc goes on to the pane. */
|
|
26
29
|
close(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Closes the target on one Esc that nothing in it took, where one Esc is
|
|
32
|
+
* enough (a floating window); false where it is not, and the Esc goes on.
|
|
33
|
+
*/
|
|
34
|
+
closeOnSingle?: () => boolean;
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
/**
|
|
30
38
|
* Esc Esc closes the focused pane, even one that could still go back: every
|
|
31
|
-
* Esc is the first half of a pair, whatever the pane did with it.
|
|
39
|
+
* Esc is the first half of a pair, whatever the pane did with it. Where one
|
|
40
|
+
* Esc is enough (`closeOnSingle`, a floating window), an Esc nothing took
|
|
41
|
+
* closes it, and the Esc after it at a double press's pace closes nothing
|
|
42
|
+
* more. Kept out:
|
|
32
43
|
*
|
|
33
44
|
* - an Esc in a text field, or while the pane is editing, unless the pane
|
|
34
45
|
* counts it because nothing typed is left behind (an empty composer);
|
|
@@ -43,10 +54,12 @@ interface DoubleEscapeCloseOptions {
|
|
|
43
54
|
* A surface that takes Esc in a scoped `before` handler (onboarding, a form,
|
|
44
55
|
* key capture) runs ahead of the arming and so never counts.
|
|
45
56
|
*/
|
|
46
|
-
export function useDoubleEscapeClose({ targetId, overlayOpen, editing, dragging, close }: DoubleEscapeCloseOptions): void {
|
|
57
|
+
export function useDoubleEscapeClose({ targetId, overlayOpen, editing, dragging, close, closeOnSingle }: DoubleEscapeCloseOptions): void {
|
|
47
58
|
const stateRef = useRef(createDoubleEscapeCloseState());
|
|
48
59
|
const live = useRef({ targetId, overlayOpen });
|
|
49
60
|
live.current = { targetId, overlayOpen };
|
|
61
|
+
/** Esc presses that came as a held key's, judged before they armed anything. */
|
|
62
|
+
const heldRef = useRef(new WeakSet<object>());
|
|
50
63
|
|
|
51
64
|
useEffect(() => {
|
|
52
65
|
if (overlayOpen) resetDoubleEscapeClose(stateRef.current);
|
|
@@ -60,6 +73,7 @@ export function useDoubleEscapeClose({ targetId, overlayOpen, editing, dragging,
|
|
|
60
73
|
return;
|
|
61
74
|
}
|
|
62
75
|
const at = Date.now();
|
|
76
|
+
if (isHeldEscapePress(state, at, event.repeat)) heldRef.current.add(event);
|
|
63
77
|
offerEscapeTowardClose(event, {
|
|
64
78
|
count: () => {
|
|
65
79
|
if (!live.current.overlayOpen) armDoubleEscapeClose(state, live.current.targetId, at, event.repeat);
|
|
@@ -72,12 +86,29 @@ export function useDoubleEscapeClose({ targetId, overlayOpen, editing, dragging,
|
|
|
72
86
|
// with more to go back through still closes. Not in a text field.
|
|
73
87
|
useShortcut((event) => {
|
|
74
88
|
if (!isEscapeKey(event) || overlayOpen || editing || dragging?.()) return;
|
|
75
|
-
|
|
89
|
+
const now = Date.now();
|
|
90
|
+
if (swallowEscapeAfterSingleClose(stateRef.current, now, event.repeat)) {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
event.stopPropagation();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (takeDoubleEscapeClose(stateRef.current, targetId, now, event.repeat) && close()) {
|
|
76
96
|
event.preventDefault();
|
|
77
97
|
event.stopPropagation();
|
|
78
98
|
}
|
|
79
99
|
}, { phase: "capture" });
|
|
80
100
|
|
|
101
|
+
// One Esc that nothing took (the window had nothing to back out of, no menu
|
|
102
|
+
// to close) closes a floating window, as it does a dialog or Help.
|
|
103
|
+
useShortcut((event) => {
|
|
104
|
+
if (!closeOnSingle || !isEscapeKey(event) || overlayOpen || editing || dragging?.()) return;
|
|
105
|
+
if (isEscapeKeptFromClosing(event) || heldRef.current.has(event)) return;
|
|
106
|
+
if (!closeOnSingle()) return;
|
|
107
|
+
takeSingleEscapeClose(stateRef.current, Date.now());
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
}, { phase: "idle" });
|
|
111
|
+
|
|
81
112
|
// The first: after the scoped surfaces that own their Esc (onboarding, a
|
|
82
113
|
// form, key capture), so theirs never counts, and before the pane.
|
|
83
114
|
useShortcut((event) => {
|
|
@@ -54,19 +54,25 @@ interface FloatingPaneWrapperProps {
|
|
|
54
54
|
children: ReactNode;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* The window's sides, between its title bar and footer, which draw the top
|
|
59
|
+
* and bottom of the frame. Focused or not, so what is under the window never
|
|
60
|
+
* runs into it; focus draws them in the focus colour, as it does the rest.
|
|
61
|
+
*/
|
|
62
|
+
function TerminalFloatingPaneBorder({ width, height, focused }: { width: number; height: number; focused: boolean }) {
|
|
58
63
|
const borderWidth = Math.max(0, Math.floor(width));
|
|
59
64
|
const borderHeight = Math.max(0, Math.floor(height));
|
|
60
65
|
const bodyHeight = Math.max(0, borderHeight - 2);
|
|
61
66
|
if (borderWidth < 2 || bodyHeight <= 0) return null;
|
|
67
|
+
const color = focused ? colors.borderFocused : colors.border;
|
|
62
68
|
|
|
63
69
|
return (
|
|
64
70
|
<>
|
|
65
71
|
<Box position="absolute" top={1} left={0} width={1} height={bodyHeight}>
|
|
66
|
-
<Text fg={
|
|
72
|
+
<Text fg={color} selectable={false}>{"│".repeat(bodyHeight)}</Text>
|
|
67
73
|
</Box>
|
|
68
74
|
<Box position="absolute" top={1} left={borderWidth - 1} width={1} height={bodyHeight}>
|
|
69
|
-
<Text fg={
|
|
75
|
+
<Text fg={color} selectable={false}>{"│".repeat(bodyHeight)}</Text>
|
|
70
76
|
</Box>
|
|
71
77
|
</>
|
|
72
78
|
);
|
|
@@ -186,7 +192,7 @@ export function FloatingPaneWrapper({
|
|
|
186
192
|
/>
|
|
187
193
|
)}
|
|
188
194
|
|
|
189
|
-
{!nativePaneChrome &&
|
|
195
|
+
{!nativePaneChrome && <TerminalFloatingPaneBorder width={width} height={height} focused={focused || windowModeSelected} />}
|
|
190
196
|
|
|
191
197
|
{nativePaneChrome ? (
|
|
192
198
|
<Box
|
|
@@ -1,23 +1,87 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
dockStackTabIds,
|
|
3
|
+
floatingStackMembers,
|
|
4
|
+
getDockedPaneIds,
|
|
5
|
+
hiddenDockTabIds,
|
|
6
|
+
hiddenFloatingTabIds,
|
|
7
|
+
} from "../../../layout/pane-manager";
|
|
2
8
|
import type { PluginRegistry } from "../../../plugins/registry";
|
|
3
9
|
import { findPaneInstance, type LayoutConfig } from "../../../types/config";
|
|
4
10
|
import { collectDisabledPaneIds } from "../shell/visible-layout";
|
|
5
11
|
|
|
12
|
+
interface PaneCycleOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Docked panes whose title bar floating windows hide: focus there could not
|
|
15
|
+
* be seen, so Tab passes them by (`coveredDockedPaneIds`).
|
|
16
|
+
*/
|
|
17
|
+
covered?: ReadonlySet<string>;
|
|
18
|
+
/** Keeps its place in the order whatever covers it, so Tab moves on from where focus is. */
|
|
19
|
+
focusedPaneId?: string | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The panes Tab and Shift+Tab step through, docked then floating: every pane
|
|
24
|
+
* that shows, a stack once (the tab it shows, never one it hides), and no
|
|
25
|
+
* docked pane a floating window hides. When nothing but the covered panes is
|
|
26
|
+
* left, those.
|
|
27
|
+
*/
|
|
6
28
|
export function getVisiblePaneCycleOrder(
|
|
7
29
|
layout: LayoutConfig,
|
|
8
30
|
pluginRegistry: PluginRegistry,
|
|
9
31
|
disabledPlugins: readonly string[],
|
|
32
|
+
{ covered, focusedPaneId = null }: PaneCycleOptions = {},
|
|
10
33
|
): string[] {
|
|
11
34
|
const disabledTypes = collectDisabledPaneIds(pluginRegistry, disabledPlugins);
|
|
35
|
+
const hiddenTabs = new Set([...hiddenDockTabIds(layout), ...hiddenFloatingTabIds(layout.floating)]);
|
|
12
36
|
const isVisiblePane = (instanceId: string) => {
|
|
13
37
|
const instance = findPaneInstance(layout, instanceId);
|
|
14
38
|
return !!instance
|
|
39
|
+
&& (!hiddenTabs.has(instanceId) || instanceId === focusedPaneId)
|
|
15
40
|
&& !disabledTypes.has(instance.paneId)
|
|
16
41
|
&& pluginRegistry.panes.has(instance.paneId);
|
|
17
42
|
};
|
|
18
43
|
|
|
19
|
-
|
|
44
|
+
const visible = [
|
|
20
45
|
...getDockedPaneIds(layout),
|
|
21
46
|
...layout.floating.map((entry) => entry.instanceId),
|
|
22
47
|
].filter(isVisiblePane);
|
|
48
|
+
if (!covered || covered.size === 0) return visible;
|
|
49
|
+
const shown = visible.filter((instanceId) => instanceId === focusedPaneId || !covered.has(instanceId));
|
|
50
|
+
return shown.some((instanceId) => instanceId !== focusedPaneId) ? shown : visible;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The tab of `paneId`'s stack, docked or floating, `direction` steps from it
|
|
55
|
+
* in tab order, round from the last to the first: what the next- and
|
|
56
|
+
* previous-tab keys show, since Tab passes the tabs a stack hides. Null when
|
|
57
|
+
* the pane is in no stack.
|
|
58
|
+
*/
|
|
59
|
+
export function adjacentStackTabId(layout: LayoutConfig, paneId: string | null, direction: 1 | -1): string | null {
|
|
60
|
+
if (!paneId) return null;
|
|
61
|
+
const docked = dockStackTabIds(layout, paneId);
|
|
62
|
+
const tabs = docked.length > 1 ? docked : floatingStackMembers(layout.floating, paneId).map((entry) => entry.instanceId);
|
|
63
|
+
const index = tabs.indexOf(paneId);
|
|
64
|
+
if (tabs.length < 2 || index < 0) return null;
|
|
65
|
+
return tabs[(index + direction + tabs.length) % tabs.length]!;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const coveredSources = new Set<() => ReadonlySet<string>>();
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The shell says which docked panes its floating windows hide, as it lays
|
|
72
|
+
* them out; Tab reads it when it moves focus. Returns the unregister.
|
|
73
|
+
*/
|
|
74
|
+
export function registerCoveredPaneSource(source: () => ReadonlySet<string>): () => void {
|
|
75
|
+
coveredSources.add(source);
|
|
76
|
+
return () => {
|
|
77
|
+
coveredSources.delete(source);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The docked panes the window's floating windows hide now (`registerCoveredPaneSource`). */
|
|
82
|
+
export function coveredDockedPaneIds(): ReadonlySet<string> {
|
|
83
|
+
if (coveredSources.size === 0) return new Set();
|
|
84
|
+
const covered = new Set<string>();
|
|
85
|
+
for (const source of coveredSources) for (const id of source()) covered.add(id);
|
|
86
|
+
return covered;
|
|
23
87
|
}
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
separatesPaneFooterSegments,
|
|
19
19
|
hasPaneFooterContent,
|
|
20
20
|
layoutPaneFooterHintRow,
|
|
21
|
+
paneFooterInfoWidth,
|
|
21
22
|
paneHintTitle,
|
|
22
23
|
terminalHintMetrics,
|
|
23
24
|
totalHintsWidth,
|
|
@@ -51,6 +52,9 @@ export {
|
|
|
51
52
|
usePaneMenuItems,
|
|
52
53
|
} from "./registration";
|
|
53
54
|
|
|
55
|
+
/** Terminal: blank cells between a framed footer's last hint and the frame's end. */
|
|
56
|
+
const FOOTER_FRAME_GAP = 1;
|
|
57
|
+
|
|
54
58
|
function footerToneColor(part: PaneFooterPart): string {
|
|
55
59
|
if (part.color) return part.color;
|
|
56
60
|
switch (part.tone) {
|
|
@@ -86,10 +90,11 @@ function terminalSegmentKey(segment: PaneFooterSegment, focused: boolean): strin
|
|
|
86
90
|
: "";
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
/** Columns an icon segment keeps when hints crowd the footer. */
|
|
93
|
+
/** Columns an icon segment keeps when hints crowd the footer: in the terminal, what it draws (`◷15m`, `⚠[!]`). */
|
|
90
94
|
function iconSegmentReserve(segment: PaneFooterSegment, focused: boolean, nativePaneChrome: boolean): number {
|
|
91
95
|
if (!segment.icon) return 0;
|
|
92
|
-
|
|
96
|
+
if (nativePaneChrome) return 3;
|
|
97
|
+
return Math.max(3, paneFooterInfoWidth([segment]) + terminalSegmentKey(segment, focused).length);
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
function SegmentView({ segment, focused }: { segment: PaneFooterSegment; focused: boolean }) {
|
|
@@ -265,12 +270,15 @@ function FooterContent({
|
|
|
265
270
|
width,
|
|
266
271
|
showBackground = true,
|
|
267
272
|
nativePaneChrome = false,
|
|
273
|
+
trailingGap = 0,
|
|
268
274
|
}: {
|
|
269
275
|
footer: CombinedPaneFooter;
|
|
270
276
|
focused: boolean;
|
|
271
277
|
width?: number;
|
|
272
278
|
showBackground?: boolean;
|
|
273
279
|
nativePaneChrome?: boolean;
|
|
280
|
+
/** Blank cells of the band after the hints, past `width`, so they never touch the frame. */
|
|
281
|
+
trailingGap?: number;
|
|
274
282
|
}) {
|
|
275
283
|
const hasInfo = footer.info.length > 0;
|
|
276
284
|
const actionableHints = focused ? footer.hints.filter((hint) => !hint.disabled) : [];
|
|
@@ -283,8 +291,10 @@ function FooterContent({
|
|
|
283
291
|
const keyLabel = useShortcutLabel();
|
|
284
292
|
const { cellWidthPx = 8 } = useUiCapabilities();
|
|
285
293
|
const metrics = nativePaneChrome ? desktopHintMetrics(cellWidthPx) : terminalHintMetrics(keyLabel);
|
|
294
|
+
// A segment with shorter forms takes the longest that fits beside the hints, gaps and terminal keys included.
|
|
295
|
+
const keysWidth = nativePaneChrome ? 0 : footer.info.reduce((total, segment) => total + terminalSegmentKey(segment, focused).length, 0);
|
|
286
296
|
const row = availableWidth !== null
|
|
287
|
-
? layoutPaneFooterHintRow({ ...footer, hints: actionableHints }, availableWidth, iconReserve, metrics)
|
|
297
|
+
? layoutPaneFooterHintRow({ ...footer, hints: actionableHints }, availableWidth, iconReserve, metrics, { terminal: !nativePaneChrome, keysWidth })
|
|
288
298
|
: null;
|
|
289
299
|
const shownHints = row?.hints ?? actionableHints;
|
|
290
300
|
const overflowHints = row?.overflow ?? [];
|
|
@@ -293,9 +303,7 @@ function FooterContent({
|
|
|
293
303
|
const infoWidth = availableWidth !== null && hasInfo
|
|
294
304
|
? (row?.infoWidth ?? Math.max(0, availableWidth - hintsWidth))
|
|
295
305
|
: undefined;
|
|
296
|
-
|
|
297
|
-
const keysWidth = nativePaneChrome ? 0 : footer.info.reduce((total, segment) => total + terminalSegmentKey(segment, focused).length, 0);
|
|
298
|
-
const info = infoWidth != null ? fitPaneFooterInfo(footer.info, infoWidth - keysWidth, { besideHints: hasHints }) : footer.info;
|
|
306
|
+
const info = infoWidth != null ? fitPaneFooterInfo(footer.info, infoWidth - keysWidth, { besideHints: hasHints, terminal: !nativePaneChrome }) : footer.info;
|
|
299
307
|
const lastTextIndex = info.findLastIndex((segment) => !segment.icon);
|
|
300
308
|
|
|
301
309
|
if (!hasInfo && !hasHints) {
|
|
@@ -312,6 +320,7 @@ function FooterContent({
|
|
|
312
320
|
flexDirection="row"
|
|
313
321
|
justifyContent="space-between"
|
|
314
322
|
overflow="hidden"
|
|
323
|
+
paddingRight={trailingGap > 0 ? trailingGap : undefined}
|
|
315
324
|
backgroundColor={backgroundColor}
|
|
316
325
|
>
|
|
317
326
|
{hasInfo && (
|
|
@@ -428,16 +437,21 @@ export function PaneFooterBar({
|
|
|
428
437
|
}
|
|
429
438
|
|
|
430
439
|
if (focused || showBorder) {
|
|
431
|
-
|
|
440
|
+
// The row ends as the title bar does (` x ─┐`): the last hint, a blank, then the rule's last dash
|
|
441
|
+
// and the corner, or the floating pane's `─◢` in the cells it reserves. A hint against the dash
|
|
442
|
+
// read as one word (`ticker─`).
|
|
443
|
+
const ruleEnd = reservedRight > 0 ? "" : "─┘";
|
|
444
|
+
const rowWidth = Math.max(0, Math.floor(width) - 1 - reservedRight - ruleEnd.length);
|
|
445
|
+
const contentWidth = Math.max(0, rowWidth - FOOTER_FRAME_GAP);
|
|
432
446
|
return (
|
|
433
447
|
<Box height={1} width={width} flexDirection="row" data-gloom-role="pane-footer" data-focused={focused ? "true" : "false"} data-empty={empty ? "true" : "false"}>
|
|
434
448
|
<Text fg={borderColor} selectable={false}>└</Text>
|
|
435
|
-
<Box width={
|
|
449
|
+
<Box width={rowWidth} height={1} overflow="hidden">
|
|
436
450
|
{empty
|
|
437
|
-
? <Text fg={borderColor} selectable={false}>{"─".repeat(
|
|
438
|
-
: <FooterContent footer={resolvedFooter} focused={focused} width={contentWidth} />}
|
|
451
|
+
? <Text fg={borderColor} selectable={false}>{"─".repeat(rowWidth)}</Text>
|
|
452
|
+
: <FooterContent footer={resolvedFooter} focused={focused} width={contentWidth} trailingGap={rowWidth - contentWidth} />}
|
|
439
453
|
</Box>
|
|
440
|
-
{
|
|
454
|
+
{ruleEnd && <Text fg={borderColor} selectable={false}>{ruleEnd}</Text>}
|
|
441
455
|
</Box>
|
|
442
456
|
);
|
|
443
457
|
}
|
|
@@ -344,6 +344,11 @@ export function totalHintsWidth(hints: readonly Pick<PaneHint, "key" | "label" |
|
|
|
344
344
|
return Math.ceil(hints.reduce((total, hint, index) => total + (index > 0 ? metrics.gap : 0) + metrics.width(hint), 0) - 1e-9);
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
/** Cells `segments` take side by side, separators and gaps included, the terminal's keys aside. */
|
|
348
|
+
export function paneFooterInfoWidth(segments: readonly PaneFooterSegment[]): number {
|
|
349
|
+
return infoTextWidth(segments);
|
|
350
|
+
}
|
|
351
|
+
|
|
347
352
|
function infoTextWidth(segments: readonly PaneFooterSegment[]): number {
|
|
348
353
|
if (segments.length === 0) return 0;
|
|
349
354
|
return segments.reduce((total, segment, index) => {
|
|
@@ -371,22 +376,33 @@ function stepDownTogether(info: PaneFooterSegment[], width: number): PaneFooterS
|
|
|
371
376
|
return fitted;
|
|
372
377
|
}
|
|
373
378
|
|
|
379
|
+
/** A warning, an icon or a pressable segment, which a row too narrow never cuts or leaves out. */
|
|
380
|
+
function holdsItsPlace(segment: PaneFooterSegment): boolean {
|
|
381
|
+
return !!segment.icon || !!segment.onPress || segment.parts.some((part) => part.tone === "warning" || part.tone === "negative");
|
|
382
|
+
}
|
|
383
|
+
|
|
374
384
|
/**
|
|
375
385
|
* A trailing status cut mid-word reads as part of the hints beside it ("quote
|
|
376
|
-
* 12h t[x] put"):
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
386
|
+
* 12h t[x] put"): the last segment that does not fit ends in an ellipsis (a
|
|
387
|
+
* column short of the hints when it ends the row), or is left out when less
|
|
388
|
+
* than half of it would show, until the row fits or only the first `keep`
|
|
389
|
+
* segments are left to give way. A warning, an icon or a pressable segment
|
|
390
|
+
* holds its place, clipped by the row if it must be; in the terminal
|
|
391
|
+
* (`pastHeld`) the text before it gives way instead (a delay clock after the
|
|
392
|
+
* count it qualifies), where the desktop stops there.
|
|
380
393
|
*/
|
|
381
|
-
function trimTrailing(info: PaneFooterSegment[], width: number, keep: number): PaneFooterSegment[] {
|
|
394
|
+
function trimTrailing(info: PaneFooterSegment[], width: number, keep: number, pastHeld: boolean): PaneFooterSegment[] {
|
|
382
395
|
let fitted = info;
|
|
383
|
-
while (
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
396
|
+
while (infoTextWidth(fitted) > width) {
|
|
397
|
+
const index = pastHeld
|
|
398
|
+
? fitted.findLastIndex((segment) => !holdsItsPlace(segment))
|
|
399
|
+
: holdsItsPlace(fitted.at(-1)!) ? -1 : fitted.length - 1;
|
|
400
|
+
if (index < keep) break;
|
|
401
|
+
const segment = fitted[index]!;
|
|
402
|
+
const own = infoTextWidth([segment]);
|
|
403
|
+
const room = width - (infoTextWidth(fitted) - own) - (index === fitted.length - 1 ? 1 : 0);
|
|
404
|
+
if (room * 2 >= own) return [...fitted.slice(0, index), clipSegment(segment, room), ...fitted.slice(index + 1)];
|
|
405
|
+
fitted = [...fitted.slice(0, index), ...fitted.slice(index + 1)];
|
|
390
406
|
}
|
|
391
407
|
return fitted;
|
|
392
408
|
}
|
|
@@ -403,18 +419,22 @@ function trimTrailing(info: PaneFooterSegment[], width: number, keep: number): P
|
|
|
403
419
|
* With no hints beside it (a pane picture's footer), the row clips the rest,
|
|
404
420
|
* so a frame that fits its own status line sees it overflow.
|
|
405
421
|
*/
|
|
406
|
-
export function fitPaneFooterInfo(
|
|
422
|
+
export function fitPaneFooterInfo(
|
|
423
|
+
info: PaneFooterSegment[],
|
|
424
|
+
width: number,
|
|
425
|
+
{ besideHints = true, terminal = false }: { besideHints?: boolean; terminal?: boolean } = {},
|
|
426
|
+
): PaneFooterSegment[] {
|
|
407
427
|
// How long ago the data loaded goes first, whole: a cut age (`fetched just`) says nothing.
|
|
408
428
|
if (infoTextWidth(info) > width && info.some((segment) => segment.age)) {
|
|
409
|
-
return fitPaneFooterInfo(info.filter((segment) => !segment.age), width, { besideHints });
|
|
429
|
+
return fitPaneFooterInfo(info.filter((segment) => !segment.age), width, { besideHints, terminal });
|
|
410
430
|
}
|
|
411
431
|
if (!besideHints) return stepDownTogether(info, width);
|
|
412
432
|
const lastWithVariants = info.findLastIndex((segment) => (segment.variants?.length ?? 0) > 0);
|
|
413
433
|
if (lastWithVariants >= 0 && lastWithVariants < info.length - 1 && infoTextWidth(info) > width) {
|
|
414
|
-
const trimmed = trimTrailing(info, width, lastWithVariants + 1);
|
|
434
|
+
const trimmed = trimTrailing(info, width, lastWithVariants + 1, terminal);
|
|
415
435
|
if (infoTextWidth(trimmed) <= width) return trimmed;
|
|
416
436
|
}
|
|
417
|
-
return trimTrailing(stepDownTogether(info, width), width, 1);
|
|
437
|
+
return trimTrailing(stepDownTogether(info, width), width, 1, terminal);
|
|
418
438
|
}
|
|
419
439
|
|
|
420
440
|
/** A segment cut to `width` behind an ellipsis, each part keeping its tone; the full text stays as its title. */
|
|
@@ -453,12 +473,28 @@ export interface PaneFooterHintRow {
|
|
|
453
473
|
infoWidth: number;
|
|
454
474
|
}
|
|
455
475
|
|
|
456
|
-
|
|
476
|
+
export interface PaneFooterHintRowOptions {
|
|
477
|
+
/** The terminal's row (layoutPaneFooterHintRow); the desktop's leaves it out. */
|
|
478
|
+
terminal?: boolean;
|
|
479
|
+
/** What the terminal draws besides the status's own text (`[!]` after an icon). */
|
|
480
|
+
keysWidth?: number;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Hints that fit this footer row, and the rest, which a More control owns.
|
|
485
|
+
* The status gives way to the hints down to its floor (INFO_FLOOR_CHARS,
|
|
486
|
+
* WARNING_FLOOR_CHARS, or `iconReserve`, the cells its icons take). In the
|
|
487
|
+
* terminal the status is kept whole while the first hint and More still fit
|
|
488
|
+
* beside it, hints going under More from the right first, and the status and
|
|
489
|
+
* the hints keep a column between them, so they never read as one
|
|
490
|
+
* ("777 matchesU◷1[m]etric").
|
|
491
|
+
*/
|
|
457
492
|
export function layoutPaneFooterHintRow(
|
|
458
493
|
footer: CombinedPaneFooter,
|
|
459
494
|
contentWidth: number,
|
|
460
495
|
iconReserve = 0,
|
|
461
496
|
metrics: PaneHintMetrics = TERMINAL_HINT_METRICS,
|
|
497
|
+
{ terminal = false, keysWidth = 0 }: PaneFooterHintRowOptions = {},
|
|
462
498
|
): PaneFooterHintRow {
|
|
463
499
|
const width = Math.max(0, Math.floor(contentWidth));
|
|
464
500
|
const hints = footer.hints.filter((hint) => !hint.disabled);
|
|
@@ -469,8 +505,14 @@ export function layoutPaneFooterHintRow(
|
|
|
469
505
|
const textFloor = footer.info.length === 0 ? 0
|
|
470
506
|
: warning || infoChars <= WARNING_FLOOR_CHARS ? Math.min(WARNING_FLOOR_CHARS, infoChars)
|
|
471
507
|
: INFO_FLOOR_CHARS;
|
|
472
|
-
const
|
|
473
|
-
const
|
|
508
|
+
const status = footer.info.length === 0 ? 0 : infoChars + keysWidth;
|
|
509
|
+
const leastHints = hints.length === 0 ? 0 : Math.min(
|
|
510
|
+
totalHintsWidth(hints, metrics),
|
|
511
|
+
Math.ceil(metrics.width(hints[0]!) + metrics.gap + moreControl(Number.POSITIVE_INFINITY).width),
|
|
512
|
+
);
|
|
513
|
+
const wholeStatus = terminal && status > 0 && status + (leastHints > 0 ? HINT_GAP + leastHints : 0) <= width;
|
|
514
|
+
const infoFloor = Math.min(width, wholeStatus ? status : Math.max(iconReserve, textFloor));
|
|
515
|
+
const hintBudget = Math.max(0, width - infoFloor - (infoFloor > 0 && hints.length > 0 ? HINT_GAP : 0));
|
|
474
516
|
const more = moreControl(hintBudget);
|
|
475
517
|
let visible = hints;
|
|
476
518
|
let overflow: PaneHint[] = [];
|
|
@@ -495,7 +537,7 @@ export function layoutPaneFooterHintRow(
|
|
|
495
537
|
moreLabel: more.label,
|
|
496
538
|
moreWidth: more.width,
|
|
497
539
|
hintsWidth,
|
|
498
|
-
infoWidth: Math.max(0, width - hintsWidth),
|
|
540
|
+
infoWidth: Math.max(0, width - hintsWidth - (terminal && footer.info.length > 0 && hintsWidth > 0 ? HINT_GAP : 0)),
|
|
499
541
|
};
|
|
500
542
|
}
|
|
501
543
|
|