Display raw escape sequences the old way again

If a binding was input starting with "\e", it's usually a raw control sequence.
Today we display the canonical version like:

    bind --preset alt-\[,1,\;,5,C foo

even if the input is

    bind --preset \e\[1\;5C foo

Make it look like the input again.  This looks more familiar and less
surprising (especially since we canonicalize CSI to "alt-[").

Except that we use the \x01 representation instead of \ca because the
"control" part can be confusing. We're inside an escape sequence so it seems
highly unlikely that an ASCII control character actually comes from the user
holding the control key.

The downside is that this hides the canonical version; it might be surprising
that a raw-escape-sequence binding can be erased using the new syntax and
vice versa.
This commit is contained in:
Johannes Altmanninger
2024-04-08 17:35:24 +02:00
parent d025b245f6
commit f61ef2c63d
5 changed files with 119 additions and 60 deletions

View File

@@ -15,8 +15,8 @@ bind -M bind-mode \cX true
bind -M bind_mode \cX true
# Listing bindings
bind | string match -v '*escape,\\[*' # Hide legacy bindings.
bind --user --preset | string match -v '*escape,\\[*'
bind | string match -v '*\e\\[*' # Hide raw bindings.
bind --user --preset | string match -v '*\e\\[*'
# CHECK: bind --preset '' self-insert
# CHECK: bind --preset enter execute
# CHECK: bind --preset tab complete
@@ -55,7 +55,7 @@ bind --user --preset | string match -v '*escape,\\[*'
# CHECK: bind -M bind_mode ctrl-x true
# Preset only
bind --preset | string match -v '*escape,\\[*'
bind --preset | string match -v '*\e\\[*'
# CHECK: bind --preset '' self-insert
# CHECK: bind --preset enter execute
# CHECK: bind --preset tab complete
@@ -75,12 +75,12 @@ bind --preset | string match -v '*escape,\\[*'
# CHECK: bind --preset ctrl-f forward-char
# User only
bind --user | string match -v '*escape,\\[*'
bind --user | string match -v '*\e\\[*'
# CHECK: bind -M bind_mode ctrl-x true
# Adding bindings
bind tab 'echo banana'
bind | string match -v '*escape,\\[*'
bind | string match -v '*\e\\[*'
# CHECK: bind --preset '' self-insert
# CHECK: bind --preset enter execute
# CHECK: bind --preset tab complete