Created
July 20, 2020 05:48
-
-
Save 3cp/e0e2758882b6f94c129c24f617f700ee to your computer and use it in GitHub Desktop.
Trap SIGWINCH in a swift terminal app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let sigwinchSrc = DispatchSource.makeSignalSource(signal: SIGWINCH, queue: .main) | |
sigwinchSrc.setEventHandler { | |
print("got SIGWINCH") | |
// Use ncurses API to get tty window size | |
// https://github.com/iachievedit/CNCURSES | |
} | |
sigwinchSrc.resume() | |
dispatchMain() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment