keybind.h 7.4 KB

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