From: matthew Date: Sat, 4 Aug 2018 20:03:46 +0000 (+0100) Subject: implemented basic error handling, need to create a ncurses window for them it seems X-Git-Url: https://git.owens.tech/rss.xml/rss.xml/git?a=commitdiff_plain;h=631c0bf1d8216504c28525a05853a9cc6e5cefa4;p=csrpg.git implemented basic error handling, need to create a ncurses window for them it seems --- diff --git a/common/err.h b/common/err.h new file mode 100644 index 0000000..35ed9f0 --- /dev/null +++ b/common/err.h @@ -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 index 0000000..cb5f0f8 --- /dev/null +++ b/nogl/err.c @@ -0,0 +1,39 @@ +#include "err.h" +#include +#include +#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); + } +}