@nmakarov/cli-toolkit 0.68.0 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-runner.cjs +21 -17
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +21 -17
- package/dist/cli-runner.js.map +1 -1
- package/dist/index.cjs +21 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/dist/init.cjs +21 -17
- package/dist/init.cjs.map +1 -1
- package/dist/init.js +21 -17
- package/dist/init.js.map +1 -1
- package/dist/screen.cjs +19 -16
- package/dist/screen.cjs.map +1 -1
- package/dist/screen.js +19 -16
- package/dist/screen.js.map +1 -1
- package/package.json +1 -1
package/dist/cli-runner.js
CHANGED
|
@@ -979,7 +979,7 @@ function scrollbarGlyphs(viewportRows, totalLines, scrollTop) {
|
|
|
979
979
|
const thumbStart = maxScroll === 0 ? 0 : Math.round(s / maxScroll * travel);
|
|
980
980
|
const glyphs = [];
|
|
981
981
|
for (let i = 0; i < view; i++) {
|
|
982
|
-
glyphs.push(i >= thumbStart && i < thumbStart + thumbSize ?
|
|
982
|
+
glyphs.push(i >= thumbStart && i < thumbStart + thumbSize ? BAR_THUMB : BAR_TRACK);
|
|
983
983
|
}
|
|
984
984
|
return glyphs;
|
|
985
985
|
}
|
|
@@ -1001,20 +1001,19 @@ function ScrollableText({
|
|
|
1001
1001
|
}) {
|
|
1002
1002
|
const [scrollTop, setScrollTop] = useState3(0);
|
|
1003
1003
|
const [, bump] = useState3(0);
|
|
1004
|
-
const termCols = process.stdout.columns || 80;
|
|
1005
1004
|
const termRows = process.stdout.rows || 24;
|
|
1006
1005
|
const viewportRows = Math.max(
|
|
1007
1006
|
4,
|
|
1008
1007
|
maxHeight != null ? Math.floor(maxHeight) : Math.max(8, termRows - 8)
|
|
1009
1008
|
);
|
|
1010
|
-
const
|
|
1011
|
-
const
|
|
1009
|
+
const contentCols = Math.max(20, getScreenWidth() - 4);
|
|
1010
|
+
const barCols = showScrollbar ? 1 : 0;
|
|
1011
|
+
const textWidth = Math.max(8, contentCols - barCols);
|
|
1012
1012
|
const allLines = useMemo(() => {
|
|
1013
1013
|
if (Array.isArray(linesProp)) return linesProp.map((l) => String(l ?? ""));
|
|
1014
|
-
return wrap ? wrapTextLines(text,
|
|
1015
|
-
}, [linesProp, text, wrap,
|
|
1014
|
+
return wrap ? wrapTextLines(text, textWidth) : String(text ?? "").split("\n");
|
|
1015
|
+
}, [linesProp, text, wrap, textWidth]);
|
|
1016
1016
|
const needsBar = showScrollbar && allLines.length > viewportRows;
|
|
1017
|
-
const textWidth = Math.max(8, termCols - (needsBar ? 1 : 0));
|
|
1018
1017
|
const maxScroll = Math.max(0, allLines.length - viewportRows);
|
|
1019
1018
|
const clamped = Math.min(Math.max(0, scrollTop), maxScroll);
|
|
1020
1019
|
const visible = allLines.slice(clamped, clamped + viewportRows);
|
|
@@ -1054,22 +1053,24 @@ function ScrollableText({
|
|
|
1054
1053
|
const status = allLines.length === 0 ? "empty" : `lines ${clamped + 1}-${Math.min(clamped + visible.length, allLines.length)} of ${allLines.length}` + (needsBar ? " \xB7 \u2325\u2191/\u2193 or PgUp/Dn page" : "");
|
|
1055
1054
|
const rowNodes = visible.map((line, i) => {
|
|
1056
1055
|
const body = padEndVisible(line, textWidth);
|
|
1057
|
-
const glyph = bar ? bar[i] ?? "
|
|
1056
|
+
const glyph = bar ? bar[i] ?? BAR_TRACK : showScrollbar ? " " : "";
|
|
1057
|
+
const isThumb = glyph === BAR_THUMB;
|
|
1058
1058
|
return h5(
|
|
1059
|
-
|
|
1060
|
-
{ key: `L${clamped + i}
|
|
1061
|
-
|
|
1062
|
-
glyph ? h5(Text5, { color:
|
|
1059
|
+
Text5,
|
|
1060
|
+
{ key: `L${clamped + i}` },
|
|
1061
|
+
body,
|
|
1062
|
+
glyph ? h5(Text5, { color: isThumb ? "cyan" : "gray" }, glyph) : null
|
|
1063
1063
|
);
|
|
1064
1064
|
});
|
|
1065
1065
|
if (bar && visible.length < viewportRows) {
|
|
1066
1066
|
for (let i = visible.length; i < viewportRows; i++) {
|
|
1067
|
+
const glyph = bar[i] ?? BAR_TRACK;
|
|
1067
1068
|
rowNodes.push(
|
|
1068
1069
|
h5(
|
|
1069
|
-
|
|
1070
|
-
{ key: `pad${i}
|
|
1071
|
-
|
|
1072
|
-
h5(Text5, { color:
|
|
1070
|
+
Text5,
|
|
1071
|
+
{ key: `pad${i}` },
|
|
1072
|
+
padEndVisible("", textWidth),
|
|
1073
|
+
h5(Text5, { color: glyph === BAR_THUMB ? "cyan" : "gray" }, glyph)
|
|
1073
1074
|
)
|
|
1074
1075
|
);
|
|
1075
1076
|
}
|
|
@@ -1082,10 +1083,13 @@ function ScrollableText({
|
|
|
1082
1083
|
...rowNodes
|
|
1083
1084
|
);
|
|
1084
1085
|
}
|
|
1085
|
-
var h5, SCROLL_KEYS;
|
|
1086
|
+
var h5, BAR_THUMB, BAR_TRACK, SCROLL_KEYS;
|
|
1086
1087
|
var init_scrollable_text = __esm({
|
|
1087
1088
|
"src/screen/scrollable-text.js"() {
|
|
1089
|
+
init_components();
|
|
1088
1090
|
h5 = createElement2;
|
|
1091
|
+
BAR_THUMB = "#";
|
|
1092
|
+
BAR_TRACK = "|";
|
|
1089
1093
|
SCROLL_KEYS = [
|
|
1090
1094
|
{ key: "upArrow", caption: "scroll", action: "scrollUp", order: 0 },
|
|
1091
1095
|
{ key: "downArrow", caption: "scroll", action: "scrollDown", order: 0 },
|