4 <STRONG>menu_driver</STRONG> - command-processing loop of the menu system
9 <STRONG>#include</STRONG> <STRONG><menu.h></STRONG>
10 int menu_driver(MENU *menu, int c);
14 <H2>DESCRIPTION</H2><PRE>
15 Once a menu has been posted (displayed), you should funnel
16 input events to it through <STRONG>menu_driver</STRONG>. This routine has
17 three major input cases; either the input is a menu navi-
18 gation request, it's a printable ASCII character or it is
19 the KEY_MOUSE special key associated with an mouse event.
20 The menu driver requests are as follows:
26 Move right to an item.
47 Move to the first item.
50 Move to the last item.
53 Move to the next item.
56 Move to the previous item.
59 Select/deselect an item.
60 Clear the menu pattern buffer.
63 Delete the previous character from the pattern
67 Move to the next item matching the pattern match.
70 Move to the previous item matching the pattern match.
72 If the second argument is a printable ASCII character, the
73 code appends it to the pattern buffer and attempts to move
74 to the next item matching the new pattern. If there is no
75 such match, <STRONG>menu_driver</STRONG> returns <STRONG>E_NO_MATCH</STRONG> and deletes the
76 appended character from the buffer.
78 If the second argument is one of the above pre-defined
79 requests, the corresponding action is performed.
81 If the second argument is the KEY_MOUSE special key, the
82 associated mouse event is translated into one of the above
83 pre-defined requests. Currently only clicks in the user
84 window (e.g. inside the menu display area or the decora-
85 tion window) are handled. If you click above the display
86 region of the menu, a REQ_SCR_ULINE is generated, if you
87 doubleclick a REQ_SCR_UPAGE is generated and if you
88 tripleclick a REQ_FIRST_ITEM is generated. If you click
89 below the display region of the menu, a REQ_SCR_DLINE is
90 generated, if you doubleclick a REQ_SCR_DPAGE is generated
91 and if you tripleclick a REQ_LAST_ITEM is generated. If
92 you click at an item inside the display area of the menu,
93 the menu cursor is positioned to that item. If you double-
94 click at an item a REQ_TOGGLE_ITEM is generated and
95 <STRONG>E_UNKNOWN_COMMAND</STRONG> is returned. This return value makes
96 sense, because a double click usually means that an item-
97 specific action should be returned. It's exactly the pur-
98 pose of this return value to signal that an application
99 specific command should be executed. If a translation into
100 a request was done, <STRONG>menu_driver</STRONG> returns the result of this
101 request. If you clicked outside the user window or the
102 mouse event couldn't be translated into a menu request an
103 <STRONG>E_REQUEST_DENIED</STRONG> is returned.
105 If the second argument is neither printable ASCII nor one
106 of the above pre-defined menu requests or KEY_MOUSE, the
107 drive assumes it is an application-specific command and
108 returns <STRONG>E_UNKNOWN_COMMAND</STRONG>. Application-defined commands
109 should be defined relative to <STRONG>MAX_COMMAND</STRONG>, the maximum
110 value of these pre-defined requests.
112 <STRONG>menu_driver</STRONG> return one of the following error codes:
114 <STRONG>E_OK</STRONG> The routine succeeded.
116 <STRONG>E_SYSTEM_ERROR</STRONG>
117 System error occurred (see <STRONG>errno</STRONG>).
119 <STRONG>E_BAD_ARGUMENT</STRONG>
120 Routine detected an incorrect or out-of-range argu-
123 <STRONG>E_BAD_STATE</STRONG>
124 Routine was called from an initialization or termina-
127 <STRONG>E_NOT_POSTED</STRONG>
128 The menu has not been posted.
130 <STRONG>E_UNKNOWN_COMMAND</STRONG>
131 The menu driver code saw an unknown request code.
133 <STRONG>E_NO_MATCH</STRONG>
134 Character failed to match.
136 <STRONG>E_REQUEST_DENIED</STRONG>
137 The menu driver could not process the request.
141 <H2>SEE ALSO</H2><PRE>
142 <STRONG><A HREF="ncurses.3x.html">curses(3X)</A></STRONG>, <STRONG><A HREF="menu.3x.html">menu(3X)</A></STRONG>.
147 The header file <STRONG><menu.h></STRONG> automatically includes the header
148 files <STRONG><curses.h></STRONG>.
152 <H2>PORTABILITY</H2><PRE>
153 These routines emulate the System V menu library. They
154 were not supported on Version 7 or BSD versions. The sup-
155 port for mouse events is ncurses specific.
159 <H2>AUTHORS</H2><PRE>
160 Juergen Pfeifer. Manual pages and adaptation for new
161 curses by Eric S. Raymond.