fixed error output not showing, moved error output to it's own window
authormatthew <matthew@owens.tech>
Sun, 5 Aug 2018 15:29:31 +0000 (16:29 +0100)
committermatthew <matthew@owens.tech>
Sun, 5 Aug 2018 15:29:31 +0000 (16:29 +0100)
nogl/err.c
nogl/main.c

index cb5f0f8..930bed6 100644 (file)
@@ -3,20 +3,24 @@
 #include <ncurses.h>
 #include "point.h"
 
-char* lpath = NULL;
-static const char lendchar = '+';
-static const char lchar = '-';
+static WINDOW *win = NULL;
+static char* lpath = NULL;
+
+#define ERR_X 0
+#define ERR_Y 0
+#define ERR_W 80
+#define ERR_H 3
 
 void err_output(const char *message)
 {
-       Point2i scrsize = point2i(0,0);
-
        if(stdscr == NULL){     // ncurses not initilised
                fprintf(stderr, message);
        } else {
                err_clear();
-               getmaxyx(stdscr, scrsize.y, scrsize.x);
-               mvprintw(5, 5, message);
+               win = newwin(ERR_H, ERR_W, ERR_Y, ERR_X);
+               wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');
+               mvwprintw(win, 1, 2, message);
+               wrefresh(win);
        }
 }
 
@@ -27,13 +31,8 @@ void err_enable_logging(const char* logpath)
 
 void err_clear()
 {
-       Point2i msgpos;
-       getmaxyx(stdscr, msgpos.y, msgpos.x);
-
-       mvaddch(msgpos.y, 0, lendchar);
-       mvaddch(msgpos.y, msgpos.x, lendchar);
-
-       for(int i = 1; i < msgpos.y; ++i){
-               mvaddch(msgpos.y, i, lchar);
-       }
+       wborder(win, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
+       wrefresh(win);
+       delwin(win);
+       win = NULL;
 }
index fd2a7c1..25b6428 100644 (file)
@@ -4,6 +4,7 @@
 #include "board.h"
 #include "point.h"
 #include "board_renderer.h"
+#include "err.h"
 #include <ncurses.h>
 
 static Board* board = NULL;
@@ -51,6 +52,12 @@ int main()
                return -1;
        }
 
+       boardRenderer_render();
+       getchar();
+       err_enable_logging("test");
+       //refresh();
+       getchar();
+       err_clear();
        boardRenderer_render();
        getchar();