summaryrefslogtreecommitdiffstats
path: root/warp/term.h
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2020-11-11 17:11:19 +0000
committerchristos <christos@NetBSD.org>2020-11-11 17:11:19 +0000
commit6eff467615806d8dd5a8bac71bad4e5ca27b5c84 (patch)
tree3167d99c7ca36002ff9d62b7db669cd5e57179b8 /warp/term.h
parent38b99ae599004d14655eba19a5dd4304366aa9c5 (diff)
downloadbsdgames-darwin-6eff467615806d8dd5a8bac71bad4e5ca27b5c84.tar.gz
bsdgames-darwin-6eff467615806d8dd5a8bac71bad4e5ca27b5c84.tar.zst
bsdgames-darwin-6eff467615806d8dd5a8bac71bad4e5ca27b5c84.zip
- use termios
- enable setgid games - enable savedir
Diffstat (limited to 'warp/term.h')
-rw-r--r--warp/term.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/warp/term.h b/warp/term.h
index 52ade745..3798a24c 100644
--- a/warp/term.h
+++ b/warp/term.h
@@ -181,9 +181,16 @@ EXT char INTRCH INIT('\03');
/* stuff wanted by terminal mode diddling routines */
-#ifdef TERMIO
+#ifdef TERMIOS
+EXT struct termios _tty, _oldtty;
+#elif defined(TERMIO)
+typedef int speed_t;
EXT struct termio _tty, _oldtty;
+#define tcsetattr(fd, how, ti) ioctl(fd, how, ti)
+#define tcgetattr(fd, ti) ioctl(fd, TCGETA, ti)
+#define cfgetospeed(ti) ((ti)->c_cflag & CBAUD)
#else
+typedef int speed_t;
EXT struct sgttyb _tty;
EXT int _res_flg INIT(0);
#endif
@@ -193,18 +200,18 @@ EXT bool bizarre INIT(false); /* do we need to restore terminal? */
/* terminal mode diddling routines */
-#ifdef TERMIO
+#if defined(TERMIO) || defined(TERMIOS)
-#define raw() ((bizarre=1),_tty.c_lflag &=~ISIG,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty))
-#define noraw() ((bizarre=1),_tty.c_lflag |= ISIG,_tty.c_cc[VEOF] = CEOF,ioctl(_tty_ch,TCSETAF,&_tty))
-#define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty))
-#define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,ioctl(_tty_ch,TCSETAF,&_tty))
-#define echo() ((bizarre=1),_tty.c_lflag |= ECHO, ioctl(_tty_ch, TCSETAW, &_tty))
-#define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, ioctl(_tty_ch, TCSETAW, &_tty))
-#define nl() ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
-#define nonl() ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
-#define savetty() (ioctl(_tty_ch, TCGETA, &_oldtty),ioctl(_tty_ch, TCGETA, &_tty))
-#define resetty() ((bizarre=0),ioctl(_tty_ch, TCSETAF, &_oldtty))
+#define raw() ((bizarre=1),_tty.c_lflag &=~ISIG,_tty.c_cc[VMIN] = 1,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
+#define noraw() ((bizarre=1),_tty.c_lflag |= ISIG,_tty.c_cc[VEOF] = CEOF,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
+#define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
+#define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
+#define echo() ((bizarre=1),_tty.c_lflag |= ECHO, tcsetattr(_tty_ch, TCSANOW, &_tty))
+#define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, tcsetattr(_tty_ch, TCSANOW, &_tty))
+#define nl() ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,tcsetattr(_tty_ch, TCSANOW, &_tty))
+#define nonl() ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,tcsetattr(_tty_ch, TCSANOW, &_tty))
+#define savetty() (tcgetattr(_tty_ch, &_oldtty),tcgetattr(_tty_ch, &_tty))
+#define resetty() ((bizarre=0),tcsetattr(_tty_ch, TCSAFLUSH, &_oldtty))
#define unflush_output()
#else