[comp.unix.xenix] Xenix clear screen function..

jfrench@photon.tamu.edu (Jeff French) (02/04/90)

Does my Xenix '286 ver. 2.1.1 have a "clear screen" funtion that I am
overlooking? Under MS/DOS the command is "cls", and on SunOS it's "clear".

Currently I have a script that cats an empty file to the screen. This works
but leaves the cursor in the lower left hand corner of the screen.

I have RTFM 'till I'm blue in the face. Any suggestions would be appreciated.

Please excuse my ignorance if their is a blatently simple solution.  Thanks!
---------------------------------------------------------------------
    jfrench@cssuN.tamu.edu       Jeff French        "Gig-Em Aggies"
---------------------------------------------------------------------

neal@mnopltd.UUCP (02/05/90)

->
->
->Does my Xenix '286 ver. 2.1.1 have a "clear screen" funtion that I am
->overlooking? Under MS/DOS the command is "cls", and on SunOS it's "clear".
->
->I have RTFM 'till I'm blue in the face. Any suggestions would be appreciated.
->

try 'tput clear'... wasn't that obvious?...



------------------------------------------------------------------------------
Neal Rhodes                       MNOP Ltd                     (404)- 972-5430
President                Lilburn (atlanta) GA 30247             Fax:  978-4741
       uunet!emory!jdyx!mnopltd!neal Or uunet!gatech!stiatl!mnopltd!neal
------------------------------------------------------------------------------

jfrench@photon.tamu.edu (Jeff French) (02/06/90)

In article <153@mnopltd.UUCP> gatech!stiatl!mnopltd!neal writes:
>
>->Does my Xenix '286 ver. 2.1.1 have a "clear screen" funtion that I am
>->overlooking? Under MS/DOS the command is "cls", and on SunOS it's "clear".
>->
>->I have RTFM 'till I'm blue in the face. Any suggestions would be appreciated.
>
>try 'tput clear'... wasn't that obvious?...
>
As the originator of this thread, I would like to thank all those that
responded. Each of the solutions were the same as the one suggested above.
The problem is that ver 2.1.1 doesn't support "tput". It is not an option
from the command line of any shell I've tried. 

The closest thing to it is "tputs", which can be used as a termcap entry.
It is not available as an external command. Am I missing something here?

---------------------------------------------------------------------
    jfrench@cssuN.tamu.edu       Jeff French        "Gig-Em Aggies"
---------------------------------------------------------------------

daveh@marob.masa.com (Dave Hammond) (02/07/90)

In article <4185@helios.TAMU.EDU> jfrench@photon.UUCP (Jeff French) writes:
>In article <153@mnopltd.UUCP> gatech!stiatl!mnopltd!neal writes:
>>->Does my Xenix '286 ver. 2.1.1 have a "clear screen" funtion that I am
>>->overlooking? Under MS/DOS the command is "cls", and on SunOS it's "clear".
>>try 'tput clear'... wasn't that obvious?...
>The problem is that ver 2.1.1 doesn't support "tput". It is not an option
>from the command line of any shell I've tried. 

On the console screen only, you can echo a Control-L to clear the screen
and move the cursor home.

Alternatively, on the console and other ANSI terminals (vt100, vt220, ...)
you can echo the 6 char sequence ESC [ H ESC [ J to clear the screen
and move the cursor home.

--
Dave Hammond
daveh@marob.masa.com
uunet!masa.com!marob!daveh

scott@bbxsda.UUCP (Scott Amspoker) (02/08/90)

In article <25CFA32B.1493@marob.masa.com> daveh@marob.masa.com (Dave Hammond) writes:
>In article <4185@helios.TAMU.EDU> jfrench@photon.UUCP (Jeff French) writes:
>>In article <153@mnopltd.UUCP> gatech!stiatl!mnopltd!neal writes:
>>>->Does my Xenix '286 ver. 2.1.1 have a "clear screen" funtion that I am
>>>->overlooking? Under MS/DOS the command is "cls", and on SunOS it's "clear".
>>>try 'tput clear'... wasn't that obvious?...
>>The problem is that ver 2.1.1 doesn't support "tput". It is not an option
>>from the command line of any shell I've tried. 
>
>On the console screen only, you can echo a Control-L to clear the screen
>and move the cursor home.

Well, I'm sitting here with a Xenix 386 ver 2.3.1 and it has a 'clear'
command that works just fine.

-- 
Scott Amspoker
Basis International, Albuquerque, NM
(505) 345-5232
unmvax.cs.unm.edu!bbx!bbxsda!scott

pf@artcom0.uucp (Peter Funk) (02/08/90)

Im Artikel <4185@helios.TAMU.EDU>, schreibt jfrench@photon.tamu.edu (Jeff French):
] In article <153@mnopltd.UUCP> gatech!stiatl!mnopltd!neal writes:
] >
] >->Does my Xenix '286 ver. 2.1.1 have a "clear screen" funtion that I am
] >->overlooking? Under MS/DOS the command is "cls", and on SunOS it's "clear".

