(mcview__get_nroff_real_len): immediately return 0 if viewer is not in nroff mode..
[midnight-commander.git] / lib / keybind.h
blob42fb04dafef21d4592eedbc36edf9b4b066f8b6c
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_Shell,
84 CK_SelectCodepage,
85 CK_History,
86 CK_HistoryNext,
87 CK_HistoryPrev,
88 CK_Complete,
89 CK_SaveAs,
90 CK_Goto,
91 CK_Reread,
92 CK_Refresh,
93 CK_Suspend,
94 CK_Swap,
95 CK_Mark,
96 CK_HotList,
97 CK_ScreenList,
98 CK_ScreenNext,
99 CK_ScreenPrev,
100 CK_FilePrev,
101 CK_FileNext,
102 CK_DeleteToWordBegin,
103 CK_DeleteToWordEnd,
104 CK_ShowNumbers,
105 CK_Store,
106 CK_Cut,
107 CK_Paste,
108 CK_MarkLeft,
109 CK_MarkRight,
110 CK_MarkUp,
111 CK_MarkDown,
112 CK_MarkToWordBegin,
113 CK_MarkToWordEnd,
114 CK_MarkToHome,
115 CK_MarkToEnd,
116 CK_ToggleNavigation,
117 CK_Sort,
118 CK_Options,
119 CK_LearnKeys,
120 CK_Bookmark,
121 CK_Quit,
122 CK_QuitQuiet,
123 /* C-x or similar */
124 CK_ExtendedKeyMap,
126 /* main commands */
127 CK_EditForceInternal = 100,
128 CK_View,
129 CK_ViewRaw,
130 CK_ViewFile,
131 CK_ViewFiltered,
132 CK_Find,
133 CK_DirSize,
134 CK_HotListAdd,
135 CK_PanelListingChange,
136 CK_CompareDirs,
137 CK_OptionsVfs,
138 CK_OptionsConfirm,
139 CK_PutCurrentLink,
140 CK_PutOtherLink,
141 CK_OptionsDisplayBits,
142 CK_EditExtensionsFile,
143 CK_EditFileHighlightFile,
144 CK_LinkSymbolicEdit,
145 CK_ExternalPanelize,
146 CK_Filter,
147 CK_ConnectFish,
148 CK_ConnectFtp,
149 CK_ConnectSmb,
150 CK_PanelInfo,
151 CK_Jobs,
152 CK_OptionsLayout,
153 CK_Link,
154 CK_PanelListing,
155 CK_ListMode,
156 CK_CdQuick,
157 CK_PanelQuickView,
158 CK_VfsList,
159 CK_SaveSetup,
160 CK_LinkSymbolic,
161 CK_PanelListingSwitch,
162 CK_ShowHidden,
163 CK_PanelTree,
164 CK_Tree,
165 CK_Undelete,
166 CK_SplitVertHoriz,
167 CK_CompareFiles,
168 CK_OptionsPanel,
169 CK_LinkSymbolicRelative,
170 CK_PutCurrentPath,
171 CK_PutOtherPath,
172 CK_PutCurrentTagged,
173 CK_PutOtherTagged,
174 CK_Select,
175 CK_Unselect,
176 CK_SelectInvert,
178 /* panels */
179 CK_PanelOtherCd = 200,
180 CK_PanelOtherCdLink,
181 CK_CopySingle,
182 CK_MoveSingle,
183 CK_DeleteSingle,
184 CK_CdChild,
185 CK_CdParent,
186 CK_CdParentSmart,
187 CK_PanelOtherSync,
188 CK_SortNext,
189 CK_SortPrev,
190 CK_SortReverse,
191 CK_SortByName,
192 CK_SortByExt,
193 CK_SortBySize,
194 CK_SortByMTime,
196 /* dialog */
197 CK_Ok = 300,
198 CK_Cancel,
200 /* input */
201 CK_Yank = 350,
203 /* help */
204 CK_Index = 400,
205 CK_Back,
206 CK_LinkNext,
207 CK_LinkPrev,
208 CK_NodeNext,
209 CK_NodePrev,
211 /* tree */
212 CK_Forget = 450,
214 /* editor */
215 /* cursor movements */
216 CK_Tab = 500,
217 CK_Undo,
218 CK_ScrollUp,
219 CK_ScrollDown,
220 CK_Return,
221 CK_ParagraphUp,
222 CK_ParagraphDown,
223 /* file commands */
224 CK_Save,
225 CK_EditFile,
226 CK_EditNew,
227 CK_InsertFile,
228 CK_EditSyntaxFile,
229 /* block commands */
230 CK_BlockSave,
231 CK_BlockShiftLeft,
232 CK_BlockShiftRight,
233 CK_DeleteLine,
234 CK_DeleteToHome,
235 CK_DeleteToEnd,
236 /* bookmarks */
237 CK_BookmarkFlush,
238 CK_BookmarkNext,
239 CK_BookmarkPrev,
240 /* mark commands */
241 CK_MarkColumn,
242 CK_MarkWord,
243 CK_MarkLine,
244 CK_MarkAll,
245 CK_Unmark,
246 CK_MarkPageUp,
247 CK_MarkPageDown,
248 CK_MarkToFileBegin,
249 CK_MarkToFileEnd,
250 CK_MarkToPageBegin,
251 CK_MarkToPageEnd,
252 CK_MarkScrollUp,
253 CK_MarkScrollDown,
254 CK_MarkParagraphUp,
255 CK_MarkParagraphDown,
256 /* column mark commands */
257 CK_MarkColumnPageUp,
258 CK_MarkColumnPageDown,
259 CK_MarkColumnLeft,
260 CK_MarkColumnRight,
261 CK_MarkColumnUp,
262 CK_MarkColumnDown,
263 CK_MarkColumnScrollUp,
264 CK_MarkColumnScrollDown,
265 CK_MarkColumnParagraphUp,
266 CK_MarkColumnParagraphDown,
267 /* macros */
268 CK_MacroStartRecord,
269 CK_MacroStopRecord,
270 CK_MacroStartStopRecord,
271 CK_MacroDelete,
272 CK_RepeatStartRecord,
273 CK_RepeatStopRecord,
274 CK_RepeatStartStopRecord,
275 /* misc commands */
276 CK_InsertOverwrite,
277 CK_ParagraphFormat,
278 CK_MatchBracket,
279 CK_OptionsSaveMode,
280 CK_About,
281 CK_ShowMargin,
282 CK_ShowTabTws,
283 CK_SyntaxOnOff,
284 CK_SyntaxChoose,
285 CK_InsertLiteral,
286 CK_ExternalCommand,
287 CK_Date,
288 CK_Mail,
290 /* viewer */
291 CK_WrapMode = 600,
292 CK_MagicMode,
293 CK_NroffMode,
294 CK_HexMode,
295 CK_HexEditMode,
296 CK_BookmarkGoto,
297 CK_Ruler,
299 /* diff viewer */
300 CK_ShowSymbols = 700,
301 CK_SplitFull,
302 CK_SplitEqual,
303 CK_SplitMore,
304 CK_SplitLess,
305 CK_Tab2,
306 CK_Tab3,
307 CK_Tab4,
308 CK_Tab8,
309 CK_HunkNext,
310 CK_HunkPrev,
311 CK_EditOther,
312 CK_Merge
315 /*** structures declarations (and typedefs of structures)*****************************************/
317 typedef struct name_keymap_t
319 const char *name;
320 unsigned long val;
321 } name_keymap_t;
323 typedef struct key_config_t
325 time_t mtime; /* mtime at the moment we read config file */
326 GArray *keymap;
327 GArray *ext_keymap;
328 gchar *labels[10];
329 } key_config_t;
331 /* The global keymaps are of this type */
332 typedef struct global_keymap_t
334 long key;
335 unsigned long command;
336 char caption[KEYMAP_SHORTCUT_LENGTH];
337 } global_keymap_t;
339 /*** global variables defined in .c file *********************************************************/
341 /*** declarations of public functions ************************************************************/
343 void keybind_cmd_bind (GArray * keymap, const char *keybind, unsigned long action);
344 unsigned long keybind_lookup_action (const char *name);
345 const char *keybind_lookup_actionname (unsigned long action);
346 const char *keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action);
347 unsigned long keybind_lookup_keymap_command (const global_keymap_t * keymap, long key);
349 /*** inline functions ****************************************************************************/
351 #endif /* MC__KEYBIND_H */