keybind.h 7.8 KB

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