exposurses

Check-in [db667542ca]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enable switching between windows with left/right keys

- Oh my, I've ended up using pointers to pointers already! Use this so
can switch the menu/win "pointing" at with left and right keys and
then scroll up down the active one.
- Also means need to just use plain getch and not wgetch as don't want
to limit input to one window.

I still don't get what determines an active window. Is it just cursor
position?

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: db667542ca87b6899f9c62fd2f366077cea5257ef29d011159bd3b9bc205a7c1
User & Date: atomicules@lavabit.com 2013-07-08 08:55:03
Original User & Date: atomicules@lavabit.com 2013-07-08 08:55:04
Context
2013-07-08
08:55
Add in values for the three menus check-in: 4b63a4b0a2 user: atomicules@lavabit.com tags: origin/master, trunk
08:55
Enable switching between windows with left/right keys

- Oh my, I've ended up using pointers to pointers already! Use this so
can switch the menu/win "pointing" at with left and right keys and
then scroll up down the active one.
- Also means need to just use plain getch and not wgetch as don't want
to limit input to one window.

I still don't get what determines an active window. Is it just cursor
position? check-in: db667542ca user: atomicules@lavabit.com tags: origin/master, trunk

08:55
First attempt at getting two menus side by side

Tricky bit was that have to re-create my_items. I thought I'd be able to
re-use that for the sake of this test. But without recreating it the
second menu is blank. check-in: 8fab8d5ebf user: atomicules@lavabit.com tags: origin/master, trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to exposurses.c.

25
26
27
28
29
30
31

32
33

34
35
36
37
38
39
40
int main(){
	ITEM **my_items1;
	/*Weird, can't just re-use my_items. Must recreate that as well*/
	ITEM **my_items2;
	int c;
	MENU *my_menu1;
	MENU *my_menu2;

	WINDOW *my_menu_win1;
	WINDOW *my_menu_win2;

	int n_choices, i;

	/* Initialize curses */
	initscr();
	start_color();
	cbreak();
	noecho();







>


>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
int main(){
	ITEM **my_items1;
	/*Weird, can't just re-use my_items. Must recreate that as well*/
	ITEM **my_items2;
	int c;
	MENU *my_menu1;
	MENU *my_menu2;
	MENU **my_menu;
	WINDOW *my_menu_win1;
	WINDOW *my_menu_win2;
	WINDOW **my_menu_win;
	int n_choices, i;

	/* Initialize curses */
	initscr();
	start_color();
	cbreak();
	noecho();
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

	attron(COLOR_PAIR(2));
	mvprintw(LINES - 2, 0, "Use PageUp and PageDown to scoll down or up a page of items");
	mvprintw(LINES - 1, 0, "Arrow Keys to navigate (F1 to Exit)");
	attroff(COLOR_PAIR(2));
	refresh();


	while((c = wgetch(my_menu_win1)) != KEY_F(1)){
		switch(c){
			case KEY_DOWN:
			menu_driver(my_menu1, REQ_DOWN_ITEM);







			menu_driver(my_menu2, REQ_DOWN_ITEM);
			break;
			case KEY_UP:
			menu_driver(my_menu1, REQ_UP_ITEM);
			menu_driver(my_menu2, REQ_UP_ITEM);
			break;
			case KEY_NPAGE:
			menu_driver(my_menu1, REQ_SCR_DPAGE);
			break;
			case KEY_PPAGE:
			menu_driver(my_menu1, REQ_SCR_UPAGE);
			break;
		}
		wrefresh(my_menu_win1);
		wrefresh(my_menu_win2);
	}	

	/* Unpost and free all the memory taken up */
	unpost_menu(my_menu1);
	free_menu(my_menu1);
	for(i = 0; i < n_choices; ++i)
		free_item(my_items1[i]);
	endwin();
}







>
|

|
|
>
>
>
>
>
>
>
|


|
<


|


|


|
<

<







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

	attron(COLOR_PAIR(2));
	mvprintw(LINES - 2, 0, "Use PageUp and PageDown to scoll down or up a page of items");
	mvprintw(LINES - 1, 0, "Arrow Keys to navigate (F1 to Exit)");
	attroff(COLOR_PAIR(2));
	refresh();


	while((c = getch())){
		switch(c){
			case KEY_LEFT:
				my_menu = &my_menu1;
				my_menu_win = &my_menu_win1;
					break;
			case KEY_RIGHT:
				my_menu = &my_menu2;
				my_menu_win = &my_menu_win2;
				 break;
			case KEY_DOWN:
			menu_driver(*my_menu, REQ_DOWN_ITEM);
			break;
			case KEY_UP:
			menu_driver(*my_menu, REQ_UP_ITEM);

			break;
			case KEY_NPAGE:
			menu_driver(*my_menu, REQ_SCR_DPAGE);
			break;
			case KEY_PPAGE:
			menu_driver(*my_menu, REQ_SCR_UPAGE);
			break;
		}
		wrefresh(*my_menu_win);

	}	

	/* Unpost and free all the memory taken up */
	unpost_menu(my_menu1);
	free_menu(my_menu1);
	for(i = 0; i < n_choices; ++i)
		free_item(my_items1[i]);
	endwin();
}