Open thejpster opened 5 years ago
I did some testing with a basic C program to see how various non-alphanumeric inputs are encoded:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
system( "/bin/stty raw" );
while ( 1 ) {
int input = getc( stdin );
printf( "Read %d (0x%02x)\r\n", input, input );
if ( ( input == 3 ) || ( input == EOF ) ) {
break;
}
}
system( "/bin/stty cooked" );
return 0;
}
Results (two bytes is a hex byte, single char is ASCII, ESC is 0x1B):
Key | Bytes | Interpretation |
---|---|---|
Up Arrow | ESC [ A | CSI A / Cursor Up 1 |
Down Arrow | ESC [ B | CSI B / Cursor Down 1 |
Right Arrow | ESC [ C | CSI C / Cursor Forward 1 |
Left Arrow | ESC [ D | CSI D / Cursor Back 1 |
Home | ESC [ H | CSI H / Cursor Position 1, 1 |
End | ESC [ F | CSI F / Cursor Previous Line 1 |
Escape | ESC | |
Page Up | ESC [ 5 ~ | CSI 5 ~ |
Page Down | ESC [ 6 ~ | CSI 6 ~ |
Insert | ESC [ 2 ~ | CSI 2 ~ |
Delete | ESC [ 3 ~ | CSI 3 ~ |
Backspace | 7f | DEL |
Print Screen | Interpreted by GNOME Desktop | |
Pause | Ignored | |
Break | Ignored | |
Sys Req | Did a print-screen | |
F1 | ESC O P | SS3 P |
F2 | ESC O Q | SS3 Q |
F3 | ESC O R | SS3 R |
F4 | ESC O S | SS3 S |
F5 | ESC [ 1 5 ~ | CSI 1 5 ~ |
F6 | ESC [ 1 7 ~ | CSI 1 7 ~ |
F7 | ESC [ 1 8 ~ | CSI 1 8 ~ |
F8 | ESC [ 1 9 ~ | CSI 1 9 ~ |
F9 | ESC [ 2 0 ~ | CSI 2 0 ~ |
F10 | No effect | |
F11 | Made window full-screen | |
F12 | ESC [ 2 4 ~ | CSI 2 4 ~ |
Control A | 01 | SOH |
Control B | 02 | STX |
Control M | 0d | CR |
Control Z | 1a | EM |
Enter | 0d | CR |
We should add proper VT100 / ANSI code support