summaryrefslogtreecommitdiff
path: root/src/essais
diff options
context:
space:
mode:
Diffstat (limited to 'src/essais')
-rwxr-xr-xsrc/essais/compil.sh2
-rw-r--r--src/essais/test.c32
2 files changed, 24 insertions, 10 deletions
diff --git a/src/essais/compil.sh b/src/essais/compil.sh
index 0b2eda7..1581e9d 100755
--- a/src/essais/compil.sh
+++ b/src/essais/compil.sh
@@ -1 +1 @@
-gcc -Wall -lncurses test.c
+gcc -Wall -g -lncurses test.c
diff --git a/src/essais/test.c b/src/essais/test.c
index 5e3a185..f8ce2b7 100644
--- a/src/essais/test.c
+++ b/src/essais/test.c
@@ -5,11 +5,9 @@ WINDOW *create_newwin(int height, int width, int starty, int startx)
{ WINDOW *local_win;
local_win = newwin(height, width, starty, startx);
- box(local_win, 0 , 0); /* 0, 0 gives default characters
- * for the vertical and horizontal
- * lines */
- wrefresh(local_win); /* Show that box */
-
+ wborder(local_win, '|', '|', '-', '-', '+', '+', '+', '+');
+// box(local_win,0,0);
+ wrefresh(local_win);
return local_win;
}
@@ -33,23 +31,40 @@ int main() {
int row,col;
char msg[256];
WINDOW *w1;
+ MEVENT event;
initscr();
getmaxyx(stdscr,row,col);
raw();
keypad(stdscr, TRUE);
noecho();
+
+ start_color();
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ mousemask(ALL_MOUSE_EVENTS, NULL);
+//http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/windows.html
+ //w1 = create_newwin(row/2, col/2, row/4, col/4);
+ w1 = create_newwin(10, 10, 10, 10);
+ attron(COLOR_PAIR(1) | A_BOLD);
mvprintw(row-2,0,"This screen has %d rows and %d columns\n",row,col);
+ attroff(COLOR_PAIR(1) | A_BOLD);
move(0,0);
-
-//http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/windows.html
- w1 = create_newwin(row/2, col/2, row/4, col/4);
+ end=0;
while (!end) {
+ refresh();
ch=getch();
switch(ch) {
+ case KEY_MOUSE:
+ if(getmouse(&event) == OK) { /* When the user clicks left mouse button */
+ if(event.bstate & BUTTON1_PRESSED) {
+ attrset(A_NORMAL);
+ printw("mouse button1\n");
+ }
+ }
+ break;
case KEY_F(2):
attrset(A_NORMAL);
printw("F2 key\n");
@@ -65,7 +80,6 @@ int main() {
wattrset(w1,A_BOLD | A_UNDERLINE);
wprintw(w1, msg);
}
- refresh();
}
endwin();