Björn Winckler wrote:

> I was hoping somebody could point me in the right direction on how to
> parse key mappings like <D-M-Left>.  I'm guessing there are already
> functions that do this for you, but where do I find them?
> 
> More specifically, given <D-M-Left> I would like to figure out what
> the modifiers are and which (printable) key they are modifying.  There
> should be no translation of keys, so given <C-a> I want to get
> "Control" and "a" (not the code for ^a).  However, with <D-M-Left> I
> want to get "Cmd", "Meta", and the keycode for "Left" (I don't want
> the string "Left").
> 
> My thought on how to do this is given a string, replace all
> occurrences of "<", ">" and "-" with NUL, and if this gives me more
> than one substring, treat all but the last one as modifiers, and treat
> the last as the actual key.  The only problem is, if the last
> substring is something like "Left" or "F1" then I need to translate
> this to a keycode, and I'm not sure how to do this.  Is there a
> function that does this translation?

This is in the function find_special_key() in src/misc2.c.

It does change <C-a> into ^A, thus you may want to reverse it (check for
characters below 0x20).

You could also use get_special_key_code().  It turns "Left" into K_LEFT
but doesn't do any modifiers.

-- 
hundred-and-one symptoms of being an internet addict:
64. The remote to the T.V. is missing...and you don't even care.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui