If you insist on going that route, using /usr/bin/tput directly would be
better than using /usr/bin/clear, since /usr/bin/clear is just a script that
calls tput.  Avoiding the script should cut out one more fork/exec.

But tput uses libcurses anyway, so it still has to at least be on the system,
even if your program can avoid linking with it directly.

So you might as well use libcurses; although, if you're really over the top,
you can use the static (at least still there in Solaris 9) libtermcap in
/usr/ucblib; or for that matter, the dynamic one.  It's perhaps somewhat
lighter weight than libcurses (or the libtermcap in /usr/lib, which is just
a link to libcurses).

I put together something that can be compiled either to use libcurses or
the ucblib libtermcap; it's at http://www.smart.net/~rlhamil/clear.c
I haven't tested it using regular libcurses since I got the ucblib libtermcap
stuff working, but I don't think I broke anything.  With -DBSD_TERMCAP,
it needs to be linked with the ucblib version of libtermcap; without it,
it should be linked with the regular version of libcurses (aka libtermcap aka
libtermlib).  Time difference between the two was negligible for me; both
were a bit faster than tput, I think.  I didn't try to get memory usage 
including
shared libs, but I suspect that's probably less with ucblib libtermcap.  The
idea is not to compile it as a standalone (although there's a main() conditional
on -DTEST if you want to), but rather to link it with your program.  The cls()
function has some stuff in it so it only does initalization the first time you
call it; on subsequent calls, it should be faster.

It's ugly, but it should get you started if you want to bite the bullet and
live with linking with the one extra library.
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to