@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.cjs
CHANGED
|
@@ -993,7 +993,7 @@ function scrollbarGlyphs(viewportRows, totalLines, scrollTop) {
|
|
|
993
993
|
const thumbStart = maxScroll === 0 ? 0 : Math.round(s / maxScroll * travel);
|
|
994
994
|
const glyphs = [];
|
|
995
995
|
for (let i = 0; i < view; i++) {
|
|
996
|
-
glyphs.push(i >= thumbStart && i < thumbStart + thumbSize ?
|
|
996
|
+
glyphs.push(i >= thumbStart && i < thumbStart + thumbSize ? BAR_THUMB : BAR_TRACK);
|
|
997
997
|
}
|
|
998
998
|
return glyphs;
|
|
999
999
|
}
|
|
@@ -1015,20 +1015,19 @@ function ScrollableText({
|
|
|
1015
1015
|
}) {
|
|
1016
1016
|
const [scrollTop, setScrollTop] = (0, import_react5.useState)(0);
|
|
1017
1017
|
const [, bump] = (0, import_react5.useState)(0);
|
|
1018
|
-
const termCols = process.stdout.columns || 80;
|
|
1019
1018
|
const termRows = process.stdout.rows || 24;
|
|
1020
1019
|
const viewportRows = Math.max(
|
|
1021
1020
|
4,
|
|
1022
1021
|
maxHeight != null ? Math.floor(maxHeight) : Math.max(8, termRows - 8)
|
|
1023
1022
|
);
|
|
1024
|
-
const
|
|
1025
|
-
const
|
|
1023
|
+
const contentCols = Math.max(20, getScreenWidth() - 4);
|
|
1024
|
+
const barCols = showScrollbar ? 1 : 0;
|
|
1025
|
+
const textWidth = Math.max(8, contentCols - barCols);
|
|
1026
1026
|
const allLines = (0, import_react5.useMemo)(() => {
|
|
1027
1027
|
if (Array.isArray(linesProp)) return linesProp.map((l) => String(l ?? ""));
|
|
1028
|
-
return wrap ? wrapTextLines(text,
|
|
1029
|
-
}, [linesProp, text, wrap,
|
|
1028
|
+
return wrap ? wrapTextLines(text, textWidth) : String(text ?? "").split("\n");
|
|
1029
|
+
}, [linesProp, text, wrap, textWidth]);
|
|
1030
1030
|
const needsBar = showScrollbar && allLines.length > viewportRows;
|
|
1031
|
-
const textWidth = Math.max(8, termCols - (needsBar ? 1 : 0));
|
|
1032
1031
|
const maxScroll = Math.max(0, allLines.length - viewportRows);
|
|
1033
1032
|
const clamped = Math.min(Math.max(0, scrollTop), maxScroll);
|
|
1034
1033
|
const visible = allLines.slice(clamped, clamped + viewportRows);
|
|
@@ -1068,22 +1067,24 @@ function ScrollableText({
|
|
|
1068
1067
|
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" : "");
|
|
1069
1068
|
const rowNodes = visible.map((line, i) => {
|
|
1070
1069
|
const body = padEndVisible(line, textWidth);
|
|
1071
|
-
const glyph = bar ? bar[i] ?? "
|
|
1070
|
+
const glyph = bar ? bar[i] ?? BAR_TRACK : showScrollbar ? " " : "";
|
|
1071
|
+
const isThumb = glyph === BAR_THUMB;
|
|
1072
1072
|
return h5(
|
|
1073
|
-
import_ink5.
|
|
1074
|
-
{ key: `L${clamped + i}
|
|
1075
|
-
|
|
1076
|
-
glyph ? h5(import_ink5.Text, { color:
|
|
1073
|
+
import_ink5.Text,
|
|
1074
|
+
{ key: `L${clamped + i}` },
|
|
1075
|
+
body,
|
|
1076
|
+
glyph ? h5(import_ink5.Text, { color: isThumb ? "cyan" : "gray" }, glyph) : null
|
|
1077
1077
|
);
|
|
1078
1078
|
});
|
|
1079
1079
|
if (bar && visible.length < viewportRows) {
|
|
1080
1080
|
for (let i = visible.length; i < viewportRows; i++) {
|
|
1081
|
+
const glyph = bar[i] ?? BAR_TRACK;
|
|
1081
1082
|
rowNodes.push(
|
|
1082
1083
|
h5(
|
|
1083
|
-
import_ink5.
|
|
1084
|
-
{ key: `pad${i}
|
|
1085
|
-
|
|
1086
|
-
h5(import_ink5.Text, { color:
|
|
1084
|
+
import_ink5.Text,
|
|
1085
|
+
{ key: `pad${i}` },
|
|
1086
|
+
padEndVisible("", textWidth),
|
|
1087
|
+
h5(import_ink5.Text, { color: glyph === BAR_THUMB ? "cyan" : "gray" }, glyph)
|
|
1087
1088
|
)
|
|
1088
1089
|
);
|
|
1089
1090
|
}
|
|
@@ -1096,12 +1097,15 @@ function ScrollableText({
|
|
|
1096
1097
|
...rowNodes
|
|
1097
1098
|
);
|
|
1098
1099
|
}
|
|
1099
|
-
var import_react5, import_ink5, h5, SCROLL_KEYS;
|
|
1100
|
+
var import_react5, import_ink5, h5, BAR_THUMB, BAR_TRACK, SCROLL_KEYS;
|
|
1100
1101
|
var init_scrollable_text = __esm({
|
|
1101
1102
|
"src/screen/scrollable-text.js"() {
|
|
1102
1103
|
import_react5 = require("react");
|
|
1103
1104
|
import_ink5 = require("ink");
|
|
1105
|
+
init_components();
|
|
1104
1106
|
h5 = import_react5.createElement;
|
|
1107
|
+
BAR_THUMB = "#";
|
|
1108
|
+
BAR_TRACK = "|";
|
|
1105
1109
|
SCROLL_KEYS = [
|
|
1106
1110
|
{ key: "upArrow", caption: "scroll", action: "scrollUp", order: 0 },
|
|
1107
1111
|
{ key: "downArrow", caption: "scroll", action: "scrollDown", order: 0 },
|