testing stuff, finish text viewing basically
+ test.txt has tabstoppage to test rendering + home/end/status line
This commit is contained in:
47
keypress.c
Normal file
47
keypress.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
struct termios orig_termios;
|
||||
|
||||
|
||||
void
|
||||
disableRawMode()
|
||||
{
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
enableRawMode()
|
||||
{
|
||||
tcgetattr(STDIN_FILENO, &orig_termios);
|
||||
atexit(disableRawMode);
|
||||
|
||||
struct termios raw = orig_termios;
|
||||
raw.c_lflag &= ~(ECHO | ICANON);
|
||||
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
enableRawMode();
|
||||
|
||||
char c;
|
||||
while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') {
|
||||
if (iscntrl(c)) {
|
||||
printf("$%02x\n", c);
|
||||
} else {
|
||||
printf("$%02x ('%c')\n", c, c);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user