mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-10 08:20:59 -04:00
scripts: generate-builtin-terminfo: use \xNN for control characters
Instead of emitting raw control characters (for e.g. bel, cub1 and kbs), use \xNN C string escapes.
This commit is contained in:
parent
a3debf7741
commit
3c4669061b
1 changed files with 3 additions and 3 deletions
|
|
@ -56,9 +56,9 @@ class StringCapability(Capability):
|
||||||
def translate_ctrl_chr(m):
|
def translate_ctrl_chr(m):
|
||||||
ctrl = m.group(1)
|
ctrl = m.group(1)
|
||||||
if ctrl == '?':
|
if ctrl == '?':
|
||||||
return chr(0x7f)
|
return '\\x7f'
|
||||||
return chr(ord(ctrl) - ord('@'))
|
return f'\\x{ord(ctrl) - ord('@'):02x}'
|
||||||
value = re.sub('\^([@A-Z[\\\\\]^_?])', translate_ctrl_chr, value)
|
value = re.sub(r'\^([@A-Z[\\\\\]^_?])', translate_ctrl_chr, value)
|
||||||
|
|
||||||
# Ensure e.g. \E7 (or \e7) doesn’t get translated to “\0337”,
|
# Ensure e.g. \E7 (or \e7) doesn’t get translated to “\0337”,
|
||||||
# which would be interpreted as octal 337 by the C compiler
|
# which would be interpreted as octal 337 by the C compiler
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue