huijunchen9260 / fm.awk

File manager written in awk
GNU General Public License v3.0
125 stars 3 forks source link

[Discussion] support for SIGWINCH? #6

Closed huijunchen9260 closed 3 years ago

huijunchen9260 commented 3 years ago

Dear all:

This is a discussion thread for possible support for SIGWINCH, which makes the TUI response to the change of the font size of the terminal.

I've tried the following script with no luck:

awk '
BEGIN{
srand()
system("stty -isig -icanon -echo")
printf "\033\1332J\033\133H" >> "/dev/stderr" # clear screen
printf "\033\133?1049h" >> "/dev/stderr" # alternate buffer
printf "\033\1337" >> "/dev/stderr" # save cursor
printf "\033\133?25l" >> "/dev/stderr" # hide cursor
printf "\033\133?7l" >> "/dev/stderr" # line wrap
while (1) {
    system("trap \"echo \"YES\"\"; WINCH")
    system("sleep 1")
}
printf "\033\1332J\033\133H" >> "/dev/stderr" # clear screen
printf "\033\133?7h" >> "/dev/stderr" # line wrap
printf "\033\1338" >> "/dev/stderr" # restore cursor
printf "\033\133?25h" >> "/dev/stderr" # hide cursor
printf "\033\133?1049l" >> "/dev/stderr" # back from alternate buffer
system("stty isig icanon echo")

}'
huijunchen9260 commented 3 years ago

Fixed by https://github.com/huijunchen9260/fm.awk/commit/8aa172aa13bd7254215b16b5f4368bdc4e8ca0f9