aboutsummaryrefslogtreecommitdiff
path: root/main.c
blob: 3c5a6f505a90726413b8181aa78683f77fa2766d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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;
}