keybind.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. /*
  2. Definitions of key bindings.
  3. Copyright (C) 2005-2024
  4. Free Software Foundation, Inc.
  5. Written by:
  6. Vitja Makarov, 2005
  7. Ilia Maslakov <il.smind@gmail.com>, 2009, 2012
  8. Andrew Borodin <aborodin@vmail.ru>, 2009-2020
  9. This file is part of the Midnight Commander.
  10. The Midnight Commander is free software: you can redistribute it
  11. and/or modify it under the terms of the GNU General Public License as
  12. published by the Free Software Foundation, either version 3 of the License,
  13. or (at your option) any later version.
  14. The Midnight Commander is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <config.h>
  22. #include <ctype.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <sys/types.h>
  26. #include "lib/global.h"
  27. #include "lib/tty/key.h" /* KEY_M_ */
  28. #include "lib/keybind.h"
  29. /*** global variables ****************************************************************************/
  30. /*** file scope macro definitions ****************************************************************/
  31. #define ADD_KEYMAP_NAME(name) { #name, CK_##name }
  32. /*** file scope type declarations ****************************************************************/
  33. typedef struct name_keymap_t
  34. {
  35. const char *name;
  36. long val;
  37. } name_keymap_t;
  38. /*** forward declarations (file scope functions) *************************************************/
  39. /*** file scope variables ************************************************************************/
  40. static name_keymap_t command_names[] = {
  41. /* common */
  42. ADD_KEYMAP_NAME (InsertChar),
  43. ADD_KEYMAP_NAME (Enter),
  44. ADD_KEYMAP_NAME (ChangePanel),
  45. ADD_KEYMAP_NAME (Up),
  46. ADD_KEYMAP_NAME (Down),
  47. ADD_KEYMAP_NAME (Left),
  48. ADD_KEYMAP_NAME (Right),
  49. ADD_KEYMAP_NAME (LeftQuick),
  50. ADD_KEYMAP_NAME (RightQuick),
  51. ADD_KEYMAP_NAME (Home),
  52. ADD_KEYMAP_NAME (End),
  53. ADD_KEYMAP_NAME (PageUp),
  54. ADD_KEYMAP_NAME (PageDown),
  55. ADD_KEYMAP_NAME (HalfPageUp),
  56. ADD_KEYMAP_NAME (HalfPageDown),
  57. ADD_KEYMAP_NAME (Top),
  58. ADD_KEYMAP_NAME (Bottom),
  59. ADD_KEYMAP_NAME (TopOnScreen),
  60. ADD_KEYMAP_NAME (MiddleOnScreen),
  61. ADD_KEYMAP_NAME (BottomOnScreen),
  62. ADD_KEYMAP_NAME (WordLeft),
  63. ADD_KEYMAP_NAME (WordRight),
  64. ADD_KEYMAP_NAME (Copy),
  65. ADD_KEYMAP_NAME (Move),
  66. ADD_KEYMAP_NAME (Delete),
  67. ADD_KEYMAP_NAME (MakeDir),
  68. ADD_KEYMAP_NAME (ChangeMode),
  69. ADD_KEYMAP_NAME (ChangeOwn),
  70. ADD_KEYMAP_NAME (ChangeOwnAdvanced),
  71. #ifdef ENABLE_EXT2FS_ATTR
  72. ADD_KEYMAP_NAME (ChangeAttributes),
  73. #endif
  74. ADD_KEYMAP_NAME (Remove),
  75. ADD_KEYMAP_NAME (BackSpace),
  76. ADD_KEYMAP_NAME (Redo),
  77. ADD_KEYMAP_NAME (Clear),
  78. ADD_KEYMAP_NAME (Menu),
  79. ADD_KEYMAP_NAME (MenuLastSelected),
  80. ADD_KEYMAP_NAME (UserMenu),
  81. ADD_KEYMAP_NAME (EditUserMenu),
  82. ADD_KEYMAP_NAME (Search),
  83. ADD_KEYMAP_NAME (SearchContinue),
  84. ADD_KEYMAP_NAME (Replace),
  85. ADD_KEYMAP_NAME (ReplaceContinue),
  86. ADD_KEYMAP_NAME (Help),
  87. ADD_KEYMAP_NAME (Shell),
  88. ADD_KEYMAP_NAME (Edit),
  89. ADD_KEYMAP_NAME (EditNew),
  90. #ifdef HAVE_CHARSET
  91. ADD_KEYMAP_NAME (SelectCodepage),
  92. #endif
  93. ADD_KEYMAP_NAME (EditorViewerHistory),
  94. ADD_KEYMAP_NAME (History),
  95. ADD_KEYMAP_NAME (HistoryNext),
  96. ADD_KEYMAP_NAME (HistoryPrev),
  97. ADD_KEYMAP_NAME (Complete),
  98. ADD_KEYMAP_NAME (Save),
  99. ADD_KEYMAP_NAME (SaveAs),
  100. ADD_KEYMAP_NAME (Goto),
  101. ADD_KEYMAP_NAME (Reread),
  102. ADD_KEYMAP_NAME (Refresh),
  103. ADD_KEYMAP_NAME (Suspend),
  104. ADD_KEYMAP_NAME (Swap),
  105. ADD_KEYMAP_NAME (HotList),
  106. ADD_KEYMAP_NAME (SelectInvert),
  107. ADD_KEYMAP_NAME (ScreenList),
  108. ADD_KEYMAP_NAME (ScreenNext),
  109. ADD_KEYMAP_NAME (ScreenPrev),
  110. ADD_KEYMAP_NAME (FileNext),
  111. ADD_KEYMAP_NAME (FilePrev),
  112. ADD_KEYMAP_NAME (DeleteToHome),
  113. ADD_KEYMAP_NAME (DeleteToEnd),
  114. ADD_KEYMAP_NAME (DeleteToWordBegin),
  115. ADD_KEYMAP_NAME (DeleteToWordEnd),
  116. ADD_KEYMAP_NAME (Cut),
  117. ADD_KEYMAP_NAME (Store),
  118. ADD_KEYMAP_NAME (Paste),
  119. ADD_KEYMAP_NAME (Mark),
  120. ADD_KEYMAP_NAME (MarkLeft),
  121. ADD_KEYMAP_NAME (MarkRight),
  122. ADD_KEYMAP_NAME (MarkUp),
  123. ADD_KEYMAP_NAME (MarkDown),
  124. ADD_KEYMAP_NAME (MarkToWordBegin),
  125. ADD_KEYMAP_NAME (MarkToWordEnd),
  126. ADD_KEYMAP_NAME (MarkToHome),
  127. ADD_KEYMAP_NAME (MarkToEnd),
  128. ADD_KEYMAP_NAME (ToggleNavigation),
  129. ADD_KEYMAP_NAME (Sort),
  130. ADD_KEYMAP_NAME (Options),
  131. ADD_KEYMAP_NAME (LearnKeys),
  132. ADD_KEYMAP_NAME (Bookmark),
  133. ADD_KEYMAP_NAME (Quit),
  134. ADD_KEYMAP_NAME (QuitQuiet),
  135. ADD_KEYMAP_NAME (ExtendedKeyMap),
  136. /* main commands */
  137. #ifdef USE_INTERNAL_EDIT
  138. ADD_KEYMAP_NAME (EditForceInternal),
  139. #endif
  140. ADD_KEYMAP_NAME (View),
  141. ADD_KEYMAP_NAME (ViewRaw),
  142. ADD_KEYMAP_NAME (ViewFile),
  143. ADD_KEYMAP_NAME (ViewFiltered),
  144. ADD_KEYMAP_NAME (Find),
  145. ADD_KEYMAP_NAME (DirSize),
  146. ADD_KEYMAP_NAME (CompareDirs),
  147. #ifdef USE_DIFF_VIEW
  148. ADD_KEYMAP_NAME (CompareFiles),
  149. #endif
  150. ADD_KEYMAP_NAME (OptionsVfs),
  151. ADD_KEYMAP_NAME (OptionsConfirm),
  152. ADD_KEYMAP_NAME (OptionsDisplayBits),
  153. ADD_KEYMAP_NAME (EditExtensionsFile),
  154. ADD_KEYMAP_NAME (EditFileHighlightFile),
  155. ADD_KEYMAP_NAME (LinkSymbolicEdit),
  156. ADD_KEYMAP_NAME (ExternalPanelize),
  157. ADD_KEYMAP_NAME (Filter),
  158. #ifdef ENABLE_VFS_SHELL
  159. ADD_KEYMAP_NAME (ConnectShell),
  160. #endif
  161. #ifdef ENABLE_VFS_FTP
  162. ADD_KEYMAP_NAME (ConnectFtp),
  163. #endif
  164. #ifdef ENABLE_VFS_SFTP
  165. ADD_KEYMAP_NAME (ConnectSftp),
  166. #endif
  167. ADD_KEYMAP_NAME (PanelInfo),
  168. #ifdef ENABLE_BACKGROUND
  169. ADD_KEYMAP_NAME (Jobs),
  170. #endif
  171. ADD_KEYMAP_NAME (OptionsLayout),
  172. ADD_KEYMAP_NAME (OptionsAppearance),
  173. ADD_KEYMAP_NAME (Link),
  174. ADD_KEYMAP_NAME (SetupListingFormat),
  175. ADD_KEYMAP_NAME (PanelListing),
  176. #ifdef LISTMODE_EDITOR
  177. ADD_KEYMAP_NAME (ListMode),
  178. #endif
  179. ADD_KEYMAP_NAME (OptionsPanel),
  180. ADD_KEYMAP_NAME (CdQuick),
  181. ADD_KEYMAP_NAME (PanelQuickView),
  182. ADD_KEYMAP_NAME (LinkSymbolicRelative),
  183. ADD_KEYMAP_NAME (VfsList),
  184. ADD_KEYMAP_NAME (SaveSetup),
  185. ADD_KEYMAP_NAME (LinkSymbolic),
  186. ADD_KEYMAP_NAME (PanelTree),
  187. ADD_KEYMAP_NAME (Tree),
  188. #ifdef ENABLE_VFS_UNDELFS
  189. ADD_KEYMAP_NAME (Undelete),
  190. #endif
  191. ADD_KEYMAP_NAME (PutCurrentLink),
  192. ADD_KEYMAP_NAME (PutOtherLink),
  193. ADD_KEYMAP_NAME (HotListAdd),
  194. ADD_KEYMAP_NAME (ShowHidden),
  195. ADD_KEYMAP_NAME (SplitVertHoriz),
  196. ADD_KEYMAP_NAME (SplitEqual),
  197. ADD_KEYMAP_NAME (SplitMore),
  198. ADD_KEYMAP_NAME (SplitLess),
  199. ADD_KEYMAP_NAME (PutCurrentPath),
  200. ADD_KEYMAP_NAME (PutOtherPath),
  201. ADD_KEYMAP_NAME (PutCurrentSelected),
  202. ADD_KEYMAP_NAME (PutCurrentFullSelected),
  203. ADD_KEYMAP_NAME (PutCurrentTagged),
  204. ADD_KEYMAP_NAME (PutOtherTagged),
  205. ADD_KEYMAP_NAME (Select),
  206. ADD_KEYMAP_NAME (Unselect),
  207. /* panel */
  208. ADD_KEYMAP_NAME (SelectExt),
  209. ADD_KEYMAP_NAME (ScrollLeft),
  210. ADD_KEYMAP_NAME (ScrollRight),
  211. ADD_KEYMAP_NAME (PanelOtherCd),
  212. ADD_KEYMAP_NAME (PanelOtherCdLink),
  213. ADD_KEYMAP_NAME (CopySingle),
  214. ADD_KEYMAP_NAME (MoveSingle),
  215. ADD_KEYMAP_NAME (DeleteSingle),
  216. ADD_KEYMAP_NAME (CdParent),
  217. ADD_KEYMAP_NAME (CdChild),
  218. ADD_KEYMAP_NAME (Panelize),
  219. ADD_KEYMAP_NAME (PanelOtherSync),
  220. ADD_KEYMAP_NAME (SortNext),
  221. ADD_KEYMAP_NAME (SortPrev),
  222. ADD_KEYMAP_NAME (SortReverse),
  223. ADD_KEYMAP_NAME (SortByName),
  224. ADD_KEYMAP_NAME (SortByExt),
  225. ADD_KEYMAP_NAME (SortBySize),
  226. ADD_KEYMAP_NAME (SortByMTime),
  227. ADD_KEYMAP_NAME (CdParentSmart),
  228. ADD_KEYMAP_NAME (CycleListingFormat),
  229. /* dialog */
  230. ADD_KEYMAP_NAME (Ok),
  231. ADD_KEYMAP_NAME (Cancel),
  232. /* input line */
  233. ADD_KEYMAP_NAME (Yank),
  234. /* help */
  235. ADD_KEYMAP_NAME (Index),
  236. ADD_KEYMAP_NAME (Back),
  237. ADD_KEYMAP_NAME (LinkNext),
  238. ADD_KEYMAP_NAME (LinkPrev),
  239. ADD_KEYMAP_NAME (NodeNext),
  240. ADD_KEYMAP_NAME (NodePrev),
  241. /* tree */
  242. ADD_KEYMAP_NAME (Forget),
  243. #if defined(USE_INTERNAL_EDIT) || defined(USE_DIFF_VIEW)
  244. ADD_KEYMAP_NAME (ShowNumbers),
  245. #endif
  246. /* chattr dialog */
  247. ADD_KEYMAP_NAME (MarkAndDown),
  248. #ifdef USE_INTERNAL_EDIT
  249. ADD_KEYMAP_NAME (Close),
  250. ADD_KEYMAP_NAME (Tab),
  251. ADD_KEYMAP_NAME (Undo),
  252. ADD_KEYMAP_NAME (ScrollUp),
  253. ADD_KEYMAP_NAME (ScrollDown),
  254. ADD_KEYMAP_NAME (Return),
  255. ADD_KEYMAP_NAME (ParagraphUp),
  256. ADD_KEYMAP_NAME (ParagraphDown),
  257. ADD_KEYMAP_NAME (EditFile),
  258. ADD_KEYMAP_NAME (MarkWord),
  259. ADD_KEYMAP_NAME (MarkLine),
  260. ADD_KEYMAP_NAME (MarkAll),
  261. ADD_KEYMAP_NAME (Unmark),
  262. ADD_KEYMAP_NAME (MarkColumn),
  263. ADD_KEYMAP_NAME (BlockSave),
  264. ADD_KEYMAP_NAME (InsertFile),
  265. ADD_KEYMAP_NAME (InsertOverwrite),
  266. ADD_KEYMAP_NAME (Date),
  267. ADD_KEYMAP_NAME (DeleteLine),
  268. ADD_KEYMAP_NAME (EditMail),
  269. ADD_KEYMAP_NAME (ParagraphFormat),
  270. ADD_KEYMAP_NAME (MatchBracket),
  271. ADD_KEYMAP_NAME (ExternalCommand),
  272. ADD_KEYMAP_NAME (MacroStartRecord),
  273. ADD_KEYMAP_NAME (MacroStopRecord),
  274. ADD_KEYMAP_NAME (MacroStartStopRecord),
  275. ADD_KEYMAP_NAME (MacroDelete),
  276. ADD_KEYMAP_NAME (RepeatStartStopRecord),
  277. #ifdef HAVE_ASPELL
  278. ADD_KEYMAP_NAME (SpellCheck),
  279. ADD_KEYMAP_NAME (SpellCheckCurrentWord),
  280. ADD_KEYMAP_NAME (SpellCheckSelectLang),
  281. #endif /* HAVE_ASPELL */
  282. ADD_KEYMAP_NAME (BookmarkFlush),
  283. ADD_KEYMAP_NAME (BookmarkNext),
  284. ADD_KEYMAP_NAME (BookmarkPrev),
  285. ADD_KEYMAP_NAME (MarkPageUp),
  286. ADD_KEYMAP_NAME (MarkPageDown),
  287. ADD_KEYMAP_NAME (MarkToFileBegin),
  288. ADD_KEYMAP_NAME (MarkToFileEnd),
  289. ADD_KEYMAP_NAME (MarkToPageBegin),
  290. ADD_KEYMAP_NAME (MarkToPageEnd),
  291. ADD_KEYMAP_NAME (MarkScrollUp),
  292. ADD_KEYMAP_NAME (MarkScrollDown),
  293. ADD_KEYMAP_NAME (MarkParagraphUp),
  294. ADD_KEYMAP_NAME (MarkParagraphDown),
  295. ADD_KEYMAP_NAME (MarkColumnPageUp),
  296. ADD_KEYMAP_NAME (MarkColumnPageDown),
  297. ADD_KEYMAP_NAME (MarkColumnLeft),
  298. ADD_KEYMAP_NAME (MarkColumnRight),
  299. ADD_KEYMAP_NAME (MarkColumnUp),
  300. ADD_KEYMAP_NAME (MarkColumnDown),
  301. ADD_KEYMAP_NAME (MarkColumnScrollUp),
  302. ADD_KEYMAP_NAME (MarkColumnScrollDown),
  303. ADD_KEYMAP_NAME (MarkColumnParagraphUp),
  304. ADD_KEYMAP_NAME (MarkColumnParagraphDown),
  305. ADD_KEYMAP_NAME (BlockShiftLeft),
  306. ADD_KEYMAP_NAME (BlockShiftRight),
  307. ADD_KEYMAP_NAME (InsertLiteral),
  308. ADD_KEYMAP_NAME (ShowTabTws),
  309. ADD_KEYMAP_NAME (SyntaxOnOff),
  310. ADD_KEYMAP_NAME (SyntaxChoose),
  311. ADD_KEYMAP_NAME (ShowMargin),
  312. ADD_KEYMAP_NAME (OptionsSaveMode),
  313. ADD_KEYMAP_NAME (About),
  314. /* An action to run external script from macro */
  315. { "ExecuteScript", CK_PipeBlock (0) },
  316. ADD_KEYMAP_NAME (WindowMove),
  317. ADD_KEYMAP_NAME (WindowResize),
  318. ADD_KEYMAP_NAME (WindowFullscreen),
  319. ADD_KEYMAP_NAME (WindowList),
  320. ADD_KEYMAP_NAME (WindowNext),
  321. ADD_KEYMAP_NAME (WindowPrev),
  322. #endif /* USE_INTERNAL_EDIT */
  323. /* viewer */
  324. ADD_KEYMAP_NAME (WrapMode),
  325. ADD_KEYMAP_NAME (HexEditMode),
  326. ADD_KEYMAP_NAME (HexMode),
  327. ADD_KEYMAP_NAME (MagicMode),
  328. ADD_KEYMAP_NAME (NroffMode),
  329. ADD_KEYMAP_NAME (BookmarkGoto),
  330. ADD_KEYMAP_NAME (Ruler),
  331. ADD_KEYMAP_NAME (SearchForward),
  332. ADD_KEYMAP_NAME (SearchBackward),
  333. ADD_KEYMAP_NAME (SearchForwardContinue),
  334. ADD_KEYMAP_NAME (SearchBackwardContinue),
  335. ADD_KEYMAP_NAME (SearchOppositeContinue),
  336. #ifdef USE_DIFF_VIEW
  337. /* diff viewer */
  338. ADD_KEYMAP_NAME (ShowSymbols),
  339. ADD_KEYMAP_NAME (SplitFull),
  340. ADD_KEYMAP_NAME (Tab2),
  341. ADD_KEYMAP_NAME (Tab3),
  342. ADD_KEYMAP_NAME (Tab4),
  343. ADD_KEYMAP_NAME (Tab8),
  344. ADD_KEYMAP_NAME (HunkNext),
  345. ADD_KEYMAP_NAME (HunkPrev),
  346. ADD_KEYMAP_NAME (EditOther),
  347. ADD_KEYMAP_NAME (Merge),
  348. ADD_KEYMAP_NAME (MergeOther),
  349. #endif /* USE_DIFF_VIEW */
  350. { NULL, CK_IgnoreKey }
  351. };
  352. /* *INDENT-OFF* */
  353. static const size_t num_command_names = G_N_ELEMENTS (command_names) - 1;
  354. /* *INDENT-ON* */
  355. /* --------------------------------------------------------------------------------------------- */
  356. /*** file scope functions ************************************************************************/
  357. /* --------------------------------------------------------------------------------------------- */
  358. static int
  359. name_keymap_comparator (const void *p1, const void *p2)
  360. {
  361. const name_keymap_t *m1 = (const name_keymap_t *) p1;
  362. const name_keymap_t *m2 = (const name_keymap_t *) p2;
  363. return g_ascii_strcasecmp (m1->name, m2->name);
  364. }
  365. /* --------------------------------------------------------------------------------------------- */
  366. static inline void
  367. sort_command_names (void)
  368. {
  369. static gboolean has_been_sorted = FALSE;
  370. if (!has_been_sorted)
  371. {
  372. qsort (command_names, num_command_names, sizeof (command_names[0]),
  373. &name_keymap_comparator);
  374. has_been_sorted = TRUE;
  375. }
  376. }
  377. /* --------------------------------------------------------------------------------------------- */
  378. static void
  379. keymap_add (GArray *keymap, long key, long cmd, const char *caption)
  380. {
  381. if (key != 0 && cmd != CK_IgnoreKey)
  382. {
  383. global_keymap_t new_bind;
  384. new_bind.key = key;
  385. new_bind.command = cmd;
  386. g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
  387. g_array_append_val (keymap, new_bind);
  388. }
  389. }
  390. /* --------------------------------------------------------------------------------------------- */
  391. /*** public functions ****************************************************************************/
  392. /* --------------------------------------------------------------------------------------------- */
  393. void
  394. keybind_cmd_bind (GArray *keymap, const char *keybind, long action)
  395. {
  396. char *caption = NULL;
  397. long key;
  398. key = tty_keyname_to_keycode (keybind, &caption);
  399. keymap_add (keymap, key, action, caption);
  400. g_free (caption);
  401. }
  402. /* --------------------------------------------------------------------------------------------- */
  403. long
  404. keybind_lookup_action (const char *name)
  405. {
  406. const name_keymap_t key = { name, 0 };
  407. name_keymap_t *res;
  408. sort_command_names ();
  409. res = bsearch (&key, command_names, num_command_names, sizeof (command_names[0]),
  410. name_keymap_comparator);
  411. return (res != NULL) ? res->val : CK_IgnoreKey;
  412. }
  413. /* --------------------------------------------------------------------------------------------- */
  414. const char *
  415. keybind_lookup_actionname (long action)
  416. {
  417. size_t i;
  418. for (i = 0; command_names[i].name != NULL; i++)
  419. if (command_names[i].val == action)
  420. return command_names[i].name;
  421. return NULL;
  422. }
  423. /* --------------------------------------------------------------------------------------------- */
  424. const char *
  425. keybind_lookup_keymap_shortcut (const global_keymap_t *keymap, long action)
  426. {
  427. if (keymap != NULL)
  428. {
  429. size_t i;
  430. for (i = 0; keymap[i].key != 0; i++)
  431. if (keymap[i].command == action)
  432. return (keymap[i].caption[0] != '\0') ? keymap[i].caption : NULL;
  433. }
  434. return NULL;
  435. }
  436. /* --------------------------------------------------------------------------------------------- */
  437. long
  438. keybind_lookup_keymap_command (const global_keymap_t *keymap, long key)
  439. {
  440. if (keymap != NULL)
  441. {
  442. size_t i;
  443. for (i = 0; keymap[i].key != 0; i++)
  444. if (keymap[i].key == key)
  445. return keymap[i].command;
  446. }
  447. return CK_IgnoreKey;
  448. }
  449. /* --------------------------------------------------------------------------------------------- */