I am building a command line tool in Swift and am wondering if there is any way to determine the current width of the viewport while running the app, in order to limit the text on screen to what will fit without wrapping.
I know this is possible in a "real" command line app, since things like pico, man, pine, etc. all render their textual interfaces based on the window size, but I can't seem to find any info on how they do it.
In fact you can even resize the window while they are running and they will refresh. Does anyone know how this works and if it's possible to add support to a command line tool written in Swift?