rivo / tview

Terminal UI library with rich, interactive widgets — written in Golang
MIT License
11.17k stars 574 forks source link

Introduce stopOnCtrlC in application. #816

Closed gizahNL closed 1 year ago

gizahNL commented 1 year ago

This allows consuming applications signal that they intend to keep running when control+c is pressed, and instead want the event to be handled by their primitives.

My use case is for a window in which I run shell commands; And that I want to cancel via pressing control+c. The current default of stopping on control+c is kept so there should not be any surprises for anyone updating.

rivo commented 1 year ago

This is what Application.SetInputCapture() is for. This specific use case is actually documented there. You can also use it to bind "Close Application" to a different key.

gizahNL commented 1 year ago

This is what Application.SetInputCapture() is for. This specific use case is actually documented there. You can also use it to bind "Close Application" to a different key.

Can you perchance explain how to do it that way? I am able to block handling of control+c that way completely, but I don't see a way to let control+c be passed down chain without the application getting stopped.

rivo commented 1 year ago

Actually, your question made me realize that there was indeed no way to forward Ctrl-C to primites. You were able to block it or translate it but not forward.

I fixed this now. There is now a specific way to achieve this. Check out the link above for details.

gizahNL commented 1 year ago

Actually, your question made me realize that there was indeed no way to forward Ctrl-C to primites. You were able to block it or translate it but not forward.

I fixed this now. There is now a specific way to achieve this. Check out the link above for details.

Many thanks! That will work for me !