Hi Sakamoto, Aaaah...much better...it works perfectly now. Thank you!
2009/8/28 Kazuki Sakamoto: > On Fri, Aug 28, 2009 at 2:40 AM, björn wrote: >>> Case of checking IM state before/after ESC key: >>> before: IM switch(off>on) > check IM state(on) > handle key > save >>> iminsert(on) >>> after : IM switch(off>on) > handle key > save iminsert(off) > check IM >>> state(on) >>> I expected _before_ behavior. >> Sorry, I don't understand the "before" and "after"? > > I will explain it. But, first, please let me know what will happen with the > following instructions in snapshot 49 or later. > > 1. :set noimdisable > 2. enter insert mode > 3. switch IM using IM icon in OS X's menu bar > 4. input text with IM > (Swedish characters, Japanese characters, Hangle characters or something) > 5. press ESC key > 6. enter insert mode > 7. input text with IM > 8. disable IM using IM icon in OS X's menu bar > 9. input ASCII text > 10. press ESC key > 11. enter insert mode > 12. you can input text "without" IM? > > I have tried it in snapshot 49 without any vimrc/gvimrc/plugins. > > 1. :set noimdisable > 2. enter insert mode > 3. switch IM using IM icon in OS X's menu bar > 4. input text with IM > 5. press ESC key > 6. enter insert mode > 7. input text with IM > 8. disable IM using IM icon in OS X's menu bar > 9. input ASCII text > 10. press ESC key > 11. enter insert mode > 12. I input text "with" IM. > > I expected that I can input text "without" IM in 12. Aha! That is a bug i was unaware of...now I'm beginning to understand your patch. >> You have moved code from from activateIm to checkImState, but this >> makes absolutely no sense to me. Please explain. Why do you need to >> send the ActivateImMsgID to Vim when the input method changes? I know >> this is how the old code works but I specifically changed the new IM >> code so that it did not have to. > > I have moved code from activateIm to checkImState because I'd like to solve > the above mentioned problem. The IM switching event and the key-bind for > switching IM (like Cmd-Space) doesn't reach MacVim. So MacVim can't know > the current IM state. MacVim should do polling to get the current IM state. > I think keyDown: method is reasonable to get the current IM state. I agree. > (If I can use CFNotificationCenterAddObserver with > kTISNotifySelectedKeyboardInputSourceChanged, > we can get rid of the polling to get the current IM state.) I don't know if there is much to gain by doing this since 10.4 needs to poll anyway. Unless there is a reason why the polling is bad I think we can just leave it as it is. But if you do know a reason why we shouldn't poll, please tell me and I can implement the notification (I have the old code lying around somewhere...I think). > And I need to send the Activate/DeactivateImMsgID to Vim(MMBackend) when > the input method changes, because, with "noimdisable" option, Vim will save > the current IM state to "iminsert" option value when Vim exits from insert > mode. Vim will use "iminsert" option value to activate/deactivate IM when > Vim enters insert mode. Also you can set "iminert" option by yourself, > for example, you can do ":set iminsert=0" when ESC is pressed by Vim script. > Besides, Vim will use it when user press "Ctrl-^" key-bind that means > switch IM. Ok, I was unaware of the bug you pointed out which is why I may have sounded a bit obtuse. >> With your patch, as soon as I enter insert mode it switches to Swedish >> layout (I'm in Sweden). > > It is because the default value of "iminsert" is "2". > I don't know the reason of it. I do ":set iminert=0 imsearch=0" in vimrc. I guess it sets it to Sweden because my time zone is set to Stockholm, Sweden...but it is a bit weird since my default language is English and my OS X version is English as well. Actually, it is pretty neat that it automatically switches to the current locale (i.e. Swedish in my case) since this is most likely the expected behaviour when 'imd' is set. Your tip of setting imi=0 and ims=0 reverts the behaviour back to what I first envisioned...so this is definitely an improvement! I've got "set imd imi=0 ims=0" in my gvimrc as well now. >> If I have several different layouts, e.g. US, >> Swedish and Kotoeri, and go to insert mode and switch to Kotoeri, then >> when I press Esc and go back to insert mode it will go back to Swedish >> again even though it should swtich to Kotoeri (the last layout used in >> insert mode). > > Sorry, I don't suppose this behavior. > I have fixed patch to remember IM source properly. Great! Now it does work the way I expect it to (and even better than I expected as I noted above). >>> > HACK! interpretKeyEvents: does not call doCommandBySelector: >>> > with Ctrl-6 or Ctrl-^ when IM is active. >>> Ctrl-^ switches IM state in Vim, it works properly on MacVim when IM >>> is not active. So I hacked handling Ctrl-6 and Ctrl-^ when IM is >>> active. >> I don't like this, but I can't think of any way to handle it better. >> Note that your solution will break if 'macmeta' is enabled. > > I have fixed it doesn't break 'macmeta' as possible as I can. I think it is good...your old patch was ok too in this respect, I just hit the "send" button a bit too soon. The only (very minor) issue I have with this patch now is that it gives you a warning due to an implicit cast from NSString* to CFStringRef, but I've fixed this myself. Thanks once again for the patch! I am very grateful that you fix these types of problems since I am no heavy IM user myself and as a result quite easily fail to detect bugs in this area (as the case was now). Björn --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_mac" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
