[erlang-questions] erlang-questions Digest, Vol 24, Issue 15

Johnny Billquist <>
Mon May 4 20:07:02 CEST 2009


John Haugeland wrote:
> 
>      > i want to clean the erlang cosole.and want to position the cursor
>      > to the top left hand cornet of the console.I went trough the c
>      > module on erlang but still i cudnt find a way to clear the screen.
>      > can anybody let me know hw to clean the erlang screen.
> 
>     This is not really an erlang question. Console implementations
>     differ in their control codes.
> 
> 
> Nonsense.  The erlang console is not an OS console.  If you need any 
> proof, just try to do nearly any of the things your OS console lets you 
> do; the Erlang console doesn't do almost any of them.
> 
> There is a rich history on this mailing list of people editing their 
> console to get it to do things that it doesn't currently do because it's 
> rudimentary, such as color output, correct work with macros, 
> parameterized modules and so on.  Don't tell someone that something 
> isn't an erlang question just because you don't know how to do 
> something.  This is something that a person can do without ever writing 
> non-Erlang code, working entirely in the Erlang codebase.
> 
> This is absolutely an Erlang question.  Much, much moreso than half the 
> stuff that goes through this mailing list, talking about people's 
> projects and companies and talking endlessly about Lisp, Hakell, Prolog, 
> complaining about C++ and back-patting each other about how awful OO is 
> when Erlang is a clearly OO language.  The "This isn't the right place" 
> argument doesn't work on this list even when it's correct.  Don't shoot 
> other people's questions down like this.

Sorry, but the original answer was absolutely correct. You just don't 
know at all what you are talking about. And going on a rant about it 
don't change that.

Even getting colors is something that is totally dependant on what kind 
of terminal (yes, *terminal*) you have. Using a window on a windowing 
system (such as Microsoft Windows or X-windows, or whatever) means that 
you have a terminal program running, which do the actual visualization.

*Erlang is in no way involved with this.*

However, almost all terminal programs have some way of controlling them, 
and thus cause visual effects. The exact way you get the terminal 
program to present the visual effects you want is possibly unique for 
that terminal program. And it is still totally outside of Erlang.
All that being said, there is an ANSI standard, which many terminal 
programs implement, which means that if your terminal program follows 
this standard, the way to get the wanted effects are well known, and can 
probably be answered by a whole bunch of people reading this list.
But this is still a question of how to control a terminal, and not a 
question about Erlang. But even so, we don't even know what kind of 
terminal the original posted is using, so we can't even make a proper 
answer based on that standard, because it might very well not be 
something that will work for him.

Sorry, but you uninformed reply really pissed me off. Uninformed people 
are not a problem. We all have to learn somehow, someway, at some point.
But making totally bogus claims, and trying to shoot down someone who 
gives a correct answer is just plain wrong. *First* you learn the topic, 
*then* you answer. Not the other way around.

To make things clear, exactly this same question pops up in all kind of 
mailing lists, for all kind of subjects. And for some totally unkown 
reason (to me), you think that it is Erlang that should have the answer. 
Geez. Maybe I should direct all the people on NetBSD-current here as 
well, when they pop this question.


And, as a friendly gnome, I'll provide the answer for when he really is 
using a terminal that is ANSI compliant:

To clear the screen, you send the sequence
CSI n J

And to move the cursor, you send the sequence
CSI y ; x H

CSI is an eight bit character, with the octal code of 233. A seven bit 
replacement is the string ESC [.
The n argument in the CSI n J sequence can be:
0 - Clear from cursor to end of screen
1 - Clear from beginning of screen to cursor
2 - Clear whole screen

The default, if no argument is given, is 0.

The cursor movement have 1,1 as the top left corner. If the arguments 
are omitted, it is the same as moving to (1,1)

So, by sending the sequence CSI H CSI J, you'll move the cursor to the 
top left, and clear the screen.
With seven bit controls, you'd send ESC [ H ESC [ J

Note that I have a space between each character sent, for readability. 
CSI(233) is one character, so is ESC(33).

I could go on for quite a while about this, but maybe you should read a 
manual instead?

And this is still totally not related to Erlang, and you'd send the same 
control sequence if your program was written in C, Perl, Haskell, Lisp, 
Prolog, Assembler, Basic, Pascal, FORTRAN, Cobol, Snobol, Algol, Dibol, 
Focal, Python, Java, or God knows what else, if your *terminal* was ANSI 
compliant.
If that shouldn't make it obvious to you that it is not related to the 
language, but to the terminal, then I don't know what would.

Now, if the question instead would have been "how do I create a CSI H 
CSI J string in Erlang?", then we're in business.

	Johnny

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email:              ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol



More information about the erlang-questions mailing list