On Thursday, June 21, 2012 10:30:55 PM UTC+2, Nicolas Holzschuch wrote:
> Hello,
>
>
>
> I am trying to extend the Applidium port of vim to iOS.
>
>
>
> Specifically, I'm trying to add support of external keyboards (the iPad is
> great, but it's even more useful with an external keyboard. Especially, since
> it's vim, one with an "Esc" key).
>
>
>
> I have code for catching keyboard events, and I can identify them (I know if
> Control has been pressed, or Alt, and with which keys). I also identify the
> special keys, such as up, down…
>
>
>
> I think I've found the way to pass the events to vim. For function keys,
> cursor keys, all is fine.
>
>
>
> I'm having trouble with control + key (and alt + key). Here's my code:
>
>
>
> // Identify the modifiers (Shift, Ctrl, Alt, Option)
>
> UInt32 vimModifiers = EventFlags2VimModifiers(eventFlags);
>
> // Are we on a special key?
>
> int isSpecial = 0;
>
> int i;
>
> int key_char;
>
> for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
>
> if (special_keys[i].key_sym == keycode[0])
>
> {
>
> key_char = TO_SPECIAL(special_keys[i].vim_code0,
>
> special_keys[i].vim_code1);
>
> key_char = simplify_key(key_char, (int *)&vimModifiers);
>
> isSpecial = TRUE;
>
> break;
>
> }
>
>
>
> if (vimModifiers)
>
> {
>
> // We place the modifiers in the buffer
>
> result[len++] = CSI;
>
> result[len++] = KS_MODIFIER;
>
> result[len++] = vimModifiers;
>
> }
>
>
>
> if (isSpecial && IS_SPECIAL(key_char))
>
> {
>
> result[len++] = CSI;
>
> result[len++] = K_SECOND(key_char);
>
> result[len++] = K_THIRD(key_char);
>
> } else if (vimModifiers) {
>
> result[len++] = keycode[0] + 0x5d; // convert key code to letter
>
> result[len++] = 0;
>
> }
>
> if (len > 0) {
>
> add_to_input_buf(result, len);
>
> }
>
>
>
> When I type control + A, I get the standard behavior for control + A (insert
> previously inserted text) *plus* the letter a, appended at the end.
>
> (same for all letters, so for example control + V ends up as only "visual",
> not "visual block")
>
>
>
> And I can't figure why. My first guess is that there is something wrong in
> the way I handle modified letters, but I couldn't find any documentation as
> to how to do it (I got this far by looking at the code for other platforms).
>
>
>
> Could you point me towards the right documentation?
>
> N Holzschuch
Hello,
I added the Ctrl key to the iOS keyboard (a touch), simply, it works like shift
key (two state, on, off), to the vim iOS version, for Ctrl+Key, you need to
send to the buffer with "add_to_input_buf" function a ASCII code that have a
value "ASCII the Key" minus 0x40H, there is a defined C function for that in
VIM, for example for <C-A> the value code is 41H-40H => 01H (H - hex value)
For Ctrl-Tab, I use <C-I>, but the shift-Tab keys combination <S-Tab>, doesn't
work in Command mode, for completion, I not find the sequence hex codes (Ascii
codes) to send to the buffer with add_to_input_buf function. There is a problem
with the UTF8 codes, it display 3 characters at a time for only one UTF8 code,
it doesn't work the conversion...
Best regards !
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.