xref: /minix3/lib/libcurses/curses_screen.3 (revision 0c3ae37f525eceade8dc047e551f5c9cb33faeb1)
1*0c3ae37fSLionel Sambuc.\"	$NetBSD: curses_screen.3,v 1.15 2012/04/21 12:27:28 roy Exp $
251ffecc1SBen Gras.\"
351ffecc1SBen Gras.\" Copyright (c) 2002
451ffecc1SBen Gras.\"	Brett Lymn (blymn@NetBSD.org, brett_lymn@yahoo.com.au)
551ffecc1SBen Gras.\"
651ffecc1SBen Gras.\" This code is donated to the NetBSD Foundation by the Author.
751ffecc1SBen Gras.\"
851ffecc1SBen Gras.\" Redistribution and use in source and binary forms, with or without
951ffecc1SBen Gras.\" modification, are permitted provided that the following conditions
1051ffecc1SBen Gras.\" are met:
1151ffecc1SBen Gras.\" 1. Redistributions of source code must retain the above copyright
1251ffecc1SBen Gras.\"    notice, this list of conditions and the following disclaimer.
1351ffecc1SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
1451ffecc1SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
1551ffecc1SBen Gras.\"    documentation and/or other materials provided with the distribution.
1651ffecc1SBen Gras.\" 3. The name of the Author may not be used to endorse or promote
1751ffecc1SBen Gras.\"    products derived from this software without specific prior written
1851ffecc1SBen Gras.\"    permission.
1951ffecc1SBen Gras.\"
2051ffecc1SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
2151ffecc1SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2251ffecc1SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2351ffecc1SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
2451ffecc1SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2551ffecc1SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2651ffecc1SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2751ffecc1SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2851ffecc1SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2951ffecc1SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3051ffecc1SBen Gras.\" SUCH DAMAGE.
3151ffecc1SBen Gras.\"
3251ffecc1SBen Gras.\"
33*0c3ae37fSLionel Sambuc.Dd April 5, 2012
3451ffecc1SBen Gras.Dt CURSES_SCREEN 3
3551ffecc1SBen Gras.Os
3651ffecc1SBen Gras.Sh NAME
3751ffecc1SBen Gras.Nm curses_screen ,
3851ffecc1SBen Gras.Nm newterm ,
3951ffecc1SBen Gras.Nm set_term ,
4051ffecc1SBen Gras.Nm delscreen ,
4151ffecc1SBen Gras.Nm endwin ,
4251ffecc1SBen Gras.Nm initscr ,
4351ffecc1SBen Gras.Nm isendwin ,
4451ffecc1SBen Gras.Nm resizeterm ,
4551ffecc1SBen Gras.Nm setterm
4651ffecc1SBen Gras.Nd curses terminal and screen routines
4751ffecc1SBen Gras.Sh LIBRARY
4851ffecc1SBen Gras.Lb libcurses
4951ffecc1SBen Gras.Sh SYNOPSIS
5051ffecc1SBen Gras.In curses.h
5151ffecc1SBen Gras.Ft SCREEN *
5251ffecc1SBen Gras.Fn newterm "char *type" "FILE *outfd" "FILE *infd"
5351ffecc1SBen Gras.Ft SCREEN *
5451ffecc1SBen Gras.Fn set_term "SCREEN *screen"
5551ffecc1SBen Gras.Ft void
5651ffecc1SBen Gras.Fn delscreen "SCREEN *screen"
5751ffecc1SBen Gras.Ft int
5851ffecc1SBen Gras.Fn endwin "void"
5951ffecc1SBen Gras.Ft WINDOW *
6051ffecc1SBen Gras.Fn initscr "void"
6151ffecc1SBen Gras.Ft bool
6251ffecc1SBen Gras.Fn isendwin "void"
6351ffecc1SBen Gras.Ft int
6451ffecc1SBen Gras.Fn resizeterm "int lines" "int cols"
6551ffecc1SBen Gras.Ft int
6651ffecc1SBen Gras.Fn setterm "char *name"
6751ffecc1SBen Gras.Pp
6851ffecc1SBen Gras.Va extern int LINES ;
6951ffecc1SBen Gras.Pp
7051ffecc1SBen Gras.Va extern int COLS ;
7151ffecc1SBen Gras.Sh DESCRIPTION
7251ffecc1SBen GrasThese functions initialize terminals and screens.
7351ffecc1SBen Gras.Pp
7451ffecc1SBen GrasThe
7551ffecc1SBen Gras.Fn newterm
7651ffecc1SBen Grasfunction initialises the curses data structures and pointers ready for
7751ffecc1SBen Grasuse by curses.
7851ffecc1SBen GrasThe
7951ffecc1SBen Gras.Fa type
8051ffecc1SBen Grasargument points to a
81*0c3ae37fSLionel Sambuc.Xr terminfo 5
82*0c3ae37fSLionel Sambucentry, or it may be
8351ffecc1SBen Gras.Dv NULL
8451ffecc1SBen Grasin which case the TERM environment variable is used.
8551ffecc1SBen GrasThe
8651ffecc1SBen Gras.Fa outfd
8751ffecc1SBen Grasand
8851ffecc1SBen Gras.Fa infd
8951ffecc1SBen Grasare the output and input file descriptors for the terminal.
9051ffecc1SBen GrasThe
9151ffecc1SBen Gras.Fn newterm
9251ffecc1SBen Grasfunction must only be called once  per terminal.
9351ffecc1SBen Gras.Pp
9451ffecc1SBen GrasThe
9551ffecc1SBen Gras.Fn set_term
9651ffecc1SBen Grasfunction can be used to switch between the screens defined by calling
9751ffecc1SBen Gras.Fn newterm ,
9851ffecc1SBen Grasa pointer to the previous screen structure that was in use will be
9951ffecc1SBen Grasreturned on success.
10051ffecc1SBen Gras.Pp
10151ffecc1SBen GrasCalling
10251ffecc1SBen Gras.Fn delscreen
10351ffecc1SBen Graswill destroy the given screen and free all allocated resources.
10451ffecc1SBen Gras.Pp
10551ffecc1SBen GrasCalling
10651ffecc1SBen Gras.Fn endwin
10751ffecc1SBen Graswill end the curses session and restore the saved terminal settings.
10851ffecc1SBen Gras.Pp
10951ffecc1SBen GrasThe curses session must be initialised by calling
11051ffecc1SBen Gras.Fn initscr
11151ffecc1SBen Graswhich saves the current terminal state and sets up the terminal and
11251ffecc1SBen Grasinternal data structures to support the curses application.
11351ffecc1SBen GrasThis
11451ffecc1SBen Grasfunction call must be, with few exceptions, the first Curses library
11551ffecc1SBen Grascall made.
11651ffecc1SBen GrasThe exception to this rule is the
11751ffecc1SBen Gras.Fn newterm
11851ffecc1SBen Grascall which may be called prior to
11951ffecc1SBen Gras.Fn initscr .
12051ffecc1SBen GrasThe size of the curses screen is determined by checking the
12151ffecc1SBen Gras.Xr tty 4
12251ffecc1SBen Grassize and then the
123*0c3ae37fSLionel Sambuc.Xr terminfo 5
12451ffecc1SBen Grasentries for the terminal type.
12551ffecc1SBen GrasIf the environment variables
12651ffecc1SBen Gras.Va LINES
12751ffecc1SBen Grasor
12851ffecc1SBen Gras.Va COLS
12951ffecc1SBen Grasare set, then these will be used instead.
13051ffecc1SBen Gras.Pp
13151ffecc1SBen GrasWhen either
13251ffecc1SBen Gras.Fn newterm
13351ffecc1SBen Grasor
13451ffecc1SBen Gras.Fn initscr
13551ffecc1SBen Grasare called, the Curses library sets up signal handlers for
13651ffecc1SBen Gras.Dv SIGTSTP
13751ffecc1SBen Grasand
13851ffecc1SBen Gras.Dv SIGWINCH .
13951ffecc1SBen GrasIf a signal handler is already installed for
14051ffecc1SBen Gras.Dv SIGWINCH ,
14151ffecc1SBen Grasthis will also be called when the Curses library handler is called.
14251ffecc1SBen Gras.Pp
14351ffecc1SBen GrasThe
14451ffecc1SBen Gras.Fn isendwin
14551ffecc1SBen Grasfunction can be used to determine whether or not a refresh of the
14651ffecc1SBen Grasscreen has occurred since the last call to
14751ffecc1SBen Gras.Fn endwin .
14851ffecc1SBen Gras.Pp
14951ffecc1SBen GrasThe size of the screen may be changed  by calling
15051ffecc1SBen Gras.Fn resizeterm
15151ffecc1SBen Graswith the updated number of lines and columns.
15251ffecc1SBen GrasThis will resize the curses internal data structures to accommodate the
15351ffecc1SBen Graschanged terminal geometry.
15451ffecc1SBen GrasThe
15551ffecc1SBen Gras.Dv curscr
15651ffecc1SBen Grasand
15751ffecc1SBen Gras.Dv stdscr
15851ffecc1SBen Graswindows and any of their subwindows will be resized to fit the new
15951ffecc1SBen Grasscreen size.
16051ffecc1SBen GrasThe application must redraw the screen after a call to
16151ffecc1SBen Gras.Fn resizeterm .
16251ffecc1SBen Gras.Pp
16351ffecc1SBen GrasThe
16451ffecc1SBen Gras.Fn setterm
16551ffecc1SBen Grasfunction sets the terminal type for the current screen to the one
16651ffecc1SBen Graspassed, initialising all the curses internal data structures with
16751ffecc1SBen Grasinformation related to the named terminal.
16851ffecc1SBen GrasThe
16951ffecc1SBen Gras.Fa name
17051ffecc1SBen Grasargument must be a valid name or alias in the
171*0c3ae37fSLionel Sambuc.Xr terminfo 5
17251ffecc1SBen Grasdatabase for this function to succeed.
17351ffecc1SBen Gras.Sh RETURN VALUES
17451ffecc1SBen GrasFunctions returning pointers will return
17551ffecc1SBen Gras.Dv NULL
17651ffecc1SBen Grasif an error is detected.
17751ffecc1SBen GrasThe functions that return an int will return one of the following
17851ffecc1SBen Grasvalues:
17951ffecc1SBen Gras.Pp
18051ffecc1SBen Gras.Bl -tag -width ERR -compact
18151ffecc1SBen Gras.It Er OK
18251ffecc1SBen GrasThe function completed successfully.
18351ffecc1SBen Gras.It Er ERR
18451ffecc1SBen GrasAn error occurred in the function.
18551ffecc1SBen Gras.El
18651ffecc1SBen Gras.Sh SEE ALSO
18751ffecc1SBen Gras.Xr curses_window 3 ,
18851ffecc1SBen Gras.Xr tty 4 ,
189*0c3ae37fSLionel Sambuc.Xr terminfo 5 ,
19051ffecc1SBen Gras.Xr signal 7
19151ffecc1SBen Gras.Sh STANDARDS
19251ffecc1SBen GrasThe
19351ffecc1SBen Gras.Nx
19451ffecc1SBen GrasCurses library complies with the X/Open Curses specification, part of the
19551ffecc1SBen GrasSingle Unix Specification.
19651ffecc1SBen Gras.Sh HISTORY
19751ffecc1SBen GrasThe Curses package appeared in
19851ffecc1SBen Gras.Bx 4.0 .
19951ffecc1SBen GrasThe
20051ffecc1SBen Gras.Fn resizeterm
20151ffecc1SBen Grasfunction is a
20251ffecc1SBen Gras.Em ncurses
20351ffecc1SBen Grasextension to the Curses library and was added in
20451ffecc1SBen Gras.Nx 1.6 .
205