2 * $Id: dlg_keys.h,v 1.32 2012/12/21 21:54:30 tom Exp $
4 * dlg_keys.h -- runtime binding support for dialog
6 * Copyright 2005-2011,2012 Thomas E. Dickey
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License, version 2.1
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to
19 * Free Software Foundation, Inc.
20 * 51 Franklin St., Fifth Floor
21 * Boston, MA 02110, USA.
24 #ifndef DLG_KEYS_H_included
25 #define DLG_KEYS_H_included 1
30 #ifdef USE_WIDE_CURSES
32 #define dlg_toupper(ch) towupper((wint_t)ch)
33 #define dlg_isupper(ch) iswupper((wint_t)ch)
35 #define dlg_toupper(ch) (((ch) > 0 && (ch) <= 255) ? toupper(ch) : (ch))
36 #define dlg_isupper(ch) (isalpha(ch) && isupper(ch))
49 #define DLG_KEYS_DATA(dialog, curses) { (curses) >= KEY_MIN, curses, dialog }
51 #define END_KEYS_BINDING { -1, 0, 0 }
54 * Define dialog's internal function-keys past the range used by curses.
57 DLGK_MIN
= KEY_MAX
+ 1,
58 /* predefined buttons */
64 /* moving from screen to screen (pages) */
69 /* moving within a list */
74 /* moving from field to field (or buttons) */
79 /* moving from form-field to form-field (or buttons) */
84 /* moving within a grid */
102 #define is_DLGK_MOUSE(code) ((code) >= M_EVENT)
103 #define DLGK_MOUSE(code) ((code) + M_EVENT)
105 #define HELPKEY_BINDINGS \
106 DLG_KEYS_DATA( DLGK_HELPFILE, CHR_HELP ), \
107 DLG_KEYS_DATA( DLGK_HELPFILE, KEY_F(1) ), \
108 DLG_KEYS_DATA( DLGK_HELPFILE, KEY_HELP )
110 #define ENTERKEY_BINDINGS \
111 DLG_KEYS_DATA( DLGK_ENTER, '\n' ), \
112 DLG_KEYS_DATA( DLGK_ENTER, '\r' ), \
113 DLG_KEYS_DATA( DLGK_ENTER, KEY_ENTER )
116 #define INPUTSTR_BINDINGS \
117 DLG_KEYS_DATA( DLGK_BEGIN, KEY_HOME ), \
118 DLG_KEYS_DATA( DLGK_DELETE_ALL, CHR_KILL ), \
119 DLG_KEYS_DATA( DLGK_DELETE_LEFT, CHR_BACKSPACE ), \
120 DLG_KEYS_DATA( DLGK_DELETE_LEFT, KEY_BACKSPACE ), \
121 DLG_KEYS_DATA( DLGK_DELETE_RIGHT, CHR_DELETE ), \
122 DLG_KEYS_DATA( DLGK_DELETE_RIGHT, KEY_DC ), \
123 DLG_KEYS_DATA( DLGK_FINAL, KEY_END ), \
124 DLG_KEYS_DATA( DLGK_GRID_LEFT, KEY_LEFT ), \
125 DLG_KEYS_DATA( DLGK_GRID_RIGHT, KEY_RIGHT )
127 #define SCROLL_FKEY_BINDINGS \
128 DLG_KEYS_DATA( DLGK_GRID_DOWN, KEY_DOWN ), \
129 DLG_KEYS_DATA( DLGK_GRID_UP, KEY_UP ), \
130 DLG_KEYS_DATA( DLGK_PAGE_FIRST, KEY_HOME ), \
131 DLG_KEYS_DATA( DLGK_PAGE_LAST, KEY_END ), \
132 DLG_KEYS_DATA( DLGK_PAGE_NEXT, KEY_NPAGE ), \
133 DLG_KEYS_DATA( DLGK_PAGE_PREV, KEY_PPAGE )
135 #define SCROLLKEY_BINDINGS \
136 SCROLL_FKEY_BINDINGS, \
137 DLG_KEYS_DATA( DLGK_GRID_DOWN, 'J' ), \
138 DLG_KEYS_DATA( DLGK_GRID_DOWN, 'j' ), \
139 DLG_KEYS_DATA( DLGK_GRID_UP, 'K' ), \
140 DLG_KEYS_DATA( DLGK_GRID_UP, 'k' ), \
141 DLG_KEYS_DATA( DLGK_PAGE_FIRST, 'g' ), \
142 DLG_KEYS_DATA( DLGK_PAGE_LAST, 'G' ), \
143 DLG_KEYS_DATA( DLGK_PAGE_NEXT, 'F' ), \
144 DLG_KEYS_DATA( DLGK_PAGE_NEXT, 'f' ), \
145 DLG_KEYS_DATA( DLGK_PAGE_PREV, 'B' ), \
146 DLG_KEYS_DATA( DLGK_PAGE_PREV, 'b' )
148 #define TRAVERSE_BINDINGS \
149 DLG_KEYS_DATA( DLGK_ENTER, ' ' ), \
150 DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_DOWN ), \
151 DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ), \
152 DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ), \
153 DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_UP ), \
154 DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_BTAB ), \
155 DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_LEFT )
157 extern int dlg_lookup_key(WINDOW
* /*win*/, int /*curses_key*/, int * /*dialog_key*/);
158 extern int dlg_result_key(int /*dialog_key*/, int /*fkey*/, int * /*resultp*/);
159 extern void dlg_register_buttons(WINDOW
* /*win*/, const char * /*name*/, const char ** /*buttons*/);
160 extern void dlg_register_window(WINDOW
* /*win*/, const char * /*name*/, DLG_KEYS_BINDING
* /*binding*/);
161 extern void dlg_unregister_window(WINDOW
* /*win*/);
164 extern int dlg_parse_bindkey(char * /*params*/);
165 extern void dlg_dump_keys(FILE * /*fp*/);
166 extern void dlg_dump_window_keys(FILE * /*fp*/, WINDOW
* /*win*/);
174 #endif /* DLG_KEYS_H_included */