1 /*-
2 * Copyright (c) 2002 Jordan DeLong
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of contributors may be
14 * used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29 #ifndef INPUT_H
30 #define INPUT_H
31
32 /*
33 * core key identifier definitions
34 */
35 enum {
36 /* basic keys */
37 KEYSYM_NOP = SCREEN_FIRSTUSRSYM,
38 KEYSYM_UP,
39 KEYSYM_DOWN,
40 KEYSYM_LEFT,
41 KEYSYM_RIGHT,
42 KEYSYM_PGUP,
43 KEYSYM_PGDN,
44 KEYSYM_HOME,
45 KEYSYM_END,
46 KEYSYM_BACKSPACE,
47 KEYSYM_DELETE,
48 KEYSYM_ENTER,
49
50 /* main keys */
51 KEYSYM_QUIT,
52 KEYSYM_SUSPEND,
53 KEYSYM_CANCEL,
54 KEYSYM_EXCMD,
55 KEYSYM_HASHSTATS,
56 KEYSYM_SAVEBUFFERS,
57 KEYSYM_SWITCHBUFF,
58 KEYSYM_SETOPT,
59 KEYSYM_OPENFILE,
60 KEYSYM_SAVE,
61 KEYSYM_SAVEAS,
62 KEYSYM_REDRAW,
63 KEYSYM_QUOTENEXT,
64 KEYSYM_AGAIN,
65 KEYSYM_VIEWCYCLE,
66 KEYSYM_PUSHVIEW,
67 KEYSYM_POPVIEW,
68 KEYSYM_VERTSPLIT,
69 KEYSYM_HORIZSPLIT,
70 KEYSYM_RMVIEW,
71 KEYSYM_RMOTHERVIEWS,
72 KEYSYM_VERTGROW,
73 KEYSYM_VERTSHRINK,
74 KEYSYM_HORIZGROW,
75 KEYSYM_HORIZSHRINK,
76 KEYSYM_FRAMECYCLE,
77 KEYSYM_NEWFRAME,
78 KEYSYM_RMFRAME,
79
80 /* macro keys */
81 KEYSYM_RECORD,
82 KEYSYM_PLAYBACK,
83 KEYSYM_REPEAT,
84
85 /* editing keys supported from the vdefault layer */
86 KEYSYM_OPENLINE,
87 KEYSYM_TOGNLSTYLE,
88 KEYSYM_UNDO,
89 KEYSYM_REDO,
90 KEYSYM_NEXTWORD,
91 KEYSYM_PREVWORD,
92 KEYSYM_NEXTPARA,
93 KEYSYM_PREVPARA,
94 KEYSYM_VIEWTOP,
95 KEYSYM_VIEWBOTTOM,
96 KEYSYM_LINEUP,
97 KEYSYM_LINEDN,
98 KEYSYM_FIRSTLINE,
99 KEYSYM_LASTLINE,
100 KEYSYM_HALFPGUP,
101 KEYSYM_HALFPGDN,
102 KEYSYM_CENTER,
103 KEYSYM_TRANCHARS,
104 KEYSYM_TRANWORDS,
105 KEYSYM_TRANLINES,
106 KEYSYM_SETMARK,
107 KEYSYM_POPMARK,
108 KEYSYM_PROMOTEMARK,
109 KEYSYM_DEMOTEMARK,
110 KEYSYM_XCHGMARK,
111 KEYSYM_KILLRGN,
112 KEYSYM_KILLLINE,
113 KEYSYM_KILLEOL,
114 KEYSYM_KILLWORD,
115 KEYSYM_FWDKILLWORD,
116 KEYSYM_APPENDKILL,
117 KEYSYM_YANK,
118 KEYSYM_YANKPOP,
119 KEYSYM_FWDYANKPOP,
120 KEYSYM_ISEARCH,
121 KEYSYM_RISEARCH,
122 KEYSYM_GOTOLN,
123 KEYSYM_REPLACE,
124 KEYSYM_FILTER,
125 KEYSYM_INSERTFILE,
126
127 /* first keysym for runtime allocation by views */
128 KEYSYM_FIRSTVIEWSYM
129 };
130
131 extern int input_exitloop;
132 extern int input_lastkeysym;
133 extern int input_nodraw;
134
135 void input_init();
136 int input_allocsyms(int count);
137 int input_getkey();
138 int input_key_pending(int m);
139 int input_isctrl(int keysym);
140 void input_default_handler(viewhdr_t *, int keysym);
141 void input_dispatch(int keysym);
142 void input_loop();
143 void input_begincancel();
144 int input_checkcancel();
145 void input_endcancel();
146
147 /*
148 * used for recursive entry into the input loop; this is used
149 * for things like entering the minibuffer.
150 */
input_recurse()151 static __inline void input_recurse() {
152 input_loop();
153 input_exitloop = 0;
154 }
155
156 #endif
157