Studying Robert Cholette's vs-code leointeg project

109 views
Skip to first unread message

Edward K. Ream

unread,
Aug 30, 2019, 3:20:35 PM8/30/19
to leo-editor
I have just taken a quick look at the leointeg repo.  Some notes:

As you will see, there are only four TypeScript files in the src folder.  They correspond roughly to the code in the leoflexx.py plugin (--gui=browser).  These files are concise.  Their overall purpose is fairly clear, but I have little idea of how they actually work.

In several places Robert borrows code from leoflexx.py.  I'm thrilled that concepts such as archived position have become useful in a new context.

I've cloned the repo and will likely use a recursive import script to study it in detail.  Not sure that Leo can import TypeScript files in a Leonine way.

gitk shows that work started August 10, and continued on 9 days from August 13 to Aug 29.  So this is rapid progress.

It would be really cool to animate the gitk commits, showing (in Leo) what each commit did.  Leo git-diff command and other git utils provides the basis for such an "animation".  I'm tempted...

Oh, how I wish Robert and I were cubicle mates.  I'd love to ask him questions, line by line about his code. This would give me a higher level view than even the git-diff animation.  For example, scripts/leoBridge.py appears to be plain python, but how is it executed?  Perhaps I should know the answer, having written leoflexx.py, but I don't :-)

Most of the rest of leointeg looks like VS-code glue: .json files, etc.

Summary

This project is tremendously exciting.  The present code is compact and powerful. I'll continue my studies.

Edward

Edward K. Ream

unread,
Aug 30, 2019, 3:27:46 PM8/30/19
to leo-editor
On Fri, Aug 30, 2019 at 2:20 PM Edward K. Ream <edre...@gmail.com> wrote:

> Oh, how I wish Robert and I were cubicle mates.  I'd love to ask him questions, line by line about his code. This would give me a higher level view than even the git-diff animation.  For example, scripts/leoBridge.py appears to be plain python, but how is it executed?  Perhaps I should know the answer, having written leoflexx.py, but I don't :-)

Apparently leoBridge.py communicates with JS using stdin and stdout, using json as the "common language".  Still not sure how leointeg starts leoBridge, but perhaps that don't matter much.

Edward

Edward K. Ream

unread,
Aug 30, 2019, 3:38:53 PM8/30/19
to leo-e...@googlegroups.com
On Friday, August 30, 2019 at 2:27:46 PM UTC-5, Edward K. Ream wrote:

> Apparently leoBridge.py communicates with JS using stdin and stdout, using json as the "common language".  Still not sure how leointeg starts leoBridge, but perhaps that don't matter much.

Well, it's pretty simple: leoIntegration.ts contains:

private initLeoProcess(...): void {
 
...
 
// * start leo via leoBridge python script.
 
const w_pythonProcess: child.ChildProcess = child.spawn("python3", [
   
this.context.extensionPath + "/scripts/leobridge.py"
 
]);
 
...

Not sure of the JS details, but clearly this is the code that starts leoBridge.py.

The rest of the initLeoProcess function sets up the communication channels on stdin and stdout

Edward K. Ream

unread,
Aug 30, 2019, 5:14:40 PM8/30/19
to leo-editor
On Friday, August 30, 2019 at 2:20:35 PM UTC-5, Edward K. Ream wrote:

> Not sure that Leo can import TypeScript files in a Leonine way.

Recent revs in devel improve support for TS as follows:

- Added leo/modes/typescript.py, thereby adding support for syntax coloring TS code.  Somehow that got left out.

- Improved the TS importer by adding support for interfaces and removing annoying context info in headlines.

All of Robert's TS files now import reasonably.

Edward

Robert Cholette

unread,
Aug 31, 2019, 12:42:35 AM8/31/19
to leo-editor
I got caught with my pants down! Not even having a .leo file at the center of my development for this project! Caught by the creator of Leo itself!

Jokes aside, I am honored. This is a great way to start my weekend! 
Like I said in the main thread about this project, I pushed a small milestone in the repo a few minutes ago: full leo browsing, headline and body. (still not optimised, debounced, nor editable) 

Going forward, I'll take a couple hours to study leoVue a little bit, to maybe make a tcp/ip communication instead of just stdIn/Out...
I also have to study your leoFlexx plugin a bit more to see what else I can gather again from it to make everything easy and smooth! :)

But on the short term, this weekend I'll probably just make the headlines and body text editable, being able to edit the outline structure along with it would be another nice milestone! 
I also have monday off (long weekend!) so perhaps I'll reach it! 

As a small explanation to start things up & help understanding :
The main mechanic is that I'm using a simple stack of promises to keep track of what's asked of the leoBridge's side of things. The first 'asked' command by vscode interface is pushed on top of this stack, and resolved from the bottom so its first-asked first-served kind-of logic. The set of possible commands that it responds to is limited for now obviously. 

I knew nothing of the vscode extension api two weeks ago, so i'm pretty new to all this too!

Please dont hesitate to ask for any clarification whatsoever,
So all right for now, I'm going to bed!  Cheers! :D
--
Félix

Austin(Xu) Wang

unread,
Aug 31, 2019, 12:55:24 AM8/31/19
to leo-editor


Going forward, I'll take a couple hours to study leoVue a little bit, to maybe make a tcp/ip communication instead of just stdIn/Out...

I vote for a standard RESTFUL API to access the nodes information.

 
So all right for now, I'm going to bed!  Cheers! :D


Have a good rest..
 

Robert Cholette

unread,
Aug 31, 2019, 1:07:51 AM8/31/19
to leo-e...@googlegroups.com
Indeed, Rest api is simplest and easiest. Going to have to think about how to be stateful, but its gonna be rest for sure. or websockets, they're good too
I'll checkout how leoVue does it first to get some ideas.


On Friday, August 30, 2019 at 3:20:35 PM UTC-4, Edward K. Ream wrote:

Edward K. Ream

unread,
Aug 31, 2019, 3:35:10 AM8/31/19
to leo-editor
On Fri, Aug 30, 2019 at 11:42 PM Robert Cholette <felix...@gmail.com> wrote:

> I got caught with my pants down! Not even having a .leo file at the center of my development for this project! Caught by the creator of Leo itself!

Hehe.  Actually, I hadn't noticed :-)  I typically use c.recursiveImport to study other people's code.  In your case, I guess I hadn't expected that there would be a .leo file involved, since you might have been developing within vs code.
Jokes aside, I am honored. This is a great way to start my weekend! 

Glad to hear it.  Your project was, likewise, a great way to start my weekend.
Going forward, I'll take a couple hours to study leoVue a little bit, to maybe make a tcp/ip communication instead of just stdIn/Out...
I also have to study your leoFlexx plugin a bit more to see what else I can gather again from it to make everything easy and smooth! :)

Excellent!  Imo, improving the various "bridges" between the python and JS worlds is pretty much the most important thing in Leo's world, and perhaps (via web assembly) the wider world. Despite having written leoflexx.py, the whole topic still seems mysterious to me.

The genius of flexx is that the JS side looks like python. That helped a lot.  As I write this, I am starting to remember the overall drill: all communication between the Python and JS sides must use something like json: there is no way to share "real" objects directly.  The mind set that I had to develop was to keep firmly in mind that "calls" didn't happen immediately.  It's was a new way of thinking. Presumably, promises are related to this way of thinking.

> The main mechanic is that I'm using a simple stack of promises to keep track of what's asked of the leoBridge's side of things. The first 'asked' command by vscode interface is pushed on top of this stack, and resolved from the bottom so its first-asked first-served kind-of logic. The set of possible commands that it responds to is limited for now obviously.

Thanks for this. 

> Please don't hesitate to ask for any clarification whatsoever,

Thank you.  For now, I'm reasonably happy with my general notion of what you are doing.  I'll leave the "how" details to you.

Edward

Matt Wilkie

unread,
Sep 2, 2019, 8:28:06 PM9/2/19
to leo-editor
It would be really cool to animate the gitk commits, showing (in Leo) what each commit did.  Leo git-diff command and other git utils provides the basis for such an "animation".  I'm tempted...

Edward K. Ream

unread,
Sep 3, 2019, 7:15:17 AM9/3/19
to leo-editor
On Mon, Sep 2, 2019 at 7:28 PM Matt Wilkie <map...@gmail.com> wrote:

It would be really cool to animate the gitk commits, showing (in Leo) what each commit did.  Leo git-diff command and other git utils provides the basis for such an "animation".  I'm tempted...

I remember Vitalije did something like this using Fossil, Rust and Leo: 

Thanks for this! #1315 tracks the idea, and the demo.

Edward
Reply all
Reply to author
Forward
0 new messages