diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/globals.h | 3 | ||||
| -rw-r--r-- | src/info.c | 4 | ||||
| -rw-r--r-- | src/util.c | 16 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/globals.h b/src/globals.h index f532644..721507c 100644 --- a/src/globals.h +++ b/src/globals.h @@ -113,9 +113,10 @@ void print_usage(int argc, char *argv[]); void print_version(void); void sig_handler(int); int output(const char*, ...); -void heading(const char *text); +void heading(const char *text, ...); void horiz_line(void); + void buy_handler(struct player_t*); void info_handler(struct player_t*); void load_handler(struct player_t*); @@ -25,8 +25,8 @@ void info_handler(struct player_t *player) free(sym); - output("Transaction history for '%s':\n", stock->symbol); - horiz_line(); + heading("Transaction history for '%s'", stock->symbol); + print_history(stock); horiz_line(); output("Current price: $%llu.%02llu\n", stock->current_price.cents / 100, stock->current_price.cents % 100); @@ -190,8 +190,7 @@ struct stock_t *find_stock(struct player_t *player, char *sym) void print_handler(struct player_t *player) { - output("Your portfolio:\n"); - horiz_line(); + heading("Your Portfolio"); ullong portfolio_value = 0; @@ -377,16 +376,25 @@ void horiz_line(void) } } -void heading(const char *text) +void heading(const char *fmt, ...) { + char text[128]; + va_list ap; + va_start(ap, fmt); + vsnprintf(text, sizeof(text), fmt, ap); + va_end(ap); + int len = strlen(text) / 2; int beg_x = getmaxx(stdscr) / 2 - len; + int d = 0; + if(strlen(text) & 1) + d++; for(int i = 0; i < beg_x - 1; ++i) output("="); output(" "); output(text); output(" "); - for(int i = 0; i < getmaxx(stdscr) - getmaxx(stdscr) / 2 - len - 1; ++i) + for(int i = 0; i < getmaxx(stdscr) - getmaxx(stdscr) / 2 - len - 1 - d; ++i) output("="); } |