From 65420c45267df9289990cb3befa078753160ab1b Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 23 May 2015 18:56:45 -0400 Subject: better support for no curses mode --- src/globals.h | 4 +++- src/main.c | 5 +++++ src/util.c | 11 ++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/globals.h b/src/globals.h index c2bb8cc..b9d6e0c 100644 --- a/src/globals.h +++ b/src/globals.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include @@ -90,7 +92,7 @@ struct command_t { extern bool have_color; -void do_menu(struct player_t*, const struct command_t*, uint len, const char *prompt); +void do_menu(struct player_t*, const struct command_t*, uint, const char*); bool get_stock_info(char *sym, struct money_t*, char **name); char *csv_read(char**); char *(*read_string)(void); diff --git a/src/main.c b/src/main.c index 33c69b8..c3edb1a 100644 --- a/src/main.c +++ b/src/main.c @@ -41,6 +41,11 @@ int main(int argc, char *argv[]) else player->cash.cents = 1000 * 100; + if(args_status & ARG_VERBOSE) + { + output("Verbose operation enabled.\n"); + } + while(1) { const struct command_t commands[] = { 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"); } -- cgit v1.1