Thanks for your reply ! 

I don't think the problem is overriding getSelectedText in the wrapper, - 
or overriding the whole wrapper itself like I successfully did anyways. 

It's that methods in Leo (such as getScript in leoGlobals.py) consider 
important to check if they're in leoBridge (!), even if they also check if 
the wrapper is available on the frame.body ! (see line 14 of getScript in 
leoGlobals.py)

Removing this check on line 14 would still check if the wrapper exists, and 
use for example, the default return value of the default wrapper method 
(that just returns empty string). This would enable replacing the wrapper 
itself, or only the methods inside it like you proposed, to be called. 

Actually, the behavior is that Leo checks if he's running via leoBridge and 
if so, decides in getscript that it's going to be the whole body text that 
is going to be the script because no text selection could exist if running 
via leoBridge, which is what I'm trying to override.

getScript should use the whole body if there's no selection, indeed, not by 
checking g.app.inBridge, but by calling the "hasSelection" of the wrapper, 
(would get the 'false' result of the WrapperAPI default class in 
leoFrame.py... if ran via leoBridge without wrapper replacements like I do, 
obviously)   

wadaya think?
--
Félix
p.s. maybe I misunderstood something crucial so just go ahead and correct 
me if its the case.



On Sunday, September 27, 2020 at 1:45:19 AM UTC-4, Félix wrote:
>
> I'm trying to tell Leo to 'fake' what it's currently selected text is, in 
> it's currently selected body, while running Leo in a leobridge. 
>
> I'v lookedin leo's code: This is set when creating a Leo bridge : 
> "inBridge" 
>
> Obviously, It's checked by leo in some commands that would  make no sense 
> if it was not running in a gui. So it makes sure "inBridge" is false.
>
> "g.app.inBridge" is the way it's usually checked...
>
> I'm trying to integrate 'selection state' by overriding the 'wrapper' 
> object ( in c.frame.body ) which would be useful for commands such as 
> 'execute selected script, extract node, etc... 
>
> Problem is, in Leo, when about to run 'getScript' or other stuff like the 
> most important method i'm overriding : "getSelectedText", Leo checks first 
> if c.frame.body.wrapper exists, which makes sense, and would be enough, but 
> then it also checks if g.app.inBridge is true, which prevents the call I 
> was expecting Leo to make to the methods in the new 'wrapper' I provided 
> for my commander's frame's body...
>
> I dont wanna force "inBridge" to be false, it's gonna break everything 
> else I presume!
>
> Any thoughts or pointers that could shed some more light on this aspect of 
> Leo's handling of it's gui wrapper interactions when opened via leoBridge? 
>
> --
> Félix
>  
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/516e7801-9c1d-417a-be55-9fd22f5625f4o%40googlegroups.com.

Reply via email to