github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/readline/signal_unix.go (about) 1 //go:build !windows && !js && !plan9 2 // +build !windows,!js,!plan9 3 4 package readline 5 6 import ( 7 "os" 8 "os/signal" 9 "syscall" 10 ) 11 12 func (rl *Instance) sigwinch() { 13 ch := make(chan os.Signal, 1) 14 signal.Notify(ch, syscall.SIGWINCH) 15 go func() { 16 for range ch { 17 18 width := GetTermWidth() 19 20 switch { 21 case !rl.modeTabCompletion || width == rl.termWidth: 22 // no nothing 23 24 case width < rl.termWidth: 25 rl.termWidth = width 26 HkFnClearScreen(rl) 27 28 default: 29 rl.termWidth = width 30 } 31 32 } 33 }() 34 35 rl.closeSigwinch = func() { 36 signal.Stop(ch) 37 close(ch) 38 } 39 }