2020-05-05 21:23:21 +02:00
|
|
|
#include<termios.h>
|
2020-05-05 21:49:31 +02:00
|
|
|
#include<sys/ioctl.h>
|
2020-05-05 23:14:15 +02:00
|
|
|
#include "types.h"
|
2020-05-05 21:23:21 +02:00
|
|
|
|
2020-05-05 21:26:10 +02:00
|
|
|
struct termios oldSettings;
|
|
|
|
|
|
|
|
void startTTY()
|
2020-05-05 21:23:21 +02:00
|
|
|
{
|
|
|
|
/* First create a struct */
|
|
|
|
struct termios termy;
|
|
|
|
|
|
|
|
/* Get current attributes */
|
|
|
|
tcgetattr(0, &termy);
|
|
|
|
|
|
|
|
/* Save current tty settings for restoral later */
|
2020-05-05 21:26:10 +02:00
|
|
|
oldSettings = termy;
|
2020-05-05 21:23:21 +02:00
|
|
|
|
|
|
|
/* 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);
|
2020-05-05 21:49:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
testicle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void testicle()
|
|
|
|
{
|
|
|
|
/* window size struct */
|
|
|
|
struct winsize size;
|
|
|
|
|
|
|
|
/* IOCTL the vnode via the fd that points to it */
|
|
|
|
ioctl(0, TIOCGWINSZ, &size);
|
|
|
|
|
|
|
|
printf("row: %u\n", size.ws_row);
|
|
|
|
printf("col: %u\n", size.ws_col);
|
2020-05-05 21:26:10 +02:00
|
|
|
}
|
2020-05-05 21:23:21 +02:00
|
|
|
|
2020-05-05 21:26:10 +02:00
|
|
|
void stopTTY()
|
|
|
|
{
|
|
|
|
/* Restore the tty settings back to the original */
|
|
|
|
tcsetattr(0, 0, &oldSettings);
|
2020-05-05 21:49:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void setCursor(int x, int y, struct TTY* tty)
|
|
|
|
{
|
|
|
|
|
2020-05-05 21:23:21 +02:00
|
|
|
}
|