2010/9/9 Nikola Knežević <[email protected]>:
> On 08.09.2010, at 15:18 , björn wrote:
>>
>> 2010/9/8 Nikola Knežević <[email protected]>:
>>>
>>> In the latest version of MacVim, it is not possible to use Cmd+Ctl+D to get
>>> system's dictionary for the work below the cursor. I can't vouch, but I
>>> think this option used to work on older versions. Can this option be added
>>> back, since it is quite useful, esp. when editing other people's texts?
>>>
>>> I'm using experimental renderer, on MacBookPro2,1, Mac OS X 10.6.4.
>>
>> This feature only works with the default renderer. I'm not sure if
>> this is hard-wired into NSTextView or if it is some sort of system
>> service. Have to check it out -- I agree that it would be nice to
>> have in the experimental renderer as well.
>>
>> Patches are welcome of course…
>
> :) Well, I have no clue about ObjC, but I would gladly try. How can I detect
> Cmd+Ctl+D is pressed, and then get the line+offset of the line under the
> pointer?
Unfortunately it is going to be a lot more complicated than that.
Cocoa defines a protocol that lets it access any text view as if it
were an array containing all the text. So Cmd+Ctrl+D works like this:
1. Cocoa tries to figure out the index of character under mouse cursor
by calling (on the text view):
- (NSUInteger)characterIndexForPoint:(NSPoint)point
2. Cocoa asks for a range of characters around index returned above by calling:
- (NSAttributedString *)attributedSubstringFromRange:(NSRange)range
E.g. if 1 returned 100, then 2 is called with the range
(location=75,length=50).
3. Cocoa tries to figure out where to pop up the dictionary window by calling:
- (NSRect)firstRectForCharacterRange:(NSRange)range
The range depends on where the closest word under cursor. It is a subrange
of the range in 2.
The problem is that this takes place in the MacVim process but all
buffers belong to a separate Vim process. So the MacVim process must
somehow get this information across the process boundary. I will have
to think hard on how this should be implemented properly.
Another problem is that as soon as you touch the methods above you are
most likely going to break the input method code (used e.g. with Asian
keyboard layouts).
Like I said: this is going to be difficult. You are welcome to try,
but unless you come up with an elegant way of dealing with all the
problems I may end up having to reject your patch.
As a temporary solution I was thinking of adding a "Look Up in
Dictionary" entry to the context menu so that you can at least
right-click to look something up in the dictionary. I just have to
figure out if there is some Apple Script-way of doing this so that I
can hook up "osascript" to do it. (I get the impression that the only
way to interact with Dictionary.app is via Services.)
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