@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/index.js
CHANGED
|
@@ -973,7 +973,7 @@ function scrollbarGlyphs(viewportRows, totalLines, scrollTop) {
|
|
|
973
973
|
const thumbStart = maxScroll === 0 ? 0 : Math.round(s / maxScroll * travel);
|
|
974
974
|
const glyphs = [];
|
|
975
975
|
for (let i = 0; i < view; i++) {
|
|
976
|
-
glyphs.push(i >= thumbStart && i < thumbStart + thumbSize ?
|
|
976
|
+
glyphs.push(i >= thumbStart && i < thumbStart + thumbSize ? BAR_THUMB : BAR_TRACK);
|
|
977
977
|
}
|
|
978
978
|
return glyphs;
|
|
979
979
|
}
|
|
@@ -995,20 +995,19 @@ function ScrollableText({
|
|
|
995
995
|
}) {
|
|
996
996
|
const [scrollTop, setScrollTop] = useState3(0);
|
|
997
997
|
const [, bump] = useState3(0);
|
|
998
|
-
const termCols = process.stdout.columns || 80;
|
|
999
998
|
const termRows = process.stdout.rows || 24;
|
|
1000
999
|
const viewportRows = Math.max(
|
|
1001
1000
|
4,
|
|
1002
1001
|
maxHeight != null ? Math.floor(maxHeight) : Math.max(8, termRows - 8)
|
|
1003
1002
|
);
|
|
1004
|
-
const
|
|
1005
|
-
const
|
|
1003
|
+
const contentCols = Math.max(20, getScreenWidth() - 4);
|
|
1004
|
+
const barCols = showScrollbar ? 1 : 0;
|
|
1005
|
+
const textWidth = Math.max(8, contentCols - barCols);
|
|
1006
1006
|
const allLines = useMemo(() => {
|
|
1007
1007
|
if (Array.isArray(linesProp)) return linesProp.map((l) => String(l ?? ""));
|
|
1008
|
-
return wrap ? wrapTextLines(text,
|
|
1009
|
-
}, [linesProp, text, wrap,
|
|
1008
|
+
return wrap ? wrapTextLines(text, textWidth) : String(text ?? "").split("\n");
|
|
1009
|
+
}, [linesProp, text, wrap, textWidth]);
|
|
1010
1010
|
const needsBar = showScrollbar && allLines.length > viewportRows;
|
|
1011
|
-
const textWidth = Math.max(8, termCols - (needsBar ? 1 : 0));
|
|
1012
1011
|
const maxScroll = Math.max(0, allLines.length - viewportRows);
|
|
1013
1012
|
const clamped = Math.min(Math.max(0, scrollTop), maxScroll);
|
|
1014
1013
|
const visible = allLines.slice(clamped, clamped + viewportRows);
|
|
@@ -1048,22 +1047,24 @@ function ScrollableText({
|
|
|
1048
1047
|
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" : "");
|
|
1049
1048
|
const rowNodes = visible.map((line, i) => {
|
|
1050
1049
|
const body = padEndVisible(line, textWidth);
|
|
1051
|
-
const glyph = bar ? bar[i] ?? "
|
|
1050
|
+
const glyph = bar ? bar[i] ?? BAR_TRACK : showScrollbar ? " " : "";
|
|
1051
|
+
const isThumb = glyph === BAR_THUMB;
|
|
1052
1052
|
return h5(
|
|
1053
|
-
|
|
1054
|
-
{ key: `L${clamped + i}
|
|
1055
|
-
|
|
1056
|
-
glyph ? h5(Text5, { color:
|
|
1053
|
+
Text5,
|
|
1054
|
+
{ key: `L${clamped + i}` },
|
|
1055
|
+
body,
|
|
1056
|
+
glyph ? h5(Text5, { color: isThumb ? "cyan" : "gray" }, glyph) : null
|
|
1057
1057
|
);
|
|
1058
1058
|
});
|
|
1059
1059
|
if (bar && visible.length < viewportRows) {
|
|
1060
1060
|
for (let i = visible.length; i < viewportRows; i++) {
|
|
1061
|
+
const glyph = bar[i] ?? BAR_TRACK;
|
|
1061
1062
|
rowNodes.push(
|
|
1062
1063
|
h5(
|
|
1063
|
-
|
|
1064
|
-
{ key: `pad${i}
|
|
1065
|
-
|
|
1066
|
-
h5(Text5, { color:
|
|
1064
|
+
Text5,
|
|
1065
|
+
{ key: `pad${i}` },
|
|
1066
|
+
padEndVisible("", textWidth),
|
|
1067
|
+
h5(Text5, { color: glyph === BAR_THUMB ? "cyan" : "gray" }, glyph)
|
|
1067
1068
|
)
|
|
1068
1069
|
);
|
|
1069
1070
|
}
|
|
@@ -1076,10 +1077,13 @@ function ScrollableText({
|
|
|
1076
1077
|
...rowNodes
|
|
1077
1078
|
);
|
|
1078
1079
|
}
|
|
1079
|
-
var h5, SCROLL_KEYS;
|
|
1080
|
+
var h5, BAR_THUMB, BAR_TRACK, SCROLL_KEYS;
|
|
1080
1081
|
var init_scrollable_text = __esm({
|
|
1081
1082
|
"src/screen/scrollable-text.js"() {
|
|
1083
|
+
init_components();
|
|
1082
1084
|
h5 = createElement2;
|
|
1085
|
+
BAR_THUMB = "#";
|
|
1086
|
+
BAR_TRACK = "|";
|
|
1083
1087
|
SCROLL_KEYS = [
|
|
1084
1088
|
{ key: "upArrow", caption: "scroll", action: "scrollUp", order: 0 },
|
|
1085
1089
|
{ key: "downArrow", caption: "scroll", action: "scrollDown", order: 0 },
|