diff options
| author | Franklin Wei <git@fwei.tk> | 2015-05-22 21:59:35 -0400 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2015-05-22 21:59:35 -0400 |
| commit | 13ac2252200bc208a09c396f6629042f0e49c16a (patch) | |
| tree | f56ead900ca7ecefe825d440fac161467139798b /src/util.c | |
| parent | 2ad946d048a38a1e3ef3c49843f60444c7c661ae (diff) | |
| download | market-sim-13ac2252200bc208a09c396f6629042f0e49c16a.zip market-sim-13ac2252200bc208a09c396f6629042f0e49c16a.tar.gz market-sim-13ac2252200bc208a09c396f6629042f0e49c16a.tar.bz2 market-sim-13ac2252200bc208a09c396f6629042f0e49c16a.tar.xz | |
some fixes
Diffstat (limited to 'src/util.c')
| -rw-r--r-- | src/util.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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("="); } |