mitosch / textual-terminal

A terminal emulator widget for Textual.
GNU Lesser General Public License v3.0
83 stars 4 forks source link

A Message for when the command terminates #6

Open candidtim opened 9 months ago

candidtim commented 9 months ago

Is there a way to know (a Message?) when a command running in the terminal terminates? Or, put differently, when a terminal stops?

mitosch commented 9 months ago

Hi There

Thanks for your your question.

For the first question, I've to investigate it. Probably not, because it is not known for Textual, that a command inside the terminal widget has been run.

For the second question, possibly yes, if the command you've defined stopped. This should already trigger some Message from Textual itself. If it would be a command inside a widget running bash, probably not. That would be the same as above.

As soon as I've some spare time, I'll investigate it.

Mitosch

candidtim commented 9 months ago

I have looked into the source code and it seems that a call to the post_message can be added to the Terminal.stop() method. I have made a simple test by extending the class and it seems to work fine. Let me know if you accept Pull Requests, I can prepare one, maybe even with some niceties to parse the exit code to raise in the message.

mitosch commented 9 months ago

Yes, that would also be my idea for the second usecase. If that is, what you need, just make a pull request.

I'd be happy to merge it and release a new version.

juergenpabel commented 2 months ago

As it might be related to this: #8