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

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