testing stuff, finish text viewing basically

+ test.txt has tabstoppage to test rendering
+ home/end/status line
This commit is contained in:
2020-02-11 03:01:21 +02:00
parent 93e8f14ca7
commit 274f14f2a6
5 changed files with 150 additions and 14 deletions

47
keypress.c Normal file
View 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;
}