root/lib/keybind.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. name_keymap_comparator
  2. sort_command_names
  3. keymap_add
  4. keybind_cmd_bind
  5. keybind_lookup_action
  6. keybind_lookup_actionname
  7. keybind_lookup_keymap_shortcut
  8. keybind_lookup_keymap_command

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

/* [previous][next][first][last][top][bottom][index][help]  */