[fpc-pascal] XTerm window resize [was: Re: hmm, freevision]
    Johann Glaser 
    Johann.Glaser at gmx.at
       
    Thu Aug 30 16:01:54 CEST 2007
    
    
  
Hi!
> Basically just that, if you change the size the console window fp is in, 
> the application sizes itself to fit the window.  it's a skill I'd like 
> to duplicate, as the app will be a console app with an interface, and 
> the fvision demo didn't do the neat trick.
Probably this is of interrest for you: The terminal sends a SIGWINCH to
the running process when it is resized. The process then requests its
current size by an ioctl() TIOCGWINSZ to the stdout handle (0).
You can test this in a simple shell window. Start two xterms (or which
terminal you like, now called "A" and "B") and then do an "strace -p
<pid>" in terminal A of the shell in terminal B (get its PID using "echo
$$"). Then resize terminal B with the mouse. I get the following output
of strace every time the size changes:
read(0, 0xbffe5d3f, 1)                  = ? ERESTARTSYS (To be restarted)
--- SIGWINCH (Window changed) @ 0 (0) ---
ioctl(0, TIOCGWINSZ, {ws_row=24, ws_col=80, ws_xpixel=480, ws_ypixel=312}) = 0
write(2, "\r\33[K\33]0;hansi at hansi:~\7\33[44;1;31m"..., 97) = 97
sigreturn()                             = ? (mask now [])
read(0, 
Bye
  Hansi
    
    
More information about the fpc-pascal
mailing list