08-01-2002
Curses is a subsystem (library) for managing character screens. Using it involves more than just calling the clear-screen function. You have to initialize it, etc.
From your question, it isn't clear to me that you are using Curses. If you want to, that's a study in itself, and there are several books on the subject, and probably some tutorials you can find on the web.
Aside from Curses, there is no standard way to clear the screen, or even to treat the terminal AS a screen. Standard C assume that the terminal is a line-at-a-time device.
10 More Discussions You Might Find Interesting
1. Programming
I searched the post and someone said to clear the screen in C, use
printf("\033[2J"); ??
However, this doesn't work...typo or no.
What is an equivalent command to 'CLS' in DOS/'clear' in UNIX to clear the screen and go to top of screen??
Thank you. (2 Replies)
Discussion started by: giannicello
2 Replies
2. Programming
How do I clear screen in g++
I've included curses and tried compile with lcurses as per gcc but fails, I can clear by using system("clear") but would prefer to use the curses library if possible. (2 Replies)
Discussion started by: gefa
2 Replies
3. Shell Programming and Scripting
Hello guys,
I wonder if it is possible to clear out the screen in AWK.
I'm printing out mail messages and I would like every message starting on the beginning of the screen. When I use FOR loop and printf("\n") it clears out the screen but my text is somewhere in the middle of the screen.
... (2 Replies)
Discussion started by: petoSVK
2 Replies
4. Programming
hi ,
Could any one tell me the command for clearing the screen in GDB session (1 Reply)
Discussion started by: useless79
1 Replies
5. UNIX for Dummies Questions & Answers
Hi...
i have one doubt pls...
1)can we clear the command line history in UNIX for a paricular login(scadm/root)if so how?.
2) can we see the time at which command executed.
history is showing like :
100 display
101 lock
102 exit (7 Replies)
Discussion started by: gincemathew
7 Replies
6. OS X (Apple)
Hi,
I'm trying to create a virtual screen, (maybe xvfb? or any other virtual screen buffer) and be able to use Screen Sharing to connect to it.
The setup is that I have a Mac Mini connected to the TV. But when my girlfriend is using Front Row, I can't use Screen Sharing at the same time from... (0 Replies)
Discussion started by: linge
0 Replies
7. Shell Programming and Scripting
I am unable to use clear or cls command on bash shell. I have recently installed Cygwin and am using that for practicing unix commands.
I see that I can use Ctrl + L to clear the screen. I created an alias in my .bashrc to do the same as
alias cls='^L'
This is how i defined other aliases ... (4 Replies)
Discussion started by: erora
4 Replies
8. Red Hat
Hi,
I have a simple question : how to disable screen lock and/or sreen saver with command line with RHEL5.4 ? (1 Reply)
Discussion started by: albator1932
1 Replies
9. UNIX for Dummies Questions & Answers
I made a screen within a screen.
Is there a way to move the inner screen up one level so that it is at the same level as the first screen running from the shell? (2 Replies)
Discussion started by: phpchick
2 Replies
10. Shell Programming and Scripting
I want to clear specific part of the screen. Say for example , i am running a bash script
for i in {1..100}
do
echo "Current Record = $i"
done
if i use a clear command over there , it will clear my screen however when i scroll up i would have the old records , is there anyway in unix to... (5 Replies)
Discussion started by: chidori
5 Replies
LEARN ABOUT NETBSD
newterm
CURSES_SCREEN(3) BSD Library Functions Manual CURSES_SCREEN(3)
NAME
curses_screen, newterm, set_term, delscreen, endwin, initscr, isendwin, resizeterm, setterm -- curses terminal and screen routines
LIBRARY
Curses Library (libcurses, -lcurses)
SYNOPSIS
#include <curses.h>
SCREEN *
newterm(char *type, FILE *outfd, FILE *infd);
SCREEN *
set_term(SCREEN *screen);
void
delscreen(SCREEN *screen);
int
endwin(void);
WINDOW *
initscr(void);
bool
isendwin(void);
int
resizeterm(int lines, int cols);
int
setterm(char *name);
extern int LINES;
extern int COLS;
DESCRIPTION
These functions initialize terminals and screens.
The newterm() function initialises the curses data structures and pointers ready for use by curses. The type argument points to a termcap(5)
capability name, or it may be NULL in which case the TERM environment variable is used. The outfd and infd are the output and input file
descriptors for the terminal. The newterm() function must only be called once per terminal.
The set_term() function can be used to switch between the screens defined by calling newterm(), a pointer to the previous screen structure
that was in use will be returned on success.
Calling delscreen() will destroy the given screen and free all allocated resources.
Calling endwin() will end the curses session and restore the saved terminal settings.
The curses session must be initialised by calling initscr() which saves the current terminal state and sets up the terminal and internal data
structures to support the curses application. This function call must be, with few exceptions, the first Curses library call made. The
exception to this rule is the newterm() call which may be called prior to initscr(). The size of the curses screen is determined by checking
the tty(4) size and then the termcap(5) entries for the terminal type. If the environment variables LINES or COLS are set, then these will
be used instead.
When either newterm() or initscr() are called, the Curses library sets up signal handlers for SIGTSTP and SIGWINCH. If a signal handler is
already installed for SIGWINCH, this will also be called when the Curses library handler is called.
The isendwin() function can be used to determine whether or not a refresh of the screen has occurred since the last call to endwin().
The size of the screen may be changed by calling resizeterm() with the updated number of lines and columns. This will resize the curses
internal data structures to accommodate the changed terminal geometry. The curscr and stdscr windows and any of their subwindows will be
resized to fit the new screen size. The application must redraw the screen after a call to resizeterm().
The setterm() function sets the terminal type for the current screen to the one passed, initialising all the curses internal data structures
with information related to the named terminal. The name argument must be a valid name or alias in the termcap(5) database for this function
to succeed.
RETURN VALUES
Functions returning pointers will return NULL if an error is detected. The functions that return an int will return one of the following
values:
OK The function completed successfully.
ERR An error occurred in the function.
SEE ALSO
curses_window(3), tty(4), termcap(5), signal(7)
STANDARDS
The NetBSD Curses library complies with the X/Open Curses specification, part of the Single Unix Specification.
HISTORY
The Curses package appeared in 4.0BSD. The resizeterm() function is a ncurses extension to the Curses library and was added in NetBSD 1.6.
BSD
October 24, 2007 BSD