Fixed issue with langmap

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Fixed issue with langmap

Vladimir A. Pavlov
Hi!

I use vim-7.2.441 and I use vim's great langmap feature when writing
russian texts.

But when I try pressing ^[ to exit insert mode (or ^O to exit it
temporarily) in russian xkb layout I got `х' (the russian character
placed at the same key as `[') inserted instead of exiting.

The following patch fixes the issue (besides Control it also processes
Alt and Win keys in similar way).

Can it be commited to vim repository?

diff -Napur vim72.orig/src/gui_gtk_x11.c vim72/src/gui_gtk_x11.c
--- vim72.orig/src/gui_gtk_x11.c        2010-06-01 13:43:45.000000000 +0400
+++ vim72/src/gui_gtk_x11.c     2010-06-01 13:45:59.000000000 +0400
@@ -878,6 +878,9 @@ keyval_to_string(unsigned int keyval, un
     uc = gdk_keyval_to_unicode(keyval);
     if (uc != 0)
     {
+        if (state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD4_MASK))
+            LANGMAP_ADJUST(uc, TRUE);
+
        /* Check for CTRL-foo */
        if ((state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80)
        {

--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|

Re: Fixed issue with langmap

Bram Moolenaar

Vladimir Pavlov wrote:

> I use vim-7.2.441 and I use vim's great langmap feature when writing
> russian texts.
>
> But when I try pressing ^[ to exit insert mode (or ^O to exit it
> temporarily) in russian xkb layout I got `È' (the russian character
> placed at the same key as `[') inserted instead of exiting.
>
> The following patch fixes the issue (besides Control it also processes
> Alt and Win keys in similar way).
>
> Can it be commited to vim repository?
>
> diff -Napur vim72.orig/src/gui_gtk_x11.c vim72/src/gui_gtk_x11.c
> --- vim72.orig/src/gui_gtk_x11.c        2010-06-01 13:43:45.000000000 +0400
> +++ vim72/src/gui_gtk_x11.c     2010-06-01 13:45:59.000000000 +0400
> @@ -878,6 +878,9 @@ keyval_to_string(unsigned int keyval, un
>      uc = gdk_keyval_to_unicode(keyval);
>      if (uc != 0)
>      {
> +        if (state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD4_MASK))
> +            LANGMAP_ADJUST(uc, TRUE);
> +
>         /* Check for CTRL-foo */
>         if ((state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80)
>         {

I don't think this is the right solution.  Any key typed with CTRL would
be affected.  I think you need to find a way to produce Esc in your
russian layout.

--
hundred-and-one symptoms of being an internet addict:
197. Your desk collapses under the weight of your computer peripherals.

 /// Bram Moolenaar -- [hidden email] -- 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.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Fixed issue with langmap

Vladimir A. Pavlov
> I don't think this is the right solution.  Any key typed with CTRL would
> be affected.

That's exactly as it supposed to work in the patch.

>  I think you need to find a way to produce Esc in your russian layout.

Yes, but not only Esc.

All the keybindings with Ctrl key don't work, such as completion
(^n, ^p, ...), editing (^w, ^u).

But now I think the right solution is not to use langmap for such
translation, but just (somehow) ignore the current layout just like
it's done in the console version (vim).

I tried geany (and kate), and there Ctrl with russian letter acts
exactly like if Ctrl is pressed with the corresponding english
letter (for example, ^т acts as ^n).

I'll try to investigate how geany does that.

--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|

Re: Fixed issue with langmap

Valery Kondakoff
2010/6/15 Vladimir A. Pavlov <[hidden email]>:
> But when I try pressing ^[ to exit insert mode (or ^O to exit it
> temporarily) in russian xkb layout I got `х' (the russian character
> placed at the same key as `[') inserted instead of exiting.
> All the keybindings with Ctrl key don't work, such as completion
> (^n, ^p, ...), editing (^w, ^u).

It seems the Windows gVim build (7.2.267) is not affected of this
issue. All the examples above works well with this langmap:

set langmap=ёйцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕHГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ;`qwertyuiop[]asdfghjkl;'zxcvbnm,.QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>


--
Best regards,
Valery Kondakoff

--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|

Re: Fixed issue with langmap

Vladimir A. Pavlov
> It seems the Windows gVim build (7.2.267) is not affected of this
> issue. All the examples above works well with this langmap:

Yes, I think the issue is in gtk+ behavior. (I even think it's not bug but a feature since, in general, it allows using sequences like ^<russian letter>).

I've looked through geany sources and have found nothing concerning keymaps.

Geany works because its keybindings are set via gtk accelerators and the
layouts are processed inside gtk.

But in gtk the task is somewhat different from what we need. In gtk the
bindings are known and when a key is pressed we just have to compare the new
key with all registered accelerators to find the actual one.

In gvim we have to translate the pressed key without knowing whether the key is
registered in gvim (and gvim knows how to process it) or not, so we have to go
another way.

The patch below fixes the issue for me.

In the patch we use gdk_keymap_translate_keyboard_state() just to know the
current level, and then use gdk_keymap_get_entries_for_keycode() to get the
list of keys and keyvals with the same keycode as the pressed key. Then we just
use the first key with the same level as the pressed one, from range 0x20 to
0x7f.

Can it be commited to vim repository?

--
You received this message from the "vim_dev" 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

=?koi8-r?Q?vim-7.2.444-ctrl+noneng=5Ffix-1.patch?= (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fixed issue with langmap

Vladimir A. Pavlov
In reply to this post by Bram Moolenaar
Any comments on the patch?

--
You received this message from the "vim_dev" 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