summaryrefslogtreecommitdiff
path: root/src/essais/test.c
blob: 5e3a185d8c19379a66f655912331b15a9c4281ca (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
#include <ncurses.h>


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 		*/

	return local_win;
}

int main() {

/*
    A_NORMAL        Normal display (no highlight)
    A_STANDOUT      Best highlighting mode of the terminal.
    A_UNDERLINE     Underlining
    A_REVERSE       Reverse video
    A_BLINK         Blinking
    A_DIM           Half bright
    A_BOLD          Extra bright or bold
    A_PROTECT       Protected mode
    A_INVIS         Invisible or blank mode
    A_ALTCHARSET    Alternate character set
    A_CHARTEXT      Bit-mask to extract a character
    COLOR_PAIR(n)   Color-pair number n 
*/
	int end, ch;
	int row,col;
	char msg[256];
	WINDOW *w1;

	initscr();
	getmaxyx(stdscr,row,col);
	raw();
	keypad(stdscr, TRUE);
	noecho();
	
	mvprintw(row-2,0,"This screen has %d rows and %d columns\n",row,col);
	move(0,0);

	
//http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/windows.html
	w1 = create_newwin(row/2, col/2, row/4, col/4);

	while (!end) {
		ch=getch();
		switch(ch) {
			case KEY_F(2):
				attrset(A_NORMAL);
				printw("F2 key\n");
				break;
			case 'q':
				end=1;
				break;
			case 'b':
				mvwchgat(w1,1,0,-1, A_REVERSE, 0, NULL);
				break;
			default:
				sprintf(msg, "%c key\n", ch);
				wattrset(w1,A_BOLD | A_UNDERLINE);
				wprintw(w1, msg);
		}
		refresh();
	}
	endwin();

	return 0;
}