From 1e4a88e0b9af866e775ea1b342a909e340497739 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 1 Mar 2024 14:14:33 +0100 Subject: [PATCH] doc: new text-editor topic for cli Signed-off-by: Joachim Wiberg --- doc/cli/quick.md | 4 ++ doc/cli/text-editor.md | 70 ++++++++++++++++++++++++++++ src/klish-plugin-infix/xml/infix.xml | 9 ++-- 3 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 doc/cli/text-editor.md diff --git a/doc/cli/quick.md b/doc/cli/quick.md index 5b5c1eaa..8f5838ba 100644 --- a/doc/cli/quick.md +++ b/doc/cli/quick.md @@ -21,5 +21,9 @@ keybindings are really useful to learn! | `help introduction` | An introduction to the CLI | | `help keybindings` | Lists keybindings and other helpful tricks | | `help tutorial` | The CLI User Guide | +| `help text-editor` | Help with the built-in text-editor command | +> In `configure` context the `help setting` command shows the YANG +> description text for each node and container. To reach the admin +> exec help from configure context, e.g., `do help text-editor` diff --git a/doc/cli/text-editor.md b/doc/cli/text-editor.md new file mode 100644 index 00000000..c81904ee --- /dev/null +++ b/doc/cli/text-editor.md @@ -0,0 +1,70 @@ +# Text Editor + +The CLI built-in `text-editor` command can be used to edit type `binary` +settings in configure context. + +The default editor is a Micro Emacs clone. Users not familiar with +terminal based editors may benefit from this introduction. + + +## Escape Meta/Alt Control Shift + +When starting up, the editor status field at the bottom shows the +following shorthand: + +``` +C-h q quick help | C-h t tutorial | C-h b key bindings | C = Ctrl | M = Alt +``` + +Key combinations with a `-` (dash) mean holding down the modifier key. +Combinations without a `-` (dash) mean without any modifier key. + +### Quick help `C-h q` + + - hold down the `Ctrl` key on + - tap the `h` key + - release `Ctrl` + - tap the `q` key + +The bottom part of the terminal now shows a "buffer" called `*quick*`: + +``` +FILE BUFFER WINDOW MARK/KILL MISC +C-x C-c exit C-x b switch C-x 0 only other C-space mark C-_ undo +C-x C-f find C-x k close C-x 1 only this C-w kill-rg C-s search +C-x C-s save C-x C-b list C-x 2 split two C-k kill-ln C-r r-search +C-x s save-all C-x h mark C-x ^ enlarge C-y yank M-% replace +C-x i insert C-x g goto-ln C-x o other win C-x C-x swap M-q reformat +``` + +### Save & Exit `C-x C-c` + + - Hold down the Ctrl key + - tap `X` + - tap `c` + - release `Ctrl` + +> The status field at the bottom asks if you are really sure, and/or if +> you want to add a final Enter/newline to the file. For binary content +> that final newline may be important. + + +## Changing the Editor + +The system has three different built-in editors: + + - `emacs` (Micro Emacs) + - `nano` (GNU Nano) + - `vi` (Visual Editor) + +Changing editor is done in configure context, in the system container: + +``` +admin@host:/> configure +admin@host:/config/> edit system +admin@host:/config/system/> set text-editor +emacs nano vi +admin@host:/config/system/> set text-editor nano +admin@host:/config/system/> leave +admin@example:/> +``` diff --git a/src/klish-plugin-infix/xml/infix.xml b/src/klish-plugin-infix/xml/infix.xml index 23e677a5..2a7c01d5 100644 --- a/src/klish-plugin-infix/xml/infix.xml +++ b/src/klish-plugin-infix/xml/infix.xml @@ -123,18 +123,19 @@ - keybindings - tutorial introduction + keybindings + text-editor + tutorial topic=${KLISH_PARAM_topic:-quick} fn="/usr/share/infix/cli/${topic}.md" if [ -f "$fn" ]; then - lowdown -t term "$fn" + lowdown -t term --term-vmargin=1 "$fn" else - echo "Topic not available." + echo "Topic not available." fi