[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Wondering about the print out function of PS



Jochen Schulz <ml@well-adjusted.de> writes:

> Camaleón:
>> On Tue, 23 Nov 2010 17:29:49 +0800, Magicloud Magiclouds wrote:
>> 
>>> But I do not know how it gets the width of the screen.
>> 
>> Well... gathering information about the running terminal is possible:
>> 
>> sm01@stt008:~$ stty -a | grep column
>> speed 38400 baud; rows 63; columns 86; line = 0;
>
> Or simply:
>
> $ echo $LINES $COLUMNS
> 31 107

Or even more simply:

$ stty size
57 118

In reply to the original question, I think the curses interface can get
the terminal size.  I haven't tried it from C, but in perl I use the
GetTerminalSize function in the Term::ReadKey module (in the debian
package libterm-readkey-perl).  The shells should also send the signal
SIGWINCH to notify the user when the terminal size changes (WINdow
CHange?).  The bash documentation state that LINES and COLUMNS are
automatically set when a SIGWINCH is received.
-- 
Carl Johnson		carlj@peak.org


Reply to: