On Sunday, 6 בMay 2007 22:06, Maxim Veksler wrote:
> What is tput then? I know it speaks with the terminfo db and that it's
> a "rather portable" to method to encode color strings (try tput setaf
> 1; whoami; tput setaf 7).

That's true, but...

> I assume this adds a fourth mechanisms?

No. Let's see:
$ strace tputs cols
..
ioctl(1, TIOCGWINSZ, {ws_row=55, ws_col=132, ws_xpixel=0, ws_ypixel=0}) = 0
..

So this utility looks at the terminfo database, for terminal
features, but also (in "modern" versions) use the ioctl() mentioned
by Nadav to query the tty driver.

> ncurses being 5th?

No. Ncurses is just a hi-level library (for some definition of hi-level ;-)
working above terminfo (used to work above termcap in Berkely Unix) and
provide more abstractions (e.g: [text] windows, scrolling management,
cursor motion, etc.)

Just to complement what Nadav already describe, if you happen to work
in an old shell that does not contain signal handling for SIGWINCH and
change your xterm size, the standard workaround is to run:
        eval `resize`
Which issues the ioctl and output the commands to set COLUMNS and LINES
environment variables.

You may notice that the output of resize depends on the $SHELL environment
variable, so it may be used both by sh/ksh/bash and csh/tcsh.

-- 
Oron Peled                             Voice/Fax: +972-4-8228492
[EMAIL PROTECTED]                  http://www.actcom.co.il/~oron
ICQ UIN: 16527398

She sells cshs by the cshore.       - Rob Malda

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to