Render control characters as Unicode Control Pictures

Inserting Tab or Backspace characters causes weird glitches. Sometimes it's
useful to paste tabs as part of a code block.

Render tabs as "␉" and so on for other ASCII control characters, see
https://unicode-table.com/en/blocks/control-pictures/. This fixes the
width-related glitches.

You can see it in action by inserting some control characters into the
command line:

	set chars
	for x in (seq 1 0x1F)
		set -a chars (printf "%02x\\\\x%02x" $x $x)
	end
	eval set chars $chars
	commandline -i "echo '" $chars

Fixes #6923
Fixes #5274
Closes #7295

We could extend this approach to display a fallback symbol for every unknown
nonprintable character, not just ASCII control characters.

In future we might want to support tab properly.
This commit is contained in:
Johannes Altmanninger
2020-08-29 09:26:34 +02:00
parent d3b700f98c
commit 0627c9d9af
3 changed files with 34 additions and 23 deletions

View File

@@ -153,6 +153,11 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind --preset -M paste \e\[201~ __fish_stop_bracketed_paste
# In paste-mode, everything self-inserts except for the sequence to get out of it
bind --preset -M paste "" self-insert
# Pass through formatting control characters else they may be dropped
# on some terminals.
bind --preset -M paste \b 'commandline -i \b'
bind --preset -M paste \t 'commandline -i \t'
bind --preset -M paste \v 'commandline -i \v'
# Without this, a \r will overwrite the other text, rendering it invisible - which makes the exercise kinda pointless.
bind --preset -M paste \r "commandline -i \n"