globox

Platform game for the terminal
git clone git://git.bitsmanent.org/globox
Log | Files | Refs | README | LICENSE

commit 0f969206ebc1b02a521ea96caad985fea54fe5ae
parent 6e7611fb07c156511e22011190dfa88fce524dce
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Wed,  5 Jul 2017 22:47:26 +0200

Code cleanups.

Diffstat:
Mglobox.c | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/globox.c b/globox.c @@ -279,7 +279,6 @@ choose(char *opts, const wchar_t *msgstr, ...) { void cleanup(void) { freescene(); - ioblock(1); tcsetattr(0, TCSANOW, &origti); wprintf(CURSON); } @@ -502,8 +501,7 @@ ioblock(int block) { tcgetattr(0, &ti); ti.c_cc[VMIN] = block; - if(!block) - ti.c_cc[VTIME] = 0; + ti.c_cc[VTIME] = 0; tcsetattr(0, TCSANOW, &ti); } @@ -658,6 +656,7 @@ restart(const Arg *arg) { void run(void) { + ioblock(0); while(running) { while(cols < scene->w || rows < scene->h) { mvprintf(1, 1, L"Terminal too small."); @@ -670,6 +669,7 @@ run(void) { if(sleepu(TICK)) die("%s: error while sleeping\n", argv0); } + ioblock(1); mvprintf(1, cols, L"%ls", CLEARLN); } @@ -686,11 +686,10 @@ setup(void) { sigaction(SIGWINCH, &sa, NULL); tcgetattr(0, &origti); - ti.c_lflag &= ~(ECHO | ICANON); + cfmakeraw(&ti); ti.c_iflag |= ICRNL; - tcsetattr(0, TCSAFLUSH, &ti); + tcsetattr(0, TCSANOW, &ti); wprintf(CURSOFF); - ioblock(0); ioctl(0, TIOCGWINSZ, &ws); resize(ws.ws_row, ws.ws_col);