aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorache <ache@ache.one>2017-11-08 03:49:10 +0100
committerache <ache@ache.one>2017-11-08 03:49:10 +0100
commit28a3fa7afebb9937fa42b9d53678eb8fd0be529d (patch)
tree83e5caf6ce15aed1cfc1145f1bea91722b67ec9b /main.c
Init commit
Diffstat (limited to 'main.c')
-rw-r--r--main.c142
1 files changed, 142 insertions, 0 deletions
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 <dirent.h>
+#include <stdnoreturn.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <unistd.h>
+
+#include "wind.h"
+
+/*
+ * Entry point of mesms and event loop
+ */
+
+
+#ifdef DEBUG
+
+#include <assert.h>
+
+#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;
+}
+
+
+