Hello,
Firstly thanks for developing foot terminal.
Well, there are some people out they're so united with their window manager's key binding, that they press close keys accidentally almost too often.
This PR shows a close dialog on top level exit request.
I had no clue what I was doing; so it needs refactoring a lot.
The rendering part is almost identical to the "url-mode". The hardest part is to check if it's ok to shutdown the term or not.
Gnome terminal and Ghostty functions are here and here. One uses the shell integration the other uses thetcgetpgrp() function. I used both.
Thetcgetpgrp() function gives the foreground process, if it's the slave process, then we use shell integration to check if cursor is at the prompt. we also need to check if shell have background process or not. which I have no idea how to do that! One option is to check whether slave has at least a child process or not. Good option in theory but not accurate enough (weird shells with child process) and it's OS dependent. The better option is to ask shells to report their jobs statues. Something like shell integration to detect where prompt is.
And of course it doesn't change the default behavior and should be activated with config file.
Thanks
Hello,
Firstly thanks for developing foot terminal.
Well, there are some people out they're so united with their window manager's key binding, that they press close keys accidentally almost too often.
This PR shows a close dialog on top level exit request.
I had no clue what I was doing; so it needs refactoring a lot.
The rendering part is almost identical to the "url-mode". The hardest part is to check if it's ok to shutdown the term or not.
Gnome terminal and Ghostty functions are [here](https://gitlab.gnome.org/GNOME/gnome-terminal/-/blob/master/src/terminal-screen.cc?ref_type=heads#L2927) and [here](https://github.com/ghostty-org/ghostty/blob/0f0a61c38dbebbd70979afbd3df81bf143efca9d/src/terminal/Terminal.zig#L1032). One uses the shell integration the other uses the`tcgetpgrp()` function. I used both.
The`tcgetpgrp()` function gives the foreground process, if it's the slave process, then we use shell integration to check if cursor is at the prompt. we also need to check if shell have background process or not. which I have no idea how to do that! One option is to check whether slave has at least a child process or not. Good option in theory but not accurate enough (weird shells with child process) and it's OS dependent. The better option is to ask shells to report their jobs statues. Something like shell integration to detect where prompt is.
And of course it doesn't change the default behavior and should be activated with config file.
Thanks