468,505 Members | 1,938 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

I want to clear a portion of screen - How??

I just want to clear the above three lines from the current position,
so that I can start printing my results from that point. In short I
want to clear a portion of my screen.

Note: I work in the UNIX environment using gcc compiler. And I'm not a
super user.

I want a "simple solution".

I tried the combination of "\r\b" escape sequences. But \b is not
taking me back to the above line?
I urgently need the key for this.
Please help me achieving this.

I daily visit my topic to see whether I got the answer or not!
Thank you.

Sep 2 '06 #1
11 4708
Rajendran said:
I just want to clear the above three lines from the current position,
so that I can start printing my results from that point. In short I
want to clear a portion of my screen.

Note: I work in the UNIX environment using gcc compiler. And I'm not a
super user.
Standard C has no solution to your problem. (Standard C does not offer
full-screen addressing.)

I suggest you ask your question in comp.unix.programmer where (I trust) the
experts there will be able to offer you a platform-specific solution.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 2 '06 #2
Rajendran wrote:
I just want to clear the above three lines from the current position,
so that I can start printing my results from that point. In short I
want to clear a portion of my screen.
See question 19.4 in the FAQ: http://www.c-faq.com
Note: I work in the UNIX environment using gcc compiler. And I'm not a
super user.
comp.unix.programmer is your friend.
I want a "simple solution".
The (n)curses library is pretty simple. There's probably not much to gain
from even simpler solutions, since they won't transfer to other platforms,
and learning them is a waste of time.
I tried the combination of "\r\b" escape sequences. But \b is not
taking me back to the above line?
\b is backspace, which "moves the active position to the previous position
on the current line. If the active position is at the initial position of a
line, the behavior of the display device is unspecified." In other words,
you can't use backspace that way and expect it to work.

S.
Sep 2 '06 #3
Rajendran said the following, on 09/02/06 03:00:
I just want to clear the above three lines from the current position,
so that I can start printing my results from that point. In short I
want to clear a portion of my screen.
The C language has no standard facilities dealing with the "screen", and
not all implementations have anything that could be so described.
Please have a look at the FAQ, <http://www.c-faq.com/>, especially
Section 19, "System Dependencies".
Note: I work in the UNIX environment using gcc compiler. And I'm not a
super user.

I want a "simple solution".
A better place to post this question would be comp.unix.programmer.

[OT]
In a Unix/Linux environment, your best bet is probably to use
screen-handling tools contained in the 'ncurses(3)' package. They are
pretty simple to use, and will allow your program to work with a wide
range of display devices.
[/OT]

--
Rich Gibbs
ri*****@gmail.com
"You can observe a lot by watching." -- Yogi Berra

Sep 2 '06 #4
I'm not quite sure about this, but google for an implementation of
"conio.h" header file, and find the implementation for function
clearScreen() or something like that, it should look something like:
printf("03[4[/j/r"); // roughly to give an idea about how strange it
is!
you might do the thing by a bit of hacking into this code.
but still, comp.unix.programmer is your friend!

Sep 3 '06 #5
Peyman said:
I'm not quite sure about this, but google for an implementation of
"conio.h" header file,
That advice is not going to do him any good. The probability of there being
a <conio.hheader on his Unix system is vanishingly small, and the
probability that it is useful to him is even smaller.

<snip>
but still, comp.unix.programmer is your friend!
That advice, however, works fine.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 3 '06 #6
Thanks to all of you!
I already posted this question as you said - on unix.progammer

Finally I started learning ncurses but the example programmes are
giving strange results on my screen. Anyhow ncurses is interesting.

Anyway I "still welcome" your solutions

Sep 3 '06 #7
Hello Peyman,
could you please give me any websites relating to this.
what does /j do? I started searching the net. Reply me.
Thank you.
-Rajen
Peyman wrote:
I'm not quite sure about this, but google for an implementation of
"conio.h" header file, and find the implementation for function
clearScreen() or something like that, it should look something like:
printf("03[4[/j/r"); // roughly to give an idea about how strange it
is!
you might do the thing by a bit of hacking into this code.
but still, comp.unix.programmer is your friend!
Sep 3 '06 #8

