Tuesday, October 03, 2006

Keyboard handling patch

Update: This patch got accepted into the official vim source (patch 7.0.138). Yay!

Mac Vims Carbon keyboard handling code doesn't apply modifiers (like shift) to special keys like the arrow keys. I wrote a patch to take care of this.

Of couse, this patch causes a few regressions (which I'm trying to fix).

I have to test the following keys with each version of the patch to make sure the regressions stay fixed:
  • C-V S-Left should insert "<s-left>" in insert mode. Done by original patch.
  • Mappings like
    map <c-e> <end>
    map <c-a> <home>
    should work (insert mode and normal mode) (regression found by Kyle Wheeler).
    Fix: Don't send CTRL modifier for keys with ASCII code < 32
  • C-F and C-B should work in normal mode (regression found by Bram Molenaar). Seems to be fixed by the patch that fixed the previous problem as well.
  • Shift-Tab should give previous match in command line completion (found by Bram Molenaar as well). simplify_key() seems to mess up the shift-tab keys. Shift-Tab is a special key and has to be send as such.
  • Shift-Space has to work (the code that removes shift from chars like (, *, + etc. removes it from space as well).
  • Unicode characters (ä etc.) should work (they are broken because of the Shift-Tab patch at the moment).
  • :map ç j doesn't work
Generally, modifiers required to generate a key (shift is required for uppercase characters or * etc, alt is required for ç (at least on my keyboard), etc) should not be sent to vim. Is there a way to find out which modifiers are necessary for a given character? This depends on the keyboard layout of course.

Notes: Keyboard layout files; this seems to be what I'm looking for
The latest version of the patch can be found here.