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

Re: clearing the console



In article <955162012.713202@clint.waikato.ac.nz>, "Matthew Luckie"
<kluckie@ihug.co.nz> wrote:

> Hi there
> 
> I am writing some code that shows a board to the user each iteration through
> a loop.
> I want this board to appear at the top of the console each time.
> How do i clear the console screen in dylan so this happens?
> 
> In c, the function that achieved this (from memory) was clrscr() although i
> cannot find any reference to that call in my documentation so i might be
> false.

This depends on your operating system environment, not on Dylan.  On some
systems this might work by printing a form feed (control-J,
as(<character>, 12)) while on others it is something different.

In a telnet session to my Linux machine I just tried:

   $ clear >mmm

... and edited the file "mmm" in hexile mode in emacs and it contained...

   <esc>[H<esc>[J

This makes sense for an ANSI terminal, and indeed "echo $TERM" says "vt102".

You can print this sequence in Dylan using:

   format-out("\<1B>[H\<1B>[J");


On the other hand, in an Xterm "clear" produces <esc>[H<esc>[2J.  No doubt
in other sorts of terminals it will produce other sequences.  In order to
do it correctly on Unix you need to use the terminfo/curses stuff.  Or
something else if you're not using Unix...

-- Bruce



Follow-Ups: References: