From: Glynn Clements <glynn@gclements.plus.com>
To: kaushal@rocsys.com
Cc: linux-c <linux-c-programming@vger.kernel.org>
Subject: Re: clear the screen
Date: Wed, 23 Feb 2005 00:16:52 +0000 [thread overview]
Message-ID: <16923.52084.408249.817998@gargle.gargle.HOWL> (raw)
In-Reply-To: <1108969688.5088.12.camel@localhost.localdomain>
kaushal wrote:
> Sorry for a very basic question.I would like to know how to clear the
> screen from within a c program without using system("clear") or any of
> the ncurses functions.Can we do this using printf?My program is in raw
> mode so is there any feature available by which I can use the termios
> structure for clearing the screen if it is not possible with printf.Long
> ago when I used work in the dos platform I used conio.h and clrscr()
> rourine.I guess I have to write that clrscr() routine's code itself.Im
> working on a linux machine now.
Unix systems don't have a "screen", they have terminals. Historically,
these would be physical terminals (e.g. vt220s) connected via serial
ports. The Linux kernel uses the keyboard and the graphics card's text
mode to emulate a number of terminals, as well as supporting physical
terminals connected to a serial port (either directly or via modems)
and pseudo-terminals (used by programs which emulate terminals, e.g.
telnetd, xterm, screen etc).
To clear the terminal's screen (assuming that it's a video terminal;
hardcopy terminals don't have a screen), you have to send the
appropriate control sequence. The exact sequence depends upon the type
of terminal (which can be determined from the value of the TERM
environment variable).
To obtain the correct control sequence, use the terminfo library to
obtain the sequence for the "clear" capability, then send that
sequence to the terminal (i.e. stdout).
See the manpage for setupterm() and tigetstr() for more information.
--
Glynn Clements <glynn@gclements.plus.com>
next prev parent reply other threads:[~2005-02-23 0:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-21 7:08 clear the screen kaushal
2005-02-21 7:59 ` J.
2005-02-21 9:56 ` Vinodkumar Nair
2005-02-21 10:12 ` YYW
2005-02-21 13:50 ` Darren Sessions
2005-02-21 14:15 ` Ron Michael Khu
2005-02-23 0:16 ` Glynn Clements [this message]
2005-02-23 12:54 ` Progga
2005-02-28 6:36 ` Glynn Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16923.52084.408249.817998@gargle.gargle.HOWL \
--to=glynn@gclements.plus.com \
--cc=kaushal@rocsys.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).