Merge branch '3620_patchfs_syntax_error'
[midnight-commander.git] / lib / keybind.h
bloba88efbc14180a288810737b297e4c558b4c1057d
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 = -1L,
38 CK_IgnoreKey = 0L,
40 /* common */
41 CK_Enter = 1L,
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 = 100L,
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_OptionsAppearance,
159 CK_Link,
160 CK_PanelListing,
161 CK_ListMode,
162 CK_CdQuick,
163 CK_PanelQuickView,
164 CK_VfsList,
165 CK_SaveSetup,
166 CK_LinkSymbolic,
167 CK_PanelListingSwitch,
168 CK_ShowHidden,
169 CK_PanelTree,
170 CK_Tree,
171 CK_Undelete,
172 CK_SplitVertHoriz,
173 CK_SplitEqual,
174 CK_SplitMore,
175 CK_SplitLess,
176 CK_CompareFiles,
177 CK_OptionsPanel,
178 CK_LinkSymbolicRelative,
179 CK_PutCurrentPath,
180 CK_PutOtherPath,
181 CK_PutCurrentTagged,
182 CK_PutOtherTagged,
183 CK_Select,
184 CK_Unselect,
185 CK_SelectExt,
186 CK_SelectInvert,
188 /* panels */
189 CK_PanelOtherCd = 200L,
190 CK_PanelOtherCdLink,
191 CK_Panelize,
192 CK_CopySingle,
193 CK_MoveSingle,
194 CK_DeleteSingle,
195 CK_CdChild,
196 CK_CdParent,
197 CK_CdParentSmart,
198 CK_PanelOtherSync,
199 CK_SortNext,
200 CK_SortPrev,
201 CK_SortReverse,
202 CK_SortByName,
203 CK_SortByExt,
204 CK_SortBySize,
205 CK_SortByMTime,
206 CK_ScrollLeft,
207 CK_ScrollRight,
209 /* dialog */
210 CK_Ok = 300L,
211 CK_Cancel,
213 /* input */
214 CK_Yank = 350L,
216 /* help */
217 CK_Index = 400L,
218 CK_Back,
219 CK_LinkNext,
220 CK_LinkPrev,
221 CK_NodeNext,
222 CK_NodePrev,
224 /* tree */
225 CK_Forget = 450L,
227 /* editor */
228 /* cursor movements */
229 CK_Tab = 500L,
230 CK_Undo,
231 CK_ScrollUp,
232 CK_ScrollDown,
233 CK_Return,
234 CK_ParagraphUp,
235 CK_ParagraphDown,
236 /* file commands */
237 CK_EditFile,
238 CK_InsertFile,
239 CK_EditSyntaxFile,
240 CK_Close,
241 /* block commands */
242 CK_BlockSave,
243 CK_BlockShiftLeft,
244 CK_BlockShiftRight,
245 CK_DeleteLine,
246 /* bookmarks */
247 CK_BookmarkFlush,
248 CK_BookmarkNext,
249 CK_BookmarkPrev,
250 /* mark commands */
251 CK_MarkColumn,
252 CK_MarkWord,
253 CK_MarkLine,
254 CK_MarkAll,
255 CK_Unmark,
256 CK_MarkPageUp,
257 CK_MarkPageDown,
258 CK_MarkToFileBegin,
259 CK_MarkToFileEnd,
260 CK_MarkToPageBegin,
261 CK_MarkToPageEnd,
262 CK_MarkScrollUp,
263 CK_MarkScrollDown,
264 CK_MarkParagraphUp,
265 CK_MarkParagraphDown,
266 /* column mark commands */
267 CK_MarkColumnPageUp,
268 CK_MarkColumnPageDown,
269 CK_MarkColumnLeft,
270 CK_MarkColumnRight,
271 CK_MarkColumnUp,
272 CK_MarkColumnDown,
273 CK_MarkColumnScrollUp,
274 CK_MarkColumnScrollDown,
275 CK_MarkColumnParagraphUp,
276 CK_MarkColumnParagraphDown,
277 /* macros */
278 CK_MacroStartRecord,
279 CK_MacroStopRecord,
280 CK_MacroStartStopRecord,
281 CK_MacroDelete,
282 CK_RepeatStartRecord,
283 CK_RepeatStopRecord,
284 CK_RepeatStartStopRecord,
285 /* window commands */
286 CK_WindowMove,
287 CK_WindowResize,
288 CK_WindowFullscreen,
289 CK_WindowList,
290 CK_WindowNext,
291 CK_WindowPrev,
292 /* misc commands */
293 CK_SpellCheck,
294 CK_SpellCheckCurrentWord,
295 CK_SpellCheckSelectLang,
296 CK_InsertOverwrite,
297 CK_ParagraphFormat,
298 CK_MatchBracket,
299 CK_OptionsSaveMode,
300 CK_About,
301 CK_ShowMargin,
302 CK_ShowTabTws,
303 CK_SyntaxOnOff,
304 CK_SyntaxChoose,
305 CK_InsertLiteral,
306 CK_ExternalCommand,
307 CK_Date,
308 CK_Mail,
310 /* viewer */
311 CK_WrapMode = 600L,
312 CK_MagicMode,
313 CK_NroffMode,
314 CK_HexMode,
315 CK_HexEditMode,
316 CK_BookmarkGoto,
317 CK_Ruler,
318 CK_SearchForward,
319 CK_SearchBackward,
320 CK_SearchForwardContinue,
321 CK_SearchBackwardContinue,
323 /* diff viewer */
324 CK_ShowSymbols = 700L,
325 CK_SplitFull,
326 CK_Tab2,
327 CK_Tab3,
328 CK_Tab4,
329 CK_Tab8,
330 CK_HunkNext,
331 CK_HunkPrev,
332 CK_EditOther,
333 CK_Merge,
334 CK_MergeOther
337 /*** structures declarations (and typedefs of structures)*****************************************/
339 typedef struct name_keymap_t
341 const char *name;
342 long val;
343 } name_keymap_t;
345 typedef struct key_config_t
347 time_t mtime; /* mtime at the moment we read config file */
348 GArray *keymap;
349 GArray *ext_keymap;
350 gchar *labels[10];
351 } key_config_t;
353 /* The global keymaps are of this type */
354 typedef struct global_keymap_t
356 long key;
357 long command;
358 char caption[KEYMAP_SHORTCUT_LENGTH];
359 } global_keymap_t;
361 /*** global variables defined in .c file *********************************************************/
363 /*** declarations of public functions ************************************************************/
365 void keybind_cmd_bind (GArray * keymap, const char *keybind, long action);
366 long keybind_lookup_action (const char *name);
367 const char *keybind_lookup_actionname (long action);
368 const char *keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, long action);
369 long keybind_lookup_keymap_command (const global_keymap_t * keymap, long key);
371 /*** inline functions ****************************************************************************/
373 #endif /* MC__KEYBIND_H */