"Rajen" <ra*****@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hello Peyman,
could you please give me any websites relating to this.
what does /j do? I started searching the net. Reply me.
Thank you.
-Rajen
Peyman wrote:
>I'm not quite sure about this, but google for an implementation of
"conio.h" header file, and find the implementation for function
clearScreen() or something like that, it should look something like:
printf("03[4[/j/r"); // roughly to give an idea about how strange it
is!
you might do the thing by a bit of hacking into this code.
but still, comp.unix.programmer is your friend!
The answer to clearing the screen is to use whatever function
your compiler vendor supplied. If the compiler was meant for
regular computer use it probably has a function - but it is off topic
for this group. RTFM

Ignoring that advice, make sure you have and ANSI screen driver
installed, and look up the codes for it. I went back to MSDOS 4
document. The driver is ANSI.SYS. All the codes start with
an escape character, aka, octal 033, decimal 27 or hex 1B.
Clear the screen is escape [2J so printing that should clear the screen.
puts("033[2J");
I suspect the previous poster worked from memory ( "something like").

------------- W H G

Sep 3 '06 #9
Thanks WHG,
What does RTFM Mean? I came to know the esacpe sequences and I'm
comfortable with them.
esc[4A - Takes the cursor four lines up from current postion
esc[#B - " # lines down "
esc[#C - # columns forward
esc[#D #columns backward
-----------------------------------------------------------------
W H G wrote:
The answer to clearing the screen is to use whatever function
your compiler vendor supplied. If the compiler was meant for
regular computer use it probably has a function - but it is off topic
for this group. RTFM

Ignoring that advice, make sure you have and ANSI screen driver
installed, and look up the codes for it. I went back to MSDOS 4
document. The driver is ANSI.SYS. All the codes start with
an escape character, aka, octal 033, decimal 27 or hex 1B.
Clear the screen is escape [2J so printing that should clear the screen.
puts("033[2J");
I suspect the previous poster worked from memory ( "something like").

------------- W H G
Sep 4 '06 #10
Op 4 Sep 2006 05:07:10 -0700 schreef Rajen:
Thanks WHG,
What does RTFM Mean? I came to know the esacpe sequences and I'm
http://www.acronymfinder.com/
--
Coos
Sep 4 '06 #11

W H G wrote:
"Rajen" <ra*****@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hello Peyman,
could you please give me any websites relating to this.
what does /j do? I started searching the net. Reply me.
Thank you.
-Rajen
Peyman wrote:
I'm not quite sure about this, but google for an implementation of
"conio.h" header file, and find the implementation for function
clearScreen() or something like that, it should look something like:
printf("03[4[/j/r"); // roughly to give an idea about how strange it
is!
you might do the thing by a bit of hacking into this code.
but still, comp.unix.programmer is your friend!

The answer to clearing the screen is to use whatever function
your compiler vendor supplied. If the compiler was meant for
regular computer use it probably has a function - but it is off topic
for this group. RTFM

Ignoring that advice, make sure you have and ANSI screen driver
installed, and look up the codes for it. I went back to MSDOS 4
document. The driver is ANSI.SYS. All the codes start with
an escape character, aka, octal 033, decimal 27 or hex 1B.
Clear the screen is escape [2J so printing that should clear the screen.
puts("033[2J");
I suspect the previous poster worked from memory ( "something like").
Yes, exactly, thank you for correcting me, what I meant was:
printf("033[2J");
or as you said, it can be:
puts("033[2J");
>
------------- W H G
Sep 4 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Dave | last post: by
6 posts views Thread by jcollins | last post: by
18 posts views Thread by Tim Mierzejewski | last post: by
6 posts views Thread by KL | last post: by
20 posts views Thread by ritchie | last post: by
reply views Thread by sajithamol | last post: by
3 posts views Thread by gieforce | last post: by
reply views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.