aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2015-05-22 21:30:11 -0400
committerFranklin Wei <git@fwei.tk>2015-05-22 21:30:11 -0400
commitb83951ad2bf5d8029dfa0af2e73a6f3619841380 (patch)
tree1db116256aa4ccc3363ce8c3197c1aa2e79648c1 /src/util.c
parent9e53ccfefd2433452fdfa2bbe2ece903c0afb790 (diff)
downloadmarket-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/util.c')
-rw-r--r--src/util.c27
1 files changed, 25 insertions, 2 deletions
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("=");
+}