1menu_driver(3X) menu_driver(3X)
2
3
4
6 menu_driver - command-processing loop of the menu system
7
9 #include <menu.h>
10 int menu_driver(MENU *menu, int c);
11
13 Once a menu has been posted (displayed), you should funnel input events
14 to it through menu_driver. This routine has three major input cases;
15 either the input is a menu navigation request, it is a printable ASCII
16 character or it is the KEY_MOUSE special key associated with an mouse
17 event. The menu driver requests are as follows:
18
19 REQ_LEFT_ITEM
20 Move left to an item.
21
22 REQ_RIGHT_ITEM
23 Move right to an item.
24
25 REQ_UP_ITEM
26 Move up to an item.
27
28 REQ_DOWN_ITEM
29 Move down to an item.
30
31 REQ_SCR_ULINE
32 Scroll up a line.
33
34 REQ_SCR_DLINE
35 Scroll down a line.
36
37 REQ_SCR_DPAGE
38 Scroll down a page.
39
40 REQ_SCR_UPAGE
41 Scroll up a page.
42
43 REQ_FIRST_ITEM
44 Move to the first item.
45
46 REQ_LAST_ITEM
47 Move to the last item.
48
49 REQ_NEXT_ITEM
50 Move to the next item.
51
52 REQ_PREV_ITEM
53 Move to the previous item.
54
55 REQ_TOGGLE_ITEM
56 Select/deselect an item.
57
58 REQ_CLEAR_PATTERN
59 Clear the menu pattern buffer.
60
61 REQ_BACK_PATTERN
62 Delete the previous character from the pattern buffer.
63
64 REQ_NEXT_MATCH
65 Move to the next item matching the pattern match.
66
67 REQ_PREV_MATCH
68 Move to the previous item matching the pattern match.
69
70 If the second argument is a printable ASCII character, the code appends
71 it to the pattern buffer and attempts to move to the next item matching
72 the new pattern. If there is no such match, menu_driver returns
73 E_NO_MATCH and deletes the appended character from the buffer.
74
75 If the second argument is one of the above pre-defined requests, the
76 corresponding action is performed.
77
78 MOUSE HANDLING
79 If the second argument is the KEY_MOUSE special key, the associated
80 mouse event is translated into one of the above pre-defined requests.
81 Currently only clicks in the user window (e.g. inside the menu display
82 area or the decoration window) are handled.
83
84 If you click above the display region of the menu:
85
86 a REQ_SCR_ULINE is generated for a single click,
87
88 a REQ_SCR_UPAGE is generated for a double-click and
89
90 a REQ_FIRST_ITEM is generated for a triple-click.
91
92 If you click below the display region of the menu:
93
94 a REQ_SCR_DLINE is generated for a single click,
95
96 a REQ_SCR_DPAGE is generated for a double-click and
97
98 a REQ_LAST_ITEM is generated for a triple-click.
99
100 If you click at an item inside the display area of the menu:
101
102 - the menu cursor is positioned to that item.
103
104 - If you double-click an item a REQ_TOGGLE_ITEM is generated
105 and E_UNKNOWN_COMMAND is returned. This return value makes
106 sense, because a double click usually means that an item-spe‐
107 cific action should be returned. It is exactly the purpose
108 of this return value to signal that an application specific
109 command should be executed.
110
111 - If a translation into a request was done, menu_driver returns
112 the result of this request.
113
114 If you clicked outside the user window or the mouse event couldn't be
115 translated into a menu request an E_REQUEST_DENIED is returned.
116
117 APPLICATION-DEFINED COMMANDS
118 If the second argument is neither printable ASCII nor one of the above
119 pre-defined menu requests or KEY_MOUSE, the drive assumes it is an
120 application-specific command and returns E_UNKNOWN_COMMAND. Applica‐
121 tion-defined commands should be defined relative to MAX_COMMAND, the
122 maximum value of these pre-defined requests.
123
125 menu_driver return one of the following error codes:
126
127 E_OK The routine succeeded.
128
129 E_SYSTEM_ERROR
130 System error occurred (see errno).
131
132 E_BAD_ARGUMENT
133 Routine detected an incorrect or out-of-range argument.
134
135 E_BAD_STATE
136 Routine was called from an initialization or termination function.
137
138 E_NOT_POSTED
139 The menu has not been posted.
140
141 E_UNKNOWN_COMMAND
142 The menu driver code saw an unknown request code.
143
144 E_NO_MATCH
145 Character failed to match.
146
147 E_REQUEST_DENIED
148 The menu driver could not process the request.
149
151 curses(3X), menu(3X).
152
154 The header file <menu.h> automatically includes the header files
155 <curses.h>.
156
158 These routines emulate the System V menu library. They were not sup‐
159 ported on Version 7 or BSD versions. The support for mouse events is
160 ncurses specific.
161
163 Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S.
164 Raymond.
165
166
167
168 menu_driver(3X)