-
Notifications
You must be signed in to change notification settings - Fork 814
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
Launching subprocesses like Vim from Textual apps #1093
Comments
See also #165 |
Just put up a related PR (I should have checked the issues first!) #1150 |
I had a similar problem but took a different approach. In my case, I wanted to be able to run an interactive program within a widget in a textual app. The attached code is pretty rough and dirty but it mostly works. Some missing things:
what it does is
I want to stress that this needs refinement and is just the first POC that actually worked for me. You need to install "pyte" and of course textual. You can save this script as interactive_shell.py and run a test like
|
chiming in my ultimate feature would be a way to pop open a dialog within a Textual layout that has a console application running inside of it, nested inside the bigger layout. for my end it's the "fzf" command so I may look into writing a mini "fzf-like" component for my immediate use case (choosing from large lists). |
@zzzeek https://github.com/mitosch/textual-terminal might interest you. |
I think this is now resolved by #4064? |
Good catch; and managing to dig this up might make @TomJGooding the Phil Harding of Textual. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
@zzzeek Where you able to make it work? When I try to call I call it from within a button press handler like so: def on_button_pressed(self, event: Button.Pressed):
with self.suspend():
iterfzf(['one', 'two', 'three']) |
@JacobKochems looks like last time I was doing a thing with fzf I didn't write the app as a textual app, just a stdin thing |
Ok, this issue seems to be specific to the kitty terminal. I can't reproduce it with e.g. gnome-terminal. I guess it must have something to do with kitty's departure from some legacy terminal behavior. |
Right now if you launch a subprocess of say Vim or Nano from a Textual app, there's a race condition between Textual and the subprocess - some of the input makes it into the subprocess, but some gets eaten by Textual's driver thread.
Also, if the subprocess changes the terminal state, then after it exits the terminal state may not be what Textual expects. For example, the cursor may be visible.
We should explore how to make this easier, e.g. via a context manager/utility method for launching subprocesses which pause the driver and resumes after the subprocess exits.
The text was updated successfully, but these errors were encountered: