Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Drag And Drop To Open File In Running Leo Session #3427

Open
tbpassin opened this issue Jul 5, 2023 · 2 comments
Open

Allow Drag And Drop To Open File In Running Leo Session #3427

tbpassin opened this issue Jul 5, 2023 · 2 comments
Assignees
Labels
Delegated Delegatated to others Enhancement
Milestone

Comments

@tbpassin
Copy link
Contributor

tbpassin commented Jul 5, 2023

It is possible to have a desktop icon, both on Windows and Linux, that can open a dropped outline in Leo. But this outline will open in a new Leo window, which is slow and usually not what is wanted.

It would be a useful improvement if Leo were able to open such dropped files in the running Leo session if there is one. Many other existing programs can do this.

@tbpassin tbpassin added this to the 6.7.5 milestone Jul 5, 2023
@edreamleo edreamleo added the Delegated Delegatated to others label Jul 5, 2023
@edreamleo
Copy link
Member

@tbpassin I'll leave this issue to you.

@tbpassin tbpassin changed the title Allow Drag Abd Drop To Open File In Running Leo Session Allow Drag And Drop To Open File In Running Leo Session Jul 6, 2023
@tbpassin
Copy link
Contributor Author

I see several ways of tackling this enhancement. I haven't sorted through them to pick an approach yet. Here are some possibilities:

  1. A file is dropped on a Leo icon and the OS tries to start Leo with the file on the command line. During startup, Leo checks to see if it is already running, and if so, has the existing session open the file. Otherwise it starts as usual.
  2. The icon actually is connected to a client program. When a file is dropped on it, the client pings Leo's monitor port to see if Leo is running. If not, it uses OS calls to open it with the file on the command line. If it is, it send the file's path to Leo's monitor port. Leo responds by opening the file.
  3. Much like 2, but Leo starts a stand-alone server that the client talks to. Leo has its own client that polls the server, and if the server has received a file-to-open request, it sends that file to Leo. If no server exists, the icon's client opens Leo with the file on the command line.
  4. Much like 2, but the client program uses OS process information to try to identify if the Leo process with that ID still exists.

With method 1, there is the matter of how Leo can check to see if it's already running. It cannot be by checking an environmental variable because the attempt to open Leo might come from a console or other source outside of Leo's current session environment. It could be a lock file, but lock files will get stranded if Leo crashes without closing them.

Maybe the lock file could contain Leo's OS process identifier, and the OS could say if that process already exists. Of course, this would need to work cross-platform and I haven't looked into it, but it sounds feasible. The system would also have to know which instance of Leo to use if more than one were running.

I already have working code for most of alternative 3 (developed for another purpose). It wouldn't be hard, I think, but I'm not sure how to deal with the situation where there are several Leo instances running and only one started the server. How would the server know which instance to send the open-file request to? Possibly, the first one that asks. But I don't think that's the lowest-surprise solution.

@edreamleo edreamleo modified the milestones: 6.7.5, Later Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Delegated Delegatated to others Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants