Annotation of src/usr.bin/vim/keymap.h, Revision 1.1.1.1
1.1 downsj 1: /* $OpenBSD$ */
2: /* vi:set ts=4 sw=4:
3: *
4: * VIM - Vi IMproved by Bram Moolenaar
5: *
6: * Do ":help uganda" in Vim to read copying and usage conditions.
7: * Do ":help credits" in Vim to see a list of people who contributed.
8: */
9:
10: #define K_CCIRCM 0x1e /* control circumflex */
11:
12: /*
13: * For MSDOS some keys produce codes larger than 0xff. They are split into two
14: * chars, the first one is K_NUL (same value used in term.h).
15: */
16: #define K_NUL (0xce) /* for MSDOS: special key follows */
17:
18: /*
19: * Keycode definitions for special keys.
20: *
21: * Any special key code sequences are replaced by these codes.
22: */
23:
24: /*
25: * K_SPECIAL is the first byte of a special key code and is always followed by
26: * two bytes.
27: * The second byte can have any value. ASCII is used for normal termcap
28: * entries, 0x80 and higher for special keys, see below.
29: * The third byte is guaranteed to be between 0x02 and 0x7f.
30: */
31:
32: #define K_SPECIAL (0x80)
33:
34: /*
35: * characters 0x0000 - 0x00ff are "normal"
36: * characters 0x0100 - 0x01ff are used for abbreviations
37: * characters 0x0200 - 0xffff are special key codes
38: */
39: #define IS_SPECIAL(c) ((c) >= 0x200)
40: #define IS_ABBR(c) ((c) >= 0x100 && (c) < 0x200)
41: #define ABBR_OFF 0x100
42:
43: /*
44: * NUL cannot be in the input string, therefore it is replaced by
45: * K_SPECIAL KS_ZERO K_FILLER
46: */
47: #define KS_ZERO 255
48:
49: /*
50: * K_SPECIAL cannot be in the input string, therefore it is replaced by
51: * K_SPECIAL KS_SPECIAL K_FILLER
52: */
53: #define KS_SPECIAL 254
54:
55: /*
56: * KS_EXTRA is used for keys that have no termcap name
57: * K_SPECIAL KS_EXTRA KE_xxx
58: */
59: #define KS_EXTRA 253
60:
61: /*
62: * KS_MODIFIER is used when a modifier is given for a (special) key
63: * K_SPECIAL KS_MODIFIER bitmask
64: */
65: #define KS_MODIFIER 252
66:
67: /*
68: * These are used for the GUI
69: * K_SPECIAL KS_xxx K_FILLER
70: */
71: #define KS_MOUSE 251
72: #define KS_MENU 250
73: #define KS_SCROLLBAR 249
74: #define KS_HORIZ_SCROLLBAR 248
75:
76: /*
77: * Filler used after KS_SPECIAL and others
78: */
79: #define K_FILLER ('X')
80:
81: /*
82: * translation of three byte code "K_SPECIAL a b" into int "K_xxx" and back
83: */
84: #define TERMCAP2KEY(a, b) ((a) + ((b) << 8))
85: #define KEY2TERMCAP0(x) ((x) & 0xff)
86: #define KEY2TERMCAP1(x) (((x) >> 8) & 0xff)
87:
88: /*
89: * get second or third byte when translating special key code into three bytes
90: */
91: #define K_SECOND(c) ((c) == K_SPECIAL ? KS_SPECIAL : (c) == NUL ? KS_ZERO : KEY2TERMCAP0(c))
92:
93: #define K_THIRD(c) (((c) == K_SPECIAL || (c) == NUL) ? K_FILLER : KEY2TERMCAP1(c))
94:
95: /*
96: * get single int code from second byte after K_SPECIAL
97: */
98: #define TO_SPECIAL(a, b) ((a) == KS_SPECIAL ? K_SPECIAL : (a) == KS_ZERO ? K_ZERO : TERMCAP2KEY(a, b))
99:
100: /*
101: * Codes for keys that do not have a termcap name.
102: *
103: * K_SPECIAL KS_EXTRA KE_xxx
104: */
105: #define KE_NAME 3 /* name of this terminal entry */
106:
107: #define KE_S_UP 4
108: #define KE_S_DOWN 5
109:
110: #define KE_S_F1 6 /* shifted function keys */
111: #define KE_S_F2 7
112: #define KE_S_F3 8
113: #define KE_S_F4 9
114: #define KE_S_F5 10
115: #define KE_S_F6 11
116: #define KE_S_F7 12
117: #define KE_S_F8 13
118: #define KE_S_F9 14
119: #define KE_S_F10 15
120:
121: #define KE_S_F11 16
122: #define KE_S_F12 17
123: #define KE_S_F13 18
124: #define KE_S_F14 19
125: #define KE_S_F15 20
126: #define KE_S_F16 21
127: #define KE_S_F17 22
128: #define KE_S_F18 23
129: #define KE_S_F19 24
130: #define KE_S_F20 25
131:
132: #define KE_S_F21 26
133: #define KE_S_F22 27
134: #define KE_S_F23 28
135: #define KE_S_F24 29
136: #define KE_S_F25 30
137: #define KE_S_F26 31
138: #define KE_S_F27 32
139: #define KE_S_F28 33
140: #define KE_S_F29 34
141: #define KE_S_F30 35
142:
143: #define KE_S_F31 36
144: #define KE_S_F32 37
145: #define KE_S_F33 38
146: #define KE_S_F34 39
147: #define KE_S_F35 40
148:
149: #define KE_MOUSE 41 /* mouse event start */
150:
151: /*
152: * Symbols for pseudo keys which are translated from the real key symbols
153: * above.
154: */
155: #define KE_LEFTMOUSE 42 /* Left mouse button click */
156: #define KE_LEFTDRAG 43 /* Drag with left mouse button down */
157: #define KE_LEFTRELEASE 44 /* Left mouse button release */
158: #define KE_MIDDLEMOUSE 45 /* Middle mouse button click */
159: #define KE_MIDDLEDRAG 46 /* Drag with middle mouse button down */
160: #define KE_MIDDLERELEASE 47 /* Middle mouse button release */
161: #define KE_RIGHTMOUSE 48 /* Right mouse button click */
162: #define KE_RIGHTDRAG 49 /* Drag with right mouse button down */
163: #define KE_RIGHTRELEASE 50 /* Right mouse button release */
164:
165: #define KE_IGNORE 51 /* Ignored mouse drag/release */
166:
167: #define KE_TAB 52 /* unshifted TAB key */
168: #define KE_S_TAB 53 /* shifted TAB key */
169:
170: /*
171: * the three byte codes are replaced with the following int when using vgetc()
172: */
173: #define K_ZERO TERMCAP2KEY(KS_ZERO, K_FILLER)
174:
175: #define K_UP TERMCAP2KEY('k', 'u')
176: #define K_DOWN TERMCAP2KEY('k', 'd')
177: #define K_LEFT TERMCAP2KEY('k', 'l')
178: #define K_RIGHT TERMCAP2KEY('k', 'r')
179: #define K_S_UP TERMCAP2KEY(KS_EXTRA, KE_S_UP)
180: #define K_S_DOWN TERMCAP2KEY(KS_EXTRA, KE_S_DOWN)
181: #define K_S_LEFT TERMCAP2KEY('#', '4')
182: #define K_S_RIGHT TERMCAP2KEY('%', 'i')
183: #define K_TAB TERMCAP2KEY(KS_EXTRA, KE_TAB)
184: #define K_S_TAB TERMCAP2KEY(KS_EXTRA, KE_S_TAB)
185:
186: #define K_F1 TERMCAP2KEY('k', '1') /* function keys */
187: #define K_F2 TERMCAP2KEY('k', '2')
188: #define K_F3 TERMCAP2KEY('k', '3')
189: #define K_F4 TERMCAP2KEY('k', '4')
190: #define K_F5 TERMCAP2KEY('k', '5')
191: #define K_F6 TERMCAP2KEY('k', '6')
192: #define K_F7 TERMCAP2KEY('k', '7')
193: #define K_F8 TERMCAP2KEY('k', '8')
194: #define K_F9 TERMCAP2KEY('k', '9')
195: #define K_F10 TERMCAP2KEY('k', ';')
196:
197: #define K_F11 TERMCAP2KEY('F', '1')
198: #define K_F12 TERMCAP2KEY('F', '2')
199: #define K_F13 TERMCAP2KEY('F', '3')
200: #define K_F14 TERMCAP2KEY('F', '4')
201: #define K_F15 TERMCAP2KEY('F', '5')
202: #define K_F16 TERMCAP2KEY('F', '6')
203: #define K_F17 TERMCAP2KEY('F', '7')
204: #define K_F18 TERMCAP2KEY('F', '8')
205: #define K_F19 TERMCAP2KEY('F', '9')
206: #define K_F20 TERMCAP2KEY('F', 'A')
207:
208: #define K_F21 TERMCAP2KEY('F', 'B')
209: #define K_F22 TERMCAP2KEY('F', 'C')
210: #define K_F23 TERMCAP2KEY('F', 'D')
211: #define K_F24 TERMCAP2KEY('F', 'E')
212: #define K_F25 TERMCAP2KEY('F', 'F')
213: #define K_F26 TERMCAP2KEY('F', 'G')
214: #define K_F27 TERMCAP2KEY('F', 'H')
215: #define K_F28 TERMCAP2KEY('F', 'I')
216: #define K_F29 TERMCAP2KEY('F', 'J')
217: #define K_F30 TERMCAP2KEY('F', 'K')
218:
219: #define K_F31 TERMCAP2KEY('F', 'L')
220: #define K_F32 TERMCAP2KEY('F', 'M')
221: #define K_F33 TERMCAP2KEY('F', 'N')
222: #define K_F34 TERMCAP2KEY('F', 'O')
223: #define K_F35 TERMCAP2KEY('F', 'P')
224:
225: #define K_S_F1 TERMCAP2KEY(KS_EXTRA, KE_S_F1) /* shifted func. keys */
226: #define K_S_F2 TERMCAP2KEY(KS_EXTRA, KE_S_F2)
227: #define K_S_F3 TERMCAP2KEY(KS_EXTRA, KE_S_F3)
228: #define K_S_F4 TERMCAP2KEY(KS_EXTRA, KE_S_F4)
229: #define K_S_F5 TERMCAP2KEY(KS_EXTRA, KE_S_F5)
230: #define K_S_F6 TERMCAP2KEY(KS_EXTRA, KE_S_F6)
231: #define K_S_F7 TERMCAP2KEY(KS_EXTRA, KE_S_F7)
232: #define K_S_F8 TERMCAP2KEY(KS_EXTRA, KE_S_F8)
233: #define K_S_F9 TERMCAP2KEY(KS_EXTRA, KE_S_F9)
234: #define K_S_F10 TERMCAP2KEY(KS_EXTRA, KE_S_F10)
235:
236: #define K_S_F11 TERMCAP2KEY(KS_EXTRA, KE_S_F11)
237: #define K_S_F12 TERMCAP2KEY(KS_EXTRA, KE_S_F12)
238: #define K_S_F13 TERMCAP2KEY(KS_EXTRA, KE_S_F13)
239: #define K_S_F14 TERMCAP2KEY(KS_EXTRA, KE_S_F14)
240: #define K_S_F15 TERMCAP2KEY(KS_EXTRA, KE_S_F15)
241: #define K_S_F16 TERMCAP2KEY(KS_EXTRA, KE_S_F16)
242: #define K_S_F17 TERMCAP2KEY(KS_EXTRA, KE_S_F17)
243: #define K_S_F18 TERMCAP2KEY(KS_EXTRA, KE_S_F18)
244: #define K_S_F19 TERMCAP2KEY(KS_EXTRA, KE_S_F19)
245: #define K_S_F20 TERMCAP2KEY(KS_EXTRA, KE_S_F20)
246:
247: #define K_S_F21 TERMCAP2KEY(KS_EXTRA, KE_S_F21)
248: #define K_S_F22 TERMCAP2KEY(KS_EXTRA, KE_S_F22)
249: #define K_S_F23 TERMCAP2KEY(KS_EXTRA, KE_S_F23)
250: #define K_S_F24 TERMCAP2KEY(KS_EXTRA, KE_S_F24)
251: #define K_S_F25 TERMCAP2KEY(KS_EXTRA, KE_S_F25)
252: #define K_S_F26 TERMCAP2KEY(KS_EXTRA, KE_S_F26)
253: #define K_S_F27 TERMCAP2KEY(KS_EXTRA, KE_S_F27)
254: #define K_S_F28 TERMCAP2KEY(KS_EXTRA, KE_S_F28)
255: #define K_S_F29 TERMCAP2KEY(KS_EXTRA, KE_S_F29)
256: #define K_S_F30 TERMCAP2KEY(KS_EXTRA, KE_S_F30)
257:
258: #define K_S_F31 TERMCAP2KEY(KS_EXTRA, KE_S_F31)
259: #define K_S_F32 TERMCAP2KEY(KS_EXTRA, KE_S_F32)
260: #define K_S_F33 TERMCAP2KEY(KS_EXTRA, KE_S_F33)
261: #define K_S_F34 TERMCAP2KEY(KS_EXTRA, KE_S_F34)
262: #define K_S_F35 TERMCAP2KEY(KS_EXTRA, KE_S_F35)
263:
264: #define K_HELP TERMCAP2KEY('%', '1')
265: #define K_UNDO TERMCAP2KEY('&', '8')
266:
267: #define K_BS TERMCAP2KEY('k', 'b')
268:
269: #define K_INS TERMCAP2KEY('k', 'I')
270: #define K_DEL TERMCAP2KEY('k', 'D')
271: #define K_HOME TERMCAP2KEY('k', 'h')
272: #define K_END TERMCAP2KEY('@', '7')
273: #define K_PAGEUP TERMCAP2KEY('k', 'P')
274: #define K_PAGEDOWN TERMCAP2KEY('k', 'N')
275:
276: #define K_MOUSE TERMCAP2KEY(KS_MOUSE, K_FILLER)
277: #define K_MENU TERMCAP2KEY(KS_MENU, K_FILLER)
278: #define K_SCROLLBAR TERMCAP2KEY(KS_SCROLLBAR, K_FILLER)
279: #define K_HORIZ_SCROLLBAR TERMCAP2KEY(KS_HORIZ_SCROLLBAR, K_FILLER)
280:
281: /*
282: * Symbols for pseudo keys which are translated from the real key symbols
283: * above.
284: */
285: #define K_LEFTMOUSE TERMCAP2KEY(KS_EXTRA, KE_LEFTMOUSE)
286: #define K_LEFTDRAG TERMCAP2KEY(KS_EXTRA, KE_LEFTDRAG)
287: #define K_LEFTRELEASE TERMCAP2KEY(KS_EXTRA, KE_LEFTRELEASE)
288: #define K_MIDDLEMOUSE TERMCAP2KEY(KS_EXTRA, KE_MIDDLEMOUSE)
289: #define K_MIDDLEDRAG TERMCAP2KEY(KS_EXTRA, KE_MIDDLEDRAG)
290: #define K_MIDDLERELEASE TERMCAP2KEY(KS_EXTRA, KE_MIDDLERELEASE)
291: #define K_RIGHTMOUSE TERMCAP2KEY(KS_EXTRA, KE_RIGHTMOUSE)
292: #define K_RIGHTDRAG TERMCAP2KEY(KS_EXTRA, KE_RIGHTDRAG)
293: #define K_RIGHTRELEASE TERMCAP2KEY(KS_EXTRA, KE_RIGHTRELEASE)
294:
295: #define K_IGNORE TERMCAP2KEY(KS_EXTRA, KE_IGNORE)
296:
297: /* Bits for modifier mask */
298: #define MOD_MASK_SHIFT 0x02
299: #define MOD_MASK_CTRL 0x04
300: #define MOD_MASK_ALT 0x08
301: #define MOD_MASK_2CLICK 0x10
302: #define MOD_MASK_3CLICK 0x20
303: #define MOD_MASK_4CLICK 0x40
304:
305: #define MOD_MASK_MULTI_CLICK (MOD_MASK_2CLICK|MOD_MASK_3CLICK|MOD_MASK_4CLICK)
306:
307: /*
308: * The length of the longest special key name, including modifiers.
309: * Current longest is <M-C-S-4-MiddleRelease> (length includes '<' and '>').
310: */
311: #define MAX_KEY_NAME_LEN 23
312:
313: /* Maximum length of a special key event as tokens. This includes modifiers.
314: * The longest event is something like <M-C-S-4-LeftDrag> which would be the
315: * following string of tokens:
316: *
317: * <K_SPECIAL> <KS_MODIFIER> bitmask <K_SPECIAL> <KS_EXTRA> <KT_LEFTDRAG>.
318: *
319: * This is a total of 6 tokens, and is currently the longest one possible.
320: */
321: #define MAX_KEY_CODE_LEN 6