@songtonyli/dsh-cli 0.1.18 → 0.1.20
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/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +12 -6
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +12 -6
- package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +548 -51
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +9 -13
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +9 -13
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +188 -329
- package/package.json +1 -1
|
@@ -5599,58 +5599,50 @@ var ModalQueue = class {
|
|
|
5599
5599
|
this.active?.withdraw();
|
|
5600
5600
|
}
|
|
5601
5601
|
};
|
|
5602
|
-
/**
|
|
5603
|
-
const
|
|
5604
|
-
/**
|
|
5605
|
-
const
|
|
5606
|
-
/**
|
|
5607
|
-
const
|
|
5608
|
-
/** Widest turn rail. */
|
|
5609
|
-
const RAIL_MAX_WIDTH = 30;
|
|
5610
|
-
/** Share of the terminal the turn rail asks for between its two bounds. */
|
|
5611
|
-
const RAIL_SHARE = .28;
|
|
5602
|
+
/** Narrowest turn list. */
|
|
5603
|
+
const LIST_MIN_WIDTH = 18;
|
|
5604
|
+
/** Widest turn list. */
|
|
5605
|
+
const LIST_MAX_WIDTH = 30;
|
|
5606
|
+
/** Share of the terminal the turn list asks for between its two bounds. */
|
|
5607
|
+
const LIST_SHARE = .28;
|
|
5612
5608
|
/** Rows the frame itself takes: the top rule, the legend rule, and the bottom rule. */
|
|
5613
5609
|
const CHROME_ROWS = 3;
|
|
5614
5610
|
/** Columns one body column spends on the border before it and the space after it. */
|
|
5615
5611
|
const COLUMN_MARGIN = 2;
|
|
5616
|
-
/** Columns a pane row spends on its left edge, which the held section accents. */
|
|
5617
|
-
const EDGE_WIDTH = 1;
|
|
5618
5612
|
/** What the chip names this mode. */
|
|
5619
5613
|
const READER_CHIP = "READER";
|
|
5620
5614
|
/** What ends a line the width cut short; one column, so the mark itself fits. */
|
|
5621
5615
|
const ELLIPSIS$1 = "…";
|
|
5622
|
-
/** The left border of a body row and the border between two
|
|
5616
|
+
/** The left border of a body row and the border between the two panels. */
|
|
5623
5617
|
const SIDE = "│";
|
|
5624
|
-
/** Marks the
|
|
5625
|
-
const
|
|
5626
|
-
/** The left edge every row of the held section carries. */
|
|
5627
|
-
const HELD_EDGE = "▌";
|
|
5618
|
+
/** Marks the listed turn the keyboard holds. */
|
|
5619
|
+
const LIST_MARK = "▸ ";
|
|
5628
5620
|
/** What a section header opens with before its label. */
|
|
5629
5621
|
const HEADER_LEAD = "──";
|
|
5630
|
-
/** What a section header fills the rest of its
|
|
5622
|
+
/** What a section header fills the rest of its panel with. */
|
|
5631
5623
|
const HEADER_FILL = "─";
|
|
5632
5624
|
/** What the reader says on a terminal it cannot draw its frame in. */
|
|
5633
5625
|
const TOO_SMALL = `terminal too small for the reader (needs ${String(24)}×${String(8)})`;
|
|
5634
5626
|
/**
|
|
5635
5627
|
* The legend of each keyboard owner inside the reader, in declared
|
|
5636
|
-
* degradation steps, widest first: the turn
|
|
5637
|
-
*
|
|
5638
|
-
*
|
|
5639
|
-
*
|
|
5628
|
+
* degradation steps, widest first: the turn list, and the turn beside it. The
|
|
5629
|
+
* query line borrows the list's half of the legend rule, so it declares none
|
|
5630
|
+
* of its own. `/help` lists the widest step of each, so the reader's keys are
|
|
5631
|
+
* named in one place.
|
|
5640
5632
|
*/
|
|
5641
5633
|
const READER_HINTS = {
|
|
5642
|
-
|
|
5643
|
-
"↑↓ turns · →
|
|
5644
|
-
"↑↓ turns · →
|
|
5634
|
+
list: [
|
|
5635
|
+
"↑↓ turns · → opens · / filters · Esc closes",
|
|
5636
|
+
"↑↓ turns · → opens · Esc closes",
|
|
5645
5637
|
"Esc closes"
|
|
5646
5638
|
],
|
|
5647
5639
|
pane: [
|
|
5648
|
-
"↑↓
|
|
5649
|
-
"↑↓
|
|
5650
|
-
"Esc
|
|
5640
|
+
"↑↓ scrolls · PgUp PgDn pages · ← turns · Esc closes",
|
|
5641
|
+
"↑↓ scrolls · ← turns · Esc closes",
|
|
5642
|
+
"Esc closes"
|
|
5651
5643
|
]
|
|
5652
5644
|
};
|
|
5653
|
-
/** A
|
|
5645
|
+
/** A panel with nothing in it, for a reader with no turn to show. */
|
|
5654
5646
|
const EMPTY_MEASURE = {
|
|
5655
5647
|
headers: [],
|
|
5656
5648
|
total: 0
|
|
@@ -5677,7 +5669,7 @@ function sameCursor(left, right) {
|
|
|
5677
5669
|
/**
|
|
5678
5670
|
* Which turn the reader holds.
|
|
5679
5671
|
* @param state - where the reader is.
|
|
5680
|
-
* @param groups - the turns the
|
|
5672
|
+
* @param groups - the turns the list names.
|
|
5681
5673
|
* @returns the index into `groups`, and 0 when no listed turn holds the cursor.
|
|
5682
5674
|
*/
|
|
5683
5675
|
function groupIndex(state, groups) {
|
|
@@ -5685,7 +5677,7 @@ function groupIndex(state, groups) {
|
|
|
5685
5677
|
return index === -1 ? 0 : index;
|
|
5686
5678
|
}
|
|
5687
5679
|
/**
|
|
5688
|
-
* Which section of its turn the reader
|
|
5680
|
+
* Which section of its turn the reader is reading.
|
|
5689
5681
|
* @param state - where the reader is.
|
|
5690
5682
|
* @param group - the turn that holds the cursor.
|
|
5691
5683
|
* @returns the index into the turn's sections, and 0 when the turn no longer carries it.
|
|
@@ -5710,8 +5702,8 @@ function sectionAt(cursor, blocks) {
|
|
|
5710
5702
|
};
|
|
5711
5703
|
}
|
|
5712
5704
|
/**
|
|
5713
|
-
* What one section is called in the
|
|
5714
|
-
* of thing it is at a glance.
|
|
5705
|
+
* What one section is called in the turn panel, with the glyph that says what
|
|
5706
|
+
* kind of thing it is at a glance.
|
|
5715
5707
|
* @param block - the block the section belongs to.
|
|
5716
5708
|
* @param part - the section.
|
|
5717
5709
|
* @returns the label, e.g. `✻ reasoning` or `⚒ bash git status · result`.
|
|
@@ -5728,25 +5720,24 @@ function paneLabel(block, part) {
|
|
|
5728
5720
|
}
|
|
5729
5721
|
}
|
|
5730
5722
|
/**
|
|
5731
|
-
* One section's rows as the
|
|
5723
|
+
* One section's rows as the panel wraps them; never folded, because folding is
|
|
5732
5724
|
* a decision the transcript makes and this is where the rest of the text is.
|
|
5733
5725
|
* @param cursor - the section.
|
|
5734
5726
|
* @param blocks - the navigable blocks.
|
|
5735
|
-
* @param width - the
|
|
5727
|
+
* @param width - the panel's columns.
|
|
5736
5728
|
* @returns the wrapped rows, unstyled.
|
|
5737
5729
|
*/
|
|
5738
5730
|
function sectionBody(cursor, blocks, width) {
|
|
5739
5731
|
const held = sectionAt(cursor, blocks);
|
|
5740
5732
|
if (held === void 0) return [];
|
|
5741
|
-
|
|
5742
|
-
return held.part.rows.flatMap((row) => wrapTextWithAnsi(row, room));
|
|
5733
|
+
return held.part.rows.flatMap((row) => wrapTextWithAnsi(row, Math.max(1, width)));
|
|
5743
5734
|
}
|
|
5744
5735
|
/**
|
|
5745
|
-
* Measure the
|
|
5746
|
-
* @param group - the turn the
|
|
5736
|
+
* Measure the turn panel, which is what the scroll keys move over.
|
|
5737
|
+
* @param group - the turn the panel shows.
|
|
5747
5738
|
* @param blocks - the navigable blocks.
|
|
5748
|
-
* @param width - the
|
|
5749
|
-
* @returns where each section's header lands and how many rows the
|
|
5739
|
+
* @param width - the panel's columns.
|
|
5740
|
+
* @returns where each section's header lands and how many rows the panel has.
|
|
5750
5741
|
*/
|
|
5751
5742
|
function measurePane(group, blocks, width) {
|
|
5752
5743
|
const headers = [];
|
|
@@ -5761,118 +5752,79 @@ function measurePane(group, blocks, width) {
|
|
|
5761
5752
|
};
|
|
5762
5753
|
}
|
|
5763
5754
|
/**
|
|
5764
|
-
*
|
|
5765
|
-
*
|
|
5766
|
-
*
|
|
5767
|
-
* width, so the line names whichever of the two is larger.
|
|
5768
|
-
* @param minColumns - columns compare needs before the body splits in two.
|
|
5769
|
-
* @returns the refusal.
|
|
5770
|
-
*/
|
|
5771
|
-
function compareRefusal(minColumns) {
|
|
5772
|
-
return `compare needs ${String(Math.max(minColumns, TWO_COLUMN_MIN_WIDTH))} columns`;
|
|
5773
|
-
}
|
|
5774
|
-
/**
|
|
5775
|
-
* How the reader's body splits one terminal.
|
|
5776
|
-
*
|
|
5777
|
-
* The rail is what gives way: compare keeps its two panes wherever both still
|
|
5778
|
-
* hold a readable section, and a terminal too narrow for two columns draws
|
|
5779
|
-
* whichever one the keyboard is in.
|
|
5755
|
+
* How the reader's body splits one terminal: the turn list and the held turn
|
|
5756
|
+
* beside it, or — on a terminal too narrow for two panels — whichever one the
|
|
5757
|
+
* keyboard is in.
|
|
5780
5758
|
* @param width - the terminal's columns.
|
|
5781
5759
|
* @param rows - the rows the reader draws.
|
|
5782
|
-
* @param state - where the reader is, which decides the single narrow
|
|
5783
|
-
* @param minColumns - columns
|
|
5784
|
-
* @
|
|
5785
|
-
* @returns the rail width, the pane widths in drawing order, the body rows,
|
|
5786
|
-
* and the refusal the legend reports.
|
|
5760
|
+
* @param state - where the reader is, which decides the single narrow panel.
|
|
5761
|
+
* @param minColumns - columns the reader needs before it draws both panels.
|
|
5762
|
+
* @returns the panel widths, the body rows, and whether the frame fits at all.
|
|
5787
5763
|
*/
|
|
5788
|
-
function readerGeometry(width, rows, state, minColumns
|
|
5764
|
+
function readerGeometry(width, rows, state, minColumns) {
|
|
5789
5765
|
const base = {
|
|
5790
5766
|
body: Math.max(0, rows - CHROME_ROWS),
|
|
5791
|
-
refusal: "",
|
|
5792
5767
|
tiny: false,
|
|
5793
|
-
|
|
5768
|
+
measure: EMPTY_MEASURE
|
|
5794
5769
|
};
|
|
5795
5770
|
if (width < 24 || rows < 8) return {
|
|
5796
5771
|
...base,
|
|
5797
|
-
|
|
5798
|
-
|
|
5772
|
+
list: 0,
|
|
5773
|
+
pane: 0,
|
|
5799
5774
|
tiny: true
|
|
5800
5775
|
};
|
|
5801
|
-
|
|
5802
|
-
if (width < TWO_COLUMN_MIN_WIDTH) return state.column === "pane" ? {
|
|
5776
|
+
if (width < minColumns) return state.column === "pane" ? {
|
|
5803
5777
|
...base,
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
panes: [width - COLUMN_MARGIN]
|
|
5778
|
+
list: 0,
|
|
5779
|
+
pane: width - COLUMN_MARGIN
|
|
5807
5780
|
} : {
|
|
5808
5781
|
...base,
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
panes: []
|
|
5812
|
-
};
|
|
5813
|
-
const rail = clamp(Math.floor(width * RAIL_SHARE), RAIL_MIN_WIDTH, RAIL_MAX_WIDTH);
|
|
5814
|
-
const single = width - rail - 2 * COLUMN_MARGIN;
|
|
5815
|
-
if (state.pinned === void 0) return {
|
|
5816
|
-
...base,
|
|
5817
|
-
rail,
|
|
5818
|
-
panes: [single]
|
|
5819
|
-
};
|
|
5820
|
-
if (width < minColumns) return {
|
|
5821
|
-
...base,
|
|
5822
|
-
rail,
|
|
5823
|
-
panes: [single],
|
|
5824
|
-
refusal
|
|
5782
|
+
list: width - COLUMN_MARGIN,
|
|
5783
|
+
pane: 0
|
|
5825
5784
|
};
|
|
5826
|
-
const
|
|
5827
|
-
if (shared >= READER_MIN_PANE) return {
|
|
5828
|
-
...base,
|
|
5829
|
-
rail,
|
|
5830
|
-
panes: [shared, shared]
|
|
5831
|
-
};
|
|
5832
|
-
const wide = Math.floor((width - 2 * COLUMN_MARGIN) / 2);
|
|
5785
|
+
const list = clamp(Math.floor(width * LIST_SHARE), LIST_MIN_WIDTH, LIST_MAX_WIDTH);
|
|
5833
5786
|
return {
|
|
5834
5787
|
...base,
|
|
5835
|
-
|
|
5836
|
-
|
|
5788
|
+
list,
|
|
5789
|
+
pane: width - list - 2 * COLUMN_MARGIN
|
|
5837
5790
|
};
|
|
5838
5791
|
}
|
|
5839
5792
|
/**
|
|
5840
|
-
* The reader's geometry over the transcript it is showing, with the
|
|
5841
|
-
*
|
|
5793
|
+
* The reader's geometry over the transcript it is showing, with the turn panel
|
|
5794
|
+
* measured at the width that geometry gives it.
|
|
5842
5795
|
* @param state - where the reader is.
|
|
5843
|
-
* @param groups - the turns the
|
|
5796
|
+
* @param groups - the turns the list names.
|
|
5844
5797
|
* @param blocks - the navigable blocks.
|
|
5845
5798
|
* @param width - the terminal's columns.
|
|
5846
5799
|
* @param rows - the rows the reader draws.
|
|
5847
|
-
* @param minColumns - columns
|
|
5848
|
-
* @returns the geometry, with its
|
|
5800
|
+
* @param minColumns - columns the reader needs before it draws both panels.
|
|
5801
|
+
* @returns the geometry, with its panel measure filled in.
|
|
5849
5802
|
*/
|
|
5850
5803
|
function readerGeometryFor(state, groups, blocks, width, rows, minColumns) {
|
|
5851
|
-
const layout = readerGeometry(width, rows, state, minColumns
|
|
5804
|
+
const layout = readerGeometry(width, rows, state, minColumns);
|
|
5852
5805
|
const group = groups[groupIndex(state, groups)];
|
|
5853
|
-
|
|
5854
|
-
if (group === void 0 || paneWidth === void 0) return layout;
|
|
5806
|
+
if (group === void 0 || layout.pane === 0) return layout;
|
|
5855
5807
|
return {
|
|
5856
5808
|
...layout,
|
|
5857
|
-
|
|
5809
|
+
measure: measurePane(group, blocks, layout.pane)
|
|
5858
5810
|
};
|
|
5859
5811
|
}
|
|
5860
5812
|
/**
|
|
5861
|
-
* The largest first visible
|
|
5813
|
+
* The largest first visible panel row; 0 while the whole turn fits at once.
|
|
5862
5814
|
* @param geometry - the reader's geometry.
|
|
5863
5815
|
* @returns the row the scroll stops at.
|
|
5864
5816
|
*/
|
|
5865
5817
|
function maxOffset(geometry) {
|
|
5866
|
-
return Math.max(0, geometry.
|
|
5818
|
+
return Math.max(0, geometry.measure.total - geometry.body);
|
|
5867
5819
|
}
|
|
5868
5820
|
/**
|
|
5869
|
-
* Where the
|
|
5821
|
+
* Where the panel scrolls to put one section's header on its first row.
|
|
5870
5822
|
* @param index - the section, by position in its turn.
|
|
5871
5823
|
* @param geometry - the reader's geometry.
|
|
5872
5824
|
* @returns the offset.
|
|
5873
5825
|
*/
|
|
5874
5826
|
function showSection(index, geometry) {
|
|
5875
|
-
return Math.min(geometry.
|
|
5827
|
+
return Math.min(geometry.measure.headers[index] ?? 0, maxOffset(geometry));
|
|
5876
5828
|
}
|
|
5877
5829
|
/**
|
|
5878
5830
|
* Where one movement target lands along a list.
|
|
@@ -5892,63 +5844,49 @@ function targetIndex(to, index, count) {
|
|
|
5892
5844
|
}
|
|
5893
5845
|
}
|
|
5894
5846
|
/**
|
|
5895
|
-
* The state without its pinned section.
|
|
5896
|
-
* @param state - where the reader is.
|
|
5897
|
-
* @returns the same state with compare off.
|
|
5898
|
-
*/
|
|
5899
|
-
function withoutPin(state) {
|
|
5900
|
-
return {
|
|
5901
|
-
cursor: state.cursor,
|
|
5902
|
-
column: state.column,
|
|
5903
|
-
offset: state.offset,
|
|
5904
|
-
...state.query === void 0 ? {} : { query: state.query }
|
|
5905
|
-
};
|
|
5906
|
-
}
|
|
5907
|
-
/**
|
|
5908
5847
|
* The state without its query.
|
|
5909
5848
|
* @param state - where the reader is.
|
|
5910
|
-
* @returns the same state with the
|
|
5849
|
+
* @returns the same state with the list naming every turn again.
|
|
5911
5850
|
*/
|
|
5912
5851
|
function withoutQuery(state) {
|
|
5913
5852
|
return {
|
|
5914
5853
|
cursor: state.cursor,
|
|
5915
5854
|
column: state.column,
|
|
5916
|
-
offset: state.offset
|
|
5917
|
-
...state.pinned === void 0 ? {} : { pinned: state.pinned }
|
|
5855
|
+
offset: state.offset
|
|
5918
5856
|
};
|
|
5919
5857
|
}
|
|
5920
5858
|
/**
|
|
5921
|
-
*
|
|
5859
|
+
* Scroll the turn panel, and read the cursor off the row it landed on: the
|
|
5860
|
+
* section the top row belongs to is the one the transcript resumes at.
|
|
5922
5861
|
* @param state - where the reader is.
|
|
5923
|
-
* @param
|
|
5924
|
-
* @param groups - the turns the
|
|
5862
|
+
* @param offset - the first visible panel row, already clamped.
|
|
5863
|
+
* @param groups - the turns the list names.
|
|
5925
5864
|
* @param geometry - the reader's geometry.
|
|
5926
|
-
* @returns the state
|
|
5865
|
+
* @returns the state at that row.
|
|
5927
5866
|
*/
|
|
5928
|
-
function
|
|
5867
|
+
function readAt(state, offset, groups, geometry) {
|
|
5929
5868
|
const group = groups[groupIndex(state, groups)];
|
|
5930
|
-
|
|
5931
|
-
const
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5869
|
+
const index = geometry.measure.headers.findLastIndex((header) => header <= offset);
|
|
5870
|
+
const cursor = group?.sections[index];
|
|
5871
|
+
return cursor === void 0 ? {
|
|
5872
|
+
...state,
|
|
5873
|
+
offset
|
|
5874
|
+
} : {
|
|
5936
5875
|
...state,
|
|
5937
|
-
column: "pane",
|
|
5938
5876
|
cursor,
|
|
5939
|
-
offset
|
|
5877
|
+
offset
|
|
5940
5878
|
};
|
|
5941
5879
|
}
|
|
5942
5880
|
/**
|
|
5943
5881
|
* Put the reader on one turn, at its first section.
|
|
5944
5882
|
* @param state - where the reader is.
|
|
5945
5883
|
* @param index - the turn, by position in the listed turns.
|
|
5946
|
-
* @param groups - the turns the
|
|
5884
|
+
* @param groups - the turns the list names.
|
|
5947
5885
|
* @returns the state on that turn, scrolled to its top.
|
|
5948
5886
|
*/
|
|
5949
5887
|
function selectTurn(state, index, groups) {
|
|
5950
5888
|
const cursor = cursorAt(groups, index, 0);
|
|
5951
|
-
/* v8 ignore next -- both callers refuse an empty
|
|
5889
|
+
/* v8 ignore next -- both callers refuse an empty list first */
|
|
5952
5890
|
if (cursor === void 0) return state;
|
|
5953
5891
|
return {
|
|
5954
5892
|
...state,
|
|
@@ -5957,100 +5895,64 @@ function selectTurn(state, index, groups) {
|
|
|
5957
5895
|
};
|
|
5958
5896
|
}
|
|
5959
5897
|
/**
|
|
5960
|
-
* Answer one page key: a page of the
|
|
5961
|
-
* a
|
|
5898
|
+
* Answer one page key: a page of the panel's rows with one row of overlap, or
|
|
5899
|
+
* a list's worth of turns.
|
|
5962
5900
|
* @param state - where the reader is.
|
|
5963
5901
|
* @param step - 1 for the next page, -1 for the previous one.
|
|
5964
|
-
* @param groups - the turns the
|
|
5902
|
+
* @param groups - the turns the list names.
|
|
5965
5903
|
* @param geometry - the reader's geometry.
|
|
5966
5904
|
* @returns the state after the page.
|
|
5967
5905
|
*/
|
|
5968
5906
|
function pageBy(state, step, groups, geometry) {
|
|
5969
5907
|
if (state.column === "pane") {
|
|
5970
5908
|
const by = Math.max(1, geometry.body - 1);
|
|
5971
|
-
return
|
|
5972
|
-
...state,
|
|
5973
|
-
offset: clamp(state.offset + step * by, 0, maxOffset(geometry))
|
|
5974
|
-
};
|
|
5909
|
+
return readAt(state, clamp(state.offset + step * by, 0, maxOffset(geometry)), groups, geometry);
|
|
5975
5910
|
}
|
|
5976
5911
|
if (groups.length === 0) return state;
|
|
5977
5912
|
return selectTurn(state, clamp(groupIndex(state, groups) + step * Math.max(1, geometry.body), 0, groups.length - 1), groups);
|
|
5978
5913
|
}
|
|
5979
5914
|
/**
|
|
5980
|
-
*
|
|
5981
|
-
*
|
|
5982
|
-
* @
|
|
5983
|
-
* @returns true while the rail and the sections take turns at the body.
|
|
5984
|
-
*/
|
|
5985
|
-
function singleColumn(geometry) {
|
|
5986
|
-
return geometry.rail === 0 && geometry.panes.length === 1;
|
|
5987
|
-
}
|
|
5988
|
-
/**
|
|
5989
|
-
* Answer `Escape` inside the reader: clear the query, close the query line,
|
|
5990
|
-
* unpin, then - on a terminal that draws one column at a time - step back to
|
|
5991
|
-
* the rail. {@link readerClosesOnEscape} reports when the chain is spent and
|
|
5992
|
-
* the press closes the reader instead.
|
|
5915
|
+
* Answer `Escape` on the query line: clear the query, then close the line and
|
|
5916
|
+
* list every turn again. From either panel the key closes the reader instead,
|
|
5917
|
+
* which {@link readerClosesOnEscape} reports.
|
|
5993
5918
|
* @param state - where the reader is.
|
|
5994
5919
|
* @returns the state after one step of the chain.
|
|
5995
5920
|
*/
|
|
5996
5921
|
function escapeStep(state) {
|
|
5997
|
-
if (state.
|
|
5998
|
-
if (state.query !== void 0 && state.query !== "") return {
|
|
5999
|
-
...state,
|
|
6000
|
-
query: ""
|
|
6001
|
-
};
|
|
6002
|
-
return withoutQuery({
|
|
6003
|
-
...state,
|
|
6004
|
-
column: "rail"
|
|
6005
|
-
});
|
|
6006
|
-
}
|
|
6007
|
-
if (state.pinned !== void 0) return withoutPin(state);
|
|
6008
|
-
return {
|
|
5922
|
+
if (state.query !== void 0 && state.query !== "") return {
|
|
6009
5923
|
...state,
|
|
6010
|
-
|
|
5924
|
+
query: ""
|
|
6011
5925
|
};
|
|
5926
|
+
return withoutQuery({
|
|
5927
|
+
...state,
|
|
5928
|
+
column: "list"
|
|
5929
|
+
});
|
|
6012
5930
|
}
|
|
6013
5931
|
/**
|
|
6014
|
-
* Whether `Escape` closes the reader rather than stepping
|
|
5932
|
+
* Whether `Escape` closes the reader rather than stepping the query chain.
|
|
6015
5933
|
* @param state - where the reader is.
|
|
6016
|
-
* @
|
|
6017
|
-
*
|
|
6018
|
-
* @returns true once no query line is open, nothing is pinned, and the
|
|
6019
|
-
* keyboard is not in a narrow terminal's sections.
|
|
5934
|
+
* @returns true from either panel; the key leaves the reader from both, and
|
|
5935
|
+
* `Left` is the way back to the turn list.
|
|
6020
5936
|
*/
|
|
6021
|
-
function readerClosesOnEscape(state
|
|
6022
|
-
|
|
6023
|
-
return !(state.column === "pane" && singleColumn(geometry));
|
|
5937
|
+
function readerClosesOnEscape(state) {
|
|
5938
|
+
return state.column !== "filter";
|
|
6024
5939
|
}
|
|
6025
5940
|
/**
|
|
6026
5941
|
* Apply one key press to the reader.
|
|
6027
5942
|
* @param state - where the reader is.
|
|
6028
5943
|
* @param intent - what the key meant.
|
|
6029
|
-
* @param groups - the turns the
|
|
6030
|
-
* @param geometry - the reader's geometry, with the
|
|
5944
|
+
* @param groups - the turns the list names, already narrowed by the query.
|
|
5945
|
+
* @param geometry - the reader's geometry, with the turn panel measured.
|
|
6031
5946
|
* @returns the state after the press; the state itself when nothing moves.
|
|
6032
5947
|
*/
|
|
6033
5948
|
function reduceReader(state, intent, groups, geometry) {
|
|
6034
5949
|
switch (intent.kind) {
|
|
6035
5950
|
case "turn": return groups.length === 0 ? state : selectTurn(state, targetIndex(intent.to, groupIndex(state, groups), groups.length), groups);
|
|
6036
|
-
case "
|
|
6037
|
-
const group = groups[groupIndex(state, groups)];
|
|
6038
|
-
if (group === void 0) return state;
|
|
6039
|
-
return selectSection(state, targetIndex(intent.to, sectionIndex(state, group), group.sections.length), groups, geometry);
|
|
6040
|
-
}
|
|
6041
|
-
case "section-at": return selectSection(state, intent.index, groups, geometry);
|
|
6042
|
-
case "scroll": return {
|
|
6043
|
-
...state,
|
|
6044
|
-
offset: clamp(state.offset + intent.step, 0, maxOffset(geometry))
|
|
6045
|
-
};
|
|
5951
|
+
case "scroll": return readAt(state, targetIndex(intent.to, state.offset, maxOffset(geometry) + 1), groups, geometry);
|
|
6046
5952
|
case "page": return pageBy(state, intent.step, groups, geometry);
|
|
6047
|
-
case "column": return
|
|
6048
|
-
...state,
|
|
6049
|
-
column: "rail"
|
|
6050
|
-
} : selectSection(state, 0, groups, geometry);
|
|
6051
|
-
case "pin": return state.pinned !== void 0 && sameCursor(state.pinned, state.cursor) ? withoutPin(state) : {
|
|
5953
|
+
case "column": return {
|
|
6052
5954
|
...state,
|
|
6053
|
-
|
|
5955
|
+
column: intent.to
|
|
6054
5956
|
};
|
|
6055
5957
|
case "filter": return {
|
|
6056
5958
|
...state,
|
|
@@ -6067,7 +5969,7 @@ function reduceReader(state, intent, groups, geometry) {
|
|
|
6067
5969
|
};
|
|
6068
5970
|
case "commit": return {
|
|
6069
5971
|
...state,
|
|
6070
|
-
column: "
|
|
5972
|
+
column: "list"
|
|
6071
5973
|
};
|
|
6072
5974
|
case "escape": return escapeStep(state);
|
|
6073
5975
|
case "anchor": return anchorOffset(state, groups, geometry);
|
|
@@ -6076,33 +5978,29 @@ function reduceReader(state, intent, groups, geometry) {
|
|
|
6076
5978
|
}
|
|
6077
5979
|
}
|
|
6078
5980
|
/**
|
|
6079
|
-
* Put the
|
|
6080
|
-
* it: the reader re-anchors on the section itself, never on a row
|
|
6081
|
-
* a narrower terminal does not lose the user's place.
|
|
5981
|
+
* Put the section being read back in view after a resize rewrapped the panel
|
|
5982
|
+
* under it: the reader re-anchors on the section itself, never on a row
|
|
5983
|
+
* number, so a narrower terminal does not lose the user's place.
|
|
6082
5984
|
* @param state - where the reader is.
|
|
6083
|
-
* @param groups - the turns the
|
|
5985
|
+
* @param groups - the turns the list names.
|
|
6084
5986
|
* @param geometry - the reader's geometry after the change.
|
|
6085
5987
|
* @returns the state with its offset settled.
|
|
6086
5988
|
*/
|
|
6087
5989
|
function anchorOffset(state, groups, geometry) {
|
|
6088
5990
|
const group = groups[groupIndex(state, groups)];
|
|
6089
5991
|
if (group === void 0) return state;
|
|
6090
|
-
const index = sectionIndex(state, group);
|
|
6091
|
-
const header = geometry.pane.headers[index] ?? 0;
|
|
6092
|
-
const top = clamp(state.offset, 0, maxOffset(geometry));
|
|
6093
|
-
const visible = header >= top && header < top + geometry.body;
|
|
6094
5992
|
return {
|
|
6095
5993
|
...state,
|
|
6096
|
-
offset:
|
|
5994
|
+
offset: showSection(sectionIndex(state, group), geometry)
|
|
6097
5995
|
};
|
|
6098
5996
|
}
|
|
6099
5997
|
/**
|
|
6100
5998
|
* Narrow the turns to the ones a query matches, keeping the conversation's
|
|
6101
|
-
* own order: the
|
|
5999
|
+
* own order: the list is a timeline, so it is filtered rather than ranked.
|
|
6102
6000
|
* @param groups - every turn of the transcript.
|
|
6103
6001
|
* @param blocks - the navigable blocks, for the text inside each turn.
|
|
6104
6002
|
* @param query - what the user typed; an empty query keeps every turn.
|
|
6105
|
-
* @returns the turns to
|
|
6003
|
+
* @returns the turns to name.
|
|
6106
6004
|
*/
|
|
6107
6005
|
function filterTurns(groups, blocks, query) {
|
|
6108
6006
|
if (query === void 0 || query === "") return groups;
|
|
@@ -6111,7 +6009,7 @@ function filterTurns(groups, blocks, query) {
|
|
|
6111
6009
|
return groups.filter((group) => matched.has(group));
|
|
6112
6010
|
}
|
|
6113
6011
|
/**
|
|
6114
|
-
* What one turn contributed, as the
|
|
6012
|
+
* What one turn contributed, as the list reports it at a glance.
|
|
6115
6013
|
* @param markers - the turn's counts and flags.
|
|
6116
6014
|
* @returns the marker strip, empty for a turn that contributed none of them.
|
|
6117
6015
|
*/
|
|
@@ -6134,75 +6032,71 @@ function cell(text, width) {
|
|
|
6134
6032
|
return `${cut}${" ".repeat(Math.max(0, width - visibleWidth(cut)))}`;
|
|
6135
6033
|
}
|
|
6136
6034
|
/**
|
|
6137
|
-
* One row of the turn
|
|
6035
|
+
* One row of the turn list: the mark, the turn number, its prompt, and what
|
|
6138
6036
|
* the turn contributed.
|
|
6139
6037
|
* @param group - the turn.
|
|
6140
|
-
* @param selected - whether the
|
|
6038
|
+
* @param selected - whether the list's selection is on it.
|
|
6039
|
+
* @param focused - whether the list itself has the keyboard.
|
|
6141
6040
|
* @param palette - the palette the row is styled with.
|
|
6142
|
-
* @param width - the
|
|
6041
|
+
* @param width - the list's columns.
|
|
6143
6042
|
* @returns the row, exactly `width` columns.
|
|
6144
6043
|
*/
|
|
6145
|
-
function
|
|
6044
|
+
function listRow(group, selected, focused, palette, width) {
|
|
6146
6045
|
const marks = markerStrip(group.markers);
|
|
6147
6046
|
const room = Math.max(1, width - visibleWidth(marks));
|
|
6148
|
-
const lead = `${selected ?
|
|
6047
|
+
const lead = `${selected ? LIST_MARK : " "}${String(group.turn)} `;
|
|
6149
6048
|
const label = truncateToWidth(group.label, Math.max(1, room - visibleWidth(lead) - (selected ? 2 : 0)), ELLIPSIS$1);
|
|
6150
6049
|
const head = `${lead}${selected ? `[${label}]` : label}`;
|
|
6151
|
-
const
|
|
6050
|
+
const paint = (text) => {
|
|
6051
|
+
if (!selected) return palette.dim(text);
|
|
6052
|
+
return focused ? palette.bold(palette.accent(text)) : palette.accent(text);
|
|
6053
|
+
};
|
|
6054
|
+
const text = truncateToWidth(paint(head), room, ELLIPSIS$1);
|
|
6152
6055
|
return `${text}${" ".repeat(Math.max(0, room - visibleWidth(text)))}${palette.dim(marks)}`;
|
|
6153
6056
|
}
|
|
6154
6057
|
/**
|
|
6155
|
-
* The turn
|
|
6156
|
-
* @param groups - the turns the
|
|
6157
|
-
* @param selected - the
|
|
6058
|
+
* The turn list's rows, windowed so the selected turn is always drawn.
|
|
6059
|
+
* @param groups - the turns the list names.
|
|
6060
|
+
* @param selected - the selected turn's index.
|
|
6061
|
+
* @param focused - whether the list itself has the keyboard.
|
|
6158
6062
|
* @param palette - the palette the rows are styled with.
|
|
6159
|
-
* @param width - the
|
|
6063
|
+
* @param width - the list's columns.
|
|
6160
6064
|
* @param body - the rows the body has.
|
|
6161
6065
|
* @returns the rows to draw, oldest first.
|
|
6162
6066
|
*/
|
|
6163
|
-
function
|
|
6067
|
+
function listColumn(groups, selected, focused, palette, width, body) {
|
|
6164
6068
|
const start = clamp(selected - Math.floor(Math.max(0, body - 1) / 2), 0, Math.max(0, groups.length - body));
|
|
6165
|
-
return groups.slice(start, start + body).map((group, index) =>
|
|
6069
|
+
return groups.slice(start, start + body).map((group, index) => listRow(group, start + index === selected, focused, palette, width));
|
|
6166
6070
|
}
|
|
6167
6071
|
/**
|
|
6168
|
-
* One section header inside
|
|
6072
|
+
* One section header inside the turn panel.
|
|
6169
6073
|
* @param text - what the section is called, with its turn.
|
|
6170
6074
|
* @param palette - the palette the header is styled with.
|
|
6171
|
-
* @param width - the
|
|
6172
|
-
* @param
|
|
6075
|
+
* @param width - the panel's columns.
|
|
6076
|
+
* @param reading - whether this is the section the top row belongs to.
|
|
6173
6077
|
* @returns the header row.
|
|
6174
6078
|
*/
|
|
6175
|
-
function headerRow(text, palette, width,
|
|
6079
|
+
function headerRow(text, palette, width, reading) {
|
|
6176
6080
|
const body = ` ${text} `;
|
|
6177
6081
|
const line = `${HEADER_LEAD}${body}${HEADER_FILL.repeat(Math.max(0, width - visibleWidth(HEADER_LEAD) - visibleWidth(body)))}`;
|
|
6178
|
-
return
|
|
6179
|
-
}
|
|
6180
|
-
/**
|
|
6181
|
-
* One section as a pane draws it: its header and every one of its rows.
|
|
6182
|
-
* @param cursor - the section.
|
|
6183
|
-
* @param blocks - the navigable blocks.
|
|
6184
|
-
* @param palette - the palette the header and the edge are styled with.
|
|
6185
|
-
* @param width - the pane's columns.
|
|
6186
|
-
* @param held - whether the keyboard holds this section.
|
|
6187
|
-
* @returns the rows, header first.
|
|
6188
|
-
*/
|
|
6189
|
-
function sectionRows(cursor, blocks, palette, width, held) {
|
|
6190
|
-
const found = sectionAt(cursor, blocks);
|
|
6191
|
-
if (found === void 0) return [];
|
|
6192
|
-
const edge = held ? palette.accent(HELD_EDGE) : " ";
|
|
6193
|
-
return [headerRow(`${paneLabel(found.block, found.part)} · turn ${String(found.block.turn)}`, palette, width, held), ...sectionBody(cursor, blocks, width).map((row) => `${edge}${row}`)];
|
|
6082
|
+
return reading ? palette.bold(palette.accent(line)) : palette.dim(line);
|
|
6194
6083
|
}
|
|
6195
6084
|
/**
|
|
6196
|
-
* The
|
|
6197
|
-
*
|
|
6085
|
+
* The turn panel's rows: every section of the held turn, in reading order,
|
|
6086
|
+
* each under its own header.
|
|
6087
|
+
* @param group - the turn the panel shows.
|
|
6198
6088
|
* @param blocks - the navigable blocks.
|
|
6199
|
-
* @param cursor - the section the
|
|
6200
|
-
* @param palette - the palette the headers
|
|
6201
|
-
* @param width - the
|
|
6089
|
+
* @param cursor - the section the top row belongs to.
|
|
6090
|
+
* @param palette - the palette the headers are styled with.
|
|
6091
|
+
* @param width - the panel's columns.
|
|
6202
6092
|
* @returns the rows, before the scroll window is applied.
|
|
6203
6093
|
*/
|
|
6204
6094
|
function paneColumn(group, blocks, cursor, palette, width) {
|
|
6205
|
-
return group.sections.flatMap((section) =>
|
|
6095
|
+
return group.sections.flatMap((section) => {
|
|
6096
|
+
const found = sectionAt(section, blocks);
|
|
6097
|
+
if (found === void 0) return [];
|
|
6098
|
+
return [headerRow(`${paneLabel(found.block, found.part)} · turn ${String(found.block.turn)}`, palette, width, sameCursor(section, cursor)), ...sectionBody(section, blocks, width)];
|
|
6099
|
+
});
|
|
6206
6100
|
}
|
|
6207
6101
|
/**
|
|
6208
6102
|
* Assemble one body row from the columns that are drawn.
|
|
@@ -6222,24 +6116,22 @@ function bodyRow(columns, row, palette, width) {
|
|
|
6222
6116
|
return truncateToWidth(line, Math.max(1, width), ELLIPSIS$1);
|
|
6223
6117
|
}
|
|
6224
6118
|
/**
|
|
6225
|
-
* What the legend rule says on its left: the query line while one is open,
|
|
6226
|
-
* the
|
|
6119
|
+
* What the legend rule says on its left: the query line while one is open, or
|
|
6120
|
+
* the keys the panel holding the keyboard answers.
|
|
6227
6121
|
* @param state - where the reader is.
|
|
6228
|
-
* @param geometry - the reader's geometry.
|
|
6229
6122
|
* @param palette - the palette the text is styled with.
|
|
6230
6123
|
* @param room - the columns the rule leaves its legend.
|
|
6231
6124
|
* @returns the styled text.
|
|
6232
6125
|
*/
|
|
6233
|
-
function legendText(state,
|
|
6126
|
+
function legendText(state, palette, room) {
|
|
6234
6127
|
if (state.column === "filter") return palette.accent(truncateToWidth(`/ ${state.query ?? ""}`, Math.max(1, room), ELLIPSIS$1));
|
|
6235
|
-
|
|
6236
|
-
return palette.dim(fitLegend(READER_HINTS[state.column === "rail" ? "rail" : "pane"], room));
|
|
6128
|
+
return palette.dim(fitLegend(READER_HINTS[state.column], room));
|
|
6237
6129
|
}
|
|
6238
6130
|
/**
|
|
6239
6131
|
* Where one entry sits in the list it belongs to, as both the top rule and
|
|
6240
6132
|
* the legend readout state it: the 1-based position, and 0 for a list with no
|
|
6241
6133
|
* entry to be at. A turn's own number is not its position — the blocks before
|
|
6242
|
-
* the first prompt are a turn of the
|
|
6134
|
+
* the first prompt are a turn of the list too — so the position is what every
|
|
6243
6135
|
* count in the frame is built from.
|
|
6244
6136
|
* @param index - the entry's index into the list.
|
|
6245
6137
|
* @param count - how many entries the list has.
|
|
@@ -6249,10 +6141,10 @@ function place(index, count) {
|
|
|
6249
6141
|
return Math.min(index + 1, count);
|
|
6250
6142
|
}
|
|
6251
6143
|
/**
|
|
6252
|
-
* What the legend rule reports on its right: how far the
|
|
6144
|
+
* What the legend rule reports on its right: how far the read has come, or
|
|
6253
6145
|
* how much of the transcript a query still holds.
|
|
6254
6146
|
* @param state - where the reader is.
|
|
6255
|
-
* @param groups - the turns the
|
|
6147
|
+
* @param groups - the turns the list names.
|
|
6256
6148
|
* @param geometry - the reader's geometry.
|
|
6257
6149
|
* @param totalTurns - the turns the transcript has before the query.
|
|
6258
6150
|
* @returns the readout.
|
|
@@ -6260,20 +6152,13 @@ function place(index, count) {
|
|
|
6260
6152
|
function readout(state, groups, geometry, totalTurns) {
|
|
6261
6153
|
if (state.query !== void 0 && state.query !== "") return `${String(groups.length)}/${String(totalTurns)} turns`;
|
|
6262
6154
|
const index = groupIndex(state, groups);
|
|
6263
|
-
const
|
|
6264
|
-
|
|
6265
|
-
const sections = group?.sections.length ?? 0;
|
|
6266
|
-
const rowsShown = Math.min(state.offset + 1, geometry.pane.total);
|
|
6267
|
-
return [
|
|
6268
|
-
`turn ${String(place(index, groups.length))}/${String(groups.length)}`,
|
|
6269
|
-
`section ${String(place(section, sections))}/${String(sections)}`,
|
|
6270
|
-
`row ${String(rowsShown)}/${String(geometry.pane.total)}`
|
|
6271
|
-
].join(" · ");
|
|
6155
|
+
const rowsShown = Math.min(state.offset + 1, geometry.measure.total);
|
|
6156
|
+
return [`turn ${String(place(index, groups.length))}/${String(groups.length)}`, `row ${String(rowsShown)}/${String(geometry.measure.total)}`].join(" · ");
|
|
6272
6157
|
}
|
|
6273
6158
|
/**
|
|
6274
6159
|
* Draw the reader.
|
|
6275
6160
|
* @param state - where the reader is.
|
|
6276
|
-
* @param groups - the turns the
|
|
6161
|
+
* @param groups - the turns the list names, already narrowed by the query.
|
|
6277
6162
|
* @param render - the palette, the blocks, the geometry inputs, and the turn total.
|
|
6278
6163
|
* @returns exactly `render.rows` lines, none wider than `render.width`.
|
|
6279
6164
|
*/
|
|
@@ -6289,39 +6174,29 @@ function readerRows(state, groups, render) {
|
|
|
6289
6174
|
const selected = groupIndex(state, groups);
|
|
6290
6175
|
const group = groups[selected];
|
|
6291
6176
|
const columns = [];
|
|
6292
|
-
if (geometry.
|
|
6293
|
-
width: geometry.
|
|
6294
|
-
rows: groups.length === 0 ? [palette.dim(`no turn matches "${state.query ?? ""}"`)] :
|
|
6295
|
-
});
|
|
6296
|
-
const [pinnedWidth, comparedWidth] = geometry.panes;
|
|
6297
|
-
const pinned = state.pinned;
|
|
6298
|
-
if (pinned !== void 0 && comparedWidth !== void 0 && pinnedWidth !== void 0) columns.push({
|
|
6299
|
-
width: pinnedWidth,
|
|
6300
|
-
rows: sectionRows(pinned, blocks, palette, pinnedWidth, false)
|
|
6177
|
+
if (geometry.list > 0) columns.push({
|
|
6178
|
+
width: geometry.list,
|
|
6179
|
+
rows: groups.length === 0 ? [palette.dim(`no turn matches "${state.query ?? ""}"`)] : listColumn(groups, selected, state.column !== "pane", palette, geometry.list, geometry.body)
|
|
6301
6180
|
});
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
rows: group === void 0 ? [] : paneColumn(group, blocks, state.cursor, palette, paneWidth).slice(state.offset)
|
|
6181
|
+
if (geometry.pane > 0) columns.push({
|
|
6182
|
+
width: geometry.pane,
|
|
6183
|
+
rows: group === void 0 ? [] : paneColumn(group, blocks, state.cursor, palette, geometry.pane).slice(state.offset)
|
|
6306
6184
|
});
|
|
6307
6185
|
const body = [];
|
|
6308
6186
|
for (let row = 0; row < geometry.body; row += 1) body.push(bodyRow(columns, row, palette, width));
|
|
6309
|
-
const badge = chip(palette, READER_CHIP);
|
|
6310
|
-
const position = `${String(state.cursor.block + 1)}/${String(blocks.length)}`;
|
|
6311
6187
|
const report = readout(state, groups, geometry, totalTurns);
|
|
6312
6188
|
const legendRoom = ruleRoom(width) - visibleWidth(report) - 1;
|
|
6313
6189
|
return [
|
|
6314
6190
|
topRule({
|
|
6315
|
-
chip:
|
|
6191
|
+
chip: chip(palette, READER_CHIP),
|
|
6316
6192
|
title: palette.bold(palette.accent(`turn ${String(place(selected, groups.length))} of ${String(groups.length)}`)),
|
|
6317
|
-
right: palette.dim(position),
|
|
6318
6193
|
width,
|
|
6319
6194
|
palette,
|
|
6320
6195
|
tone: "focus"
|
|
6321
6196
|
}),
|
|
6322
6197
|
...body,
|
|
6323
6198
|
legendRule({
|
|
6324
|
-
left: legendText(state,
|
|
6199
|
+
left: legendText(state, palette, legendRoom),
|
|
6325
6200
|
right: palette.dim(report),
|
|
6326
6201
|
width,
|
|
6327
6202
|
palette,
|
|
@@ -6355,12 +6230,10 @@ function readerRows(state, groups, render) {
|
|
|
6355
6230
|
*
|
|
6356
6231
|
* The pane holds no copy of the transcript: it re-reads the blocks and their
|
|
6357
6232
|
* turns on every render, so a reply that is still streaming grows inside it,
|
|
6358
|
-
* a tool result that lands appears, and a new turn joins the
|
|
6233
|
+
* a tool result that lands appears, and a new turn joins the list, all with
|
|
6359
6234
|
* no push and no second clock.
|
|
6360
6235
|
* @module @deepseek-ai/dsh-tui-app/reader-overlay
|
|
6361
6236
|
*/
|
|
6362
|
-
/** Which digits select a section of the held turn directly. */
|
|
6363
|
-
const SECTION_DIGIT = /^[1-9]$/u;
|
|
6364
6237
|
/** The key that opens the query line. */
|
|
6365
6238
|
const FILTER_KEY = "/";
|
|
6366
6239
|
/**
|
|
@@ -6369,7 +6242,7 @@ const FILTER_KEY = "/";
|
|
|
6369
6242
|
*/
|
|
6370
6243
|
var ReaderPane = class {
|
|
6371
6244
|
options;
|
|
6372
|
-
/** Where the reader left the keyboard and the
|
|
6245
|
+
/** Where the reader left the keyboard and the reading. */
|
|
6373
6246
|
settled;
|
|
6374
6247
|
resolve;
|
|
6375
6248
|
/** Whether the reader is still open; a second close is ignored. */
|
|
@@ -6418,7 +6291,7 @@ var ReaderPane = class {
|
|
|
6418
6291
|
const groups = turnGroups(blocks);
|
|
6419
6292
|
const visible = filterTurns(groups, blocks, this.state.query);
|
|
6420
6293
|
const geometry = this.geometryFor(visible, blocks, rows);
|
|
6421
|
-
const layout = `${geometry.
|
|
6294
|
+
const layout = `${String(geometry.pane)}x${String(geometry.body)}`;
|
|
6422
6295
|
if (this.layout !== layout) {
|
|
6423
6296
|
this.layout = layout;
|
|
6424
6297
|
this.state = reduceReader(this.state, { kind: "anchor" }, visible, geometry);
|
|
@@ -6464,7 +6337,7 @@ var ReaderPane = class {
|
|
|
6464
6337
|
if (matchesKey(data, "escape")) this.close("transcript");
|
|
6465
6338
|
return;
|
|
6466
6339
|
}
|
|
6467
|
-
if (matchesKey(data, "escape") && readerClosesOnEscape(this.state
|
|
6340
|
+
if (matchesKey(data, "escape") && readerClosesOnEscape(this.state)) {
|
|
6468
6341
|
this.close("transcript");
|
|
6469
6342
|
return;
|
|
6470
6343
|
}
|
|
@@ -6506,7 +6379,7 @@ var ReaderPane = class {
|
|
|
6506
6379
|
intentOf(data) {
|
|
6507
6380
|
switch (this.state.column) {
|
|
6508
6381
|
case "filter": return filterIntent(data);
|
|
6509
|
-
case "
|
|
6382
|
+
case "list": return listIntent(data);
|
|
6510
6383
|
case "pane": return paneIntent(data);
|
|
6511
6384
|
/* v8 ignore next 2 -- closed-union exhaustiveness guard */
|
|
6512
6385
|
default: return assertNever(this.state.column, "tui reader column");
|
|
@@ -6536,11 +6409,13 @@ function filterIntent(data) {
|
|
|
6536
6409
|
};
|
|
6537
6410
|
}
|
|
6538
6411
|
/**
|
|
6539
|
-
* What one key means while the turn
|
|
6412
|
+
* What one key means while the turn list owns the keyboard. `Escape` is not
|
|
6413
|
+
* among them: it leaves the reader, which {@link ReaderPane.handleInput}
|
|
6414
|
+
* answers before a key reaches this map.
|
|
6540
6415
|
* @param data - the raw key bytes.
|
|
6541
|
-
* @returns the intent, or undefined for a key the
|
|
6416
|
+
* @returns the intent, or undefined for a key the list ignores.
|
|
6542
6417
|
*/
|
|
6543
|
-
function
|
|
6418
|
+
function listIntent(data) {
|
|
6544
6419
|
if (matchesKey(data, "up")) return {
|
|
6545
6420
|
kind: "turn",
|
|
6546
6421
|
to: "previous"
|
|
@@ -6569,30 +6444,29 @@ function railIntent(data) {
|
|
|
6569
6444
|
kind: "column",
|
|
6570
6445
|
to: "pane"
|
|
6571
6446
|
};
|
|
6572
|
-
if (matchesKey(data, "escape")) return { kind: "escape" };
|
|
6573
6447
|
return typedText(data) === FILTER_KEY ? { kind: "filter" } : void 0;
|
|
6574
6448
|
}
|
|
6575
6449
|
/**
|
|
6576
|
-
* What one key means while the
|
|
6450
|
+
* What one key means while the turn panel owns the keyboard.
|
|
6577
6451
|
* @param data - the raw key bytes.
|
|
6578
|
-
* @returns the intent, or undefined for a key the
|
|
6452
|
+
* @returns the intent, or undefined for a key the panel ignores.
|
|
6579
6453
|
*/
|
|
6580
6454
|
function paneIntent(data) {
|
|
6581
|
-
if (matchesKey(data, "
|
|
6455
|
+
if (matchesKey(data, "up")) return {
|
|
6582
6456
|
kind: "scroll",
|
|
6583
|
-
|
|
6457
|
+
to: "previous"
|
|
6584
6458
|
};
|
|
6585
|
-
if (matchesKey(data, "
|
|
6459
|
+
if (matchesKey(data, "down")) return {
|
|
6586
6460
|
kind: "scroll",
|
|
6587
|
-
|
|
6461
|
+
to: "next"
|
|
6588
6462
|
};
|
|
6589
|
-
if (matchesKey(data, "
|
|
6590
|
-
kind: "
|
|
6591
|
-
to: "
|
|
6463
|
+
if (matchesKey(data, "home")) return {
|
|
6464
|
+
kind: "scroll",
|
|
6465
|
+
to: "first"
|
|
6592
6466
|
};
|
|
6593
|
-
if (matchesKey(data, "
|
|
6594
|
-
kind: "
|
|
6595
|
-
to: "
|
|
6467
|
+
if (matchesKey(data, "end")) return {
|
|
6468
|
+
kind: "scroll",
|
|
6469
|
+
to: "last"
|
|
6596
6470
|
};
|
|
6597
6471
|
if (matchesKey(data, "pageUp")) return {
|
|
6598
6472
|
kind: "page",
|
|
@@ -6602,25 +6476,10 @@ function paneIntent(data) {
|
|
|
6602
6476
|
kind: "page",
|
|
6603
6477
|
step: 1
|
|
6604
6478
|
};
|
|
6605
|
-
if (matchesKey(data, "home")) return {
|
|
6606
|
-
kind: "section",
|
|
6607
|
-
to: "first"
|
|
6608
|
-
};
|
|
6609
|
-
if (matchesKey(data, "end")) return {
|
|
6610
|
-
kind: "section",
|
|
6611
|
-
to: "last"
|
|
6612
|
-
};
|
|
6613
6479
|
if (matchesKey(data, "left") || matchesKey(data, "tab") || matchesKey(data, "shift+tab")) return {
|
|
6614
6480
|
kind: "column",
|
|
6615
|
-
to: "
|
|
6481
|
+
to: "list"
|
|
6616
6482
|
};
|
|
6617
|
-
if (matchesKey(data, "enter")) return { kind: "pin" };
|
|
6618
|
-
if (matchesKey(data, "escape")) return { kind: "escape" };
|
|
6619
|
-
const digit = typedText(data);
|
|
6620
|
-
return digit !== void 0 && SECTION_DIGIT.test(digit) ? {
|
|
6621
|
-
kind: "section-at",
|
|
6622
|
-
index: Number(digit) - 1
|
|
6623
|
-
} : void 0;
|
|
6624
6483
|
}
|
|
6625
6484
|
//#endregion
|
|
6626
6485
|
//#region lib/types/screen.js
|
|
@@ -7173,7 +7032,7 @@ const HELP_LABEL_GAP = 2;
|
|
|
7173
7032
|
* @returns the lines, unstyled.
|
|
7174
7033
|
*/
|
|
7175
7034
|
function helpKeyLines() {
|
|
7176
|
-
const states = [...FOCUS_REGIONS.map((region) => [REGION_LABELS[region], KEY_LINES[region]]), [READER_LABEL, [READER_HINTS.
|
|
7035
|
+
const states = [...FOCUS_REGIONS.map((region) => [REGION_LABELS[region], KEY_LINES[region]]), [READER_LABEL, [READER_HINTS.list[0], READER_HINTS.pane[0]]]];
|
|
7177
7036
|
const column = Math.max(...states.map(([label]) => visibleWidth(label))) + HELP_LABEL_GAP;
|
|
7178
7037
|
return states.flatMap(([label, lines]) => lines.map((line, index) => `${(index === 0 ? label : "").padEnd(column)}${line}`));
|
|
7179
7038
|
}
|
|
@@ -9903,7 +9762,7 @@ const Config = z.object({
|
|
|
9903
9762
|
toolPreviewLines: z.natural().min(1).default(8),
|
|
9904
9763
|
contextPreviewLines: z.natural().min(1).default(4),
|
|
9905
9764
|
focusPreviewLines: z.natural().min(1).default(12),
|
|
9906
|
-
readerMinColumns: z.natural().min(40).default(
|
|
9765
|
+
readerMinColumns: z.natural().min(40).default(60),
|
|
9907
9766
|
toastMs: z.natural().min(500).default(TOAST_MS),
|
|
9908
9767
|
liveRefreshMs: z.natural().min(100).default(1e3),
|
|
9909
9768
|
streamFadeSteps: z.natural().min(2).default(8),
|