From b83951ad2bf5d8029dfa0af2e73a6f3619841380 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Fri, 22 May 2015 21:30:11 -0400 Subject: fancy curses stuff --- src/util.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index f0493cd..654e7d8 100644 --- a/src/util.c +++ b/src/util.c @@ -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("="); +} -- cgit v1.1