gansm / finalcut

A text-based widget toolkit
https://github.com/gansm/finalcut/wiki/First-steps#first-steps-with-the-final-cut-widget-toolkit
GNU Lesser General Public License v3.0
981 stars 52 forks source link

Catching the terminal focus and unfocus signal in finalcut #114

Closed wimstockman closed 1 year ago

wimstockman commented 1 year ago

Feature Request

Hi Markus, It would be great if the final cut could detect when the terminal loses its focus and when it gets its focus back. So for instance you could change the backgroundcolor when the terminal looses focus. I know you can activate this with the escape sequence \033[?1004h on a terminal after that you receive " ^[[I " for back in focus and "^[[0 "for unfocus signal.

What do you think about it ? Thanks a lot Wim Stockman

gansm commented 1 year ago

Great idea! I have immediately implemented it in code (3a3ab9e). The root widget now has the methods onTermFocusIn (FFocusEvent) and onTermFocusOut (FFocusEvent).

I have also written a small program examples/terminal-focus.cpp.

The terminal has the focus: grafik

The terminal does not have the focus: grafik

wimstockman commented 1 year ago

Great ! I had this issue with St terminal emulator from suckless.org and focus patch. That the colours changed when my program went out of focus. So I got the Idea there must be a signal to the terminal :-). This is such a cool feature . For the moment I already implemented it to hide all the windows for privacy concerns. Thanks really love playing around with your toolkit. See ya :-) Wim Stockman