nix repl has no way(?) to navigate by words #501

Closed
opened 2024-09-07 21:54:06 +00:00 by rbt · 3 comments
Owner

When I press <Ctrl-left> or <Ctrl-right> or <Alt-left> or <Alt-right> or various combinations of these, nix repl does not navigate the prompt cursor by words.

nix-repl> a b c 
# Press <Ctrl-left> and <Ctrl-right> a few times
nix-repl> a b c[D[D[C[C
# Noooo!!!!

This makes me very sad and makes me press arrow keys way too many times. Is this editline's fault? Do we need to improve our bindings? Who knows.

When I press `<Ctrl-left>` or `<Ctrl-right>` or `<Alt-left>` or `<Alt-right>` or various combinations of these, `nix repl` does not navigate the prompt cursor by words. ``` nix-repl> a b c # Press <Ctrl-left> and <Ctrl-right> a few times nix-repl> a b c[D[D[C[C # Noooo!!!! ``` This makes me very sad and makes me press arrow keys way too many times. Is this `editline`'s fault? Do we need to improve our bindings? Who knows.
rbt added the
ux
E/help wanted
Area/repl
labels 2024-09-07 21:54:06 +00:00

Since I happened to be digging into editline recently already I thought I'd try to add some context here (edit: and, forgot to mention, these keybinds do work in the Lix REPL for me):

I think this is at least partially dependent on your terminal emulator, and what escape sequences it sends when you press those keys; for example this is a subset of mine:

Screenshot 2024-09-07 at 18.09.42.png

Those correspond to

  • alt-b
  • Home
  • alt-f
  • End

respectively, AFAIK.

The output you wrote makes me think yours might be sending \e[D and \e[C, for example, which don't have builtin editline bindings, but there are a number of builtin ones for other escape sequences: ac81ca6d4b/src/editline.c (L1984-L1987)

It may be possible to add bindings with el_bind_key_in_metamap for the sequences your terminal emulator is sending too, but I'm not sure what they are normally supposed to translate to... From what I can find it seems like maybe that would normally just be the same as arrow keys?

There is also a CONFIG_ANSI_ARROWS we might need to enable (but I think that must be enabled already, for normal arrow key functionality to work)....

Since I happened to be digging into `editline` recently already I thought I'd try to add some context here (edit: and, forgot to mention, these keybinds _do_ work in the Lix REPL for me): I think this is at least partially dependent on your terminal emulator, and what escape sequences it sends when you press those keys; for example this is a subset of mine: ![Screenshot 2024-09-07 at 18.09.42.png](/attachments/3cc2327f-d34c-4e2d-a0ce-ceb5259155d5) Those correspond to - `alt-b` - `Home` - `alt-f` - `End` respectively, AFAIK. The output you wrote makes me think yours might be sending `\e[D` and `\e[C`, for example, which don't have builtin `editline` bindings, but there are a number of builtin ones for other escape sequences: https://github.com/troglobit/editline/blob/ac81ca6d4b15b5da64c6f8bfb6026fdb1c7c3687/src/editline.c#L1984-L1987 It may be possible to add bindings with `el_bind_key_in_metamap` for the sequences your terminal emulator is sending too, but I'm not sure what they are normally supposed to translate to... From [what I can find](https://en.wikipedia.org/wiki/ANSI_escape_code#Terminal_input_sequences) it seems like maybe that would normally just be the same as arrow keys? There is also a `CONFIG_ANSI_ARROWS` we might need to enable (but I think that must be enabled already, for normal arrow key functionality to work)....
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/1883 ("repl: Patch editline to recognize Meta-Left & Meta-Right")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/1883", "number": 1883, "kind": "commit message"}], "cl_meta": {"1883": {"change_title": "repl: Patch editline to recognize Meta-Left & Meta-Right"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/1883](https://gerrit.lix.systems/c/lix/+/1883) ("repl: Patch editline to recognize Meta-Left & Meta-Right")
Author
Owner
Fixed: https://gerrit.lix.systems/c/lix/+/1883 Upstream: https://github.com/troglobit/editline/pull/70
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#501
No description provided.