aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorFranklin Wei <franklin@fwei.ml>2015-05-22 21:30:11 -0400
committerFranklin Wei <frankhwei536@gmail.com>2015-05-22 21:30:11 -0400
commite1a71a012bc9a5e666fb03ed8b7eca16b7eabb3a (patch)
tree1db116256aa4ccc3363ce8c3197c1aa2e79648c1 /src/util.c
parent50b5b9d966fc51d2ad819f313ed26d110fb658a4 (diff)
downloadmarket-sim-e1a71a012bc9a5e666fb03ed8b7eca16b7eabb3a.zip
market-sim-e1a71a012bc9a5e666fb03ed8b7eca16b7eabb3a.tar.gz
market-sim-e1a71a012bc9a5e666fb03ed8b7eca16b7eabb3a.tar.bz2
market-sim-e1a71a012bc9a5e666fb03ed8b7eca16b7eabb3a.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("=");
+}