Screen Editing

S

someone

I was just wondering if there is any way of editing anything already
printed on the screen with out using the system("cls") command.
 
C

Christopher Benson-Manica

someone said:
I was just wondering if there is any way of editing anything already
printed on the screen with out using the system("cls") command.

Not portably, since a standard-conformant implementation need not
involve anything resembling a "screen". There are a number of choices
available depending on your needs and platform, but none of them are
topical here.
 
K

Keith Thompson

someone said:
I was just wondering if there is any way of editing anything already
printed on the screen with out using the system("cls") command.

There is no portable way to do this.

The comp.lang.c FAQ is at <http://www.c-faq.com/>. You have asked
question 19.4.
 
C

Chen Shusheng

printf("\033[2J"); /* clear screen */
printf("\033[%d;%dH", 10, 20); /* move cursor (row 10, col 20) */
printf("Hello, ");
printf("\033[7mworld\033[0m!"); /* inverse video */

I tried upper commands. Seems does not work proper as the explanations.

printf("\033[2J"); display"<-2j"
...........
could anyone tell me his results?
------------------------------------------------------
 
?

=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=

Chen said:
printf("\033[2J"); /* clear screen */
printf("\033[%d;%dH", 10, 20); /* move cursor (row 10, col 20) */
printf("Hello, ");
printf("\033[7mworld\033[0m!"); /* inverse video */
flush the output, stdout might be buffered.
I tried upper commands. Seems does not work proper as the explanations.

printf("\033[2J"); display"<-2j"
..........
could anyone tell me his results?

Perhaps your output device doesn't understand these ansi escape
codes, read its documentation.
 
A

Ancient_Hacker

someone said:
I was just wondering if there is any way of editing anything already
printed on the screen with out using the system("cls") command.

There is no "C" way to do this, as C precedes most CRT terminals,

Even the few that existed back then cost about $3 to $15 THOUSAND
dollars each, and each had its own quirky control sequence for clearing
the screen. The first one I ever saw was in 1969, at a trade show,
made by Univac, and cost $15,000, retail.



and it's not clear terminal control falls under the baliwick of the C
language or th standard C libraries..


The most portable way is dorky, but works most every place I can think
of:


for( i=1; i <= 66 + 24 /* for those TALL full page displays,plus
lagniappe */; i++ )
puts( "\n" );


If your intended terminal has some alleged "ANSI" control code
capability, there's something gross, like puts( "\033;2J" ) that does
the trick, google for "termcap vt100" or ANSI and see the "cl" entry.
 
A

Andrew Smallshaw

The most portable way is dorky, but works most every place I can think
of:

for( i=1; i <= 66 + 24 /* for those TALL full page displays,plus
lagniappe */; i++ )
puts( "\n" );

If your intended terminal has some alleged "ANSI" control code
capability, there's something gross, like puts( "\033;2J" ) that does
the trick, google for "termcap vt100" or ANSI and see the "cl" entry.

Most terminals, particularly modern ones, will clear the screen if
you simply send them a formfeed. It's not guaranteed, but it's a
similar kind of assumption to backspace will move the cursor left
which seems pretty much standard these days.

I'd agree looking at the termcap manual would be a good idea, though,
at least if the OP is talking about a serial terminal or an emulation
of one.
 
M

Martin Ambuhl

Ancient_Hacker said:
There is no "C" way to do this, as C precedes most CRT terminals,

Strange. Those CRT terminals that I was using regularly for more than
10 years before C existed. In fact, the first PDP-1 of 1957 had a CRT
display (which is iconized in the DECUS logo). I used plenty of VT05s
and VT52s (the later are still 4 years before C). Even the ANSI
standard X3.64 predates the publication of K&R1, although Heath's
implementation and DEC's VT100 were not yet out at K&R1's publication date.
 
H

Herbert Rosenau

I was just wondering if there is any way of editing anything already
printed on the screen with out using the system("cls") command.
No, because C does know nothing about a screen, TTY, printer or other
devises. So you may ask in a group related to POSIX or to your OS to
get a solution beside standard C.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
 
T

Thomas Dickey

Andrew Smallshaw said:
Most terminals, particularly modern ones, will clear the screen if
you simply send them a formfeed. It's not guaranteed, but it's a

you're confused. Whether you've observed a particular terminal driver,
or a user application is probably irrelevant.
 
T

Tak-Shing Chan

you're confused. Whether you've observed a particular terminal driver,
or a user application is probably irrelevant.

