diff --git a/src/intf.c b/src/intf.c index 916a01b..471581b 100644 --- a/src/intf.c +++ b/src/intf.c @@ -51,9 +51,9 @@ void init_screen (void) { initscr(); - if ((COLS < MIN_COLUMNS) || (LINES < MIN_LINES)) { + if ((COLS < MIN_COLS) || (LINES < MIN_LINES)) { err_exit("terminal size is too small (%d x %d required)", - MIN_COLUMNS, MIN_LINES); + MIN_COLS, MIN_LINES); } noecho(); diff --git a/src/intf.h b/src/intf.h index 6a44ab0..2291481 100644 --- a/src/intf.h +++ b/src/intf.h @@ -39,9 +39,21 @@ * Constants and type declarations * ************************************************************************/ -#define MIN_COLUMNS (80) /* Minimum number of columns in terminal */ +#define MIN_COLS (80) /* Minimum number of columns in terminal */ #define MIN_LINES (24) /* Minimum number of lines in terminal */ +/* + This version of Star Traders only utilises WIN_COLS x WIN_LINES of a + terminal window. COL_OFFSET and LINE_OFFSET define offsets that should + be added to each newwin() call to position the window correctly. +*/ + +#define WIN_COLS MIN_COLS /* Number of columns in main windows */ +#define WIN_LINES MIN_LINES /* Number of lines in main windows */ + +#define COL_OFFSET ((COLS - MIN_COLS) / 2) /* Window offsets */ +#define LINE_OFFSET (0) + #define OUTBUFSIZE (1024) /* Output string buffer size */ diff --git a/src/trader.c b/src/trader.c index 8727fdc..0b97184 100644 --- a/src/trader.c +++ b/src/trader.c @@ -78,12 +78,12 @@ int main (int argc, char *argv[]) WINDOW *w1, *w2; - w1 = newwin(0, 0, 7, 0); + w1 = newwin(WIN_LINES - 7, WIN_COLS, LINE_OFFSET + 7, COL_OFFSET + 0); wbkgd(w1, COLOR_PAIR(WHITE_ON_BLUE)); box(w1, 0, 0); wrefresh(w1); - w2 = newwin(LINES - 9, COLS - 8, 8, 4); + w2 = newwin(WIN_LINES - 9, WIN_COLS - 8, LINE_OFFSET + 8, COL_OFFSET + 4); wbkgd(w2, COLOR_PAIR(WHITE_ON_BLUE)); wattrset(w2, has_colors() ? COLOR_PAIR(WHITE_ON_RED) | A_BOLD : A_REVERSE | A_BOLD);