diff options
| author | Franklin Wei <git@fwei.tk> | 2015-05-22 21:30:11 -0400 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2015-05-22 21:30:11 -0400 |
| commit | b83951ad2bf5d8029dfa0af2e73a6f3619841380 (patch) | |
| tree | 1db116256aa4ccc3363ce8c3197c1aa2e79648c1 /src | |
| parent | 9e53ccfefd2433452fdfa2bbe2ece903c0afb790 (diff) | |
| download | market-sim-b83951ad2bf5d8029dfa0af2e73a6f3619841380.zip market-sim-b83951ad2bf5d8029dfa0af2e73a6f3619841380.tar.gz market-sim-b83951ad2bf5d8029dfa0af2e73a6f3619841380.tar.bz2 market-sim-b83951ad2bf5d8029dfa0af2e73a6f3619841380.tar.xz | |
fancy curses stuff
Diffstat (limited to 'src')
| -rw-r--r-- | src/globals.h | 2 | ||||
| -rw-r--r-- | src/info.c | 5 | ||||
| -rw-r--r-- | src/main.c | 2 | ||||
| -rw-r--r-- | src/util.c | 27 |
4 files changed, 31 insertions, 5 deletions
diff --git a/src/globals.h b/src/globals.h index ee6790f..f532644 100644 --- a/src/globals.h +++ b/src/globals.h @@ -113,6 +113,8 @@ 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 horiz_line(void); void buy_handler(struct player_t*); void info_handler(struct player_t*); @@ -26,9 +26,8 @@ void info_handler(struct player_t *player) output("Transaction history for '%s':\n", stock->symbol); - output("================================================================================\n"); + horiz_line(); print_history(stock); - output("================================================================================\n"); - + horiz_line(); output("Current price: $%llu.%02llu\n", stock->current_price.cents / 100, stock->current_price.cents % 100); } @@ -38,6 +38,8 @@ int main(int argc, char *argv[]) if(!args_status & ARG_LOADED) player->cash.cents = 1000 * 100; + heading("Market Simulator " PROGRAM_VERSION); + while(1) { const struct command_t commands[] = { @@ -11,6 +11,7 @@ void cleanup(void) void sig_handler(int sig) { + (void) sig; cleanup(); exit(EXIT_FAILURE); } @@ -190,7 +191,7 @@ struct stock_t *find_stock(struct player_t *player, char *sym) void print_handler(struct player_t *player) { output("Your portfolio:\n"); - output("================================================================================\n"); + horiz_line(); ullong portfolio_value = 0; @@ -214,7 +215,7 @@ void print_handler(struct player_t *player) } } } - output("================================================================================\n"); + horiz_line(); output("Portfolio value: $%llu.%02llu\n", portfolio_value / 100, portfolio_value % 100); @@ -367,3 +368,25 @@ int output(const char *fmt, ...) return ret; } + +void horiz_line(void) +{ + for(int i = 0; i < getmaxx(stdscr); ++i) + { + output("="); + } +} + +void heading(const char *text) +{ + int len = strlen(text) / 2; + int beg_x = getmaxx(stdscr) / 2 - len; + + 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) + output("="); +} |