Ticket #2839: Fix keybindings for Quit command of mcedit.
[midnight-commander.git] / lib / keybind.h
blob1258b44cea67dd2f0eccf6092b987c6402195291
1 #ifndef MC__KEYBIND_H
2 #define MC__KEYBIND_H
4 #include <sys/types.h>
5 #include <sys/time.h> /* time_t */
7 #include "lib/global.h"
9 /*** typedefs(not structures) and defined constants **********************************************/
11 /* keymap sections */
12 #define KEYMAP_SECTION_MAIN "main"
13 #define KEYMAP_SECTION_MAIN_EXT "main:xmap"
14 #define KEYMAP_SECTION_PANEL "panel"
15 #define KEYMAP_SECTION_DIALOG "dialog"
16 #define KEYMAP_SECTION_INPUT "input"
17 #define KEYMAP_SECTION_LISTBOX "listbox"
18 #define KEYMAP_SECTION_TREE "tree"
19 #define KEYMAP_SECTION_HELP "help"
20 #define KEYMAP_SECTION_EDITOR "editor"
21 #define KEYMAP_SECTION_EDITOR_EXT "editor:xmap"
22 #define KEYMAP_SECTION_VIEWER "viewer"
23 #define KEYMAP_SECTION_VIEWER_HEX "viewer:hex"
24 #define KEYMAP_SECTION_DIFFVIEWER "diffviewer"
26 #define KEYMAP_SHORTCUT_LENGTH 32 /* FIXME: is 32 bytes enough for shortcut? */
28 #define CK_PipeBlock(i) (10000+(i))
29 #define CK_Macro(i) (20000+(i))
30 #define CK_MacroLast CK_Macro(0x7FFF)
32 /*** enums ***************************************************************************************/
34 enum
36 /* special commands */
37 CK_InsertChar = -1,
38 CK_IgnoreKey = 0,
40 /* common */
41 CK_Enter = 1,
42 CK_Up,
43 CK_Down,
44 CK_Left,
45 CK_Right,
46 CK_Home,
47 CK_End,
48 CK_LeftQuick,
49 CK_RightQuick,
50 CK_PageUp,
51 CK_PageDown,
52 CK_HalfPageUp,
53 CK_HalfPageDown,
54 CK_Top,
55 CK_Bottom,
56 CK_TopOnScreen,
57 CK_MiddleOnScreen,
58 CK_BottomOnScreen,
59 CK_WordLeft,
60 CK_WordRight,
61 CK_Copy,
62 CK_Move,
63 CK_Delete,
64 CK_MakeDir,
65 CK_ChangeMode,
66 CK_ChangeOwn,
67 CK_ChangeOwnAdvanced,
68 CK_Remove,
69 CK_BackSpace,
70 CK_Redo,
71 CK_Clear,
72 CK_Menu,
73 CK_MenuLastSelected,
74 CK_UserMenu,
75 CK_EditUserMenu,
76 CK_Search,
77 CK_SearchContinue,
78 CK_Replace,
79 CK_ReplaceContinue,
80 CK_SearchStop,
81 CK_Help,
82 CK_Edit,
83 CK_EditNew,
84 CK_Shell,
85 CK_SelectCodepage,
86 CK_History,
87 CK_HistoryNext,
88 CK_HistoryPrev,
89 CK_Complete,
90 CK_Save,
91 CK_SaveAs,
92 CK_Goto,
93 CK_Reread,
94 CK_Refresh,
95 CK_Suspend,
96 CK_Swap,
97 CK_Mark,
98 CK_HotList,
99 CK_ScreenList,
100 CK_ScreenNext,
101 CK_ScreenPrev,
102 CK_FilePrev,
103 CK_FileNext,
104 CK_DeleteToHome,
105 CK_DeleteToEnd,
106 CK_DeleteToWordBegin,
107 CK_DeleteToWordEnd,
108 CK_ShowNumbers,
109 CK_Store,
110 CK_Cut,
111 CK_Paste,
112 CK_MarkLeft,
113 CK_MarkRight,
114 CK_MarkUp,
115 CK_MarkDown,
116 CK_MarkToWordBegin,
117 CK_MarkToWordEnd,
118 CK_MarkToHome,
119 CK_MarkToEnd,
120 CK_ToggleNavigation,
121 CK_Sort,
122 CK_Options,
123 CK_LearnKeys,
124 CK_Bookmark,
125 CK_Quit,
126 CK_QuitQuiet,
127 /* C-x or similar */
128 CK_ExtendedKeyMap,
130 /* main commands */
131 CK_EditForceInternal = 100,
132 CK_View,
133 CK_ViewRaw,
134 CK_ViewFile,
135 CK_ViewFiltered,
136 CK_Find,
137 CK_DirSize,
138 CK_HotListAdd,
139 CK_PanelListingChange,
140 CK_CompareDirs,
141 CK_OptionsVfs,
142 CK_OptionsConfirm,
143 CK_PutCurrentLink,
144 CK_PutOtherLink,
145 CK_OptionsDisplayBits,
146 CK_EditExtensionsFile,
147 CK_EditFileHighlightFile,
148 CK_LinkSymbolicEdit,
149 CK_ExternalPanelize,
150 CK_Filter,
151 CK_ConnectFish,
152 CK_ConnectFtp,
153 CK_ConnectSftp,
154 CK_ConnectSmb,
155 CK_PanelInfo,
156 CK_Jobs,
157 CK_OptionsLayout,
158 CK_Link,
159 CK_PanelListing,
160 CK_ListMode,
161 CK_CdQuick,
162 CK_PanelQuickView,
163 CK_VfsList,
164 CK_SaveSetup,
165 CK_LinkSymbolic,
166 CK_PanelListingSwitch,
167 CK_ShowHidden,
168 CK_PanelTree,
169 CK_Tree,
170 CK_Undelete,
171 CK_SplitVertHoriz,
172 CK_SplitEqual,
173 CK_SplitMore,
174 CK_SplitLess,
175 CK_CompareFiles,
176 CK_OptionsPanel,
177 CK_LinkSymbolicRelative,
178 CK_PutCurrentPath,
179 CK_PutOtherPath,
180 CK_PutCurrentTagged,
181 CK_PutOtherTagged,
182 CK_Select,
183 CK_Unselect,
184 CK_SelectInvert,
186 /* panels */
187 CK_PanelOtherCd = 200,
188 CK_PanelOtherCdLink,
189 CK_Panelize,
190 CK_CopySingle,
191 CK_MoveSingle,
192 CK_DeleteSingle,
193 CK_CdChild,
194 CK_CdParent,
195 CK_CdParentSmart,
196 CK_PanelOtherSync,
197 CK_SortNext,
198 CK_SortPrev,
199 CK_SortReverse,
200 CK_SortByName,
201 CK_SortByExt,
202 CK_SortBySize,
203 CK_SortByMTime,
204 CK_ScrollLeft,
205 CK_ScrollRight,
207 /* dialog */
208 CK_Ok = 300,
209 CK_Cancel,
211 /* input */
212 CK_Yank = 350,
214 /* help */
215 CK_Index = 400,
216 CK_Back,
217 CK_LinkNext,
218 CK_LinkPrev,
219 CK_NodeNext,
220 CK_NodePrev,
222 /* tree */
223 CK_Forget = 450,
225 /* editor */
226 /* cursor movements */
227 CK_Tab = 500,
228 CK_Undo,
229 CK_ScrollUp,
230 CK_ScrollDown,
231 CK_Return,
232 CK_ParagraphUp,
233 CK_ParagraphDown,
234 /* file commands */
235 CK_EditFile,
236 CK_InsertFile,
237 CK_EditSyntaxFile,
238 CK_Close,
239 /* block commands */
240 CK_BlockSave,
241 CK_BlockShiftLeft,
242 CK_BlockShiftRight,
243 CK_DeleteLine,
244 /* bookmarks */
245 CK_BookmarkFlush,
246 CK_BookmarkNext,
247 CK_BookmarkPrev,
248 /* mark commands */
249 CK_MarkColumn,
250 CK_MarkWord,
251 CK_MarkLine,
252 CK_MarkAll,
253 CK_Unmark,
254 CK_MarkPageUp,
255 CK_MarkPageDown,
256 CK_MarkToFileBegin,
257 CK_MarkToFileEnd,
258 CK_MarkToPageBegin,
259 CK_MarkToPageEnd,
260 CK_MarkScrollUp,
261 CK_MarkScrollDown,
262 CK_MarkParagraphUp,
263 CK_MarkParagraphDown,
264 /* column mark commands */
265 CK_MarkColumnPageUp,
266 CK_MarkColumnPageDown,
267 CK_MarkColumnLeft,
268 CK_MarkColumnRight,
269 CK_MarkColumnUp,
270 CK_MarkColumnDown,
271 CK_MarkColumnScrollUp,
272 CK_MarkColumnScrollDown,
273 CK_MarkColumnParagraphUp,
274 CK_MarkColumnParagraphDown,
275 /* macros */
276 CK_MacroStartRecord,
277 CK_MacroStopRecord,
278 CK_MacroStartStopRecord,
279 CK_MacroDelete,
280 CK_RepeatStartRecord,
281 CK_RepeatStopRecord,
282 CK_RepeatStartStopRecord,
283 /* window commands */
284 CK_WindowMove,
285 CK_WindowResize,
286 CK_WindowFullscreen,
287 CK_WindowList,
288 CK_WindowNext,
289 CK_WindowPrev,
290 /* misc commands */
291 CK_SpellCheck,
292 CK_SpellCheckCurrentWord,
293 CK_SpellCheckSelectLang,
294 CK_InsertOverwrite,
295 CK_ParagraphFormat,
296 CK_MatchBracket,
297 CK_OptionsSaveMode,
298 CK_About,
299 CK_ShowMargin,
300 CK_ShowTabTws,
301 CK_SyntaxOnOff,
302 CK_SyntaxChoose,
303 CK_InsertLiteral,
304 CK_ExternalCommand,
305 CK_Date,
306 CK_Mail,
308 /* viewer */
309 CK_WrapMode = 600,
310 CK_MagicMode,
311 CK_NroffMode,
312 CK_HexMode,
313 CK_HexEditMode,
314 CK_BookmarkGoto,
315 CK_Ruler,
316 CK_SearchForward,
317 CK_SearchBackward,
318 CK_SearchForwardContinue,
319 CK_SearchBackwardContinue,
321 /* diff viewer */
322 CK_ShowSymbols = 700,
323 CK_SplitFull,
324 CK_Tab2,
325 CK_Tab3,
326 CK_Tab4,
327 CK_Tab8,
328 CK_HunkNext,
329 CK_HunkPrev,
330 CK_EditOther,
331 CK_Merge
334 /*** structures declarations (and typedefs of structures)*****************************************/
336 typedef struct name_keymap_t
338 const char *name;
339 unsigned long val;
340 } name_keymap_t;
342 typedef struct key_config_t
344 time_t mtime; /* mtime at the moment we read config file */
345 GArray *keymap;
346 GArray *ext_keymap;
347 gchar *labels[10];
348 } key_config_t;
350 /* The global keymaps are of this type */
351 typedef struct global_keymap_t
353 long key;
354 unsigned long command;
355 char caption[KEYMAP_SHORTCUT_LENGTH];
356 } global_keymap_t;
358 /*** global variables defined in .c file *********************************************************/
360 /*** declarations of public functions ************************************************************/
362 void keybind_cmd_bind (GArray * keymap, const char *keybind, unsigned long action);
363 unsigned long keybind_lookup_action (const char *name);
364 const char *keybind_lookup_actionname (unsigned long action);
365 const char *keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action);
366 unsigned long keybind_lookup_keymap_command (const global_keymap_t * keymap, long key);
368 /*** inline functions ****************************************************************************/
370 #endif /* MC__KEYBIND_H */