aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2015-05-23 18:56:45 -0400
committerFranklin Wei <git@fwei.tk>2015-05-23 18:56:45 -0400
commit65420c45267df9289990cb3befa078753160ab1b (patch)
treece02944cedb0ad28b129355506b1d842a376e4ad /src
parentc09f5635ce6edda4a93025a556565921cadc300e (diff)
downloadmarket-sim-65420c45267df9289990cb3befa078753160ab1b.zip
market-sim-65420c45267df9289990cb3befa078753160ab1b.tar.gz
market-sim-65420c45267df9289990cb3befa078753160ab1b.tar.bz2
market-sim-65420c45267df9289990cb3befa078753160ab1b.tar.xz
better support for no curses mode
Diffstat (limited to 'src')
-rw-r--r--src/globals.h4
-rw-r--r--src/main.c5
-rw-r--r--src/util.c11
3 files changed, 16 insertions, 4 deletions
diff --git a/src/globals.h b/src/globals.h
index c2bb8cc..b9d6e0c 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -10,6 +10,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
#include <curl/curl.h>
#include <ncurses.h>
@@ -90,7 +92,7 @@ struct command_t {
extern bool have_color;
-void do_menu(struct player_t*, const struct command_t*, uint len, const char *prompt);
+void do_menu(struct player_t*, const struct command_t*, uint, const char*);
bool get_stock_info(char *sym, struct money_t*, char **name);
char *csv_read(char**);
char *(*read_string)(void);
diff --git a/src/main.c b/src/main.c
index 33c69b8..c3edb1a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,11 @@ int main(int argc, char *argv[])
else
player->cash.cents = 1000 * 100;
+ if(args_status & ARG_VERBOSE)
+ {
+ output("Verbose operation enabled.\n");
+ }
+
while(1)
{
const struct command_t commands[] = {
diff --git a/src/util.c b/src/util.c
index c43ae65..64edb45 100644
--- a/src/util.c
+++ b/src/util.c
@@ -394,7 +394,9 @@ void horiz_line_curses(void)
void horiz_line_nocurses(void)
{
- for(int i = 0; i < 80; ++i)
+ struct winsize sz;
+ ioctl(STDOUT_FILENO, TIOCGWINSZ, &sz);
+ for(int i = 0; i < sz.ws_col; ++i)
output("=");
output("\n");
}
@@ -432,8 +434,11 @@ void heading_nocurses(const char *fmt, ...)
vsnprintf(text, sizeof(text), fmt, ap);
va_end(ap);
+ struct winsize w;
+ ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
+
int len = strlen(text) / 2;
- int beg_x = 40 - len;
+ int beg_x = w.ws_col / 2 - len;
int d = 0;
if(strlen(text) & 1)
d++;
@@ -443,7 +448,7 @@ void heading_nocurses(const char *fmt, ...)
output(" ");
output(text);
output(" ");
- for(int i = 0; i < 40 - len - 1 - d; ++i)
+ for(int i = 0; i < w.ws_col / 2 - len - 1 - d; ++i)
output("=");
output("\n");
}