Moved most tty functions to tty.c
This commit is contained in:
parent
0aa31e1835
commit
49f5bc290d
24
src/ped.c
24
src/ped.c
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue