Change exit hotkey to ^X from ^C to avoid accidents

This commit is contained in:
Chris 2024-10-02 02:00:31 +02:00
parent 3211e55e05
commit bf6756773e

View File

@ -207,8 +207,7 @@ class Editor
$this->modified = true; $this->modified = true;
break; break;
case 'Q': case "\x18": // ctrl-x
case "\x03": // ctrl-w
$this->running = false; $this->running = false;
break; break;
@ -418,7 +417,7 @@ class Editor
[$w,$h] = $this->term->getSize(); [$w,$h] = $this->term->getSize();
$text = <<<EOT $text = <<<EOT
JSONEdit Alpha - Copyright (C) 2024, NoccyLabs ## JSONEdit Alpha - Copyright (C) 2024, NoccyLabs
Licensed under GNU GPL v3.0 or later. Licensed under GNU GPL v3.0 or later.
@ -661,17 +660,28 @@ class Editor
if (!$keys) { if (!$keys) {
$keys = [ $keys = [
'h' => 'Help', 'h' => 'Help',
'e' => 'Edit',
'E' => 'Edit key',
'I' => 'Insert…',
//'i' => 'Ins value',
'D' => 'Delete', 'D' => 'Delete',
//'C' => 'Copy', ];
//'P' => 'Paste', $node = $this->list->getNodeForIndex($this->currentRow);
'^N' => 'New', if ($node instanceof ValueNode) {
$keys = [ ...$keys,
'e' => 'Edit',
];
}
if ($node instanceof ObjectNode || $node instanceof ArrayNode) {
$keys = [ ...$keys,
'I' => 'Insert…',
];
}
if ($this->modified) {
$keys = [ ...$keys,
'^N' => 'New',
'^W' => 'Write',
];
}
$keys = [ ...$keys,
'^R' => 'Read', '^R' => 'Read',
'^W' => 'Write', '^X' => 'Exit',
'^C' => 'Exit',
]; ];
} }