diff options
| author | Franklin Wei <git@fwei.tk> | 2015-05-23 18:56:45 -0400 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2015-05-23 18:56:45 -0400 |
| commit | 65420c45267df9289990cb3befa078753160ab1b (patch) | |
| tree | ce02944cedb0ad28b129355506b1d842a376e4ad /src/util.c | |
| parent | c09f5635ce6edda4a93025a556565921cadc300e (diff) | |
| download | market-sim-65420c45267df9289990cb3befa078753160ab1b.zip market-sim-65420c45267df9289990cb3befa078753160ab1b.tar.gz market-sim-65420c45267df9289990cb3befa078753160ab1b.tar.bz2 market-sim-65420c45267df9289990cb3befa078753160ab1b.tar.xz | |
better support for no curses mode
Diffstat (limited to 'src/util.c')
| -rw-r--r-- | src/util.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -394,7 +394,9 @@ void horiz_line_curses(void) void horiz_line_nocurses(void) { - for(int i = 0; i < 80; ++i) + struct winsize sz; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &sz); + for(int i = 0; i < sz.ws_col; ++i) output("="); output("\n"); } @@ -432,8 +434,11 @@ void heading_nocurses(const char *fmt, ...) vsnprintf(text, sizeof(text), fmt, ap); va_end(ap); + struct winsize w; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + int len = strlen(text) / 2; - int beg_x = 40 - len; + int beg_x = w.ws_col / 2 - len; int d = 0; if(strlen(text) & 1) d++; @@ -443,7 +448,7 @@ void heading_nocurses(const char *fmt, ...) output(" "); output(text); output(" "); - for(int i = 0; i < 40 - len - 1 - d; ++i) + for(int i = 0; i < w.ws_col / 2 - len - 1 - d; ++i) output("="); output("\n"); } |