session-preserver 0.1.2 → 0.1.3
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/index.js +14 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -274,7 +274,7 @@ function pickInteractive(rows) {
|
|
|
274
274
|
const height = () => Math.max(5, (process.stdout.rows || 24) - 3);
|
|
275
275
|
|
|
276
276
|
const draw = () => {
|
|
277
|
-
const out = [
|
|
277
|
+
const out = [`\x1b[H\x1b[J↑/↓ j/k move · PgUp/PgDn page · g/G top/bottom · enter resume · s summary · q quit [${sel + 1}/${rows.length}]\n`];
|
|
278
278
|
const h = height();
|
|
279
279
|
if (sel < offset) offset = sel;
|
|
280
280
|
if (sel >= offset + h) offset = sel - h + 1;
|
|
@@ -298,11 +298,18 @@ function pickInteractive(rows) {
|
|
|
298
298
|
process.stdin.resume();
|
|
299
299
|
process.stdin.setEncoding("utf8");
|
|
300
300
|
process.stdin.on("data", (key) => {
|
|
301
|
+
const h = height();
|
|
301
302
|
if (key === "q" || key === "\x03" || key === "\x1b") return done("quit");
|
|
302
|
-
if (key === "\x1b[A" || key === "k")
|
|
303
|
-
if (key === "\x1b[B" || key === "j")
|
|
304
|
-
if (key === "\
|
|
305
|
-
if (key === "
|
|
303
|
+
if (key === "\x1b[A" || key === "k") sel = Math.max(0, sel - 1);
|
|
304
|
+
else if (key === "\x1b[B" || key === "j") sel = Math.min(rows.length - 1, sel + 1);
|
|
305
|
+
else if (key === "\x1b[5~" || key === "\x02") sel = Math.max(0, sel - h); // PgUp / Ctrl-B
|
|
306
|
+
else if (key === "\x1b[6~" || key === "\x06") sel = Math.min(rows.length - 1, sel + h); // PgDn / Ctrl-F
|
|
307
|
+
else if (key === "g") sel = 0;
|
|
308
|
+
else if (key === "G") sel = rows.length - 1;
|
|
309
|
+
else if (key === "\r" || key === "\n") return done("open");
|
|
310
|
+
else if (key === "s") return done("summary");
|
|
311
|
+
else return;
|
|
312
|
+
draw();
|
|
306
313
|
});
|
|
307
314
|
process.stdout.write("\x1b[?1049h"); // alt screen (after raw mode so first draw is clean)
|
|
308
315
|
draw();
|
|
@@ -347,9 +354,9 @@ let cmd = "ls";
|
|
|
347
354
|
if (COMMANDS.has(argv[0])) cmd = argv.shift();
|
|
348
355
|
|
|
349
356
|
if (cmd === "ls") {
|
|
350
|
-
const args = { n:
|
|
357
|
+
const args = { n: 500, since: null, tool: null, query: null };
|
|
351
358
|
for (let i = 0; i < argv.length; i++) {
|
|
352
|
-
if (argv[i] === "-n") args.n = Number(argv[++i]);
|
|
359
|
+
if (argv[i] === "-n") { args.n = Number(argv[++i]); if (!args.n) args.n = Infinity; }
|
|
353
360
|
else if (argv[i] === "--since") args.since = argv[++i];
|
|
354
361
|
else if (argv[i] === "--tool") {
|
|
355
362
|
args.tool = argv[++i];
|