Reputation: 35298
I am writing some behavioural tests for code that interacts with a terminal and I need to assert behaviour on the sequence C-p C-q
(ctrl-p ctrl-q). In order to do this, I need to write the raw characters to the PTY. I have a small mapping at the moment for things like C-d => 0x04, C-h => 0x08
.
Is there somewhere I can get a basic mapping of human readable control sequences, mapped to raw byte sequences for xterm?
Upvotes: 0
Views: 289
Reputation: 129001
Take the ASCII value of the character (e.g., for ^H
, take 72), and subtract 64. Thus, ^H
is 8.
This works for any control character. Using it, you can discover that, for example, ^@
is the NUL character and ^[
is ESC.
Upvotes: 2