blun-king-cli 7.3.2 → 7.3.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/lib/chat.js +17 -6
- package/package.json +1 -1
package/lib/chat.js
CHANGED
|
@@ -382,6 +382,13 @@ function startChat() {
|
|
|
382
382
|
function openDropdownBelow(items, onSelect, onClose) {
|
|
383
383
|
var active = true;
|
|
384
384
|
var selected = 0;
|
|
385
|
+
var menuHeight = items.length + 2; // items + help line + padding
|
|
386
|
+
// Temporarily increase panel height to make room for menu below panel
|
|
387
|
+
var savedHeight = INPUT_PANEL_HEIGHT;
|
|
388
|
+
INPUT_PANEL_HEIGHT = 5 + menuHeight; // 5 = panel itself
|
|
389
|
+
// Recalculate scroll region
|
|
390
|
+
setupLayout();
|
|
391
|
+
drawInputPanel();
|
|
385
392
|
|
|
386
393
|
function getMenuStart() {
|
|
387
394
|
var rows = getRows();
|
|
@@ -389,12 +396,15 @@ function startChat() {
|
|
|
389
396
|
return panelTop + 5; // right after the bottom frame of input panel
|
|
390
397
|
}
|
|
391
398
|
|
|
392
|
-
function
|
|
393
|
-
|
|
399
|
+
function restoreLayout() {
|
|
400
|
+
INPUT_PANEL_HEIGHT = savedHeight;
|
|
394
401
|
var rows = getRows();
|
|
395
|
-
|
|
396
|
-
|
|
402
|
+
// Clear the entire menu + panel area
|
|
403
|
+
for (var r = rows - INPUT_PANEL_HEIGHT - menuHeight; r <= rows; r++) {
|
|
404
|
+
process.stdout.write(cursorTo(Math.max(1, r), 1) + clearLine());
|
|
397
405
|
}
|
|
406
|
+
setupLayout();
|
|
407
|
+
drawInputPanel();
|
|
398
408
|
}
|
|
399
409
|
|
|
400
410
|
function drawMenu() {
|
|
@@ -428,7 +438,7 @@ function startChat() {
|
|
|
428
438
|
if ((key === "\u001b" && key.length === 1) || key === "\u0003") {
|
|
429
439
|
active = false;
|
|
430
440
|
process.stdin.removeAllListeners("data");
|
|
431
|
-
|
|
441
|
+
restoreLayout();
|
|
432
442
|
if (onClose) onClose();
|
|
433
443
|
startRawInput();
|
|
434
444
|
return;
|
|
@@ -452,6 +462,7 @@ function startChat() {
|
|
|
452
462
|
if (key === "\u001b[D" || key === "\u001b[C") {
|
|
453
463
|
if (items[selected].onCycle) {
|
|
454
464
|
items[selected].onCycle(key === "\u001b[C" ? 1 : -1);
|
|
465
|
+
drawInputPanel();
|
|
455
466
|
drawMenu();
|
|
456
467
|
}
|
|
457
468
|
return;
|
|
@@ -461,7 +472,7 @@ function startChat() {
|
|
|
461
472
|
if (key === "\r" || key === "\n") {
|
|
462
473
|
active = false;
|
|
463
474
|
process.stdin.removeAllListeners("data");
|
|
464
|
-
|
|
475
|
+
restoreLayout();
|
|
465
476
|
if (onSelect) onSelect(items[selected]);
|
|
466
477
|
startRawInput();
|
|
467
478
|
return;
|