Yes, Leo does the file derivation/weaving itself, and file change detection, etc... I merely ask a controller in Leo to do stuff. (as documented in Leo's official leoBridge documentation.) Its a 2 way dance: see /src/leoAsync.ts, vscode's side of things listens for log entries in the 'leo log window' output pane I instanciated and also I react in a 'blocking' way if Leo asks for a confirmation to refresh when file changes are detected.
I did implement a gnx based
filesystem for the body panes, but for the outline tree, I implemented a
treeview, which has nothing to do with 'file browsing' nor the 'filesystem' used for the body panes.
Those 2 systems are independent and unrelated.
/src/leoIntegration.ts orchestrates the method calls between class instances of those 2 controller objects. in short, /src/leoIntegration.ts is the central hub for managing concepts such as: "this was clicked in the tree" and "replace the text in the body pane editor" and other precise actions such as "refresh the tree and make sure the selected node matches the one in Leo" (which is performed when a string of commands have finished resolving - it would be unwise to refresh between rapidly entered commands)
On the Leo side of things, in /leobridgeserver.py,. the script receives a json string, which when converted to a python object, makes for a virtual "bridge" between the two paradigms.
The crucial line takes the json packet, and knows there's going to be an "action" member string name, and also a 'parameter sub object' ... the crucial line makes use of the "getattr" python method (at line 1082):
answer = getattr(integController, w_param['action'])(w_param['param']) # Crux
So this line calls a method on the integController, by name, contained in 'action' part of w_param. This method called will be called with a set of parameters too: the 'param' part of w_param.
The matching side of what I just explained back into vscode 'leoInteg' side is the function _buildActionParameter in /src/leoBridge.ts :
/**
* * Build JSON string for action parameter to the leoBridge
* @param p_action Action string to be invoked as command by Leo in the leobridgeserver.py script
* @param p_jsonParam Optional JSON string to be added as a 'param' to the action sent to Leo
*/
private _buildActionParameter(p_action: string, p_jsonParam?: string): string {
return "{\"id\":" + (++this._leoBridgeSerialId) + // no quotes, serial id is a number, pre incremented
", \"action\": \"" + p_action + // action is string so surround with quotes
"\", \"param\":" + p_jsonParam + // param is already json, no need for added quotes
"}";
}
LeoInteg is a year's worth of professional web development across many API, languages and platforms. So I'll continue explaining some more later, feel free to divert the subject to any part in particular. I'm going bed now. g'night chat with y'all some more tomorrow :)
Félix