On 7 November 2010 16:56, Kazé <[email protected]> wrote:
> Hello,
>
> with MacVim, the "macmeta" currently allows to use both "Option" keys
> either as "Meta" or "AltGr". Like a lot of European users, I'd prefer
> the "macmeta" pref to set only one "Option" key as "Meta" (e.g. the
> left one, as it works on Windows and GNU/Linux) and keep the other one
> for special characters on non-English keyboard layouts.
>
> In case someone is interested if having both a Meta key *and* an
> Option key when "macmeta" is set, here's a quick and dirty patch:
>
>  diff --git a/src/MacVim/MMTextViewHelper.m b/src/MacVim/
> MMTextViewHelper.m
>  index 4d10432..42f311b 100644
>  --- a/src/MacVim/MMTextViewHelper.m
>  +++ b/src/MacVim/MMTextViewHelper.m
>  @@ -22,6 +22,9 @@
>  #import "MMWindowController.h"
>  #import "Miscellaneous.h"
>
>  +// asymetric meta keys
>  +#define NSLeftAlternateKeyMask  (0x000020 | NSAlternateKeyMask)
>  +#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask)
>
>  // The max/min drag timer interval in seconds
>  static NSTimeInterval MMDragTimerMaxInterval = 0.3;
>  @@ -165,7 +168,8 @@ KeyboardInputSourcesEqual(TISInputSourceRef
> a,TISInputSourceRef b)
>     // ASCII chars in the range after space (0x20) and before
> backspace (0x7f).
>     // Note that this implies that 'mmta' (if enabled) breaks input
> methods
>     // when the Alt key is held.
>  -    if ((flags & NSAlternateKeyMask) && [mmta boolValue] && [unmod
> length] == 1
>  +    if (((flags & NSLeftAlternateKeyMask) == NSLeftAlternateKeyMask)
>  +            && [mmta boolValue] && [unmod length] == 1
>             && [unmod characterAtIndex:0] > 0x20
>             && [unmod characterAtIndex:0] < 0x7f) {
>         ASLogDebug(@"MACMETA key, don't interpret it");
>
> This is just a trivial adaptation of this iTerm patch:
> http://swissarmyhammer.wordpress.com/2010/06/07/osx-terminal-meta-key-national-characters/
> I think a proper MacVim integration would require to modify the
> 'macmeta' stuff, e.g. by using a string pref instead of a boolean one:
>
>  * set macmeta=l     => left Option key is Meta
>  * set macmeta=r     => right Option key is Meta
>  * set macmeta=rl    => both Option keys are Meta
>  * set macmeta=      => no Meta key
>
> Thoughts?

Hi,

I can see that this sort of behavior would be useful for non-english
keyboard layouts.  Perhaps an easier solution (implementation-wise)
than modifying the 'macmeta' option (and one that doesn't break
backwards compatibility) would be to have a user default to set which
key is used as meta when 'macmeta' is enabled.  This way it would be
an app-level setting so all windows would use the same setting -- I
don't know if this is a disadvantage or not (perhaps it is a bit
confusing?).

Anyway, that was just a though...I don't know which solution is better
(making 'macmeta' a string option, or adding a user default).  Does
anybody else have any comments about this?

I'm not against merging such a patch...

Björn

-- 
You received this message from the "vim_mac" 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 via email to