mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05: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):
|
||||
ctrl = m.group(1)
|
||||
if ctrl == '?':
|
||||
return chr(0x7f)
|
||||
return chr(ord(ctrl) - ord('@'))
|
||||
value = re.sub('\^([@A-Z[\\\\\]^_?])', translate_ctrl_chr, value)
|
||||
return '\\x7f'
|
||||
return f'\\x{ord(ctrl) - ord('@'):02x}'
|
||||
value = re.sub(r'\^([@A-Z[\\\\\]^_?])', translate_ctrl_chr, value)
|
||||
|
||||
# Ensure e.g. \E7 (or \e7) doesn’t get translated to “\0337”,
|
||||
# which would be interpreted as octal 337 by the C compiler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue