initial checkin (modified man page)

This commit is contained in:
gdr 1997-10-01 02:57:29 +00:00
parent c6b6448216
commit fe19a1dddc
72 changed files with 10167 additions and 0 deletions

View File

@ -0,0 +1,112 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)ex1.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
#include <sys/types.h>
#include <curses.h>
#include <stdio.h>
#include <signal.h>
#define YSIZE 10
#define XSIZE 20
int quit();
main()
{
int i, j, c;
size_t len;
char id[100];
FILE *fp;
char *s;
initscr(); /* Always call initscr() first */
signal(SIGINT, quit); /* Make sure wou have a 'cleanup' fn */
crmode(); /* We want cbreak mode */
noecho(); /* We want to have control of chars */
delwin(stdscr); /* Create our own stdscr */
stdscr = newwin(YSIZE, XSIZE, 10, 35);
flushok(stdscr, TRUE); /* Enable flushing of stdout */
scrollok(stdscr, TRUE); /* Enable scrolling */
erase(); /* Initially, clear the screen */
standout();
move(0,0);
while (1) {
c = getchar();
switch(c) {
case 'q': /* Quit on 'q' */
quit();
break;
case 's': /* Go into standout mode on 's' */
standout();
break;
case 'e': /* Exit standout mode on 'e' */
standend();
break;
case 'r': /* Force a refresh on 'r' */
wrefresh(curscr);
break;
default: /* By default output the character */
addch(c);
refresh();
}
}
}
int
quit()
{
erase(); /* Terminate by erasing the screen */
refresh();
endwin(); /* Always end with endwin() */
delwin(curscr); /* Return storage */
delwin(stdscr);
putchar('\n');
exit(0);
}

22
lib/libcurses/Makefile Normal file
View File

@ -0,0 +1,22 @@
# From: @(#)Makefile 8.2 (Berkeley) 1/2/94
# $Id: Makefile,v 1.1 1997/10/01 02:57:00 gdr Exp $
CFLAGS+=#-DTFILE=\"/dev/ttyp0\"
CFLAGS+=-D_CURSES_PRIVATE -I${.CURDIR}
LDADD+= -ltermcap
LIB= curses
SRCS= addbytes.c addch.c addnstr.c box.c clear.c clrtobot.c clrtoeol.c \
cr_put.c ctrace.c cur_hash.c curses.c delch.c deleteln.c delwin.c \
erase.c fullname.c getch.c getstr.c id_subwins.c idlok.c initscr.c \
insch.c insertln.c longname.c move.c mvwin.c newwin.c overlay.c \
overwrite.c printw.c _putchar.c putchar.c refresh.c scanw.c scroll.c \
setterm.c standout.c toucholap.c touchwin.c tscroll.c tstp.c tty.c \
unctrl.c
MAN3= curses.3
beforeinstall:
-cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/curses.h || \
install -c -o ${BINOWN} -g ${BINGRP} -m 444 curses.h \
${DESTDIR}/usr/include
.include <bsd.lib.mk>

View File

@ -0,0 +1,35 @@
# @(#)Makefile 8.1 (Berkeley) 8/14/93
DIR= psd/19.curses
SRCS= Master
MACROS= -me
CLEANFILES+=win_st.gr twinkle1.gr twinkle2.gr life.gr intro.2.tbl appen.A.tbl \
ex1.gr ex2.gr
.SUFFIXES:
.SUFFIXES: .c .gr
#
# this section formats C input source into nice troffable (or nroffable)
# versions. It uses the capabilites of "vgrind", which sets keywords in
# bold font, and comments in italics.
#
# Don't re-run vgrind unless you want to patch the output files.
VFONT= /usr/libexec/vfontedpr
.c.gr:
${VFONT} $*.c | grep -v "^'wh" > $*.gr
paper.ps: ${SRCS}
${ROFF} ${SRCS} > ${.TARGET}
Master: twinkle1.gr ex1.gr ex2.gr fns.doc intro.5 intro.2.tbl intro.0 intro.1 \
intro.3 intro.4 intro.6 macros c_macros
intro.2.tbl: intro.2
${TBL} intro.2 > intro.2.tbl
.include <bsd.doc.mk>

View File

@ -0,0 +1,54 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)Master 8.2 (Berkeley) 5/24/94
.\"
.ds Ln Screen Package
.so macros
.so c_macros
.so intro.0
.pn 3
.bp
.so intro.1
.so intro.2.tbl
.so intro.3
.so intro.4
.so intro.5
.so intro.6
.bp
.so appen.A
.pn 2
.oh '\*(Ln''PSD:19-%'
.eh 'PSD:19-%''\*(Ln'
.bp
.bi Contents
.sp
.xp

View File

@ -0,0 +1,77 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)appen.A 8.1 (Berkeley) 6/8/93
.\"
.ie t .oh '\*(Ln Appendix A''PS1:19-%'
.eh 'PS1:19-%''\*(Ln Appendix A'
.el .he ''\fIAppendix A\fR''
.bp
.(x
.ti 0
.b "Appendix A"
.)x
.sh 1 "Examples" 1
.pp
Here we present a few examples
of how to use the package.
They attempt to be representative,
though not comprehensive. Further examples can be found in the games section
of the source tree and in various utilities that use the screen such as
.i systat(1) .
.pp
The following examples are intended to demonstrate
the basic structure of a program
using the package. An additional, more comprehensive, program can be found in
the source code in the
\fIexamples\fP subdirectory.
.sh 2 "Simple Character Output"
.pp
This program demonstrates how to set up a window and output characters to it.
Also, it demonstrates how one might control the output to the window. If
you run this program, you will get a demonstration of the character output
chracteristics discussed in the above Character Output section.
.(l I
.so ex1.gr
.)l
.sh 2 "Twinkle"
.pp
This is a moderately simple program which prints
patterns on the screen.
It switches between patterns of asterisks,
putting them on one by one in random order,
and then taking them off in the same fashion.
It is more efficient to write this
using only the motion optimization,
as is demonstrated below.
.(l I
.so twinkle1.gr
.)l

View File

@ -0,0 +1,201 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)appen.B 8.1 (Berkeley) 6/8/93
.\"
.ie t .oh '\*(Ln Appendix B''PS1:19-%'
.eh 'PS1:19-%''\*(Ln Appendix B'
.el .he ''\fIAppendix B\fR''
.bp
.(x
.ti 0
.b "Appendix B"
.)x
.nr $1 0
.sh 1 "The WINDOW structure"
.pp
The WINDOW structure is defined as follows:
.(l I
.so win_st.gr
.)l
.pp
.Vn \*_cury \\*
.(f
\**
All variables not normally accessed directly by the user
are named with an initial
.Bq \*_
to avoid conflicts with the user's variables.
.)f
and
.Vn \*_curx
are the current \*y for the window.
New characters added to the screen
are added at this point.
.Vn \*_maxy
and
.Vn \*_maxx
are the maximum values allowed for
.Vn \*_cury\*,\*_curx ). (
.Vn \*_begy
and
.Vn \*_begx
are the starting \*y on the terminal for the window,
.i i.e. ,
the window's home.
.Vn \*_cury ,
.Vn \*_curx ,
.Vn \*_maxy ,
and
.Vn \*_maxx
are measured relative to
.Vn \*_begy\*,\*_begx ), (
not the terminal's home.
.pp
.Vn \*_clear
tells if a clear-screen sequence is to be generated
on the next
.Fn refresh
call.
This is only meaningful for screens.
The initial clear-screen for the first
.Fn refresh
call is generated by initially setting clear to be TRUE for
.Vn curscr ,
which always generates a clear-screen if set,
irrelevant of the dimensions of the window involved.
.Vn \*_leave
is TRUE if the current \*y and the cursor
are to be left after the last character changed on the terminal,
or not moved if there is no change.
.Vn \*_scroll
is TRUE
if scrolling is allowed.
.pp
.Vn \*_y
is a pointer to an array of lines which describe the terminal.
Thus:
.(l
\*_y[i]
.)l
.lp
is a pointer to the
.Vn i th
line, and
.(l
\*_y[i][j]
.)l
.lp
is the
.Vn j th
character on the
.Vn i th
line.
.Vn \*_flags
can have one or more values
or'd into it.
.pp
For windows that are not subwindows,
.Vn \*_orig
is
NULL .
For subwindows,
it points to the main window
to which the window is subsidiary.
.Vn \*_nextp
is a pointer in a circularly linked list
of all the windows which are subwindows of the same main window,
plus the main window itself.
.pp
.Vn \*_firstch
and
.Vn \*_lastch
are
.Fn malloc ed
arrays which contain the index of the
first and last changed characters
on the line.
.Vn \*_ch\*_off
is the x offset for the window
in the
.Vn \*_firstch
and
.Vn \*_lastch
arrays for this window.
For main windows,
this is always 0;
for subwindows
it is the difference between the starting point of the main window
and that of the subindow,
so that change markers can be set relative to the main window.
This makes these markers global in scope.
.pp
All subwindows share the appropriate portions of
.Vn _y ,
.Vn _firstch ,
.Vn _lastch ,
and
.Vn _insdel
with their main window.
.pp
.b \*_ENDLINE
says that the end of the line for this window
is also the end of a screen.
.b \*_FULLWIN
says that this window is a screen.
.b \*_SCROLLWIN
indicates that the last character of this screen
is at the lower right-hand corner of the terminal;
.i i.e. ,
if a character was put there,
the terminal would scroll.
.b \*_FULLLINE
says that the width of a line is the same as the width of the terminal.
If
.b \*_FLUSH
is set,
it says that
.Fn fflush "" "" stdout
should be called at the end of each
.Fn refresh
.b \*_STANDOUT
says that all characters added to the screen
are in standout mode.
.b \*_INSDEL
is reserved for future use,
and is set by
.Fn idlok .
.Vn \*_firstch
is set to
.b \*_NOCHANGE
for lines on which there has been no change
since the last
.Fn refresh .

View File

@ -0,0 +1,127 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)appen.C 8.1 (Berkeley) 6/8/93
.\"
.ie t .oh '\*(Ln Appendix A''PS1:19-%'
.eh 'PS1:19-%''\*(Ln Appendix A'
.el .he ''\fIAppendix A\fR''
.bp
.(x
.ti 0
.b "Appendix A"
.)x
.sh 1 "Examples" 1
.pp
Here we present a few examples
of how to use the package.
They attempt to be representative,
though not comprehensive. Further examples can be found in the games section
of the source tree and in various utilities that use the screen such as
.i systat(1) .
.sh 2 "Screen Updating"
.pp
The following examples are intended to demonstrate
the basic structure of a program
using the screen updating sections of the package.
Several of the programs require calculational sections
which are irrelevant of to the example,
and are therefore usually not included.
It is hoped that the data structure definitions
give enough of an idea to allow understanding
of what the relevant portions do.
.sh 3 "Simple Character Output"
.pp
This program demonstrates how to set up a window and output characters to it.
Also, it demonstrates how one might control the output to the window. If
you run this program, you will get a demonstration of the character output
chracteristics discussed in the above Character Output section.
.(l I
.so t2.gr
.)l
.sh 3 "A Small Screen Manipulator"
.pp
The next example follows the lines of the previous one but extends then to
demonstrate the various othe uses of the package. Make sure you understand
how this program works as it encompasses most of anything you will
need to do with the package.
.(l I
.so t3.gr
.)l
.sh 3 "Twinkle"
.pp
This is a moderately simple program which prints
patterns on the screen.
It switches between patterns of asterisks,
putting them on one by one in random order,
and then taking them off in the same fashion.
It is more efficient to write this
using only the motion optimization,
as is demonstrated below.
.(l I
.so twinkle1.gr
.)l
.sh 3 "Life"
.pp
This program fragment models the famous computer pattern game of life
(Scientific American, May, 1974).
The calculational routines create a linked list of structures
defining where each piece is.
Nothing here claims to be optimal,
merely demonstrative.
This code, however,
is a very good place to use the screen updating routines,
as it allows them to worry about what the last position looked like,
so you don't have to.
It also demonstrates some of the input routines.
.(l I
.so life.gr
.)l
.sh 2 "Motion optimization"
.pp
The following example shows how motion optimization
is written on its own.
Programs which flit from one place to another without
regard for what is already there
usually do not need the overhead of both space and time
associated with screen updating.
They should instead use motion optimization.
.sh 3 "Twinkle"
.pp
The
.b twinkle
program
is a good candidate for simple motion optimization.
Here is how it could be written
(only the routines that have been changed are shown):
.(l
.so twinkle2.gr
.)l

View File

@ -0,0 +1,77 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)appen.A 8.1 (Berkeley) 6/8/93
.\"
.ie t .oh '\*(Ln Appendix A''PS1:19-%'
.eh 'PS1:19-%''\*(Ln Appendix A'
.el .he ''\fIAppendix A\fR''
.bp
.(x
.ti 0
.b "Appendix A"
.)x
.sh 1 "Examples" 1
.pp
Here we present a few examples
of how to use the package.
They attempt to be representative,
though not comprehensive. Further examples can be found in the games section
of the source tree and in various utilities that use the screen such as
.i systat(1) .
.pp
The following examples are intended to demonstrate
the basic structure of a program
using the package. An additional, more comprehensive, program can be found in
the source code in the
\fIexamples\fP subdirectory.
.sh 2 "Simple Character Output"
.pp
This program demonstrates how to set up a window and output characters to it.
Also, it demonstrates how one might control the output to the window. If
you run this program, you will get a demonstration of the character output
chracteristics discussed in the above Character Output section.
.(l I
.so ex1.gr
.)l
.sh 2 "Twinkle"
.pp
This is a moderately simple program which prints
patterns on the screen.
It switches between patterns of asterisks,
putting them on one by one in random order,
and then taking them off in the same fashion.
It is more efficient to write this
using only the motion optimization,
as is demonstrated below.
.(l I
.so twinkle1.gr
.)l

View File

@ -0,0 +1,70 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)c_macros 8.1 (Berkeley) 6/4/93
.\"
'ie t 'ds _ \d\(mi\u
'el 'ds _ _
'tr *\(**
'ps 9p
'vs 10p
'ds - \(mi
'ds /* \\h'\\w' 'u-\\w'/'u'/*
'bd B 3
'bd S B 3
'nr cm 0
'nf
'de ()
'pn 1
..
'de +C
'nr cm 1
'ft 2
'ds +K
'ds -K
..
'de -C
'nr cm 0
'ft 1
.ie t 'ds +K \f3
.el 'ds +K \fI
'ds -K \fP
..
'+C
'-C
'am +C
'ne 3
..
'de -F
'rm =f
..
'ft 1
'lg 0

349
lib/libcurses/PSD.doc/doc.I Normal file
View File

@ -0,0 +1,349 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)doc.I 8.1 (Berkeley) 6/4/93
.\"
.Ds
.Fd addch ch \*m
char ch;
.Fd waddch win\*,ch
WINDOW *win;
char ch;
.De
Add the character
.Vn ch
on the window
at the current \*y.
If the character is a newline
(\'\en\')
the line will be cleared to the end,
and the current \*y will be changed to the
beginning off the next line
if newline mapping is on,
or to the next line at the same x co-ordinate
if it is off.
A return
(\'\er\')
will move to the beginning of the line on the window.
Tabs
(\'\et\')
will be expanded into spaces
in the normal tabstop positions of
every eight characters.
\*(Es
.Ds
.Fd addstr str \*m
char *str;
.Fd waddstr win\*,str
WINDOW *win;
char *str;
.De
Add the string pointed to by
.Vn str
on the window at the current \*y.
\*(Es
In this case, it will put on as much as it can.
.Ds
.Fd box win\*,vert\*,hor
WINDOW *win;
char vert\*,hor;
.De
.Pp
Draws a box around the window using
.Vn vert
as the character for drawing the vertical sides, and
.Vn hor
for drawing the horizontal lines.
If scrolling is not allowed,
and the window encompasses the lower right-hand corner of the terminal,
the corners are left blank to avoid a scroll.
.Ds
.Fd clear "" \*m
.Fd wclear win
WINDOW *win;
.De
Resets the entire window to blanks.
If
.Vn win
is a screen,
this sets the clear flag,
which will cause a clear-screen sequence to be sent
on the next
.Fn refresh
call.
This also moves the current \*y
to (0\*,0).
.Ds
.Fd clearok scr\*,boolf \*m
WINDOW *scr;
bool boolf;
.De
Sets the clear flag for the screen
.Vn scr .
If
.Vn boolf
is TRUE,
this will force a clear-screen to be printed on the next
.Fn refresh ,
or stop it from doing so if
.Vn boolf
is FALSE.
This only works on screens,
and,
unlike
.Fn clear ,
does not alter the contents of the screen.
If
.Vn scr
is
.Vn curscr ,
the next
.Fn refresh
call will cause a clear-screen,
even if the window passed to
.Fn refresh
is not a screen.
.Ds
.Fd clrtobot "" \*m
.Fd wclrtobot win
WINDOW *win;
.De
Wipes the window clear from the current \*y to the bottom.
This does not force a clear-screen sequence on the next refresh
under any circumstances.
\*(Nm
.Ds
.Fd clrtoeol "" \*m
.Fd wclrtoeol win
WINDOW *win;
.De
Wipes the window clear from the current \*y to the end of the line.
\*(Nm
.Ds
.Fd delch
.Fd wdelch win
WINDOW *win;
.De
Delete the character at the current \*y.
Each character after it on the line shifts to the left,
and the last character becomes blank.
.Ds
.Fd deleteln
.Fd wdeleteln win
WINDOW *win;
.De
Delete the current line.
Every line below the current one will move up,
and the bottom line will become blank.
The current \*y will remain unchanged.
.Ds
.Fd erase "" \*m
.Fd werase win
WINDOW *win;
.De
Erases the window to blanks without setting the clear flag.
This is analagous to
.Fn clear ,
except that it never causes a clear-screen sequence to be generated
on a
.Fn refresh .
\*(Nm
.Ds
.Fd flushok win\*,boolf \*m
WINDOW *win;
bool boolf;
.De
Normally,
.Fn refresh
.Fn fflush 's
.Vn stdout
when it is finished.
.Fn flushok
allows you to control this.
if
.Vn boolf
is TRUE
(\c
.i i.e. ,
non-zero)
it will do the
.Fn fflush ;
if it is FALSE.
it will not.
.Ds
.Fd idlok win\*,boolf
WINDOW *win;
bool boolf;
.De
Reserved for future use.
This will eventually signal to
.Fn refresh
that it is all right to use the insert and delete line sequences
when updating the window.
.Ds
.Fd insch c
char c;
.Fd winsch win\*,c
WINDOW *win;
char c;
.De
Insert
.Vn c
at the current \*y
Each character after it shifts to the right,
and the last character disappears.
\*(Es
.Ds
.Fd insertln
.Fd winsertln win
WINDOW *win;
.De
Insert a line above the current one.
Every line below the current line
will be shifted down,
and the bottom line will disappear.
The current line will become blank,
and the current \*y will remain unchanged.
.Ds
.Fd move y\*,x \*m
int y\*,x;
.Fd wmove win\*,y\*,x
WINDOW *win;
int y\*,x;
.De
Change the current \*y of the window to
.Vn y\*,x ). (
\*(Es
.Ds
.Fd overlay win1\*,win2
WINDOW *win1\*,*win2;
.De
Overlay
.Vn win1
on
.Vn win2 .
The contents of
.Vn win1 ,
insofar as they fit,
are placed on
.Vn win2
at their starting \*y.
This is done non-destructively,
i.e., blanks on
.Vn win1
leave the contents of the space on
.Vn win2
untouched.
.Ds
.Fd overwrite win1\*,win2
WINDOW *win1\*,*win2;
.De
Overwrite
.Vn win1
on
.Vn win2 .
The contents of
.Vn win1 ,
insofar as they fit,
are placed on
.Vn win2
at their starting \*y.
This is done destructively,
.i i.e. ,
blanks on
.Vn win1
become blank on
.Vn win2 .
.Ds
.Fd printw fmt\*,arg1\*,arg2\*,...
char *fmt;
.Fd wprintw win\*,fmt\*,arg1\*,arg2\*,...
WINDOW *win;
char *fmt;
.De
Performs a
.Fn printf
on the window starting at the current \*y.
It uses
.Fn addstr
to add the string on the window.
It is often advisable to use the field width options of
.Fn printf
to avoid leaving things on the window from earlier calls.
\*(Es
.Ds
.Fd refresh "" \*m
.Fd wrefresh win
WINDOW *win;
.De
Synchronize the terminal screen with the desired window.
If the window is not a screen,
only that part covered by it is updated.
\*(Es
In this case, it will update whatever it can
without causing the scroll.
.sp
As a special case,
if
.Fn wrefresh
is called with the window
.Vn curscr
the screen is cleared
and repainted as it is currently.
This is very useful for allowing the redrawing of the screen
when the user has garbage dumped on his terminal.
.Ds
.Fd standout "" \*m
.Fd wstandout win
WINDOW *win;
.Fd standend "" \*m
.Fd wstandend win
WINDOW *win;
.De
Start and stop putting characters onto
.i win
in standout mode.
.Fn standout
causes any characters added to the window
to be put in standout mode on the terminal
(if it has that capability).
.Fn standend
stops this.
The sequences
.Vn SO
and
.Vn SE
(or
.Vn US
and
.Vn UE
if they are not defined)
are used (see Appendix A).

View File

@ -0,0 +1,142 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)doc.II 8.1 (Berkeley) 6/4/93
.\"
.Ds
.Fd cbreak "" \*m
.Fd nocbreak "" \*m
.Fd crmode "" \*m
.Fd nocrmode "" \*m
.De
Set or unset the terminal to/from cbreak mode.
The misnamed macros
.Fn crmode
and
.Fn nocrmode
are retained for backwards compatibility
with ealier versions of the library.
.Ds
.Fd echo "" \*m
.Fd noecho "" \*m
.De
Sets the terminal to echo or not echo characters.
.Ds
.Fd getch "" \*m
.Fd wgetch win
WINDOW *win;
.De
Gets a character from the terminal and (if necessary)
echos it on the window.
\*(Es
Otherwise, the character gotten is returned.
If
.i noecho
has been set, then the window is left unaltered.
In order to retain control of the terminal,
it is necessary to have one of
.i noecho ,
.i cbreak ,
or
.i rawmode
set.
If you do not set one,
whatever routine you call to read characters will set
.i cbreak
for you,
and then reset to the original mode when finished.
.Ds
.Fd getstr str \*m
char *str;
.Fd wgetstr win\*,str
WINDOW *win;
char *str;
.De
Get a string through the window
and put it in the location pointed to by
.Vn str ,
which is assumed to be large enough to handle it.
It sets tty modes if necessary,
and then calls
.Fn getch
(or
.Fn wgetch ) "" win
to get the characters needed to fill in the string
until a newline or EOF is encountered.
The newline stripped off the string.
\*(Es
.Ds
.Fd \*_putchar c
char c;
.De
Put out a character using the
.Fn putchar
macro.
This function is used to output every character
that
.b curses
generates.
Thus,
it can be redefined by the user who wants to do non-standard things
with the output.
It is named with an initial \*(lq\*_\*(rq
because it usually should be invisible to the programmer.
.Ds
.Fd raw "" \*m
.Fd noraw "" \*m
.De
Set or unset the terminal to/from raw mode.
On version 7
.Un \**
.(f
\**
.Un
is a trademark of Bell Laboratories.
.)f
this also turns of newline mapping
(see
.Fn nl ).
.Ds
.Fd scanw fmt\*,arg1\*,arg2\*,...
char *fmt;
.Fd wscanw win\*,fmt\*,arg1\*,arg2\*,...
WINDOW *win;
char *fmt;
.De
Perform a
.Fn scanf
through the window using
.Vn fmt .
It does this using consecutive
.Fn getch 's
(or
.Fn wgetch 's). "" win
\*(Es

View File

@ -0,0 +1,343 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)doc.III 8.1 (Berkeley) 6/4/93
.\"
.Ds
.Fd baudrate "" \*m
.De
Returns the output baud rate of the terminal.
This is a system dependent constant
(defined in
.b <sys/tty.h>
on BSD systems,
which is included by
.b <curses.h> ).
.Ds
.Fd delwin win
WINDOW *win;
.De
Deletes the window from existence.
All resources are freed for future use by
.b calloc (3).
If a window has a
.Fn subwin
allocated window inside of it,
deleting the outer window
the subwindow is not affected,
even though this does invalidate it.
Therefore,
subwindows should be deleted before their
outer windows are.
.Ds
.Fd endwin
.De
Finish up window routines before exit.
This restores the terminal to the state it was before
.Fn initscr
(or
.Fn gettmode
and
.Fn setterm )
was called.
It should always be called before exiting.
It does not exit.
This is especially useful for resetting tty stats
when trapping rubouts via
.b signal (2).
.Ds
.Fd erasechar "" \*m
.De
Returns the erase character
for the terminal,
.i i.e. ,
the character used by the user to erase a single character from the input.
.Ds
.Fd getcap str "" "char *"
char *str;
.De
Return a pointer to the
.b termcap
capability described by
.Vn str
(see
.b termcap (5)
for details).
.Ds
.Fd getyx win\*,y\*,x \*m
WINDOW *win;
int y\*,x;
.De
Puts the current \*y of
.Vn win
in the variables
.Vn y
and
.Vn x .
Since it is a macro,
not a function,
you do not pass the address
of
.Vn y
and
.Vn x .
.Ds
.Fd inch "" \*m
.Fd winch win \*m
WINDOW *win;
.De
Returns the character at the current \*(y
on the given window.
This does not make any changes to the window.
.Ds
.Fd initscr
.De
Initialize the screen routines.
This must be called before any of the screen routines are used.
It initializes the terminal-type data and such,
and without it none of the routines can operate.
If standard input is not a tty,
it sets the specifications to the terminal
whose name is pointed to by
.Vn Def\*_term
(initialy "dumb").
If the boolean
.Vn My\*_term
is true,
.Vn Def\*_term
is always used.
If the system supports the
.b TIOCGWINSZ
.Fn ioctl "" "" 2
call,
it is used to get the number of lines and columns for the terminal,
otherwise it is taken from the
.b termcap
description.
.Ds
.Fd killchar "" \*m
.De
Returns the line kill character
for the terminal,
.i i.e. ,
the character used by the user to erase an entire line from the input.
.Ds
.Fd leaveok win\*,boolf \*m
WINDOW *win;
bool boolf;
.De
Sets the boolean flag for leaving the cursor after the last change.
If
.Vn boolf
is TRUE,
the cursor will be left after the last update on the terminal,
and the current \*y for
.Vn win
will be changed accordingly.
If it is FALSE,
it will be moved to the current \*y.
This flag
(initialy FALSE)
retains its value until changed by the user.
.Ds
.Fd longname termbuf\*,name
char *termbuf\*,*name;
.Fd fullname termbuf\*,name
char *termbuf\*,*name;
.De
.Fn longname
fills in
.Vn name
with the long name of the terminal described by the
.b termcap
entry in
.Vn termbuf .
It is generally of little use,
but is nice for telling the user in a readable format what terminal
we think he has.
This is available in the global variable
.Vn ttytype .
.Vn termbuf
is usually set via the termlib routine
.Fn tgetent .
.Fn fullname
is the same as
.Fn longname ,
except that it gives the fullest name given in the entry,
which can be quite verbose.
.Ds
.Fd mvwin win\*,y\*,x
WINDOW *win;
int y, x;
.De
Move the home position of the window
.Vn win
from its current starting coordinates
to
.Vn y\*,x ). (
If that would put part or all of the window
off the edge of the terminal screen,
.Fn mvwin
returns ERR and does not change anything.
For subwindows,
.Fn mvwin
also returns ERR if you attempt to move it off its main window.
If you move a main window,
all subwindows are moved along with it.
.Ds
.Fd newwin lines\*,cols\*,begin\*_y\*,begin\*_x "" "WINDOW *"
int lines\*,cols\*,begin\*_y\*,begin\*_x;
.De
Create a new window with
.Vn lines
lines and
.Vn cols
columns starting at position
.Vn begin\*_y\*,begin\*_x ). (
If either
.Vn lines
or
.Vn cols
is 0 (zero),
that dimension will be set to
.Vn "LINES \- begin\*_y" ) (
or
.Vn "COLS \- begin\*_x" ) (
respectively.
Thus, to get a new window of dimensions
.Vn LINES
\(mu
.Vn COLS ,
use
.Fn newwin . "" 0\*,0\*,0\*,0
.Ds
.Fd nl "" \*m
.Fd nonl "" \*m
.De
Set or unset the terminal to/from nl mode,
.i i.e. ,
start/stop the system from mapping
.b <RETURN>
to
.b <LINE-FEED> .
If the mapping is not done,
.Fn refresh
can do more optimization,
so it is recommended, but not required, to turn it off.
.Ds
.Fd scrollok win\*,boolf \*m
WINDOW *win;
bool boolf;
.De
Set the scroll flag for the given window.
If
.Vn boolf
is FALSE, scrolling is not allowed.
This is its default setting.
.Ds
.Fd touchline win\*,y\*,startx\*,endx
WINDOW *win;
int y\*,startx\*,endx;
.De
This function performs a function similar to
.Fn touchwin
on a single line.
It marks the first change for the given line
to be
.Vn startx ,
if it is before the current first change mark,
and
the last change mark is set to be
.Vn endx
if it is currently less than
.Vn endx .
.Ds
.Fd touchoverlap win1\*,win2
WINDOW *win1, *win2;
.De
Touch the window
.Vn win2
in the area which overlaps with
.Vn win1 .
If they do not overlap,
no changes are made.
.Ds
.Fd touchwin win
WINDOW *win;
.De
Make it appear that the every location on the window
has been changed.
This is usually only needed for refreshes with overlapping windows.
.Ds
.Fd subwin win\*,lines\*,cols\*,begin\*_y\*,begin\*_x "" "WINDOW *"
WINDOW *win;
int lines\*,cols\*,begin\*_y\*,begin\*_x;
.De
Create a new window with
.Vn lines
lines and
.Vn cols
columns starting at position
.Vn begin\*_y\*,begin\*_x ) (
inside the window
.i win .
This means that any change made to either window
in the area covered
by the subwindow will be made on both windows.
.Vn begin\*_y\*,begin\*_x
are specified relative to the overall screen,
not the relative (0\*,0) of
.Vn win .
If either
.Vn lines
or
.Vn cols
is 0 (zero),
that dimension will be set to
.Vn "LINES \- begin\*_y" ) (
or
.Vn "COLS \- begin\*_x" ) (
respectively.
.Ds
.Fd unctrl ch \*m
char ch;
.De
This is actually a debug function for the library,
but it is of general usefulness.
It returns a string which is a representation of
.Vn ch .
Control characters become their upper-case equivalents preceded by a "^".
Other letters stay just as they are.
To use
.Fn unctrl ,
you may have to have
.b #include\ <unctrl.h>
in your file.

View File

@ -0,0 +1,110 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
.\"
.\" @(#)doc.IV 8.1 (Berkeley) 6/4/93
.\"
.Ds
.Fd gettmode
.De
Get the tty stats.
This is normally called by
.Fn initscr .
.Ds
.Fd mvcur lasty\*,lastx\*,newy\*,newx
int lasty\*,lastx\*,newy\*,newx;
.De
Moves the terminal's cursor from
.Vn lasty\*,lastx ) (
to
.Vn newy\*,newx ) (
in an approximation of optimal fashion.
This routine uses the functions borrowed from
.i ex
version 2.6.
It is possible to use this optimization
without the benefit of the screen routines.
With the screen routines, this should not be called by the user.
.Fn move
and
.Fn refresh
should be used to move the cursor position,
so that the routines know what's going on.
.Ds
.Fd scroll win
WINDOW *win;
.De
Scroll the window upward one line.
This is normally not used by the user.
.Ds
.Fd savetty "" \*m
.Fd resetty "" \*m
.De
.Fn savetty
saves the current tty characteristic flags.
.Fn resetty
restores them to what
.Fn savetty
stored.
These functions are performed automatically by
.Fn initscr
and
.Fn endwin .
.Ds
.Fd setterm name
char *name;
.De
Set the terminal characteristics to be those of the terminal named
.Vn name ,
getting the terminal size from the
.b TIOCGWINSZ
.Fn ioctl "" "" 2
if it exists,
otherwise from the environment.
This is normally called by
.Fn initscr .
.Ds
.Fd tstp
.De
If the new
.b tty (4)
driver is in use,
this function
will save the current tty state
and then put the process to sleep.
When the process gets restarted,
it restores the tty state
and then calls
.Fn wrefresh "" "" curscr
to redraw the screen.
.Fn initscr
sets the signal
SIGTSTP
to trap to this routine.

102
lib/libcurses/PSD.doc/ex1.c Normal file