summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-06 13:54:49 +0100
committersumuel <samuel@yakubos.org>2026-08-06 13:54:49 +0100
commit121aaa819958473e12197ff48933f7ca8cc4e7bc (patch)
treeb33c8ddabf6cb526faaa9d93c7bfa06d5000b72e /main.c
Diffstat (limited to 'main.c')
-rw-r--r--main.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..b79f16d
--- /dev/null
+++ b/main.c
@@ -0,0 +1,46 @@
+#include <ncurses.h>
+#include <stdlib.h>
+#include "board.h"
+
+int main(void) {
+ initscr(); /* Start curses mode */
+ if(has_colors() == FALSE)
+ { endwin();
+ printf("Your terminal does not support colour\n");
+ return 1;
+ }
+ start_color(); /* Start color */
+ noecho();
+ curs_set(0);
+ /* End of ncurses init nonsense */
+
+ int ch;
+ bool reveal = false;
+ generate_first_line(puzzle);
+ generate_puzzle(puzzle);
+
+ while (1) {
+ print_puzzle(puzzle, reveal);
+
+ ch = getch();
+ switch (ch) {
+ case 'q':
+ endwin();
+ return 1;
+ break;
+ case 'g':
+ reveal = false;
+ generate_first_line(puzzle);
+ generate_puzzle(puzzle);
+ break;
+ case 'r':
+ if ( reveal == true ) reveal = false;
+ else reveal = true;
+ break;
+ }
+ clear();
+ };
+
+ endwin(); /* End curses mode */
+ return 0;
+}