aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2015-05-23 18:56:45 -0400
committerFranklin Wei <git@fwei.tk>2015-05-23 18:56:45 -0400
commit65420c45267df9289990cb3befa078753160ab1b (patch)
treece02944cedb0ad28b129355506b1d842a376e4ad /src/util.c
parentc09f5635ce6edda4a93025a556565921cadc300e (diff)
downloadmarket-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.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index c43ae65..64edb45 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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");
}