Page 1 of 1

clear a LXTerminal window

Posted: Sun May 15, 2016 7:50 pm
by davenull
hello,
is it possible to clear a LXTerminal window before starting to write anew?

Re: clear a LXTerminal window

Posted: Sun May 15, 2016 8:14 pm
by jahboater
From the shell, the command "clear" clears the screen (see man clear).

From curses in a C program, use clear() or erase().

Re: clear a LXTerminal window

Posted: Sun May 15, 2016 8:23 pm
by davenull
hmm, I'm not using curses, just the normal LXterminal window opened as stdout for printf(), but perhaps
system("clear");
would work then in a C program...

Already a little late now, my Pi robot is off, but I'll try it tomorrow then ASAP :)

Re: clear a LXTerminal window

Posted: Sun May 15, 2016 8:24 pm
by jojopi
The escape sequence "\033[2J" clears the whole visible window without moving the cursor, and "\033[H" homes the cursor to the top left.

Again I recommend http://rtfm.etla.org/xterm/ctlseq.html as a guide to the sequences understood by xterm. Let us know if there is terminology there that you do not understand. In a C string, "\033" is the ASCII ESC character, and note that CSI is often used to mean "\033[".

The exact repertoire of escape sequences will vary between terminal emulators. Libraries such as ncurses can make your program terminal-independent, but that is not as important these days. xterm is something of a standard.

Re: clear a LXTerminal window

Posted: Sun May 15, 2016 8:27 pm
by davenull
yes, thank you, but that is faaaar toooo muchhhh to read!
( actually I do not even know where to start to read over there!) O.o

But this is fine:
"\033[2J" clears the whole visible window without moving the cursor
and the other one
and "\033[H" homes the cursor to the top left.
I am already using 8-)

thank you very much for your help! :)

Re: clear a LXTerminal window

Posted: Mon May 16, 2016 8:16 am
by davenull
update:
"\033[2J" clears the whole visible window without moving the cursor
I tested it and everything works like a charm! 8-)

thanks again very much! :)