Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 1998-2010,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | .\" * |
| 5 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 | .\" copy of this software and associated documentation files (the * |
| 7 | .\" "Software"), to deal in the Software without restriction, including * |
| 8 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 9 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 10 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 11 | .\" furnished to do so, subject to the following conditions: * |
| 12 | .\" * |
| 13 | .\" The above copyright notice and this permission notice shall be included * |
| 14 | .\" in all copies or substantial portions of the Software. * |
| 15 | .\" * |
| 16 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 | .\" * |
| 24 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 25 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 26 | .\" sale, use or other dealings in this Software without prior written * |
| 27 | .\" authorization. * |
| 28 | .\"*************************************************************************** |
| 29 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 30 | .\" $Id: menu_driver.3x,v 1.47 2024/03/16 15:35:01 tom Exp $ |
| 31 | .TH menu_driver 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 32 | .de bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 33 | .ie n .IP \(bu 4 |
| 34 | .el .IP \(bu 2 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 35 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 36 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 37 | \fBmenu_driver\fP \- |
| 38 | command-processing loop of the menu system |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 39 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 40 | .nf |
| 41 | \fB#include <menu.h> |
| 42 | .PP |
| 43 | \fBint menu_driver(MENU *\fImenu\fP, int \fIc\fP); |
| 44 | .fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 45 | .SH DESCRIPTION |
| 46 | Once a menu has been posted (displayed), you should funnel input events to it |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 47 | through \fBmenu_driver\fP. This routine has three major input cases: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 48 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 49 | The input is a form navigation request. |
| 50 | Navigation request codes are constants defined in \fB<form.h>\fP, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 51 | which are distinct from the key- and character codes |
| 52 | returned by \fBwgetch\fP(3X). |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 53 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 54 | The input is a printable character. |
| 55 | Printable characters (which must be positive, less than 256) are |
| 56 | checked according to the program's locale settings. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 57 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 58 | The input is the KEY_MOUSE special key associated with an mouse event. |
| 59 | .PP |
| 60 | The menu driver requests are as follows: |
| 61 | .TP 5 |
| 62 | REQ_LEFT_ITEM |
| 63 | Move left to an item. |
| 64 | .TP 5 |
| 65 | REQ_RIGHT_ITEM |
| 66 | Move right to an item. |
| 67 | .TP 5 |
| 68 | REQ_UP_ITEM |
| 69 | Move up to an item. |
| 70 | .TP 5 |
| 71 | REQ_DOWN_ITEM |
| 72 | Move down to an item. |
| 73 | .TP 5 |
| 74 | REQ_SCR_ULINE |
| 75 | Scroll up a line. |
| 76 | .TP 5 |
| 77 | REQ_SCR_DLINE |
| 78 | Scroll down a line. |
| 79 | .TP 5 |
| 80 | REQ_SCR_DPAGE |
| 81 | Scroll down a page. |
| 82 | .TP 5 |
| 83 | REQ_SCR_UPAGE |
| 84 | Scroll up a page. |
| 85 | .TP 5 |
| 86 | REQ_FIRST_ITEM |
| 87 | Move to the first item. |
| 88 | .TP 5 |
| 89 | REQ_LAST_ITEM |
| 90 | Move to the last item. |
| 91 | .TP 5 |
| 92 | REQ_NEXT_ITEM |
| 93 | Move to the next item. |
| 94 | .TP 5 |
| 95 | REQ_PREV_ITEM |
| 96 | Move to the previous item. |
| 97 | .TP 5 |
| 98 | REQ_TOGGLE_ITEM |
| 99 | Select/deselect an item. |
| 100 | .TP 5 |
| 101 | REQ_CLEAR_PATTERN |
| 102 | Clear the menu pattern buffer. |
| 103 | .TP 5 |
| 104 | REQ_BACK_PATTERN |
| 105 | Delete the previous character from the pattern buffer. |
| 106 | .TP 5 |
| 107 | REQ_NEXT_MATCH |
| 108 | Move to the next item matching the pattern match. |
| 109 | .TP 5 |
| 110 | REQ_PREV_MATCH |
| 111 | Move to the previous item matching the pattern match. |
| 112 | .PP |
| 113 | If the second argument is a printable character, the code appends |
| 114 | it to the pattern buffer and attempts to move to the next item matching |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 115 | the new pattern. |
| 116 | If there is no such match, \fBmenu_driver\fP returns |
| 117 | \fBE_NO_MATCH\fP and deletes the appended character from the buffer. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 118 | .PP |
| 119 | If the second argument is one of the above pre-defined requests, the |
| 120 | corresponding action is performed. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 121 | .SS "Mouse Handling" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 122 | If the second argument is the KEY_MOUSE special key, the associated |
| 123 | mouse event is translated into one of the above pre-defined requests. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 124 | Currently only clicks in the user window (e.g., inside the menu display |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 125 | area or the decoration window) are handled. |
| 126 | .PP |
| 127 | If you click above the display region of the menu: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 128 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 129 | a REQ_SCR_ULINE is generated for a single click, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 130 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 131 | a REQ_SCR_UPAGE is generated for a double-click and |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 132 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 133 | a REQ_FIRST_ITEM is generated for a triple-click. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 134 | .PP |
| 135 | If you click below the display region of the menu: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 136 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 137 | a REQ_SCR_DLINE is generated for a single click, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 138 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 139 | a REQ_SCR_DPAGE is generated for a double-click and |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 140 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 141 | a REQ_LAST_ITEM is generated for a triple-click. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 142 | .PP |
| 143 | If you click at an item inside the display area of the menu: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 144 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 145 | the menu cursor is positioned to that item. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 146 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 147 | If you double-click an item a REQ_TOGGLE_ITEM |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 148 | is generated and \fBE_UNKNOWN_COMMAND\fP is returned. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 149 | This return value makes sense, |
| 150 | because a double click usually means that an item-specific action should |
| 151 | be returned. |
| 152 | It is exactly the purpose of this return value to signal that an |
| 153 | application specific command should be executed. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 154 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 155 | If a translation |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 156 | into a request was done, \fBmenu_driver\fP returns the result of this request. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 157 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 158 | If you clicked outside the user window |
| 159 | or the mouse event could not be translated |
| 160 | into a menu request an \fBE_REQUEST_DENIED\fP is returned. |
| 161 | .SS "Application-defined Commands" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 162 | If the second argument is neither printable nor one of the above |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 163 | pre-defined menu requests or KEY_MOUSE, |
| 164 | the drive assumes it is an application-specific |
| 165 | command and returns \fBE_UNKNOWN_COMMAND\fP. Application-defined commands |
| 166 | should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 167 | pre-defined requests. |
| 168 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 169 | \fBmenu_driver\fP return one of the following error codes: |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 170 | .TP 5 |
| 171 | .B E_OK |
| 172 | The routine succeeded. |
| 173 | .TP 5 |
| 174 | .B E_SYSTEM_ERROR |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 175 | System error occurred (see \fBerrno\fP(3)). |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 176 | .TP 5 |
| 177 | .B E_BAD_ARGUMENT |
| 178 | Routine detected an incorrect or out-of-range argument. |
| 179 | .TP 5 |
| 180 | .B E_BAD_STATE |
| 181 | Routine was called from an initialization or termination function. |
| 182 | .TP 5 |
| 183 | .B E_NOT_POSTED |
| 184 | The menu has not been posted. |
| 185 | .TP 5 |
| 186 | .B E_UNKNOWN_COMMAND |
| 187 | The menu driver code saw an unknown request code. |
| 188 | .TP 5 |
| 189 | .B E_NO_MATCH |
| 190 | Character failed to match. |
| 191 | .TP 5 |
| 192 | .B E_REQUEST_DENIED |
| 193 | The menu driver could not process the request. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 194 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 195 | These routines emulate the System V menu library. |
| 196 | They were not supported on |
| 197 | Version 7 or BSD versions. |
| 198 | The support for mouse events is \fI\%ncurses\fP specific. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 199 | .SH AUTHORS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 200 | Juergen Pfeifer. |
| 201 | Manual pages and adaptation for new curses by Eric S. Raymond. |
| 202 | .SH SEE ALSO |
| 203 | \fB\%curses\fP(3X), |
| 204 | \fB\%getch\fP(3X), |
| 205 | \fB\%menu\fP(3X) |