be

based editor
git clone git://git.kocotian.pl/be.git
Log | Files | Refs | README | LICENSE

commit 52e2895b6c9694bc6ab3761fda4ec950765ef753
parent 18f6c5a7ca8929c5ee7ad56e2ce1002f19005e5b
Author: kocotian <kocotian@kocotian.pl>
Date:   Sat, 17 Apr 2021 19:38:31 +0200

Raw mode

Diffstat:
Mbe.c | 33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git a/be.c b/be.c @@ -1,5 +1,38 @@ +#include <termios.h> +#include <unistd.h> + +static void rawRestore(void); +static void rawOn(void); + +static struct termios origtermios; + +static void +rawOn(void) +{ + struct termios raw; + + tcgetattr(STDIN_FILENO, &origtermios); + raw = origtermios; + raw.c_cflag |= (CS8); + raw.c_iflag &= (tcflag_t)~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + raw.c_lflag &= (tcflag_t)~(ECHO | ICANON | IEXTEN | ISIG); + raw.c_oflag &= (tcflag_t)~(OPOST); + raw.c_cc[VMIN] = 0; + raw.c_cc[VTIME] = 1; + tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); +} + +static void +rawRestore(void) +{ + tcsetattr(STDIN_FILENO, TCSAFLUSH, &origtermios); +} + int main(int argc, char *argv[]) { + rawOn(); + /* code */ + rawRestore(); return 0; }