Allow left/right for collapse, more hotkeys

* Use 'b' to toggle fold icon before/after key
* Use 'g' to toggle indentation guide lines
* Cosmetic fixes
This commit is contained in:
2024-10-03 15:29:56 +02:00
parent f023de0198
commit ddfefa124b
4 changed files with 77 additions and 9 deletions

View File

@ -174,8 +174,8 @@ class Editor
'value' => "Insert Value",
'object' => "Insert Object{}",
'array' => "Insert Array[]",
'sep0' => "---",
'__paste' => "Paste from clipboard",
//'sep0' => "---",
//'__paste' => "Paste from clipboard",
], 'Insert');
$this->redrawInfoBar([ '^C' => 'Cancel', '↑/↓' => 'Select option', 'Enter' => 'Accept' ]);
$sel = $menu->display(0, 0, 30, 0, "value");
@ -213,6 +213,18 @@ class Editor
$this->running = false;
break;
case "g":
Settings::$indentationGuides = !Settings::$indentationGuides;
$this->redrawEditor();
$this->showMessage("Toggle indentation guides (g)");
break;
case "b":
Settings::$collapseBefore = !Settings::$collapseBefore;
$this->redrawEditor();
$this->showMessage("Toggle collapse icon before item (b)");
break;
case "+":
$node = $this->list->getNodeForIndex($this->currentRow);
if ($node instanceof CollapsibleNode) {
@ -221,16 +233,36 @@ class Editor
$this->redrawEditor();
}
break;
case "k{LEFT}":
$node = $this->list->getNodeForIndex($this->currentRow);
if ($node instanceof CollapsibleNode) {
$node->collapse(true);
$this->list->parseTree();
$this->redrawEditor();
}
break;
case "k{RIGHT}":
$node = $this->list->getNodeForIndex($this->currentRow);
if ($node instanceof CollapsibleNode) {
$node->collapse(false);
$this->list->parseTree();
$this->redrawEditor();
}
break;
case "q":
Settings::$editorQuotedKeys = !Settings::$editorQuotedKeys;
$this->redrawEditor();
$this->showMessage("Toggle quoted keys (q)");
break;
case "c":
Settings::$compactGroups = !Settings::$compactGroups;
$this->list->parseTree();
$this->redrawEditor();
$this->showMessage("Toggle compact groups (c)");
break;
case "\x0e": // ctrl-n