Please try :
	/bin/echo '\014\c'
This should work almost everywhere. (May be even in the USSR ;-))
-->
Peter Funk  / ArtCom GmbH, Schwachhauser Heerstr. 78, D-2800 Bremen 1
Work at home/ Oldenburger Str.86, D-2875 Ganderkesee 1 /+49 4222 6018 (8am-6pm)

daveh@marob.masa.com (Dave Hammond) (02/08/90)

In article <601@bbxsda.UUCP> scott@bbxsda.UUCP (Scott Amspoker) writes:
>In article <25CFA32B.1493@marob.masa.com> daveh@marob.masa.com  writes:
>>In article <4185@helios.TAMU.EDU> jfrench@photon.UUCP (Jeff French) writes:
>>>Does my Xenix '286 ver. 2.1.1 have a "clear screen" funtion that I am
		  ^^^^^^^^^^^^^^^^^^^^^
>>>overlooking? Under MS/DOS the command is "cls", and on SunOS it's "clear".
>>On the console screen only, you can echo a Control-L to clear the screen
>>and move the cursor home.
>Well, I'm sitting here with a Xenix 386 ver 2.3.1 and it has a 'clear'
>command that works just fine.

As does mine.  Unfortunately, the original poster has Xenix 286 version
2.1.1 which does not have a 'clear' command (as he stated above).

barton@holston.UUCP (Barton A. Fisk) (02/09/90)

In article <25CFA32B.1493@marob.masa.com>, daveh@marob.masa.com (Dave Hammond) writes:
> In article <4185@helios.TAMU.EDU> jfrench@photon.UUCP (Jeff French) writes:
> >In article <153@mnopltd.UUCP> gatech!stiatl!mnopltd!neal writes:
> Alternatively, on the console and other ANSI terminals (vt100, vt220, ...)
> you can echo the 6 char sequence ESC [ H ESC [ J to clear the screen
> and move the cursor home.
> 
On the ansi console it's easier to just enter echo "\f\c". This
can be put into a script called clear in /usr/bin and
should clear the screen and move the cursor home. I used this on
my old version of xenix 2.1.
-- 
Barton A. Fisk          | UUCP: {attctc,texbell}vector!holston!barton
PO Box 1781             | (PSEUDO) DOMAIN: barton@holston.UUCP     
Lake Charles, La. 70602 | ----------------------------------------
318-439-5984            | "Let him who is without sin cast the first stone"-JC

brothers@jetsun.WEITEK.COM (bill brothers) (02/09/90)

In article <4174@helios.TAMU.EDU> jfrench@cssuN.tamu.edu (Jeff French) writes:
>
>Does my Xenix '286 ver. 2.1.1 have a "clear screen" funtion that I am
>overlooking? Under MS/DOS the command is "cls", and on SunOS it's "clear".
>
>Currently I have a script that cats an empty file to the screen. This works
>but leaves the cursor in the lower left hand corner of the screen.
>
>I have RTFM 'till I'm blue in the face. Any suggestions would be appreciated.
>
>Please excuse my ignorance if their is a blatently simple solution.  Thanks!
>---------------------------------------------------------------------
>    jfrench@cssuN.tamu.edu       Jeff French        "Gig-Em Aggies"
>---------------------------------------------------------------------
Jeff,
couldn't make my mailer talk to you... Here is a quick pgm to fix your
problem. clear wasn't shipped on XENIX until 2.2...


extern char *getenv();
extern char *tgetstr();

main()
{
	char buf[1024], a[1024], *area;
	area = a;

	tgetent( buf, getenv("TERM") );
	printf("%s", tgetstr("cl", &area) );
}

Bill
brothers@weitek.COM

brad@microm.UUCP (Bradley W. Fisher) (02/10/90)

In article <25CFA32B.1493@marob.masa.com>, daveh@marob.masa.com (Dave Hammond) writes:
> 
> On the console screen only, you can echo a Control-L to clear the screen
> and move the cursor home.
> 
> Alternatively, on the console and other ANSI terminals (vt100, vt220, ...)
> you can echo the 6 char sequence ESC [ H ESC [ J to clear the screen
> and move the cursor home.

echo "\f"  works too if your TERM variable is set right.
------------------------------------------------------------------------------
I'm just a wanna be UNIX guru (IJWBUG)               | Micro Maintenance, Inc.
						     | 2465 W. 12th St. #6
	   -== Brad Fisher ==- 		             | Tempe, Arizona  85281
     ...!asuvax!mcdphx!hrc!microm		     | 602/894-5526
------------------------------------------------------------------------------

staceyc@sco.COM (Stacey Campbell) (02/13/90)

In article <5677@holston.UUCP> barton@holston.UUCP (Barton A. Fisk) writes:
>On the ansi console it's easier to just enter echo "\f\c". This
>can be put into a script called clear in /usr/bin and
>should clear the screen and move the cursor home.

A more portable version of clear can be implemented with the following
very short C program.

#include <curses.h>

main()

{
	initscr();
	wclear(stdscr);
	wrefresh(stdscr);
	endwin();
}

Compile under Xenix with;

cc clear.c -o clear -lcurses -ltermlib

Many curses implementations will find a way to clear the screen even
if that particular capability is not directly supported by the terminal.
-- 
Stacey Campbell                                             _--_|\
{uunet,ucscc,decwrl,att,microsoft,wyse}!sco!staceyc        /      \
staceyc@sco.com                                            \_.--._/
                                                                 v

brothers@jetsun.WEITEK.COM (bill brothers) (02/14/90)

In article <251@microm.UUCP> brad@microm.UUCP (Bradley W. Fisher) writes:
>In article <25CFA32B.1493@marob.masa.com>, daveh@marob.masa.com (Dave Hammond) writes:
>> 
>> On the console screen only, you can echo a Control-L to clear the screen
>> and move the cursor home.
>> 
>> Alternatively, on the console and other ANSI terminals (vt100, vt220, ...)
>> you can echo the 6 char sequence ESC [ H ESC [ J to clear the screen
>> and move the cursor home.

The "right :*) way is using termcap/info"... Here is a bitty  pgm for
that...



extern char *getenv();
extern char *tgetstr();

main()
{
	char buf[1024], a[1024], *area;
	area = a;

	tgetent( buf, getenv("TERM") );
	printf("%s", tgetstr("cl", &area) );
}


There but the grace of god go i...

Bill
brothers@weitek.com

paul@devon.lns.pa.us (Paul Sutcliffe Jr.) (02/16/90)

In article <873@jetsun.WEITEK.COM> brothers@jetsun.WEITEK.COM (bill brothers)
writes:
+---------
| >> On the console screen only, you can echo a Control-L to clear the screen
| >> and move the cursor home.
| >> 
| >> Alternatively, on the console and other ANSI terminals (vt100, vt220, ...)
| >> you can echo the 6 char sequence ESC [ H ESC [ J to clear the screen
| >> and move the cursor home.
| 
| The "right :*) way is using termcap/info"... Here is a bitty  pgm for
| that...
+---------

You're correct, the "right" way is termcap/terminfo.  However, you've
implemented it the *WRONG* *WAY* in your example:

+---------
| extern char *getenv();
| extern char *tgetstr();
| 
| main()
| {
| 	char buf[1024], a[1024], *area;
| 	area = a;
| 
| 	tgetent( buf, getenv("TERM") );
| 	printf("%s", tgetstr("cl", &area) );
| }
+---------
First, tgetstr doesn't decode any cursor addressing and/or padding
information defined in the termcap entry -- read the manual page!  
Second, you've used printf, which calls the whole stdio library
into your object, and which won't properly handle the padding returned
by tgetstr.  The string returned from tgetstr should be handed to
tputs() -- again, read the manual page!

Here's a *much better* solution; it doesn't use stdio, uses tgetstr
correctly, and even does proper error checking:

----- 8< ---------- 8< ---------- 8< ---------- 8< ---------- 8< -----
/*
 *	clear.c  -  clear crt screen
 *
 *	compile me by saying:  cc -O -s -o o clear clear.c -ltermlib
 */

#define	BUFSIZE	1024
#define	NULL	0

char	termcap[BUFSIZE], buffer[BUFSIZE];
int	outc();

main()
{
	char	*getenv(), *tgetstr();
	char	*term, *bptr;

	bptr = buffer;

	if ((term = getenv("TERM")) != (char *) NULL)
		if (tgetent(termcap, term) > 0)
			if (tgetstr("cl", &bptr) != (char *) NULL)
				tputs(buffer, 1, outc);
}

outc(ch)
char	ch;
{
	write(1, &ch, 1);	/* write ch on stdout */
}
----- 8< ---------- 8< ---------- 8< ---------- 8< ---------- 8< -----

Ghod, I even saw someone post a solution that used *curses*!  How big
was that binary anyway?

- paul

INTERNET:  paul@devon.lns.pa.us        |      If life's a bitch, then
UUCP:      ...!rutgers!devon!paul      |      we must be her puppies.

staceyc@sco.COM (Stacey Campbell) (02/17/90)

In article <1990Feb15.234804.26734@devon.lns.pa.us> paul@devon.LNS.PA.US (Paul Sutcliffe Jr.) writes:
>Ghod, I even saw someone post a solution that used *curses*!  How big
>was that binary anyway?

The stripped binary of that program is 31000 bytes, the stripped binary
of the program you have suggested is 14700 bytes.  The extra 16K bytes
does provide extra functionality.  The curses version will make an effort
to clear the screen even if the terminal does not support this in the
hardware.  If you don't need this functionality and you very much need
the extra 16K then the choice is clear.
-- 
Stacey Campbell                                             _--_|\
{uunet,ucscc,decwrl,att,microsoft,wyse}!sco!staceyc        /      \
staceyc@sco.com                                            \_.--._/
                                                                 v