On Aug 15, 2014, at 20:47, Boris Dušek < email@hidden> wrote:
But to the std::map (in our case std::map<NSRange, LinkProxyObject*> - the point is in NSDictionary you can search only for exact match of key - i.e. if you have a link at range (100, 7) and VO requests AXAttributedStringForRange for
(102, 10), you would have no way to get at the link at (100, 7) without walking all values in the NSDictionary (valueForKey:(102, whatever) would return nil, under reasonable assumption there are no overlapping links), and you do need to add part of that link
at (102, 5) to the returned attributed string for (102, 10). But with std::map, you can ask for first value (in our case link) whose key (in our case the range) satisfies an inequality (I mean the lower_bound and upper_bound member functions), so with this
you could get all links that intersect with a certain range in O(log N) (N is the length of the whole text), if for the comparison function of the std::map you use numerical comparison of the location of the range. But if we are speaking about some text that
fits into one screen, I think you should not bother with this yet (however make your own performance measurements :-).
well, now I realize you could do it efficiently without the std::map if you specified [parameter rangeValue] for the inRange: parameter and query selfAttString directly for the border cases…
Yes, I figured that out too. But as you rightly said in your followup, I need to make sure that I’m always returning the same child objects. I tried always creating the objects on the fly (both for AXChildren and separately for the parameterized attributed
string), and VO complained that it couldn’t find the proxy object returned from the parameterized method in the list of children.
I’m at a loss for how to do this properly though given a situation like this:
There are more things in heaven [and] earth, Horatio
If just the single word “and" is selected by the parameterized range, should I really return the same link proxy object as AXChildren has? After all, that object will return a title of “heaven and earth”. But perhaps VO is smart enough to figure that out…
Anyway, I’ve tried that approach and fixed the other problems you’ve pointed out. They’re all in this new version, which sadly still doesn’t work yet:
-Nick
|