@gloom-sh/terminal 0.20.10 → 0.20.11
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 +1 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
- package/src/api-client/socket-connection.ts +355 -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 +150 -983
- 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/components/chart/native/kitty/manager.ts +2 -0
- package/src/components/chart/native/surface/manager.ts +211 -11
- 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/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/pane/footer/index.tsx +25 -11
- package/src/components/layout/pane/footer/model.ts +62 -20
- package/src/components/layout/pane/sidebar.tsx +125 -15
- package/src/components/layout/shell/active-drag.ts +18 -13
- package/src/components/layout/shell/drag/magnets.ts +34 -18
- package/src/components/ticker/list-table-view.tsx +5 -0
- 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 +267 -23
- package/src/components/ui/data-table/opentui/model.ts +43 -4
- package/src/components/ui/data-table/types.ts +49 -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/table-layout.ts +120 -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/market-data/coordinator/index.ts +4 -3
- package/src/market-data/coordinator/quotes.ts +12 -4
- package/src/market-data/quotes/freshness.ts +12 -0
- package/src/market-data/quotes/live-valuation.ts +1 -1
- package/src/market-data/quotes/regular-session-valuation.ts +1 -1
- package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
- package/src/plugins/builtin/broker-manager/index.tsx +6 -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/chat/sidebar.tsx +33 -16
- package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
- 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/futures/index.tsx +15 -1
- package/src/plugins/builtin/futures/table.tsx +1 -1
- package/src/plugins/builtin/fx-matrix/index.tsx +2 -0
- package/src/plugins/builtin/holders/pane.tsx +30 -20
- package/src/plugins/builtin/iv-history/events.ts +5 -0
- package/src/plugins/builtin/iv-history/headless.ts +7 -2
- package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
- package/src/plugins/builtin/macro-day/headless.ts +12 -3
- package/src/plugins/builtin/options/view.tsx +2 -0
- 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/pane/index.tsx +13 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +5 -0
- package/src/plugins/builtin/rate-path/pane.tsx +2 -0
- package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
- package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
- package/src/plugins/builtin/seasonality/pane.tsx +2 -1
- 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/vol-surface/heat-grid.tsx +2 -1
- package/src/plugins/builtin/vol-surface/pane.tsx +2 -1
- package/src/plugins/builtin/world-indices/index.tsx +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +2 -1
- 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/styles.css +22 -0
- 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/state/app/context/index.tsx +22 -0
- package/src/test-support/app-store.ts +24 -1
- package/src/time-series/live-quotes.ts +3 -9
- package/src/ui/host.tsx +18 -0
- package/src/ui/pointer-drag.ts +11 -2
- package/src/utils/fundamentals.ts +14 -3
- package/src/utils/share-multiples.cases.json +780 -2
- package/src/utils/share-multiples.ts +154 -24
|
@@ -4,6 +4,9 @@ import { useOptionalDialog, type PromptContext } from "../../ui/dialog";
|
|
|
4
4
|
import { usePaneMenuItems } from "../layout/pane/footer";
|
|
5
5
|
import { ChoiceDialog } from "../ui/choice-dialog";
|
|
6
6
|
import type { DataTableColumn } from "../ui";
|
|
7
|
+
import type { ContextMenuItem } from "../../types/context-menu";
|
|
8
|
+
|
|
9
|
+
const NO_ITEMS: readonly ContextMenuItem[] = [];
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* A sortable table's header clicks, for the keyboard: "Sort by…" in the pane
|
|
@@ -17,6 +20,7 @@ export function useDataTableSortMenu({
|
|
|
17
20
|
sortDirection,
|
|
18
21
|
onHeaderClick,
|
|
19
22
|
onSortChange,
|
|
23
|
+
columnItems = NO_ITEMS,
|
|
20
24
|
}: {
|
|
21
25
|
enabled: boolean;
|
|
22
26
|
columns: DataTableColumn[];
|
|
@@ -25,6 +29,8 @@ export function useDataTableSortMenu({
|
|
|
25
29
|
onHeaderClick: (columnId: string) => void;
|
|
26
30
|
/** Sets a direction outright, for a header click that cycles through "unsorted". */
|
|
27
31
|
onSortChange?: (columnId: string, direction: "asc" | "desc") => void;
|
|
32
|
+
/** The table's column entries (Move Column…, Reset Columns), listed with its sort. */
|
|
33
|
+
columnItems?: readonly ContextMenuItem[];
|
|
28
34
|
}) {
|
|
29
35
|
const dialog = useOptionalDialog();
|
|
30
36
|
const registrationId = `data-table-sort:${useId()}`;
|
|
@@ -39,7 +45,7 @@ export function useDataTableSortMenu({
|
|
|
39
45
|
const sortableColumns = columns.filter((column) => column.label.trim().length > 0);
|
|
40
46
|
|
|
41
47
|
usePaneMenuItems(registrationId, () => {
|
|
42
|
-
if (!enabled || !dialog || sortableColumns.length === 0) return null;
|
|
48
|
+
if (!enabled || !dialog || sortableColumns.length === 0) return columnItems.length > 0 ? [...columnItems] : null;
|
|
43
49
|
const chooseColumn = async () => {
|
|
44
50
|
const current = latest.current;
|
|
45
51
|
const arrow = current.sortDirection === "asc" ? "▲" : "▼";
|
|
@@ -70,6 +76,7 @@ export function useDataTableSortMenu({
|
|
|
70
76
|
...(sortColumnId
|
|
71
77
|
? [{ id: "sort-reverse", label: "Reverse Sort", onSelect: reverse }]
|
|
72
78
|
: []),
|
|
79
|
+
...columnItems,
|
|
73
80
|
];
|
|
74
|
-
}, [dialog, enabled, sortColumnId, sortableColumns.length]);
|
|
81
|
+
}, [columnItems, dialog, enabled, sortColumnId, sortableColumns.length]);
|
|
75
82
|
}
|
|
@@ -13,7 +13,9 @@ import { useBeforeShortcut, useShortcut } from "../../react/input";
|
|
|
13
13
|
import { isPlainKey, isPlainKeyboardEvent } from "../../utils/keyboard";
|
|
14
14
|
import { DataTable, PaneStatusBody, type DataTableColumn, type DataTableProps, type PaneStatusBodyProps } from "../ui";
|
|
15
15
|
import { useDataTableSortMenu } from "./sort-menu";
|
|
16
|
-
import {
|
|
16
|
+
import { useDataTableColumnMenuItems } from "./column-menu";
|
|
17
|
+
import { drawnTableColumns, tableFreezesFirstColumn, tableRevealLeft, tableScrollStep } from "../ui/table-layout";
|
|
18
|
+
import { useDataTableColumnOrder } from "../ui/data-table/use-column-order";
|
|
17
19
|
import {
|
|
18
20
|
TableViewFrame,
|
|
19
21
|
useResetTableScroll,
|
|
@@ -211,13 +213,31 @@ export function DataTableView<
|
|
|
211
213
|
...tableProps
|
|
212
214
|
}: DataTableViewProps<T, C>) {
|
|
213
215
|
const onHeaderClick = tableProps.onHeaderClick;
|
|
216
|
+
// Ordered here, so a sideways step and a revealed column count the columns as they are drawn.
|
|
217
|
+
const columnOrder = useDataTableColumnOrder(
|
|
218
|
+
tableProps.columns,
|
|
219
|
+
tableProps.onColumnMove ? false : tableProps.columnReorder,
|
|
220
|
+
{ menu: false },
|
|
221
|
+
);
|
|
222
|
+
const columns = columnOrder.columns;
|
|
223
|
+
const onColumnMove = tableProps.onColumnMove ?? columnOrder.onColumnMove;
|
|
224
|
+
const anchoredColumns = tableProps.onColumnMove ? tableProps.anchoredColumns ?? 1 : columnOrder.anchoredColumns;
|
|
225
|
+
const columnItems = useDataTableColumnMenuItems({
|
|
226
|
+
enabled: focused && keyboardNavigation,
|
|
227
|
+
columns,
|
|
228
|
+
anchoredColumns,
|
|
229
|
+
onColumnMove,
|
|
230
|
+
customized: columnOrder.customized,
|
|
231
|
+
reset: columnOrder.reset,
|
|
232
|
+
});
|
|
214
233
|
useDataTableSortMenu({
|
|
215
234
|
enabled: focused && keyboardNavigation && !!onHeaderClick && (sortable ?? true),
|
|
216
|
-
columns: isColumnSortable ?
|
|
235
|
+
columns: isColumnSortable ? columns.filter(isColumnSortable) : columns,
|
|
217
236
|
sortColumnId: tableProps.sortColumnId ?? null,
|
|
218
237
|
sortDirection: tableProps.sortDirection ?? "asc",
|
|
219
238
|
onHeaderClick: onHeaderClick ?? ignoreHeaderClick,
|
|
220
239
|
onSortChange,
|
|
240
|
+
columnItems,
|
|
221
241
|
});
|
|
222
242
|
const {
|
|
223
243
|
effectiveHeaderScrollRef,
|
|
@@ -697,13 +717,15 @@ export function DataTableView<
|
|
|
697
717
|
// At either edge the key is still the table's, so it never falls through
|
|
698
718
|
// to switch a tab.
|
|
699
719
|
stopTableKey(event);
|
|
720
|
+
// The columns in their order, at the widths the terminal's fit drew them.
|
|
721
|
+
const drawn = drawnTableColumns.get(body) ?? columns;
|
|
700
722
|
const nextLeft = tableScrollStep({
|
|
701
|
-
columns:
|
|
723
|
+
columns: drawn,
|
|
702
724
|
columnGap: tableProps.columnGap,
|
|
703
725
|
horizontalPadding: tableProps.horizontalPadding,
|
|
704
726
|
frozenFirstColumn: tableFreezesFirstColumn({
|
|
705
727
|
freezeFirstColumn: tableProps.freezeFirstColumn,
|
|
706
|
-
columns:
|
|
728
|
+
columns: drawn,
|
|
707
729
|
columnGap: tableProps.columnGap,
|
|
708
730
|
horizontalPadding: tableProps.horizontalPadding,
|
|
709
731
|
viewportWidth,
|
|
@@ -725,7 +747,7 @@ export function DataTableView<
|
|
|
725
747
|
// The column asked for, in the middle of the scrolled columns once the body has its width. Keyed on the
|
|
726
748
|
// column and the pane's width only: a refresh that resizes a column to its new figures, or a scroll the
|
|
727
749
|
// reader made with Shift+arrows, stays where it is. An empty table waits for its rows.
|
|
728
|
-
const revealColumnIndex = revealColumnId == null ? -1 :
|
|
750
|
+
const revealColumnIndex = revealColumnId == null ? -1 : columns.findIndex((column) => column.id === revealColumnId);
|
|
729
751
|
const revealKey = revealColumnIndex < 0 ? null : `${revealColumnIndex}:${rootWidth ?? ""}`;
|
|
730
752
|
const revealedKeyRef = useRef<string | null>(null);
|
|
731
753
|
const hasRows = tableProps.items.length > 0;
|
|
@@ -742,7 +764,8 @@ export function DataTableView<
|
|
|
742
764
|
if (scrollWidth > 0) revealedKeyRef.current = revealKey;
|
|
743
765
|
return scrollWidth > 0;
|
|
744
766
|
}
|
|
745
|
-
|
|
767
|
+
// The columns in their order, at the widths the terminal's fit drew them.
|
|
768
|
+
const shared = { columns: drawnTableColumns.get(body) ?? columns, columnGap: tableProps.columnGap, horizontalPadding: tableProps.horizontalPadding };
|
|
746
769
|
const nextLeft = tableRevealLeft({ ...shared, columnIndex: revealColumnIndex, viewportWidth, maxLeft,
|
|
747
770
|
frozenFirstColumn: tableFreezesFirstColumn({ ...shared, freezeFirstColumn: tableProps.freezeFirstColumn, viewportWidth, overflows: true }) });
|
|
748
771
|
if (nextLeft !== body.scrollLeft) {
|
|
@@ -811,6 +834,10 @@ export function DataTableView<
|
|
|
811
834
|
>
|
|
812
835
|
{bodyStatusShown(status) ? <PaneStatusBody {...status} /> : <DataTable<T, C>
|
|
813
836
|
{...tableProps}
|
|
837
|
+
columns={columns}
|
|
838
|
+
columnReorder={false}
|
|
839
|
+
onColumnMove={onColumnMove}
|
|
840
|
+
anchoredColumns={anchoredColumns}
|
|
814
841
|
headerScrollRef={effectiveHeaderScrollRef}
|
|
815
842
|
scrollRef={effectiveScrollRef}
|
|
816
843
|
syncHeaderScroll={effectiveSyncHeaderScroll}
|
|
@@ -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,
|
|
@@ -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
|
|
|
@@ -1,5 +1,7 @@
|
|
|
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
7
|
import { blendHex, colors, hoverBg } from "../../../theme/colors";
|
|
@@ -37,7 +39,7 @@ const PaneSidebarContext = createContext<PaneSidebarContextValue | null>(null);
|
|
|
37
39
|
|
|
38
40
|
function usePaneSidebarContext(): PaneSidebarContextValue {
|
|
39
41
|
const context = useContext(PaneSidebarContext);
|
|
40
|
-
if (!context) throw new Error("PaneSidebarRow and PaneSidebarAction must be rendered inside PaneSidebar.");
|
|
42
|
+
if (!context) throw new Error("PaneSidebarList, PaneSidebarRow and PaneSidebarAction must be rendered inside PaneSidebar.");
|
|
41
43
|
return context;
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -309,20 +311,125 @@ export function PaneSidebar({
|
|
|
309
311
|
);
|
|
310
312
|
}
|
|
311
313
|
|
|
312
|
-
|
|
314
|
+
interface PaneSidebarListContextValue {
|
|
315
|
+
/** Marks `node` as the row the list keeps in view, and brings it there. */
|
|
316
|
+
setCurrent: (node: BoxRenderable | null) => void;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const PaneSidebarListContext = createContext<PaneSidebarListContextValue | null>(null);
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Keeps the row `ref` is on in view while it is `current`: the row the
|
|
323
|
+
* keyboard is on, or the open item. Rows outside a PaneSidebarList, and the
|
|
324
|
+
* desktop list, which scrolls by CSS, ignore it.
|
|
325
|
+
*/
|
|
326
|
+
export function usePaneSidebarReveal(ref: RefObject<BoxRenderable | null>, current: boolean): void {
|
|
327
|
+
const list = useContext(PaneSidebarListContext);
|
|
328
|
+
useLayoutEffect(() => {
|
|
329
|
+
if (!list || !current) return;
|
|
330
|
+
list.setCurrent(ref.current);
|
|
331
|
+
return () => list.setCurrent(null);
|
|
332
|
+
}, [current, list, ref]);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface PaneSidebarListRenderState {
|
|
336
|
+
/** The width a row has beside the list's scrollbar, while it shows one. */
|
|
337
|
+
listWidth: number;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* The scrolling part of a sidebar. The wheel scrolls it, a scrollbar shows
|
|
342
|
+
* while it holds more rows than fit, and the row a `PaneSidebarRow` marks
|
|
343
|
+
* `active` (or `usePaneSidebarReveal` marks current) stays in view as the
|
|
344
|
+
* keyboard moves it.
|
|
345
|
+
*/
|
|
346
|
+
export function PaneSidebarList({ children }: { children: ReactNode | ((state: PaneSidebarListRenderState) => ReactNode) }) {
|
|
313
347
|
const { nativePaneChrome } = useUiCapabilities();
|
|
348
|
+
const sidebar = usePaneSidebarContext();
|
|
349
|
+
if (nativePaneChrome) {
|
|
350
|
+
return (
|
|
351
|
+
<Box
|
|
352
|
+
flexGrow={1}
|
|
353
|
+
flexShrink={1}
|
|
354
|
+
flexBasis={0}
|
|
355
|
+
minHeight={0}
|
|
356
|
+
data-gloom-role="pane-sidebar-list"
|
|
357
|
+
style={{ minHeight: 0, overflowX: "hidden", overflowY: "auto" }}
|
|
358
|
+
>
|
|
359
|
+
{typeof children === "function" ? children({ listWidth: sidebar.listWidth }) : children}
|
|
360
|
+
</Box>
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
return <TerminalPaneSidebarList sidebar={sidebar}>{children}</TerminalPaneSidebarList>;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function TerminalPaneSidebarList({ sidebar, children }: {
|
|
367
|
+
sidebar: PaneSidebarContextValue;
|
|
368
|
+
children: ReactNode | ((state: PaneSidebarListRenderState) => ReactNode);
|
|
369
|
+
}) {
|
|
370
|
+
// The host's own ScrollBox, which the pane scroll keys do not drive: the
|
|
371
|
+
// list's keys move its cursor, and the pane's bring the cursor into view.
|
|
372
|
+
const { ScrollBox } = useUiHost();
|
|
373
|
+
const scrollRef = useRef<ScrollBoxRenderable | null>(null);
|
|
374
|
+
const currentRef = useRef<BoxRenderable | null>(null);
|
|
375
|
+
const [scrollbar, setScrollbar] = useState(false);
|
|
376
|
+
const reveal = useCallback(() => afterLayout(() => revealInScrollBox(scrollRef.current, currentRef.current)), []);
|
|
377
|
+
const list = useMemo<PaneSidebarListContextValue>(() => ({
|
|
378
|
+
setCurrent: (node) => {
|
|
379
|
+
currentRef.current = node;
|
|
380
|
+
if (node) reveal();
|
|
381
|
+
},
|
|
382
|
+
}), [reveal]);
|
|
383
|
+
// The scrollbar shows once the rows outgrow the list, and takes a column
|
|
384
|
+
// from them. Read once the whole pass is laid out: the content is at least
|
|
385
|
+
// as tall as the viewport, and is not yet sized to it when the viewport
|
|
386
|
+
// reports.
|
|
387
|
+
const syncScrollbar = useCallback(() => afterLayout(() => {
|
|
388
|
+
const scrollBox = scrollRef.current;
|
|
389
|
+
if (!scrollBox) return;
|
|
390
|
+
const viewportHeight = scrollBox.viewport?.height ?? 0;
|
|
391
|
+
setScrollbar(viewportHeight > 0 && scrollBox.scrollHeight > viewportHeight);
|
|
392
|
+
}), []);
|
|
393
|
+
// A list that opens, or is made shorter or taller, brings the row under the
|
|
394
|
+
// cursor back into view. Rows coming and going, and the scrollbar taking a
|
|
395
|
+
// column, leave the scroll where the wheel put it.
|
|
396
|
+
const viewportHeightRef = useRef(0);
|
|
397
|
+
const syncViewport = useCallback(() => {
|
|
398
|
+
syncScrollbar();
|
|
399
|
+
const height = scrollRef.current?.viewport?.height ?? 0;
|
|
400
|
+
if (height === viewportHeightRef.current) return;
|
|
401
|
+
viewportHeightRef.current = height;
|
|
402
|
+
reveal();
|
|
403
|
+
}, [reveal, syncScrollbar]);
|
|
404
|
+
useEffect(() => observeScrollBoxViewportSize(scrollRef.current, syncViewport), [syncViewport]);
|
|
405
|
+
useEffect(() => observeScrollBoxContentSize(scrollRef.current, syncScrollbar), [syncScrollbar]);
|
|
406
|
+
// In the same frame as the rows narrow or widen for it.
|
|
407
|
+
useLayoutEffect(() => {
|
|
408
|
+
const bar = scrollRef.current?.verticalScrollBar;
|
|
409
|
+
if (bar) bar.visible = scrollbar;
|
|
410
|
+
}, [scrollbar]);
|
|
411
|
+
const listWidth = Math.max(1, sidebar.listWidth - (scrollbar ? 1 : 0));
|
|
412
|
+
const context = useMemo(() => ({ ...sidebar, listWidth }), [sidebar, listWidth]);
|
|
413
|
+
|
|
314
414
|
return (
|
|
315
|
-
<
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
415
|
+
<PaneSidebarContext.Provider value={context}>
|
|
416
|
+
<PaneSidebarListContext.Provider value={list}>
|
|
417
|
+
<ScrollBox
|
|
418
|
+
ref={scrollRef}
|
|
419
|
+
flexGrow={1}
|
|
420
|
+
flexShrink={1}
|
|
421
|
+
flexBasis={0}
|
|
422
|
+
minHeight={0}
|
|
423
|
+
scrollY
|
|
424
|
+
focusable={false}
|
|
425
|
+
verticalScrollbarOptions={{ visible: false }}
|
|
426
|
+
horizontalScrollbarOptions={{ visible: false }}
|
|
427
|
+
data-gloom-role="pane-sidebar-list"
|
|
428
|
+
>
|
|
429
|
+
{typeof children === "function" ? children({ listWidth }) : children}
|
|
430
|
+
</ScrollBox>
|
|
431
|
+
</PaneSidebarListContext.Provider>
|
|
432
|
+
</PaneSidebarContext.Provider>
|
|
326
433
|
);
|
|
327
434
|
}
|
|
328
435
|
|
|
@@ -349,6 +456,8 @@ export function PaneSidebarRow({
|
|
|
349
456
|
}) {
|
|
350
457
|
const { activeBackgroundColor, backgroundColor, keyboardFocused, listWidth } = usePaneSidebarContext();
|
|
351
458
|
const [hovered, setHovered] = useState(false);
|
|
459
|
+
const rowRef = useRef<BoxRenderable>(null);
|
|
460
|
+
usePaneSidebarReveal(rowRef, active);
|
|
352
461
|
const foregroundColor = active
|
|
353
462
|
? colors.selectedText
|
|
354
463
|
: keyboardFocused
|
|
@@ -369,6 +478,7 @@ export function PaneSidebarRow({
|
|
|
369
478
|
|
|
370
479
|
return (
|
|
371
480
|
<Box
|
|
481
|
+
ref={rowRef}
|
|
372
482
|
height={height}
|
|
373
483
|
width={listWidth}
|
|
374
484
|
flexDirection="row"
|
|
@@ -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;
|