keybind.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. /*
  2. Definitions of key bindings.
  3. Copyright (C) 2005-2021
  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. /*** 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_FISH
  159. ADD_KEYMAP_NAME (ConnectFish),
  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. #ifdef ENABLE_VFS_SMB
  168. ADD_KEYMAP_NAME (ConnectSmb),
  169. #endif
  170. ADD_KEYMAP_NAME (PanelInfo),
  171. #ifdef ENABLE_BACKGROUND
  172. ADD_KEYMAP_NAME (Jobs),
  173. #endif
  174. ADD_KEYMAP_NAME (OptionsLayout),
  175. ADD_KEYMAP_NAME (OptionsAppearance),
  176. ADD_KEYMAP_NAME (Link),
  177. ADD_KEYMAP_NAME (SetupListingFormat),
  178. ADD_KEYMAP_NAME (PanelListing),
  179. #ifdef LISTMODE_EDITOR
  180. ADD_KEYMAP_NAME (ListMode),
  181. #endif
  182. ADD_KEYMAP_NAME (OptionsPanel),
  183. ADD_KEYMAP_NAME (CdQuick),
  184. ADD_KEYMAP_NAME (PanelQuickView),
  185. ADD_KEYMAP_NAME (LinkSymbolicRelative),
  186. ADD_KEYMAP_NAME (VfsList),
  187. ADD_KEYMAP_NAME (SaveSetup),
  188. ADD_KEYMAP_NAME (LinkSymbolic),
  189. ADD_KEYMAP_NAME (PanelTree),
  190. ADD_KEYMAP_NAME (Tree),
  191. #ifdef ENABLE_VFS_UNDELFS
  192. ADD_KEYMAP_NAME (Undelete),
  193. #endif
  194. ADD_KEYMAP_NAME (PutCurrentLink),
  195. ADD_KEYMAP_NAME (PutOtherLink),
  196. ADD_KEYMAP_NAME (HotListAdd),
  197. ADD_KEYMAP_NAME (ShowHidden),
  198. ADD_KEYMAP_NAME (SplitVertHoriz),
  199. ADD_KEYMAP_NAME (SplitEqual),
  200. ADD_KEYMAP_NAME (SplitMore),
  201. ADD_KEYMAP_NAME (SplitLess),
  202. ADD_KEYMAP_NAME (PutCurrentPath),
  203. ADD_KEYMAP_NAME (PutOtherPath),
  204. ADD_KEYMAP_NAME (PutCurrentSelected),
  205. ADD_KEYMAP_NAME (PutCurrentFullSelected),
  206. ADD_KEYMAP_NAME (PutCurrentTagged),
  207. ADD_KEYMAP_NAME (PutOtherTagged),
  208. ADD_KEYMAP_NAME (Select),
  209. ADD_KEYMAP_NAME (Unselect),
  210. /* panel */
  211. ADD_KEYMAP_NAME (SelectExt),
  212. ADD_KEYMAP_NAME (ScrollLeft),
  213. ADD_KEYMAP_NAME (ScrollRight),
  214. ADD_KEYMAP_NAME (PanelOtherCd),
  215. ADD_KEYMAP_NAME (PanelOtherCdLink),
  216. ADD_KEYMAP_NAME (CopySingle),
  217. ADD_KEYMAP_NAME (MoveSingle),
  218. ADD_KEYMAP_NAME (DeleteSingle),
  219. ADD_KEYMAP_NAME (CdParent),
  220. ADD_KEYMAP_NAME (CdChild),
  221. ADD_KEYMAP_NAME (Panelize),
  222. ADD_KEYMAP_NAME (PanelOtherSync),
  223. ADD_KEYMAP_NAME (SortNext),
  224. ADD_KEYMAP_NAME (SortPrev),
  225. ADD_KEYMAP_NAME (SortReverse),
  226. ADD_KEYMAP_NAME (SortByName),
  227. ADD_KEYMAP_NAME (SortByExt),
  228. ADD_KEYMAP_NAME (SortBySize),
  229. ADD_KEYMAP_NAME (SortByMTime),
  230. ADD_KEYMAP_NAME (CdParentSmart),
  231. ADD_KEYMAP_NAME (CycleListingFormat),
  232. /* dialog */
  233. ADD_KEYMAP_NAME (Ok),
  234. ADD_KEYMAP_NAME (Cancel),
  235. /* input line */
  236. ADD_KEYMAP_NAME (Yank),
  237. /* help */
  238. ADD_KEYMAP_NAME (Index),
  239. ADD_KEYMAP_NAME (Back),
  240. ADD_KEYMAP_NAME (LinkNext),
  241. ADD_KEYMAP_NAME (LinkPrev),
  242. ADD_KEYMAP_NAME (NodeNext),
  243. ADD_KEYMAP_NAME (NodePrev),
  244. /* tree */
  245. ADD_KEYMAP_NAME (Forget),
  246. #if defined (USE_INTERNAL_EDIT) || defined (USE_DIFF_VIEW)
  247. ADD_KEYMAP_NAME (ShowNumbers),
  248. #endif
  249. /* chattr dialog */
  250. ADD_KEYMAP_NAME (MarkAndDown),
  251. #ifdef USE_INTERNAL_EDIT
  252. ADD_KEYMAP_NAME (Close),
  253. ADD_KEYMAP_NAME (Tab),
  254. ADD_KEYMAP_NAME (Undo),
  255. ADD_KEYMAP_NAME (ScrollUp),
  256. ADD_KEYMAP_NAME (ScrollDown),
  257. ADD_KEYMAP_NAME (Return),
  258. ADD_KEYMAP_NAME (ParagraphUp),
  259. ADD_KEYMAP_NAME (ParagraphDown),
  260. ADD_KEYMAP_NAME (EditFile),
  261. ADD_KEYMAP_NAME (MarkWord),
  262. ADD_KEYMAP_NAME (MarkLine),
  263. ADD_KEYMAP_NAME (MarkAll),
  264. ADD_KEYMAP_NAME (Unmark),
  265. ADD_KEYMAP_NAME (MarkColumn),
  266. ADD_KEYMAP_NAME (BlockSave),
  267. ADD_KEYMAP_NAME (InsertFile),
  268. ADD_KEYMAP_NAME (InsertOverwrite),
  269. ADD_KEYMAP_NAME (Date),
  270. ADD_KEYMAP_NAME (DeleteLine),
  271. ADD_KEYMAP_NAME (EditMail),
  272. ADD_KEYMAP_NAME (ParagraphFormat),
  273. ADD_KEYMAP_NAME (MatchBracket),
  274. ADD_KEYMAP_NAME (ExternalCommand),
  275. ADD_KEYMAP_NAME (MacroStartRecord),
  276. ADD_KEYMAP_NAME (MacroStopRecord),
  277. ADD_KEYMAP_NAME (MacroStartStopRecord),
  278. ADD_KEYMAP_NAME (MacroDelete),
  279. ADD_KEYMAP_NAME (RepeatStartStopRecord),
  280. #ifdef HAVE_ASPELL
  281. ADD_KEYMAP_NAME (SpellCheck),
  282. ADD_KEYMAP_NAME (SpellCheckCurrentWord),
  283. ADD_KEYMAP_NAME (SpellCheckSelectLang),
  284. #endif /* HAVE_ASPELL */
  285. ADD_KEYMAP_NAME (BookmarkFlush),
  286. ADD_KEYMAP_NAME (BookmarkNext),
  287. ADD_KEYMAP_NAME (BookmarkPrev),
  288. ADD_KEYMAP_NAME (MarkPageUp),
  289. ADD_KEYMAP_NAME (MarkPageDown),
  290. ADD_KEYMAP_NAME (MarkToFileBegin),
  291. ADD_KEYMAP_NAME (MarkToFileEnd),
  292. ADD_KEYMAP_NAME (MarkToPageBegin),
  293. ADD_KEYMAP_NAME (MarkToPageEnd),
  294. ADD_KEYMAP_NAME (MarkScrollUp),
  295. ADD_KEYMAP_NAME (MarkScrollDown),
  296. ADD_KEYMAP_NAME (MarkParagraphUp),
  297. ADD_KEYMAP_NAME (MarkParagraphDown),
  298. ADD_KEYMAP_NAME (MarkColumnPageUp),
  299. ADD_KEYMAP_NAME (MarkColumnPageDown),
  300. ADD_KEYMAP_NAME (MarkColumnLeft),
  301. ADD_KEYMAP_NAME (MarkColumnRight),
  302. ADD_KEYMAP_NAME (MarkColumnUp),
  303. ADD_KEYMAP_NAME (MarkColumnDown),
  304. ADD_KEYMAP_NAME (MarkColumnScrollUp),
  305. ADD_KEYMAP_NAME (MarkColumnScrollDown),
  306. ADD_KEYMAP_NAME (MarkColumnParagraphUp),
  307. ADD_KEYMAP_NAME (MarkColumnParagraphDown),
  308. ADD_KEYMAP_NAME (BlockShiftLeft),
  309. ADD_KEYMAP_NAME (BlockShiftRight),
  310. ADD_KEYMAP_NAME (InsertLiteral),
  311. ADD_KEYMAP_NAME (ShowTabTws),
  312. ADD_KEYMAP_NAME (SyntaxOnOff),
  313. ADD_KEYMAP_NAME (SyntaxChoose),
  314. ADD_KEYMAP_NAME (ShowMargin),
  315. ADD_KEYMAP_NAME (OptionsSaveMode),
  316. ADD_KEYMAP_NAME (About),
  317. /* An action to run external script from macro */
  318. {"ExecuteScript", CK_PipeBlock (0)},
  319. ADD_KEYMAP_NAME (WindowMove),
  320. ADD_KEYMAP_NAME (WindowResize),
  321. ADD_KEYMAP_NAME (WindowFullscreen),
  322. ADD_KEYMAP_NAME (WindowList),
  323. ADD_KEYMAP_NAME (WindowNext),
  324. ADD_KEYMAP_NAME (WindowPrev),
  325. #endif /* USE_INTERNAL_EDIT */
  326. /* viewer */
  327. ADD_KEYMAP_NAME (WrapMode),
  328. ADD_KEYMAP_NAME (HexEditMode),
  329. ADD_KEYMAP_NAME (HexMode),
  330. ADD_KEYMAP_NAME (MagicMode),
  331. ADD_KEYMAP_NAME (NroffMode),
  332. ADD_KEYMAP_NAME (BookmarkGoto),
  333. ADD_KEYMAP_NAME (Ruler),
  334. ADD_KEYMAP_NAME (SearchForward),
  335. ADD_KEYMAP_NAME (SearchBackward),
  336. ADD_KEYMAP_NAME (SearchForwardContinue),
  337. ADD_KEYMAP_NAME (SearchBackwardContinue),
  338. ADD_KEYMAP_NAME (SearchOppositeContinue),
  339. #ifdef USE_DIFF_VIEW
  340. /* diff viewer */
  341. ADD_KEYMAP_NAME (ShowSymbols),
  342. ADD_KEYMAP_NAME (SplitFull),
  343. ADD_KEYMAP_NAME (Tab2),
  344. ADD_KEYMAP_NAME (Tab3),
  345. ADD_KEYMAP_NAME (Tab4),
  346. ADD_KEYMAP_NAME (Tab8),
  347. ADD_KEYMAP_NAME (HunkNext),
  348. ADD_KEYMAP_NAME (HunkPrev),
  349. ADD_KEYMAP_NAME (EditOther),
  350. ADD_KEYMAP_NAME (Merge),
  351. ADD_KEYMAP_NAME (MergeOther),
  352. #endif /* USE_DIFF_VIEW */
  353. {NULL, CK_IgnoreKey}
  354. };
  355. /* *INDENT-OFF* */
  356. static const size_t num_command_names = G_N_ELEMENTS (command_names) - 1;
  357. /* *INDENT-ON* */
  358. /*** file scope functions ************************************************************************/
  359. /* --------------------------------------------------------------------------------------------- */
  360. static int
  361. name_keymap_comparator (const void *p1, const void *p2)
  362. {
  363. const name_keymap_t *m1 = (const name_keymap_t *) p1;
  364. const name_keymap_t *m2 = (const name_keymap_t *) p2;
  365. return g_ascii_strcasecmp (m1->name, m2->name);
  366. }
  367. /* --------------------------------------------------------------------------------------------- */
  368. static inline void
  369. sort_command_names (void)
  370. {
  371. static gboolean has_been_sorted = FALSE;
  372. if (!has_been_sorted)
  373. {
  374. qsort (command_names, num_command_names,
  375. sizeof (command_names[0]), &name_keymap_comparator);
  376. has_been_sorted = TRUE;
  377. }
  378. }
  379. /* --------------------------------------------------------------------------------------------- */
  380. static void
  381. keymap_add (GArray * keymap, long key, long cmd, const char *caption)
  382. {
  383. if (key != 0 && cmd != CK_IgnoreKey)
  384. {
  385. global_keymap_t new_bind;
  386. new_bind.key = key;
  387. new_bind.command = cmd;
  388. g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
  389. g_array_append_val (keymap, new_bind);
  390. }
  391. }
  392. /* --------------------------------------------------------------------------------------------- */
  393. /*** public functions ****************************************************************************/
  394. /* --------------------------------------------------------------------------------------------- */
  395. void
  396. keybind_cmd_bind (GArray * keymap, const char *keybind, long action)
  397. {
  398. char *caption = NULL;
  399. long key;
  400. key = lookup_key (keybind, &caption);
  401. keymap_add (keymap, key, action, caption);
  402. g_free (caption);
  403. }
  404. /* --------------------------------------------------------------------------------------------- */
  405. long
  406. keybind_lookup_action (const char *name)
  407. {
  408. const name_keymap_t key = { name, 0 };
  409. name_keymap_t *res;
  410. sort_command_names ();
  411. res = bsearch (&key, command_names, num_command_names,
  412. sizeof (command_names[0]), name_keymap_comparator);
  413. return (res != NULL) ? res->val : CK_IgnoreKey;
  414. }
  415. /* --------------------------------------------------------------------------------------------- */
  416. const char *
  417. keybind_lookup_actionname (long action)
  418. {
  419. size_t i;
  420. for (i = 0; command_names[i].name != NULL; i++)
  421. if (command_names[i].val == action)
  422. return command_names[i].name;
  423. return NULL;
  424. }
  425. /* --------------------------------------------------------------------------------------------- */
  426. const char *
  427. keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, long action)
  428. {
  429. if (keymap != NULL)
  430. {
  431. size_t i;
  432. for (i = 0; keymap[i].key != 0; i++)
  433. if (keymap[i].command == action)
  434. return (keymap[i].caption[0] != '\0') ? keymap[i].caption : NULL;
  435. }
  436. return NULL;
  437. }
  438. /* --------------------------------------------------------------------------------------------- */
  439. long
  440. keybind_lookup_keymap_command (const global_keymap_t * keymap, long key)
  441. {
  442. if (keymap != NULL)
  443. {
  444. size_t i;
  445. for (i = 0; keymap[i].key != 0; i++)
  446. if (keymap[i].key == key)
  447. return keymap[i].command;
  448. }
  449. return CK_IgnoreKey;
  450. }
  451. /* --------------------------------------------------------------------------------------------- */