Skip to content

Commit

Permalink
doc: new text-editor topic for cli
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Mar 1, 2024
1 parent ba25914 commit 1e4a88e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/cli/quick.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
70 changes: 70 additions & 0 deletions doc/cli/text-editor.md
Original file line number Diff line number Diff line change
@@ -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 <TAB>
emacs nano vi
admin@host:/config/system/> set text-editor nano
admin@host:/config/system/> leave
admin@example:/>
```
7 changes: 4 additions & 3 deletions src/klish-plugin-infix/xml/infix.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,19 @@
<COMMAND name="help" help="Help system (try also the '?' key)">
<PARAM name="topic" ptype="/STRING" min="0" help="Help topic">
<COMPL>
<ACTION sym="printl">introduction</ACTION>
<ACTION sym="printl">keybindings</ACTION>
<ACTION sym="printl">text-editor</ACTION>
<ACTION sym="printl">tutorial</ACTION>
<ACTION sym="printl">introduction</ACTION>
</COMPL>
</PARAM>
<ACTION sym="script">
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
</ACTION>
</COMMAND>
Expand Down

0 comments on commit 1e4a88e

Please sign in to comment.