menu_driver.3x.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  2. <!--
  3. ****************************************************************************
  4. * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
  5. * *
  6. * Permission is hereby granted, free of charge, to any person obtaining a *
  7. * copy of this software and associated documentation files (the *
  8. * "Software"), to deal in the Software without restriction, including *
  9. * without limitation the rights to use, copy, modify, merge, publish, *
  10. * distribute, distribute with modifications, sublicense, and/or sell *
  11. * copies of the Software, and to permit persons to whom the Software is *
  12. * furnished to do so, subject to the following conditions: *
  13. * *
  14. * The above copyright notice and this permission notice shall be included *
  15. * in all copies or substantial portions of the Software. *
  16. * *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
  20. * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
  21. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
  23. * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
  24. * *
  25. * Except as contained in this notice, the name(s) of the above copyright *
  26. * holders shall not be used in advertising or otherwise to promote the *
  27. * sale, use or other dealings in this Software without prior written *
  28. * authorization. *
  29. ****************************************************************************
  30. * @Id: menu_driver.3x,v 1.15 2008/06/21 21:55:30 tom Exp @
  31. -->
  32. <HTML>
  33. <HEAD>
  34. <TITLE>menu_driver 3x</TITLE>
  35. <link rev=made href="mailto:bug-ncurses@gnu.org">
  36. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  37. </HEAD>
  38. <BODY>
  39. <H1>menu_driver 3x</H1>
  40. <HR>
  41. <PRE>
  42. <!-- Manpage converted by man2html 3.0.1 -->
  43. <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG> <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>
  44. </PRE>
  45. <H2>NAME</H2><PRE>
  46. <STRONG>menu_driver</STRONG> - command-processing loop of the menu system
  47. </PRE>
  48. <H2>SYNOPSIS</H2><PRE>
  49. <STRONG>#include</STRONG> <STRONG>&lt;menu.h&gt;</STRONG>
  50. int menu_driver(MENU *menu, int c);
  51. </PRE>
  52. <H2>DESCRIPTION</H2><PRE>
  53. Once a menu has been posted (displayed), you should funnel
  54. input events to it through <STRONG>menu_driver</STRONG>. This routine has
  55. three major input cases:
  56. - The input is a form navigation request. Navigation
  57. request codes are constants defined in <STRONG>&lt;form.h&gt;</STRONG>, which
  58. are distinct from the key- and character codes returned
  59. by <STRONG>wgetch</STRONG>.
  60. - The input is a printable character. Printable charac-
  61. ters (which must be positive, less than 256) are
  62. checked according to the program's locale settings.
  63. - The input is the KEY_MOUSE special key associated with
  64. an mouse event.
  65. The menu driver requests are as follows:
  66. REQ_LEFT_ITEM
  67. Move left to an item.
  68. REQ_RIGHT_ITEM
  69. Move right to an item.
  70. REQ_UP_ITEM
  71. Move up to an item.
  72. REQ_DOWN_ITEM
  73. Move down to an item.
  74. REQ_SCR_ULINE
  75. Scroll up a line.
  76. REQ_SCR_DLINE
  77. Scroll down a line.
  78. REQ_SCR_DPAGE
  79. Scroll down a page.
  80. REQ_SCR_UPAGE
  81. Scroll up a page.
  82. REQ_FIRST_ITEM
  83. Move to the first item.
  84. REQ_LAST_ITEM
  85. Move to the last item.
  86. REQ_NEXT_ITEM
  87. Move to the next item.
  88. REQ_PREV_ITEM
  89. Move to the previous item.
  90. REQ_TOGGLE_ITEM
  91. Select/deselect an item.
  92. REQ_CLEAR_PATTERN
  93. Clear the menu pattern buffer.
  94. REQ_BACK_PATTERN
  95. Delete the previous character from the pattern
  96. buffer.
  97. REQ_NEXT_MATCH
  98. Move to the next item matching the pattern match.
  99. REQ_PREV_MATCH
  100. Move to the previous item matching the pattern match.
  101. If the second argument is a printable character, the code
  102. appends it to the pattern buffer and attempts to move to
  103. the next item matching the new pattern. If there is no
  104. such match, <STRONG>menu_driver</STRONG> returns <STRONG>E_NO_MATCH</STRONG> and deletes the
  105. appended character from the buffer.
  106. If the second argument is one of the above pre-defined
  107. requests, the corresponding action is performed.
  108. <STRONG>MOUSE</STRONG> <STRONG>HANDLING</STRONG>
  109. If the second argument is the KEY_MOUSE special key, the
  110. associated mouse event is translated into one of the above
  111. pre-defined requests. Currently only clicks in the user
  112. window (e.g. inside the menu display area or the decora-
  113. tion window) are handled.
  114. If you click above the display region of the menu:
  115. a REQ_SCR_ULINE is generated for a single click,
  116. a REQ_SCR_UPAGE is generated for a double-click and
  117. a REQ_FIRST_ITEM is generated for a triple-click.
  118. If you click below the display region of the menu:
  119. a REQ_SCR_DLINE is generated for a single click,
  120. a REQ_SCR_DPAGE is generated for a double-click and
  121. a REQ_LAST_ITEM is generated for a triple-click.
  122. If you click at an item inside the display area of the
  123. menu:
  124. - the menu cursor is positioned to that item.
  125. - If you double-click an item a REQ_TOGGLE_ITEM is
  126. generated and <STRONG>E_UNKNOWN_COMMAND</STRONG> is returned.
  127. This return value makes sense, because a double
  128. click usually means that an item-specific action
  129. should be returned. It is exactly the purpose
  130. of this return value to signal that an applica-
  131. tion specific command should be executed.
  132. - If a translation into a request was done,
  133. <STRONG>menu_driver</STRONG> returns the result of this request.
  134. If you clicked outside the user window or the mouse event
  135. could not be translated into a menu request an
  136. <STRONG>E_REQUEST_DENIED</STRONG> is returned.
  137. <STRONG>APPLICATION-DEFINED</STRONG> <STRONG>COMMANDS</STRONG>
  138. If the second argument is neither printable nor one of the
  139. above pre-defined menu requests or KEY_MOUSE, the drive
  140. assumes it is an application-specific command and returns
  141. <STRONG>E_UNKNOWN_COMMAND</STRONG>. Application-defined commands should be
  142. defined relative to <STRONG>MAX_COMMAND</STRONG>, the maximum value of
  143. these pre-defined requests.
  144. </PRE>
  145. <H2>RETURN VALUE</H2><PRE>
  146. <STRONG>menu_driver</STRONG> return one of the following error codes:
  147. <STRONG>E_OK</STRONG> The routine succeeded.
  148. <STRONG>E_SYSTEM_ERROR</STRONG>
  149. System error occurred (see <STRONG>errno</STRONG>).
  150. <STRONG>E_BAD_ARGUMENT</STRONG>
  151. Routine detected an incorrect or out-of-range argu-
  152. ment.
  153. <STRONG>E_BAD_STATE</STRONG>
  154. Routine was called from an initialization or termina-
  155. tion function.
  156. <STRONG>E_NOT_POSTED</STRONG>
  157. The menu has not been posted.
  158. <STRONG>E_UNKNOWN_COMMAND</STRONG>
  159. The menu driver code saw an unknown request code.
  160. <STRONG>E_NO_MATCH</STRONG>
  161. Character failed to match.
  162. <STRONG>E_REQUEST_DENIED</STRONG>
  163. The menu driver could not process the request.
  164. </PRE>
  165. <H2>SEE ALSO</H2><PRE>
  166. <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="menu.3x.html">menu(3x)</A></STRONG>, <STRONG><A HREF="wgetch.3x.html">wgetch(3x)</A></STRONG>.
  167. </PRE>
  168. <H2>NOTES</H2><PRE>
  169. The header file <STRONG>&lt;menu.h&gt;</STRONG> automatically includes the header
  170. files <STRONG>&lt;curses.h&gt;</STRONG>.
  171. </PRE>
  172. <H2>PORTABILITY</H2><PRE>
  173. These routines emulate the System V menu library. They
  174. were not supported on Version 7 or BSD versions. The sup-
  175. port for mouse events is ncurses specific.
  176. </PRE>
  177. <H2>AUTHORS</H2><PRE>
  178. Juergen Pfeifer. Manual pages and adaptation for new
  179. curses by Eric S. Raymond.
  180. <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>
  181. </PRE>
  182. <HR>
  183. <ADDRESS>
  184. Man(1) output converted with
  185. <a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
  186. </ADDRESS>
  187. </BODY>
  188. </HTML>