summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index c4fd207..56fc9d7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,6 +6,10 @@
#include "tower.h"
#include "ring.h"
+#define TERMINAL_MIN_HEIGHT 14
+#define TERMINAL_MIN_WIDTH 39
+
+bool check_terminal();
void draw_title();
void draw_body();
void draw_tower(int ring_index, int startx, int starty);
@@ -45,22 +49,34 @@ int main()
curs_set(0);
keypad(stdscr, TRUE);
- // draw title
- draw_title();
- refresh();
+ // check that the terminal can handle the program
+ if(check_terminal()) {
+
+ // draw title
+ draw_title();
+ refresh();
- // draw body
- wbody = newwin(12, getmaxx(wmain), 8, 0);
- draw_body();
- wrefresh(wbody);
+ // draw body
+ wbody = newwin(12, getmaxx(wmain), getmaxy(wmain)/2 - 6, 0);
+ draw_body();
+ wrefresh(wbody);
- input_loop();
+ input_loop();
+ }
endwin();
return 0;
}
+bool check_terminal() {
+ // check that terminal is big enough
+ if(getmaxx(wmain) < TERMINAL_MIN_WIDTH) return false;
+ if(getmaxy(wmain) < TERMINAL_MIN_HEIGHT) return false;
+
+ return true;
+}
+
void draw_title() {
move(0, getmaxx(wmain)/2 - strlen(TITLE)/2);
printw(TITLE);