keybind.c 15 KB

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