Monday, January 6, 2014

Re: getchar() / nr2char() with non-default 'keymap'

Am 05.01.2014 22:28, schrieb Justin M. Keyes:
> Hi,
>
> I am using getchar() in a plugin to get input from the user. But
> getchar() returns the same keycode no matter what keymap is activated.
> So for example:
>
> :set keymap=bulgarian-phonetic
>
> With this keymap, in insert-mode, typing "b" on a US keyboard inputs
> "б". But typing "b" in the getchar() prompt always returns 98, and
> nr2char(98) always returns "b" regardless of the keymap.
>
> Is there some other function instead of nr2char() that gets the
> keymapped character from a keycode?
>
> Vim 7.4.35
>
> Thanks!
>
> Justin M. Keyes

You can do the lmap-translation yourself

func! LmapArg(chr)
let chrtrans = maparg(a:chr, "l")
return chrtrans=="" ? a:chr : chrtrans
endfunc


With enabled keymap
:echo LmapArg('b')
б

Not sure what to do (how to detect) if more than one char needs to be typed to get
the lmap'ed character.

(Lame solutions might parse the :redir output of :lmap, or the keymap file)

--
Andy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: