1menu_driver(3X)                                                menu_driver(3X)
2
3
4

NAME

6       menu_driver - command-processing loop of the menu system
7

SYNOPSIS

9       #include <menu.h>
10       int menu_driver(MENU *menu, int c);
11

DESCRIPTION

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
16       ·   The input is a form navigation request.  Navigation  request  codes
17           are constants defined in <form.h>, which are distinct from the key-
18           and character codes returned by wgetch(3X).
19
20       ·   The input is a printable character.   Printable  characters  (which
21           must  be positive, less than 256) are checked according to the pro‐
22           gram's locale settings.
23
24       ·   The input is the KEY_MOUSE special key  associated  with  an  mouse
25           event.
26
27       The menu driver requests are as follows:
28
29       REQ_LEFT_ITEM
30            Move left to an item.
31
32       REQ_RIGHT_ITEM
33            Move right to an item.
34
35       REQ_UP_ITEM
36            Move up to an item.
37
38       REQ_DOWN_ITEM
39            Move down to an item.
40
41       REQ_SCR_ULINE
42            Scroll up a line.
43
44       REQ_SCR_DLINE
45            Scroll down a line.
46
47       REQ_SCR_DPAGE
48            Scroll down a page.
49
50       REQ_SCR_UPAGE
51            Scroll up a page.
52
53       REQ_FIRST_ITEM
54            Move to the first item.
55
56       REQ_LAST_ITEM
57            Move to the last item.
58
59       REQ_NEXT_ITEM
60            Move to the next item.
61
62       REQ_PREV_ITEM
63            Move to the previous item.
64
65       REQ_TOGGLE_ITEM
66            Select/deselect an item.
67
68       REQ_CLEAR_PATTERN
69            Clear the menu pattern buffer.
70
71       REQ_BACK_PATTERN
72            Delete the previous character from the pattern buffer.
73
74       REQ_NEXT_MATCH
75            Move to the next item matching the pattern match.
76
77       REQ_PREV_MATCH
78            Move to the previous item matching the pattern match.
79
80       If the second argument is a printable character, the code appends it to
81       the pattern buffer and attempts to move to the next item  matching  the
82       new pattern.  If there is no such match, menu_driver returns E_NO_MATCH
83       and deletes the appended character from the buffer.
84
85       If the second argument is one of the above  pre-defined  requests,  the
86       corresponding action is performed.
87
88   MOUSE HANDLING
89       If  the  second  argument  is the KEY_MOUSE special key, the associated
90       mouse event is translated into one of the above  pre-defined  requests.
91       Currently only clicks in the user window (e.g., inside the menu display
92       area or the decoration window) are handled.
93
94       If you click above the display region of the menu:
95
96       ·   a REQ_SCR_ULINE is generated for a single click,
97
98       ·   a REQ_SCR_UPAGE is generated for a double-click and
99
100       ·   a REQ_FIRST_ITEM is generated for a triple-click.
101
102       If you click below the display region of the menu:
103
104       ·   a REQ_SCR_DLINE is generated for a single click,
105
106       ·   a REQ_SCR_DPAGE is generated for a double-click and
107
108       ·   a REQ_LAST_ITEM is generated for a triple-click.
109
110       If you click at an item inside the display area of the menu:
111
112       ·   the menu cursor is positioned to that item.
113
114       ·   If you double-click an item  a  REQ_TOGGLE_ITEM  is  generated  and
115           E_UNKNOWN_COMMAND  is  returned.   This  return  value makes sense,
116           because a double click usually means that an  item-specific  action
117           should be returned.  It is exactly the purpose of this return value
118           to signal that an application specific command should be executed.
119
120       ·   If a translation into a request was done, menu_driver  returns  the
121           result of this request.
122
123       If  you clicked outside the user window or the mouse event could not be
124       translated into a menu request an E_REQUEST_DENIED is returned.
125
126   APPLICATION-DEFINED COMMANDS
127       If the second argument is neither printable nor one of the  above  pre-
128       defined menu requests or KEY_MOUSE, the drive assumes it is an applica‐
129       tion-specific  command  and  returns  E_UNKNOWN_COMMAND.   Application-
130       defined commands should be defined relative to MAX_COMMAND, the maximum
131       value of these pre-defined requests.
132

RETURN VALUE

134       menu_driver return one of the following error codes:
135
136       E_OK The routine succeeded.
137
138       E_SYSTEM_ERROR
139            System error occurred (see errno).
140
141       E_BAD_ARGUMENT
142            Routine detected an incorrect or out-of-range argument.
143
144       E_BAD_STATE
145            Routine was called from an initialization or termination function.
146
147       E_NOT_POSTED
148            The menu has not been posted.
149
150       E_UNKNOWN_COMMAND
151            The menu driver code saw an unknown request code.
152
153       E_NO_MATCH
154            Character failed to match.
155
156       E_REQUEST_DENIED
157            The menu driver could not process the request.
158

SEE ALSO

160       curses(3X), menu(3X), getch(3X).
161

NOTES

163       The header  file  <menu.h>  automatically  includes  the  header  files
164       <curses.h>.
165

PORTABILITY

167       These  routines  emulate the System V menu library.  They were not sup‐
168       ported on Version 7 or BSD versions. The support for  mouse  events  is
169       ncurses specific.
170

AUTHORS

172       Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric S.
173       Raymond.
174
175
176
177                                                               menu_driver(3X)
Impressum