---- On Thu, 21 Apr 2016 13:04:43 -0500 Greg Reagle <greg.rea...@umbc.edu> 
wrote ---- 

 > Is it appropriate to use ANSI escape codes in the program rather than 
 > using something like tput or terminfo, or to just execute the "clear" 
 > command?  Are the escape codes portable?

clear(1) from ncurses also clears the scrollback buffer if the terminal
supports it (see the manpage), that's not what you'd want here. As for
portability, tput clear does `^[[2J^[[H` for basically everything:

    # List the value of `tput clear` for everything in /usr/share/terminfo:
    for T in $(toe -a | cut -f1);
        do printf "%-40.s%s\n" "tput -T $T clear" "$(tput -T $T clear | cat 
-v)";
    done

The only terminals where it's not some variation on `^[[2J^[[H` are ancient and
obscure. But hey, it looks like the Apple II didn't support it (cf. infocmp 
appleII),
so if you're trying to run watch there you may be disappointed.


Reply via email to