aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2015-05-24 21:22:10 -0400
committerFranklin Wei <git@fwei.tk>2015-05-24 21:22:10 -0400
commit4f6e8cfe95cd42071ac0d53eb8d22b22236c4b40 (patch)
tree799749113e1f9f34e3c5af75da7b75f9ed13f6b2 /src
parent6b12863d33a904a8c6dcda0d580dd903e2434a67 (diff)
downloadmarket-sim-4f6e8cfe95cd42071ac0d53eb8d22b22236c4b40.zip
market-sim-4f6e8cfe95cd42071ac0d53eb8d22b22236c4b40.tar.gz
market-sim-4f6e8cfe95cd42071ac0d53eb8d22b22236c4b40.tar.bz2
market-sim-4f6e8cfe95cd42071ac0d53eb8d22b22236c4b40.tar.xz
hack for noninteractive mode
Diffstat (limited to 'src')
-rw-r--r--src/util.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/util.c b/src/util.c
index 9bf7011..e0b7f5b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -414,9 +414,14 @@ void horiz_line_curses(void)
void horiz_line_nocurses(void)
{
- struct winsize sz;
- ioctl(STDOUT_FILENO, TIOCGWINSZ, &sz);
- for(int i = 0; i < sz.ws_col; ++i)
+ struct winsize w;
+ ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
+
+ /* dirty hack for noninteractive mode */
+ if(!w.ws_col)
+ w.ws_col = 80;
+
+ for(int i = 0; i < w.ws_col; ++i)
output("=");
output("\n");
}
@@ -457,7 +462,9 @@ void heading_nocurses(const char *fmt, ...)
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
- output("width: %d\n", w.ws_col);
+ /* dirty hack for noninteractive mode */
+ if(!w.ws_col)
+ w.ws_col = 80;
int len = strlen(text) / 2;
int beg_x = w.ws_col / 2 - len;