I don't think Andrew is confused. I think you are.

Tak-Shing
 
T

Tak-Shing Chan

No, because C does know nothing about a screen, TTY, printer or other
devises. So you may ask in a group related to POSIX or to your OS to
get a solution beside standard C.

C does know about character display semantics (ISO 9899/1990
*and* 1999, 5.2.2), specifically backspaces ('\b'), form feeds
('\f'), and carriage returns ('\r'). So yes, it is possible to
``edit'' something already printed on a display device (however,
quality of implementation differs).

Tak-Shing
 
T

Tak-Shing Chan

There is no "C" way to do this, as C precedes most CRT terminals,

What about ISO 9899:1990, 5.2.2, where escape sequences for
display devices (such as '\f', '\b' and '\r') are defined? The
only problem with these are quality of implementation issues.

Tak-Shing
 
T

Thomas Dickey

Tak-Shing Chan said:
you're confused. Whether you've observed a particular terminal driver,
or a user application is probably irrelevant.
[/QUOTE]
I don't think Andrew is confused. I think you are.

hmm. I have a list in mind. Which "modern" one clears the screen
when you send a form-feed to it?
 
T

Thomas Dickey

hmm. I have a list in mind. Which "modern" one clears the screen
when you send a form-feed to it?

It occurs to me that you don't know
(googling to get a sense of your background makes that apparent).

A quick check shows putty doing this. vt100/etc don't. putty, of course,
is not a vt100 emulator (or xterm, etc). xterm and anything that emulates
vt100 will simply move the cursor to the next line.

There's some useful information on vt100.net which you might read before
wasting more bandwidth.

bye
 
T

Tak-Shing Chan

hmm. I have a list in mind. Which "modern" one clears the screen
when you send a form-feed to it?

Andrew wrote: ``it's not guaranteed''. Which part of ``it's
not guaranteed'' you don't understand?

Tak-Shing
 
T

Tak-Shing Chan

It occurs to me that you don't know
(googling to get a sense of your background makes that apparent).

A quick check shows putty doing this. vt100/etc don't. putty, of course,
is not a vt100 emulator (or xterm, etc). xterm and anything that emulates
vt100 will simply move the cursor to the next line.

There's some useful information on vt100.net which you might read before
wasting more bandwidth.

All irrelevant to my point. By the way, PuTTY is more
"modern" than vt100, but I suppose you are not aware of this
(judging from what you wrote above).

Tak-Shing
 
T

Thomas Dickey

Tak-Shing Chan said:
hmm. I have a list in mind. Which "modern" one clears the screen
when you send a form-feed to it?
[/QUOTE]
Andrew wrote: ``it's not guaranteed''. Which part of ``it's
not guaranteed'' you don't understand?

Indeed. You don't know the answer to my question, so you're attempting
to justify it by changing the question.
 
T

Tak-Shing Chan

Indeed. You don't know the answer to my question, so you're attempting
to justify it by changing the question.

I don't need to know the answer, since Steve Summit's C-FAQ
19.4 covered this (``for clearing the screen, a halfway portable
solution is to print a form-feed character ('\f'), which will
cause some displays to clear''). Presumably, those displays that
would clear are still in use.

Tak-Shing
 
T

Thomas Dickey

Tak-Shing Chan said:
It occurs to me that you don't know
(googling to get a sense of your background makes that apparent).

A quick check shows putty doing this. vt100/etc don't. putty, of course,
is not a vt100 emulator (or xterm, etc). xterm and anything that emulates
vt100 will simply move the cursor to the next line.

There's some useful information on vt100.net which you might read before
wasting more bandwidth.
[/QUOTE]
All irrelevant to my point. By the way, PuTTY is more
"modern" than vt100, but I suppose you are not aware of this
(judging from what you wrote above).

not at all. The statement was that

"most terminals, particularly modern ones",

fall into this category. Offhand, I know that xterm, gnome-terminal,
konsole, mlterm, rxvt (and kindred) all emulate this feature of vt100.
Even Linux console, now that I think of it.

Now again - where's your list?

I'll give a hint: one is smaller than six (even lumping together rxvt,
Eterm, aterm, wterm, mterm and rxvt-unicode). There are of course
other terminal emulators running only in Windows - but most of those
emulate vt100 reasonably well (and it's unlikely that many of them would
have such an easily observed defect). Still, you're welcome to make a
list, and (for the edification of _your_ peers), convince them that
a list of one item makes a general case.

bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top