enabled raw mode with no echo, character input rather than line input, ignore to stop build files being pushed

This commit is contained in:
2025-12-23 16:09:03 +00:00
parent 84f3049da0
commit 455a0aaf53
4 changed files with 34 additions and 6 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
kilo

View File

@@ -1,2 +1,9 @@
kilo: kilo.c kilo: kilo.c
$(CC) kilo.c -o kilo -Wall -Wextra -pedantic -std=c99 mkdir -p ./out
$(CC) kilo.c -o ./out/kilo -Wall -Wextra -pedantic -std=c99
run:
./out/kilo
clean:
rm -rf ./out

BIN
kilo

Binary file not shown.

30
kilo.c
View File

@@ -1,8 +1,28 @@
#include <stdlib.h>
#include <termios.h>
#include <unistd.h> #include <unistd.h>
int main() { struct termios orig_termios;
char c;
while (read(STDIN_FILENO, &c, 1) == 1) void disableRawMode() {
; tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
return 0; }
void enableRawMode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_lflag &= ~(ECHO);
raw.c_lflag &= ~(ICANON);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enableRawMode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q');
return 0;
} }