implemented basic error handling, need to create a ncurses window for them it seems
authormatthew <matthew@owens.tech>
Sat, 4 Aug 2018 20:03:46 +0000 (21:03 +0100)
committermatthew <matthew@owens.tech>
Sat, 4 Aug 2018 20:03:46 +0000 (21:03 +0100)
common/err.h [new file with mode: 0644]
nogl/err.c [new file with mode: 0644]

diff --git a/common/err.h b/common/err.h
new file mode 100644 (file)
index 0000000..35ed9f0
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef ERR_H
+#define ERR_H
+
+void err_output(const char* message);
+void err_enable_logging(const char* logpath);
+void err_clear();
+#endif//ERR_H
diff --git a/nogl/err.c b/nogl/err.c
new file mode 100644 (file)
index 0000000..cb5f0f8
--- /dev/null
@@ -0,0 +1,39 @@
+#include "err.h"
+#include <stdio.h>
+#include <ncurses.h>
+#include "point.h"
+
+char* lpath = NULL;
+static const char lendchar = '+';
+static const char lchar = '-';
+
+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);
+       }
+}
+
+void err_enable_logging(const char* logpath)
+{
+       err_output("logging not yet implemented");
+}
+
+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);
+       }
+}