mirror of
1
0
Fork 0

Moved most tty functions to tty.c

This commit is contained in:
Tristan B. Kildaire 2020-05-05 21:23:21 +02:00
parent 0aa31e1835
commit 49f5bc290d
2 changed files with 29 additions and 21 deletions

View File

@ -13,6 +13,7 @@
#include "commands.c"
#include<dlfcn.h>
#include "tty.c"
struct termios oldSettings;
@ -83,27 +84,8 @@ void redraw(struct Session* session)
void newEditor(struct Session* session)
{
/* First create a struct */
struct termios termy;
/* Get current attributes */
tcgetattr(0, &termy);
/* Save current tty settings for restoral later */
oldSettings = termy;
/* Set the tty input modes */
//tcflag_t inputFlags = 0;
termy.c_iflag = termy.c_iflag | IGNBRK;
termy.c_lflag = termy.c_lflag & ~ISIG;
termy.c_lflag = termy.c_lflag & ~ECHO;
cfmakeraw(&termy);
/* Set the tty to raw mode */
tcsetattr(0, 0, &termy);
char isActive = 1;
/* Setup the tty */
oldSettings = startTTY();
/* Output the file as of now */
redraw(session);

26
src/tty.c Normal file
View File

@ -0,0 +1,26 @@
#include<termios.h>
struct termios startTTY()
{
/* First create a struct */
struct termios termy;
/* Get current attributes */
tcgetattr(0, &termy);
/* Save current tty settings for restoral later */
struct termios oldTermy = termy;
/* Set the tty input modes */
//tcflag_t inputFlags = 0;
termy.c_iflag = termy.c_iflag | IGNBRK;
termy.c_lflag = termy.c_lflag & ~ISIG;
termy.c_lflag = termy.c_lflag & ~ECHO;
cfmakeraw(&termy);
/* Set the tty to raw mode */
tcsetattr(0, 0, &termy);
return oldTermy;
}