pexpect test for commandline --current-process

It was not clear to me hwo this behaves when there are comments.

Include a friendly helper to compute control characters.
No functional change.
This commit is contained in:
Johannes Altmanninger
2020-03-29 18:34:08 +02:00
parent 108108bb5e
commit c6e1704f00
2 changed files with 48 additions and 1 deletions

View File

@@ -341,3 +341,25 @@ class SpawnedProc(object):
"LIGHTCYAN": ansic(96),
"WHITE": ansic(97),
}
def control(char: str) -> str:
""" Returns the char sent when control is pressed along the given key. """
assert len(char) == 1
char = char.lower()
if ord("a") <= ord(char) <= ord("z"):
return chr(ord(char) - ord("a") + 1)
return chr({
"@": 0,
"`": 0,
"[": 27,
"{": 27,
"\\": 28,
"|": 28,
"]": 29,
"}": 29,
"^": 30,
"~": 30,
"_": 31,
"?": 127,
}[char])