Hi tfer :) I'm glad you're interested and I'm also happy to explain this project, in fact I'll need to document sooner or later so explaining a bit here is a good start for me to copy/paste it later in some real document in leoInteg's repo.
> Would you explain a bit of the vscode/leo back and forth over the > websocket? You implemented a gnx based "filesystem" for body text and a > vscode "file browser" to serve as the outline tree, (if I'm understanding > things correctly). Do you use the websocket and leobridge to update the > internal state of the associated commander, (e.g. its vnodes), on a > transaction by transaction basis? Does leo handle the weaving/saving? 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 <https://code.visualstudio.com/api/references/vscode-api#FileSystemProvider> for the body panes, but for the outline tree, I implemented a treeview <https://code.visualstudio.com/api/extension-guides/tree-view>, 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 On Saturday, June 13, 2020 at 11:18:57 AM UTC-4, tfer wrote: > > > > On Saturday, June 13, 2020 at 4:02:26 AM UTC-4, Félix wrote: >> >> Thanks that is good input. I'm considering this. There's also the >> 'injectable' aspect of grammars in vscode that i'm thinking of using for >> coloring the directives specific to leo. >> > That's something I hadn't considered, good point. > > >> I'm currently learning the 'textmate' grammar definition that's used in >> vscode. Still not 100% sure of the final approach i'll use but i got some >> good ideas now. >> >> gonna continue reading and trying out more stuff with this tomorrow >> > > Would you explain a bit of the vscode/leo back and forth over the > websocket? You implemented a gnx based "filesystem" for body text and a > vscode "file browser" to serve as the outline tree, (if I'm understanding > things correctly). Do you use the websocket and leobridge to update the > internal state of the associated commander, (e.g. its vnodes), on a > transaction by transaction basis? Does leo handle the weaving/saving? > > I ask because I'm thinking of hooking leo to neovim. > > Tom > -- 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/e7b8b4a6-95fd-4474-a721-38bf5953c980o%40googlegroups.com.
