2007-10-26 00:42:07 +04:00
|
|
|
.\" $NetBSD: curses_screen.3,v 1.14 2007/10/25 20:42:07 jdc Exp $
|
2002-10-21 17:55:12 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2002
|
2003-02-14 19:29:11 +03:00
|
|
|
.\" Brett Lymn (blymn@NetBSD.org, brett_lymn@yahoo.com.au)
|
2002-10-21 17:55:12 +04:00
|
|
|
.\"
|
|
|
|
.\" This code is donated to the NetBSD Foundation by the Author.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. The name of the Author may not be used to endorse or promote
|
|
|
|
.\" products derived from this software without specific prior written
|
|
|
|
.\" permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\"
|
2007-10-26 00:42:07 +04:00
|
|
|
.Dd October 24, 2007
|
2002-10-21 17:55:12 +04:00
|
|
|
.Dt CURSES_SCREEN 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm curses_screen ,
|
|
|
|
.Nm newterm ,
|
|
|
|
.Nm set_term ,
|
|
|
|
.Nm delscreen ,
|
|
|
|
.Nm endwin ,
|
|
|
|
.Nm initscr ,
|
|
|
|
.Nm isendwin ,
|
|
|
|
.Nm resizeterm ,
|
|
|
|
.Nm setterm
|
|
|
|
.Nd curses terminal and screen routines
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libcurses
|
|
|
|
.Sh SYNOPSIS
|
2003-04-16 17:34:34 +04:00
|
|
|
.In curses.h
|
2002-10-21 17:55:12 +04:00
|
|
|
.Ft SCREEN *
|
|
|
|
.Fn newterm "char *type" "FILE *outfd" "FILE *infd"
|
|
|
|
.Ft SCREEN *
|
|
|
|
.Fn set_term "SCREEN *screen"
|
|
|
|
.Ft void
|
|
|
|
.Fn delscreen "SCREEN *screen"
|
|
|
|
.Ft int
|
|
|
|
.Fn endwin "void"
|
2003-01-16 02:13:51 +03:00
|
|
|
.Ft WINDOW *
|
2002-10-21 17:55:12 +04:00
|
|
|
.Fn initscr "void"
|
|
|
|
.Ft bool
|
|
|
|
.Fn isendwin "void"
|
|
|
|
.Ft int
|
|
|
|
.Fn resizeterm "int lines" "int cols"
|
|
|
|
.Ft int
|
|
|
|
.Fn setterm "char *name"
|
2003-04-11 13:37:15 +04:00
|
|
|
.Pp
|
2003-04-09 01:19:15 +04:00
|
|
|
.Va extern int LINES ;
|
2003-04-11 13:37:15 +04:00
|
|
|
.Pp
|
2003-04-09 01:19:15 +04:00
|
|
|
.Va extern int COLS ;
|
2002-10-21 17:55:12 +04:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
These functions initialize terminals and screens.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn newterm
|
2004-03-16 22:25:39 +03:00
|
|
|
function initialises the curses data structures and pointers ready for
|
2002-10-21 17:55:12 +04:00
|
|
|
use by curses.
|
|
|
|
The
|
|
|
|
.Fa type
|
|
|
|
argument points to a
|
|
|
|
.Xr termcap 5
|
|
|
|
capability name, or it may be
|
|
|
|
.Dv NULL
|
|
|
|
in which case the TERM environment variable is used.
|
|
|
|
The
|
|
|
|
.Fa outfd
|
|
|
|
and
|
|
|
|
.Fa infd
|
2002-10-21 18:06:17 +04:00
|
|
|
are the output and input file descriptors for the terminal.
|
|
|
|
The
|
2002-10-21 17:55:12 +04:00
|
|
|
.Fn newterm
|
|
|
|
function must only be called once per terminal.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn set_term
|
|
|
|
function can be used to switch between the screens defined by calling
|
|
|
|
.Fn newterm ,
|
|
|
|
a pointer to the previous screen structure that was in use will be
|
|
|
|
returned on success.
|
|
|
|
.Pp
|
|
|
|
Calling
|
|
|
|
.Fn delscreen
|
|
|
|
will destroy the given screen and free all allocated resources.
|
|
|
|
.Pp
|
|
|
|
Calling
|
|
|
|
.Fn endwin
|
|
|
|
will end the curses session and restore the saved terminal settings.
|
|
|
|
.Pp
|
|
|
|
The curses session must be initialised by calling
|
|
|
|
.Fn initscr
|
|
|
|
which saves the current terminal state and sets up the terminal and
|
|
|
|
internal data structures to support the curses application.
|
|
|
|
This
|
2004-03-22 21:57:10 +03:00
|
|
|
function call must be, with few exceptions, the first Curses library
|
2002-10-21 17:55:12 +04:00
|
|
|
call made.
|
|
|
|
The exception to this rule is the
|
|
|
|
.Fn newterm
|
|
|
|
call which may be called prior to
|
|
|
|
.Fn initscr .
|
2003-04-08 22:57:09 +04:00
|
|
|
The size of the curses screen is determined by checking the
|
|
|
|
.Xr tty 4
|
|
|
|
size and then the
|
|
|
|
.Xr termcap 5
|
|
|
|
entries for the terminal type.
|
|
|
|
If the environment variables
|
2003-04-09 01:19:15 +04:00
|
|
|
.Va LINES
|
2003-04-08 22:57:09 +04:00
|
|
|
or
|
2003-04-09 01:19:15 +04:00
|
|
|
.Va COLS
|
2003-04-08 22:57:09 +04:00
|
|
|
are set, then these will be used instead.
|
2002-10-21 17:55:12 +04:00
|
|
|
.Pp
|
2004-03-22 21:57:10 +03:00
|
|
|
When either
|
2004-03-22 22:51:18 +03:00
|
|
|
.Fn newterm
|
2004-03-22 21:57:10 +03:00
|
|
|
or
|
|
|
|
.Fn initscr
|
|
|
|
are called, the Curses library sets up signal handlers for
|
|
|
|
.Dv SIGTSTP
|
|
|
|
and
|
|
|
|
.Dv SIGWINCH .
|
|
|
|
If a signal handler is already installed for
|
|
|
|
.Dv SIGWINCH ,
|
|
|
|
this will also be called when the Curses library handler is called.
|
|
|
|
.Pp
|
2002-10-21 17:55:12 +04:00
|
|
|
The
|
|
|
|
.Fn isendwin
|
|
|
|
function can be used to determine whether or not a refresh of the
|
|
|
|
screen has occurred since the last call to
|
2002-12-05 22:13:12 +03:00
|
|
|
.Fn endwin .
|
2002-10-21 17:55:12 +04:00
|
|
|
.Pp
|
|
|
|
The size of the screen may be changed by calling
|
|
|
|
.Fn resizeterm
|
|
|
|
with the updated number of lines and columns.
|
2004-03-16 22:25:39 +03:00
|
|
|
This will resize the curses internal data structures to accommodate the
|
2002-10-21 17:55:12 +04:00
|
|
|
changed terminal geometry.
|
2007-10-26 00:42:07 +04:00
|
|
|
The
|
|
|
|
.Dv curscr
|
|
|
|
and
|
|
|
|
.Dv stdscr
|
|
|
|
windows and any of their subwindows will be resized to fit the new
|
|
|
|
screen size.
|
2002-10-21 17:55:12 +04:00
|
|
|
The application must redraw the screen after a call to
|
|
|
|
.Fn resizeterm .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn 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
|
|
|
|
.Fa name
|
|
|
|
argument must be a valid name or alias in the
|
|
|
|
.Xr termcap 5
|
|
|
|
database for this function to succeed.
|
|
|
|
.Sh RETURN VALUES
|
|
|
|
Functions returning pointers will return
|
|
|
|
.Dv NULL
|
|
|
|
if an error is detected.
|
|
|
|
The functions that return an int will return one of the following
|
|
|
|
values:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width ERR -compact
|
|
|
|
.It Er OK
|
|
|
|
The function completed successfully.
|
|
|
|
.It Er ERR
|
|
|
|
An error occurred in the function.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr curses_window 3 ,
|
2003-04-09 01:19:15 +04:00
|
|
|
.Xr tty 4 ,
|
2004-03-22 21:57:10 +03:00
|
|
|
.Xr termcap 5 ,
|
|
|
|
.Xr signal 7
|
2002-10-21 17:55:12 +04:00
|
|
|
.Sh STANDARDS
|
|
|
|
The
|
|
|
|
.Nx
|
2003-04-08 22:57:09 +04:00
|
|
|
Curses library complies with the X/Open Curses specification, part of the
|
|
|
|
Single Unix Specification.
|
2002-10-21 17:55:12 +04:00
|
|
|
.Sh HISTORY
|
|
|
|
The Curses package appeared in
|
|
|
|
.Bx 4.0 .
|
|
|
|
The
|
|
|
|
.Fn resizeterm
|
2007-07-13 15:16:11 +04:00
|
|
|
function is a
|
|
|
|
.Em ncurses
|
|
|
|
extension to the Curses library and was added in
|
2002-10-21 17:55:12 +04:00
|
|
|
.Nx 1.6 .
|