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

add: Exec, program.ReleaseTerminal and RestoreTerminal to re-use input and terminal #237

Merged
merged 22 commits into from Apr 12, 2022

Conversation

muesli
Copy link
Member

@muesli muesli commented Feb 21, 2022

Program.ReleaseTerminal makes Bubble Tea release the input / terminal, so users can spawn a sub-command. Program.RestoreTerminal sets the input reader up again and triggers a repaint.

Exec is provided as a Cmd interface, and should be the primary method for running a blocking exec.Command from within Bubble Tea.

Fixes #171.

@muesli muesli added the enhancement New feature or request label Feb 21, 2022
@muesli muesli marked this pull request as draft February 21, 2022 06:17
@muesli muesli mentioned this pull request Feb 21, 2022
@muesli muesli force-pushed the exec-cancelreader branch 4 times, most recently from 33be89c to 5cd97b7 Compare February 25, 2022 08:10
@muesli muesli changed the title add: program.CancelInput & RestoreInput to temporarily pause consuming inputs add: program.ReleaseTerminal and RestoreTerminal to re-use input & terminal Feb 25, 2022
@muesli muesli marked this pull request as ready for review February 25, 2022 08:28
@meowgorithm meowgorithm force-pushed the exec-cancelreader branch 3 times, most recently from 3667b41 to 0a31836 Compare March 1, 2022 21:02
@jefferai
Copy link

Played around with this for a few minutes this morning and found an issue. I haven't had time to dig into this yet but figured I'd raise it here in case this is going to be merged imminently -- I saw some activity on it yesterday.

I'm running a program that is normally terminated by Ctrl+C but accepts both SIGINT and SIGTERM. If I tell it to terminate by sending it a kill then the program terminates and I'm back into my TUI. However, if I terminate it via Ctrl+C in the terminal where the program was spawned, I do not go back into my TUI...instead I'm simply left at the CLI.

I followed this only enough to know that it's not hitting the update function's handling of a ctrl+c KeyMsg.

@meowgorithm
Copy link
Member

@jefferai Wow, thank you. We were actually planning in merging this. Will look into this, I have some theories as to what’s happening.

@meowgorithm meowgorithm changed the title add: program.ReleaseTerminal and RestoreTerminal to re-use input & terminal add: Exec, program.ReleaseTerminal and RestoreTerminal to re-use input and terminal Apr 11, 2022
@meowgorithm meowgorithm merged commit 3795c03 into master Apr 12, 2022
@meowgorithm meowgorithm deleted the exec-cancelreader branch April 12, 2022 14:23
@blaggacao blaggacao mentioned this pull request Apr 19, 2022
4 tasks
@blaggacao
Copy link

blaggacao commented Apr 20, 2022

@muesli

Scenario:

  • As a task runner TUI, I want to run a program (might be interactive or not) and

  • show it's log outputs to the user,

  • as if it was run natrually.

  • Upon termintation 0 or !=0, I want to give the user the possibilitiy to keep staring at the logs,

  • but upon pressing a specified button, e.g. q or esc

  • return to the teaTUI

What do you think? Does it make sense? Is that something that you could easily wrap onto this PR (if blunt asking is allowed 😄)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spawning editors
5 participants