From 28a3fa7afebb9937fa42b9d53678eb8fd0be529d Mon Sep 17 00:00:00 2001 From: ache Date: Wed, 8 Nov 2017 03:49:10 +0100 Subject: Init commit --- main.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 main.c (limited to 'main.c') diff --git a/main.c b/main.c new file mode 100644 index 0000000..3c5a6f5 --- /dev/null +++ b/main.c @@ -0,0 +1,142 @@ +#include "main.h" +#include "readline.h" + +#include +#include +#include +#include +#include + +#include "wind.h" + +/* + * Entry point of mesms and event loop + */ + + +#ifdef DEBUG + +#include + +#endif + +const int color[] = { + COLOR_BLACK, COLOR_RED, + COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, + COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE}; + + + + + +#define MAX_PATH 1024 + + + +extern char* msg_win_str; + +static bool visual_mode = false; +WINDOW *cmd_win; +WINDOW *sep_win; +char status[10]; + + +void fail_exit(const char *msg) { + if (visual_mode) + endwin(); + fprintf(stderr, "%s\n", msg); + exit(EXIT_FAILURE); +} + +int main(int argc, char* argv[]){ + + /* Gestion des paramètres */ + while (1) { + int c; + int optIndex = 0; + static struct option optlv[] = { + {"help", no_argument, 0, 'h' }, + {"version", no_argument, 0, 'v' }, + {NULL, 0, 0, 0 } + }; + + + c = getopt_long(argc, argv, "hv:", optlv, &optIndex); + if (c == -1) + break; + + switch (c) { + case 'v': + if( !strcmp(optlv[optIndex].name, "version") ) { + puts( VERSION_MESMS ); + } + break; + + case 'h': + puts( HELP_STRING_MESMS ); + return EXIT_SUCCESS; + + break; + case '?': + default: + return EXIT_FAILURE; + } + } + + + + + /* Initialisation */ + + int size = 0; + int c; + int comp = 0; + + setlocale(LC_ALL, ""); + + initscr(); + if (has_colors()) { + CHECK(start_color); + } + + CHECK(cbreak); + CHECK(noecho); + CHECK(nonl); + CHECK(intrflush, NULL, FALSE); + visual_mode = true; + curs_set(0); + + cmd_win = newwin(1, COLS, LINES - 20, 0); + sep_win = newwin(1, COLS, LINES - 2, 0); + + init_pair( 12, COLOR_WHITE, COLOR_BLUE); + + CHECK(wbkgd, sep_win, COLOR_PAIR(12)); + CHECK(wrefresh, sep_win); + init_readline(); + + for(int i = 0 ; i < 9 ; i++) { + init_pair( i+1, i, COLOR_BLACK); + } + + /* Premier affichage */ + + /* Event loop */ + while( c = getch() ) { + if (c == KEY_RESIZE) { + continue; + } + + refresh(); + } + + refresh(); + getch(); +end: + endwin(); + + return 0; +} + + + -- cgit v1.2.3