update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
This commit is contained in:
parent
c70688046b
commit
b4beac8f5f
|
@ -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>
|
||||
|
||||
|
|
@ -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.1 (Berkeley) 6/8/93
|
||||
.\"
|
||||
.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''PS1:19-%'
|
||||
.eh 'PS1:19-%''\*(Ln'
|
||||
.bp
|
||||
.bi Contents
|
||||
.sp
|
||||
.xp
|
|
@ -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
|
|
@ -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 .
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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).
|
|
@ -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
|
|
@ -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.
|
|
@ -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.
|
|
@ -0,0 +1,102 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)ex1.c 8.1 (Berkeley) 6/8/93
|
||||
.\"
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)ex2.c 8.1 (Berkeley) 6/8/93
|
||||
.\"
|
||||
#include <curses.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define YSIZE LINES
|
||||
#define XSIZE COLS
|
||||
|
||||
static int quit();
|
||||
|
||||
/*
|
||||
* This program fills the screen up with characters and the allows the user to
|
||||
* manipulate the text on the screen using some basic commands.
|
||||
* Nothing fancy, just a demonstration of the elementary features of the
|
||||
* curses(3) package.
|
||||
*/
|
||||
main()
|
||||
{
|
||||
int i, j, c, n, d = 0;
|
||||
char id[100];
|
||||
int hh = 0;
|
||||
int curx, cury, base, arg;
|
||||
|
||||
initscr();
|
||||
signal(SIGINT, quit);
|
||||
crmode();
|
||||
noecho();
|
||||
nonl();
|
||||
delwin(stdscr);
|
||||
stdscr = newwin(YSIZE, XSIZE, 0, 0);
|
||||
flushok(stdscr, TRUE);
|
||||
scrollok(stdscr, TRUE);
|
||||
erase();
|
||||
refresh();
|
||||
|
||||
move(0,0);
|
||||
refresh();
|
||||
for (i = 0; i < YSIZE + 2; i++) {
|
||||
sprintf(id, "%d: ", i);
|
||||
addstr(id);
|
||||
for (j = 0; j < XSIZE - strlen(id); j++)
|
||||
addch('0' + (i % 10));
|
||||
}
|
||||
c = getchar();
|
||||
base = 2;
|
||||
curx = cury = 0;
|
||||
move(0, 0);
|
||||
refresh();
|
||||
|
||||
/*
|
||||
* The screen manipulator has the following commands:
|
||||
* 'D' - clear to the end of the current line.
|
||||
* 'B' - clear to the bottom of the screen.
|
||||
* 'E' - erase the screen.
|
||||
* 's' - enter standout mode.
|
||||
* 'e' - exit standout mode.
|
||||
* 'd' n - delete n lines below cursor line.
|
||||
* 'i' n - insert n lines below cursor line.
|
||||
* 'q' - quit.
|
||||
* 'f' - move cursor one position to the right.
|
||||
* 'b' - move cursor one position to the left.
|
||||
* 'n' - move cursor one line down.
|
||||
* 'p' - move cursor one line up.
|
||||
* 'h' - home cusor.
|
||||
* 'l' - force refresh.
|
||||
* 'r' - simulate a carriage return.
|
||||
*
|
||||
* All other characters are ignored.
|
||||
*/
|
||||
for(;;) {
|
||||
switch(c = getchar()) {
|
||||
case 'D':
|
||||
clrtoeol();
|
||||
refresh();
|
||||
continue;
|
||||
case 'B':
|
||||
clrtobot();
|
||||
refresh();
|
||||
continue;
|
||||
case 'E':
|
||||
erase();
|
||||
refresh();
|
||||
continue;
|
||||
case 's':
|
||||
standout();
|
||||
continue;
|
||||
case 'e':
|
||||
standend();
|
||||
continue;
|
||||
case 'd':
|
||||
arg = getchar() - '0';
|
||||
for (i = 0; i < arg; i++)
|
||||
deleteln();
|
||||
refresh();
|
||||
continue;
|
||||
case 'i':
|
||||
arg = getchar() - '0';
|
||||
for (i = 0; i < arg; i++)
|
||||
insertln();
|
||||
refresh();
|
||||
continue;
|
||||
case 'q':
|
||||
quit();
|
||||
case 'f':
|
||||
if (curx < XSIZE - 1)
|
||||
curx++;
|
||||
else {
|
||||
cury++;
|
||||
curx = 0;
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
if (curx == 0) {
|
||||
cury--;
|
||||
curx = XSIZE - 1;
|
||||
} else
|
||||
curx--;
|
||||
break;
|
||||
case 'n':
|
||||
cury++;
|
||||
break;
|
||||
case 'p':
|
||||
cury--;
|
||||
break;
|
||||
case 'h':
|
||||
curx = cury = 0;
|
||||
break;
|
||||
case 'l':
|
||||
wrefresh(curscr);
|
||||
continue;
|
||||
case 'r': /* return */
|
||||
{
|
||||
int x, y;
|
||||
getyx(stdscr, y, x);
|
||||
move(y+1, 0);
|
||||
insertln();
|
||||
move(y, x);
|
||||
clrtoeol();
|
||||
refresh();
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cury < 0) {
|
||||
base--;
|
||||
move(0, 0);
|
||||
insertln();
|
||||
sprintf(id, "%d: ", base);
|
||||
addstr(id);
|
||||
for (j = 0; j < XSIZE - strlen(id) - 2; j++)
|
||||
addch('0' + (base % 10));
|
||||
cury++;
|
||||
} else if (cury >= YSIZE) {
|
||||
move(0, 0);
|
||||
deleteln();
|
||||
move(YSIZE - 1, 0);
|
||||
sprintf(id, "%d: ", base + YSIZE);
|
||||
addstr(id);
|
||||
for (j = 0; j < XSIZE - strlen(id) - 2; j++)
|
||||
addch('0' + ((base + YSIZE) % 10));
|
||||
cury--;
|
||||
base++;
|
||||
}
|
||||
move(cury, curx);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
quit()
|
||||
{
|
||||
erase();
|
||||
refresh();
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
|
@ -0,0 +1,795 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)fns.doc 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Ds
|
||||
.Fn addch "char ch" \(dg
|
||||
.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
|
||||
.Fn addstr "char *str" \(dg
|
||||
.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
|
||||
.Fn baudrate "" \(dg
|
||||
.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
|
||||
.Fn box "WINDOW win" "char vert" "char 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
|
||||
.Fn cbreak "" \(dg
|
||||
.De
|
||||
Set or the terminal to cbreak mode.
|
||||
.Ds
|
||||
.Fn clear "" \(dg
|
||||
.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
|
||||
.Fn clearok "WINDOW *scr" "int boolf" \(dg
|
||||
.De
|
||||
Sets the clear flag for the screen
|
||||
.Vn scr .
|
||||
If
|
||||
.Vn boolf
|
||||
is non-zero,
|
||||
this will force a clear-screen to be printed on the next
|
||||
.Fn refresh ,
|
||||
or stop it from doing so if
|
||||
.Vn boolf
|
||||
is 0.
|
||||
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
|
||||
.Fn clrtobot "" \(dg
|
||||
.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
|
||||
.Fn clrtoeol "" \(dg
|
||||
.De
|
||||
Wipes the window clear from the current \*y to the end of the line.
|
||||
\*(Nm
|
||||
.Ds
|
||||
.Fn crmode "" \(dg
|
||||
.De
|
||||
Identical to
|
||||
.Fn cbreak .
|
||||
The misnamed macro
|
||||
.Fn crmode
|
||||
and
|
||||
.Fn nocrmode
|
||||
is retained for backwards compatibility
|
||||
with ealier versions of the library.
|
||||
.Ds
|
||||
.Fn delch ""
|
||||
.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
|
||||
.Fn deleteln ""
|
||||
.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
|
||||
.Fn delwin "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
|
||||
.Fn echo "" \(dg
|
||||
.De
|
||||
Sets the terminal to echo characters.
|
||||
.Ds
|
||||
.Fn 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 and before the final calls to
|
||||
.Fn delwin .
|
||||
It does not exit.
|
||||
This is especially useful for resetting tty stats
|
||||
when trapping rubouts via
|
||||
.b signal (2).
|
||||
.Ds
|
||||
.Fn erase "" \(dg
|
||||
.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
|
||||
.Fn erasechar "" \(dg
|
||||
.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
|
||||
.Fn flushok "WINDOW *win" "int 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 non-zero
|
||||
(\c
|
||||
.i i.e. ,
|
||||
non-zero)
|
||||
it will do the
|
||||
.Fn fflush ,
|
||||
otherwise it will not.
|
||||
.Ds
|
||||
.Fn getch "" \(dg
|
||||
.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
|
||||
.Fn getstr "char *str" \(dg
|
||||
.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 )
|
||||
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
|
||||
.Fn gettmode ""
|
||||
.De
|
||||
Get the tty stats.
|
||||
This is normally called by
|
||||
.Fn initscr .
|
||||
.Ds
|
||||
.Fn getyx "WINDOW *win" "int y" "int 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
|
||||
.Fn idlok "WINDOW *win" "int 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
|
||||
.Fn inch "" \(dg
|
||||
.De
|
||||
Returns the character at the current position on the given window.
|
||||
This does not make any changes to the window.
|
||||
.Ds
|
||||
.Fn 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
|
||||
(initially "dumb").
|
||||
If the boolean
|
||||
.Vn My\*_term
|
||||
is non-zero,
|
||||
.Vn Def\*_term
|
||||
is always used.
|
||||
If the system supports the
|
||||
.b TIOCGWINSZ
|
||||
.i 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
|
||||
.Fn insch "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
|
||||
.Fn insertln ""
|
||||
.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
|
||||
.Fn killchar "" \(dg
|
||||
.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
|
||||
.Fn leaveok "WINDOW *win" "int boolf" \(dg
|
||||
.De
|
||||
Sets the boolean flag for leaving the cursor after the last change.
|
||||
If
|
||||
.Vn boolf
|
||||
is non-zero,
|
||||
the cursor will be left after the last update on the terminal,
|
||||
and the current \*y for
|
||||
.Vn win
|
||||
will be changed accordingly.
|
||||
If
|
||||
.Vn boolf
|
||||
is 0 the cursor will be moved to the current \*y.
|
||||
This flag
|
||||
(initially 0)
|
||||
retains its value until changed by the user.
|
||||
.Ds
|
||||
.Fn move "int y" "int x"
|
||||
.De
|
||||
Change the current \*y of the window to
|
||||
.Vn y\*,x ). (
|
||||
\*(Es
|
||||
.Ds
|
||||
.Fn mvcur "int lasty" "int lastx" "int newy" "int 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
|
||||
.Fn mvprintw "int y" "int x" "const char *fmt" "..."
|
||||
.De
|
||||
Equivalent to:
|
||||
.(l
|
||||
move(y, x);
|
||||
printw(fmt, ...);
|
||||
.)l
|
||||
.Ds
|
||||
.Fn mvscanw "int y" "int x" "const char *fmt" "..."
|
||||
.De
|
||||
Equivalent to:
|
||||
.(l
|
||||
move(y, x);
|
||||
scanw(fmt, ...);
|
||||
.)l
|
||||
.Ds
|
||||
.Fn mvwin "WINDOW *win" "int y" "int 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
|
||||
.Fn mvwprintw "WINDOW *win" "int y" "int x" "const char *fmt" "..."
|
||||
.De
|
||||
Equivalent to:
|
||||
.(l
|
||||
wmove(win, y, x);
|
||||
printw(fmt, ...);
|
||||
.)l
|
||||
.Ds
|
||||
.Fn mvwscanw "WINDOW *win" "int y" "int x" "const char *fmt" "..."
|
||||
.De
|
||||
Equivalent to:
|
||||
.(l
|
||||
wmove(win, y, x);
|
||||
scanw(fmt, ...);
|
||||
.)l
|
||||
.Ds
|
||||
.Ft "WINDOW *"
|
||||
.Fn newwin "int lines" "int cols" "int begin_y" "int 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
|
||||
.Fn nl "" \(dg
|
||||
.De
|
||||
Set the terminal to 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
|
||||
.Fn nocbreak "" \(dg
|
||||
.De
|
||||
Unset the terminal from cbreak mode.
|
||||
.Ds
|
||||
.Fn nocrmode "" \(dg
|
||||
.De
|
||||
Identical to
|
||||
.Fn nocbreak .
|
||||
The misnamed macro
|
||||
.Fn nocrmode
|
||||
is retained for backwards compatibility
|
||||
with ealier versions of the library.
|
||||
.Ds
|
||||
.Fn noecho "" \(dg
|
||||
.De
|
||||
Turn echoing of characters off.
|
||||
.Ds
|
||||
.Fn nonl "" \(dg
|
||||
.De
|
||||
Unset the terminal to from nl mode. See
|
||||
.Fn nl .
|
||||
.Ds
|
||||
.Fn noraw "" \(dg
|
||||
.De
|
||||
Unset the terminal from raw mode. See
|
||||
.Fn raw .
|
||||
.Ds
|
||||
.Fn overlay "WINDOW *win1" "WINDOW *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. Note that all non-blank characters are overwritten
|
||||
destructively in the overlay.
|
||||
.Ds
|
||||
.Fn overwrite "WINDOW *win1" "WINDOW *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
|
||||
.Fn printw "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
|
||||
.Fn raw "" \(dg
|
||||
.De
|
||||
Set the terminal to raw mode.
|
||||
On version 7
|
||||
.Un \**
|
||||
.(f
|
||||
\**
|
||||
.Un
|
||||
is a trademark of Unix System Laboratories.
|
||||
.)f
|
||||
this also turns off newline mapping
|
||||
(see
|
||||
.Fn nl ).
|
||||
.Ds
|
||||
.Fn refresh "" \(dg
|
||||
.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
|
||||
.Fn resetty "" \(dg
|
||||
.De
|
||||
.Fn resetty
|
||||
restores them to what
|
||||
.Fn savetty
|
||||
stored.
|
||||
These functions are performed automatically by
|
||||
.Fn initscr
|
||||
and
|
||||
.Fn endwin .
|
||||
This function should not be used by the user.
|
||||
.Ds
|
||||
.Fn savetty "" \(dg
|
||||
.De
|
||||
.Fn savetty
|
||||
saves the current tty characteristic flags. See
|
||||
.Fn resetty .
|
||||
This function should not be used by the user.
|
||||
.Ds
|
||||
.Fn scanw "char *fmt" "..."
|
||||
.De
|
||||
Perform a
|
||||
.Fn scanf
|
||||
through the window using
|
||||
.Vn fmt .
|
||||
It does this using consecutive calls to
|
||||
.Fn getch
|
||||
(or
|
||||
.Fn wgetch ).
|
||||
\*(Es
|
||||
.Ds
|
||||
.Fn scroll "WINDOW *win"
|
||||
.De
|
||||
Scroll the window upward one line.
|
||||
This is normally not used by the user.
|
||||
.Ds
|
||||
.Fn scrollok "WINDOW *win" "int boolf" \(dg
|
||||
.De
|
||||
Set the scroll flag for the given window.
|
||||
If
|
||||
.Vn boolf
|
||||
is 0, scrolling is not allowed.
|
||||
This is its default setting.
|
||||
.Ds
|
||||
.Fn standend "" \(dg
|
||||
.De
|
||||
End standout mode initiated by
|
||||
.Fn standout .
|
||||
.Ds
|
||||
.Fn standout "" \(dg
|
||||
.De
|
||||
Causes any characters added to the window
|
||||
to be put in standout mode on the terminal
|
||||
(if it has that capability).
|
||||
.Ds
|
||||
.Ft "WINDOW *"
|
||||
.Fn subwin "WINDOW *win" "int lines" "int cols" "int begin_y" "int 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
|
||||
.Fn touchline "WINDOW *win" "int y" "int startx" "int 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
|
||||
.Fn touchoverlap "WINDOW *win1" "WINDOW *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
|
||||
.Fn touchwin "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
|
||||
.Fn tstp
|
||||
.De
|
||||
This function
|
||||
will save the current tty state
|
||||
and then put the process to sleep.
|
||||
When the process gets restarted,
|
||||
it restores the saved tty state
|
||||
and then calls
|
||||
.Fn wrefresh "curscr"
|
||||
to redraw the screen.
|
||||
.Fn Initscr
|
||||
sets the signal
|
||||
SIGTSTP
|
||||
to trap to this routine.
|
||||
.Ds
|
||||
.Fn unctrl "char *ch" \(dg
|
||||
.De
|
||||
Returns a string which is an ASCII representation of
|
||||
.Vn ch .
|
||||
Characters are 8 bits long.
|
||||
.Ds
|
||||
.Fn unctrllen "char *ch" \(dg
|
||||
.De
|
||||
Returns the length of the ASCII representation of
|
||||
.Vn ch .
|
||||
.Ds
|
||||
.Fn vwprintw "WINDOW *win" "const char *fmt" "va_list ap"
|
||||
.De
|
||||
Identical to
|
||||
.Fn printw
|
||||
except that it takes both a window specification and a pointer to a variable
|
||||
length argument list.
|
||||
.Ds
|
||||
.Fn vwscanw "WINDOW *win" "const char *fmt" "va_list ap"
|
||||
.De
|
||||
Identical to
|
||||
.Fn scanw
|
||||
except that it takes both a window specification and a pointer to a variable
|
||||
length argument list.
|
||||
.Ds
|
||||
.Fn waddbytes "WINDOW *win" "char *str" "int len"
|
||||
.De
|
||||
This function is the low level character output function.
|
||||
.Vn Len
|
||||
characters of the string
|
||||
.Vn str
|
||||
are output to the current \*y position of the window specified by
|
||||
.Vn win.
|
||||
.sp 2
|
||||
.pp
|
||||
\fIThe following functions differ from the standard functions only in their
|
||||
specification of a window, rather than the use of the default
|
||||
.Vn stdscr.\fP
|
||||
.Ds
|
||||
.Fn waddch "WINDOW *win" "char ch"
|
||||
.Fn waddstr "WINDOW *win" "char *str"
|
||||
.Fn wclear "WINDOW *win"
|
||||
.Fn wclrtobot "WINDOW *win"
|
||||
.Fn wclrtoeol "WINDOW *win"
|
||||
.Fn wdelch "WINDOW *win"
|
||||
.Fn wdeleteln "WINDOW *win"
|
||||
.Fn werase "WINDOW *win"
|
||||
.Fn wgetch "WINDOW *win"
|
||||
.Fn wgetstr "WINDOW *win" "char *str"
|
||||
.Fn winch "WINDOW *win" \(dg
|
||||
.Fn winsch "WINDOW *win" "char c"
|
||||
.Fn winsertln "WINDOW *win"
|
||||
.Fn wmove "WINDOW *win" "int y" int x"
|
||||
.Fn wprintw "WINDOW *win" "char *fmt" "..."
|
||||
.Fn wrefresh "WINDOW *win"
|
||||
.Fn wscanw "WINDOW *win" "char *fmt" "..."
|
||||
.Fn wstandend "WINDOW *win"
|
||||
.Fn wstandout "WINDOW *win"
|
||||
.Dg
|
|
@ -0,0 +1,106 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)intro.0 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.tp
|
||||
.(l C
|
||||
.ps 12
|
||||
.ft B
|
||||
Screen Updating and Cursor Movement Optimization:
|
||||
.fl
|
||||
A Library Package
|
||||
.ft
|
||||
.ps
|
||||
.sp
|
||||
.i "Kenneth C. R. C. Arnold"
|
||||
.i "Elan Amir"
|
||||
.sp
|
||||
Computer Science Division
|
||||
Department of Electrical Engineering and Computer Science
|
||||
University of California, Berkeley
|
||||
Berkeley, California 94720
|
||||
.sp 3
|
||||
.bi ABSTRACT
|
||||
.sp 2
|
||||
.)l
|
||||
.(q
|
||||
.pp
|
||||
This document describes a package of C library functions
|
||||
which allow the user to:
|
||||
.ie t .ip \ \ \ \(bu
|
||||
.el .ip 1)
|
||||
update a screen with reasonable optimization,
|
||||
.ie t .ip \ \ \ \(bu
|
||||
.el .ip 2)
|
||||
get input from the terminal
|
||||
in a screen-oriented fashion,
|
||||
and
|
||||
.ie t .ip \ \ \ \(bu
|
||||
.el .ip 3)
|
||||
independent from the above, move the cursor optimally
|
||||
from one point to another.
|
||||
.pp
|
||||
These routines all use the
|
||||
\*(tc \*(db to describe the capabilities of the terminal.
|
||||
.)q
|
||||
.b Acknowledgements
|
||||
.pp
|
||||
This package would not exist
|
||||
without the work of Bill Joy,
|
||||
who,
|
||||
in writing his editor,
|
||||
created the capability to generally describe terminals,
|
||||
wrote the routines which read this \*(db,
|
||||
and, most importantly,
|
||||
those which implement optimal cursor movement,
|
||||
which routines I have simply lifted nearly intact.
|
||||
Doug Merritt and Kurt Shoens also were extremely important,
|
||||
as were both willing to waste time listening to me rant and rave.
|
||||
The help and/or support of
|
||||
Ken Abrams,
|
||||
Alan Char,
|
||||
Mark Horton,
|
||||
and
|
||||
Joe Kalash,
|
||||
was, and is,
|
||||
also greatly appreciated.
|
||||
.i "Ken Arnold 16 April 1986"
|
||||
.pp
|
||||
The help and/or support of Kirk McKusick and Keith Bostic (public vi!)
|
||||
was invaluable in bringing the package ``into the 90's'', which now
|
||||
includes completely new data structures and screen refresh optimization
|
||||
routines.
|
||||
.i "Elan Amir 29 December 1992"
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)intro.1 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.bp
|
||||
.sh 1 Overview
|
||||
.pp
|
||||
In making available the generalized terminal descriptions in \*(tc,
|
||||
much information was made available to the programmer,
|
||||
but little work was taken out of one's hands.
|
||||
The purpose of this package is to allow the C programmer
|
||||
to do the most common type of terminal dependent functions,
|
||||
those of movement optimization and optimal screen updating,
|
||||
without doing any of the dirty work,
|
||||
and with nearly as much ease as is necessary to simply print
|
||||
or read things.
|
||||
.sh 2 "Terminology"
|
||||
.pp
|
||||
In this document, the following terminology is used:
|
||||
.de Ip
|
||||
.sp
|
||||
.in 5n
|
||||
.ti 0n
|
||||
.b "\\$1" :
|
||||
..
|
||||
.Ip window
|
||||
An internal representation
|
||||
containing an image of what a section of the terminal screen may look like
|
||||
at some point in time.
|
||||
This subsection can either encompass the entire terminal screen,
|
||||
or any smaller portion down to a single character within that screen.
|
||||
.Ip terminal
|
||||
Sometimes called
|
||||
.b terminal
|
||||
.b screen .
|
||||
The package's idea of what the terminal's screen currently looks like,
|
||||
.i i.e. ,
|
||||
what the user sees now.
|
||||
This is a special
|
||||
.i screen :
|
||||
.Ip screen
|
||||
This is a subset of windows which are as large as the terminal screen,
|
||||
.i i.e. ,
|
||||
they start at the upper left hand corner
|
||||
and encompass the lower right hand corner.
|
||||
One of these,
|
||||
.Vn stdscr ,
|
||||
is automatically provided for the programmer.
|
||||
.rm Ip
|
||||
.sh 2 "Compiling Applications"
|
||||
.pp
|
||||
In order to use the library,
|
||||
it is necessary to have certain types and variables defined.
|
||||
Therefore, the programmer must have a line:
|
||||
.(l
|
||||
.b "#include <curses.h>"
|
||||
.)l
|
||||
at the top of the program source.
|
||||
Compilations should have the following form:
|
||||
.(l
|
||||
.ie t \fBcc\fR [ \fIflags\fR ] file ... \fB\-lcurses \-ltermcap\fR
|
||||
.el \fIcc\fR [ flags ] file ... \fI\-lcurses \-ltermcap\fR
|
||||
.)l
|
||||
.sh 2 "Screen Updating"
|
||||
.pp
|
||||
In order to update the screen optimally,
|
||||
it is necessary for the routines to know what the screen currently looks like
|
||||
and what the programmer wants it to look like next.
|
||||
For this purpose,
|
||||
a data type
|
||||
(structure)
|
||||
named
|
||||
.Vn WINDOW
|
||||
is defined
|
||||
which describes a window image to the routines,
|
||||
including its starting position on the screen
|
||||
(the \*y of the upper left hand corner)
|
||||
and its size.
|
||||
One of these
|
||||
(called
|
||||
.Vn curscr
|
||||
for
|
||||
.i "current screen" )
|
||||
is a screen image of what the terminal currently looks like.
|
||||
Another screen
|
||||
(called
|
||||
.Vn stdscr ,
|
||||
for
|
||||
.i "standard screen" )
|
||||
is provided
|
||||
by default
|
||||
to make changes on.
|
||||
.pp
|
||||
A window is a purely internal representation.
|
||||
It is used to build and store
|
||||
a potential image of a portion of the terminal.
|
||||
It doesn't bear any necessary relation
|
||||
to what is really on the terminal screen.
|
||||
It is more like an array of characters on which to make changes.
|
||||
.pp
|
||||
When one has a window which describes
|
||||
what some part the terminal should look like,
|
||||
the routine
|
||||
.Fn refresh
|
||||
(or
|
||||
.Fn wrefresh
|
||||
if the window is not
|
||||
.Vn stdscr )
|
||||
is called.
|
||||
.Fn Refresh
|
||||
makes the terminal,
|
||||
in the area covered by the window,
|
||||
look like that window.
|
||||
Note, therefore, that changing something on a window
|
||||
.i does
|
||||
.bi not
|
||||
.i "change the terminal" .
|
||||
Actual updates to the terminal screen
|
||||
are made only by calling
|
||||
.Fn refresh
|
||||
or
|
||||
.Fn wrefresh .
|
||||
This allows the programmer to maintain several different ideas
|
||||
of what a portion of the terminal screen should look like.
|
||||
Also, changes can be made to windows in any order,
|
||||
without regard to motion efficiency.
|
||||
Then, at will,
|
||||
the programmer can effectively say
|
||||
.q "make it look like this" ,
|
||||
and the package will execute the changes in an optimal way.
|
||||
.sh 2 "Naming Conventions"
|
||||
.pp
|
||||
As hinted above,
|
||||
the routines can use several windows,
|
||||
but two are always available:
|
||||
.Vn curscr ,
|
||||
which is the image of what the terminal looks like at present,
|
||||
and
|
||||
.Vn stdscr ,
|
||||
which is the image of what the programmer wants the terminal to look like next.
|
||||
The user should not access
|
||||
.Vn curscr
|
||||
directly.
|
||||
Changes should be made to
|
||||
the appropriate screen,
|
||||
and then the routine
|
||||
.Fn refresh
|
||||
(or
|
||||
.Fn wrefresh )
|
||||
should be called.
|
||||
.pp
|
||||
Many functions are set up to deal with
|
||||
.Vn stdscr
|
||||
as a default screen.
|
||||
For example, to add a character to
|
||||
.Vn stdscr ,
|
||||
one calls
|
||||
.Fn addch
|
||||
with the desired character.
|
||||
If a different window is to be used,
|
||||
the routine
|
||||
.Fn waddch
|
||||
(for
|
||||
.b w indow-specific
|
||||
.Fn addch )
|
||||
is provided\**.
|
||||
.(f
|
||||
\**
|
||||
Actually,
|
||||
.Fn addch
|
||||
is really a
|
||||
.q #define
|
||||
macro with arguments,
|
||||
as are most of the "functions" which act upon
|
||||
.Vn stdscr .
|
||||
.)f
|
||||
This convention of prepending function names with a
|
||||
.Bq w
|
||||
when they are to be applied to specific windows
|
||||
is consistent.
|
||||
The only routines which do
|
||||
.i not
|
||||
do this are those
|
||||
to which a window must always be specified.
|
||||
.pp
|
||||
In order to move the current \*y from one point to another,
|
||||
the routines
|
||||
.Fn move
|
||||
and
|
||||
.Fn wmove
|
||||
are provided.
|
||||
However,
|
||||
it is often desirable to first move and then perform some I/O operation.
|
||||
In order to avoid clumsiness,
|
||||
most I/O routines can be preceded by the prefix
|
||||
.Bq mv
|
||||
and the desired \*y can then be added to the arguments to the function.
|
||||
For example,
|
||||
the calls
|
||||
.(l
|
||||
move(y\*,x);
|
||||
addch(ch);
|
||||
.)l
|
||||
can be replaced by
|
||||
.(l
|
||||
mvaddch(y\*,x\*,ch);
|
||||
.)l
|
||||
and
|
||||
.(l
|
||||
wmove(win\*,y\*,x);
|
||||
waddch(win\*,ch);
|
||||
.)l
|
||||
can be replaced by
|
||||
.(l
|
||||
mvwaddch(win\*,y\*,x\*,ch);
|
||||
.)l
|
||||
Note that the window description pointer
|
||||
.Vn win ) (
|
||||
comes before the added \*y.
|
||||
If a window pointer is needed, it is always the first parameter passed.
|
|
@ -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.
|
||||
.\"
|
||||
.\" @(#)intro.2 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.sh 1 Variables
|
||||
.pp
|
||||
Many variables which are used to describe the terminal environment
|
||||
are available to the programmer. They are:
|
||||
.(b
|
||||
.TS
|
||||
expand;
|
||||
lw(6m) lw(8n) lw(50n).
|
||||
type name description
|
||||
_
|
||||
WINDOW * curscr T{
|
||||
.fi
|
||||
current version of the screen (terminal screen).
|
||||
T}
|
||||
WINDOW * stdscr T{
|
||||
standard screen. Most updates are usually done here.
|
||||
T}
|
||||
char * Def\*_term T{
|
||||
default terminal type if type cannot be determined
|
||||
T}
|
||||
bool My\*_term T{
|
||||
use the terminal specification in \fIDef\*_term\fR as terminal,
|
||||
irrelevant of real terminal type
|
||||
T}
|
||||
char * ttytype T{
|
||||
full name of the current terminal.
|
||||
T}
|
||||
int LINES T{
|
||||
number of lines on the terminal
|
||||
T}
|
||||
int COLS T{
|
||||
number of columns on the terminal
|
||||
T}
|
||||
int ERR T{
|
||||
error flag returned by routines on a fail.
|
||||
T}
|
||||
int OK T{
|
||||
flag returned by routines upon success.
|
||||
T}
|
||||
.TE
|
||||
.fi
|
||||
.ev
|
||||
.)b
|
||||
.lp
|
|
@ -0,0 +1,228 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)intro.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.sh 1 Usage
|
||||
.pp
|
||||
This is a description of how to actually use the screen package.
|
||||
For simplicity, we assume all updating, reading, etc.
|
||||
is applied to
|
||||
.Vn stdscr ,
|
||||
although a different window can of course be specified.
|
||||
.sh 2 "Initialization"
|
||||
.pp
|
||||
In order to use the screen package,
|
||||
the routines must know about terminal characteristics,
|
||||
and the space for
|
||||
.Vn curscr
|
||||
and
|
||||
.Vn stdscr
|
||||
must be allocated.
|
||||
These functions are performed by
|
||||
.Fn initscr .
|
||||
Since it must allocate space for the windows,
|
||||
it can overflow core when attempting to do so.
|
||||
On this rather rare occasion,
|
||||
.Fn initscr
|
||||
returns ERR.
|
||||
.Fn Initscr
|
||||
must
|
||||
.bi always
|
||||
be called before any of the routines which affect windows are used.
|
||||
If it is not,
|
||||
the program will core dump as soon as either
|
||||
.Vn curscr
|
||||
or
|
||||
.Vn stdscr
|
||||
are referenced.
|
||||
However, it is usually best to wait to call it
|
||||
until after you are sure you will need it,
|
||||
like after checking for startup errors.
|
||||
Terminal status changing routines
|
||||
like
|
||||
.Fn nl
|
||||
and
|
||||
.Fn cbreak
|
||||
should be called after
|
||||
.Fn initscr .
|
||||
.pp
|
||||
After the initial window allocation done by
|
||||
.Fn initscr ,
|
||||
specific window characteristics can be set.
|
||||
Scrolling can be enabled by calling
|
||||
.Fn scrollok .
|
||||
If you want the cursor to be left after the last change, use
|
||||
.Fn leaveok .
|
||||
If this isn't done,
|
||||
.Fn refresh
|
||||
will move the cursor to the window's current \*y after updating it.
|
||||
Additional windows can be created by using the functions
|
||||
.Fn newwin
|
||||
and
|
||||
.Fn subwin .
|
||||
.Fn Delwin
|
||||
allows you to delete an exisiting window.
|
||||
The variables
|
||||
.Vn LINES
|
||||
and
|
||||
.Vn COLS
|
||||
control the size of the terminal. They are initially implicitly set by
|
||||
.Fn initscr ,
|
||||
but can be altered explicitly by the user followed by a call to
|
||||
.Fn initscr .
|
||||
Note that any call to
|
||||
.Fn initscr ,
|
||||
will always delete any existing
|
||||
.Vn stdscr
|
||||
and/or
|
||||
.Vn curscr
|
||||
before creating new ones so this change is best done before the initial call to
|
||||
.Fn initscr .
|
||||
.pp
|
||||
.sh 2 "Output"
|
||||
.pp
|
||||
The basic functions
|
||||
used to change what will go on a window are
|
||||
.Fn addch
|
||||
and
|
||||
.Fn move .
|
||||
.Fn Addch
|
||||
adds a character at the current \*y,
|
||||
returning ERR if it would cause the window to illegally scroll,
|
||||
.i i.e. ,
|
||||
printing a character in the lower right-hand corner
|
||||
of a terminal which automatically scrolls
|
||||
if scrolling is not allowed.
|
||||
.Fn Move
|
||||
changes the current \*y to whatever you want them to be.
|
||||
It returns ERR if you try to move off the window.
|
||||
As mentioned above, you can combine the two into
|
||||
.Fn mvaddch
|
||||
to do both things in one call.
|
||||
.pp
|
||||
The other output functions
|
||||
(such as
|
||||
.Fn addstr
|
||||
and
|
||||
.Fn printw )
|
||||
all call
|
||||
.Fn addch
|
||||
to add characters to the window.
|
||||
.pp
|
||||
After a change has been made to the window,
|
||||
you must call
|
||||
.Fn refresh .
|
||||
when you want the portion of the terminal covered by the window
|
||||
to reflect the change.
|
||||
In order to optimize finding changes,
|
||||
.Fn refresh
|
||||
assumes that any part of the window not changed
|
||||
since the last
|
||||
.Fn refresh
|
||||
of that window has not been changed on the terminal,
|
||||
.i i.e. ,
|
||||
that you have not refreshed a portion of the terminal
|
||||
with an overlapping window.
|
||||
If this is not the case,
|
||||
the routines
|
||||
.Fn touchwin ,
|
||||
.Fn touchline ,
|
||||
and
|
||||
.Fn touchoverlap
|
||||
are provided to make it look like a desired part of window has been changed,
|
||||
thus forcing
|
||||
.Fn refresh
|
||||
to check that whole subsection of the terminal for changes.
|
||||
.pp
|
||||
If you call
|
||||
.Fn wrefresh
|
||||
with
|
||||
.Vn curscr ,
|
||||
it will make the screen look like the image of
|
||||
.Vn curscr .
|
||||
This is useful for implementing a command
|
||||
which would redraw the screen in case it got messed up.
|
||||
.sh 2 Input
|
||||
.pp
|
||||
Input is essentially a mirror image of output.
|
||||
The complementary function to
|
||||
.Fn addch
|
||||
is
|
||||
.Fn getch
|
||||
which,
|
||||
if echo is set,
|
||||
will call
|
||||
.Fn addch
|
||||
to echo the character.
|
||||
Since the screen package needs to know what is on the terminal at all times,
|
||||
if characters are to be echoed,
|
||||
the tty must be in raw or cbreak mode.
|
||||
If it is not,
|
||||
.Fn getch
|
||||
sets it to be cbreak,
|
||||
and then reads in the character.
|
||||
.sh 2 "Termination"
|
||||
.pp
|
||||
In order to perform certain optimizations,
|
||||
and,
|
||||
on some terminals,
|
||||
to work at all,
|
||||
some things must be done
|
||||
before the screen routines start up.
|
||||
These functions are performed in
|
||||
.Fn getttmode
|
||||
and
|
||||
.Fn setterm ,
|
||||
which are called by
|
||||
.Fn initscr .
|
||||
In order to clean up after the routines,
|
||||
the routine
|
||||
.Fn endwin
|
||||
is provided.
|
||||
It restores tty modes to what they were
|
||||
when
|
||||
.Fn initscr
|
||||
was first called.
|
||||
The terminal state module uses the variable
|
||||
.Vn curses_termios
|
||||
to save the original terminal state which is then restored upon a call to
|
||||
.Fn endwin .
|
||||
Thus,
|
||||
anytime after the call to initscr,
|
||||
.Fn endwin
|
||||
should be called before exiting. Note however, that
|
||||
.Fn endwin
|
||||
should always be called
|
||||
.b before
|
||||
the final calls to
|
||||
.Fn delwin ,
|
||||
which free the storage of the windows.
|
|
@ -0,0 +1,69 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)intro.4 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.sh 1 "Cursor Movement Optimizations"
|
||||
.pp
|
||||
One of the most difficult things to do properly is motion optimization.
|
||||
After using
|
||||
.Fn gettmode
|
||||
and
|
||||
.Fn setterm
|
||||
to get the terminal descriptions,
|
||||
the function
|
||||
.Fn mvcur
|
||||
deals with this task.
|
||||
It usage is simple:
|
||||
simply tell it where you are now and where you want to go.
|
||||
For example
|
||||
.(l
|
||||
mvcur(0\*,0\*,LINES/2\*,COLS/2);
|
||||
.)l
|
||||
.lp
|
||||
would move the cursor from the home position (0\*,0)
|
||||
to the middle of the screen.
|
||||
If you wish to force absolute addressing,
|
||||
you can use the function
|
||||
.Fn tgoto
|
||||
from the
|
||||
.b termlib (7)
|
||||
routines,
|
||||
or you can tell
|
||||
.Fn mvcur
|
||||
that you are impossibly far away,
|
||||
For example,
|
||||
to absolutely address the lower left hand corner of the screen
|
||||
from anywhere
|
||||
just claim that you are in the upper right hand corner:
|
||||
.(l
|
||||
mvcur(0\*,COLS\-1\*,LINES\-1\*,0);
|
||||
.)l
|
|
@ -0,0 +1,87 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)intro.5 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.sh 1 "Character Output and Scrolling"
|
||||
.pp
|
||||
The character output policy deals with the following problems. First,
|
||||
where is the location of the cursor after a character is printed, and
|
||||
secondly, when does the screen scroll if scrolling is enabled.
|
||||
.pp
|
||||
In the normal case the characters are output as expected, with the cursor
|
||||
occupying the position of the next character to be output. However, when the
|
||||
cursor is on the last column of the line, the cursor will remain on that
|
||||
position after the last character on the line is output and will only assume
|
||||
the position on the next line when the next character (the first on the next
|
||||
line) is output.
|
||||
.pp
|
||||
Likewise, if scrolling is enabled, a scroll will be invoked only when the
|
||||
first character on he first line past the bottom line of the window is
|
||||
output. If scrolling is not enabled the chracters will to be output to the
|
||||
bottom right corner of the window which is the cursor location.
|
||||
.pp
|
||||
This policy allows consistent behavior of the cursor at the boundary
|
||||
conditions. Furthermore, it prevents a scroll from happening before it is
|
||||
actually needed (the old package used to scroll when the bottom right position
|
||||
was output a character). As a precendent, it models the
|
||||
.i xterm
|
||||
character output conventions.
|
||||
.sh 1 "Terminal State Handling"
|
||||
.pp
|
||||
The variable
|
||||
.Vn curses_termios
|
||||
contains the terminal state of the terminal. Certain historical routines
|
||||
return information:
|
||||
.Fn baudrate ,
|
||||
.Fn erasechar ,
|
||||
.Fn killchar ,
|
||||
and
|
||||
.Fn ospeed .
|
||||
These routines are obsolete and exist only for backward compatibility. If
|
||||
you wish to use the information in the
|
||||
.Vn curses_termios
|
||||
structure, you should use the
|
||||
\fItsetattr\fP(3)
|
||||
routines.
|
||||
.sh 1 "Subwindows"
|
||||
.pp
|
||||
Subwindows are windows which do not have an independent text structure,
|
||||
.i i.e. ,
|
||||
they are windows whose text is a subset of the text of a larger window: the
|
||||
.i parent
|
||||
window. One consequence of this is that changes to either the parent or the
|
||||
child window are destructive to the other,
|
||||
.i i.e. ,
|
||||
a change to the subwindow is also a change to the parent window and a change
|
||||
to the parent window in the region defined by the subwindow is implicitly a
|
||||
change to the subwindow as well.
|
||||
Apart from this detail, subwindows function like any other window.
|
|
@ -0,0 +1,44 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)intro.6 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.sh 1 "The Functions"
|
||||
.pp
|
||||
In the following definitions,
|
||||
.q \*m
|
||||
means that the
|
||||
.q function
|
||||
is really a
|
||||
.q #define
|
||||
macro with arguments.
|
||||
.ta 11m 17m 25m 33m 41m 49m 57m 65m 73m
|
||||
.so fns.doc
|
|
@ -0,0 +1,163 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)life.c 8.1 (Berkeley) 6/8/93
|
||||
.\"
|
||||
# include <curses.h>
|
||||
# include <signal.h>
|
||||
|
||||
/*
|
||||
* Run a life game. This is a demonstration program for
|
||||
* the Screen Updating section of the -lcurses cursor package.
|
||||
*/
|
||||
|
||||
typedef struct lst_st { /* linked list element */
|
||||
int y, x; /* (y, x) position of piece */
|
||||
struct lst_st *next, *last; /* doubly linked */
|
||||
} LIST;
|
||||
|
||||
LIST *Head; /* head of linked list */
|
||||
|
||||
int die();
|
||||
|
||||
main(ac, av)
|
||||
int ac;
|
||||
char *av[];
|
||||
{
|
||||
evalargs(ac, av); /* evaluate arguments */
|
||||
|
||||
initscr(); /* initialize screen package */
|
||||
signal(SIGINT, die); /* set to restore tty stats */
|
||||
cbreak(); /* set for char-by-char */
|
||||
noecho(); /* input */
|
||||
nonl(); /* for optimization */
|
||||
|
||||
getstart(); /* get starting position */
|
||||
for (;;) {
|
||||
prboard(); /* print out current board */
|
||||
update(); /* update board position */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the routine which is called when rubout is hit.
|
||||
* It resets the tty stats to their original values. This
|
||||
* is the normal way of leaving the program.
|
||||
*/
|
||||
die()
|
||||
{
|
||||
signal(SIGINT, SIG_IGN); /* ignore rubouts */
|
||||
mvcur(0, COLS - 1, LINES - 1, 0); /* go to bottom of screen */
|
||||
endwin(); /* set terminal to good state */
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the starting position from the user. They keys u, i, o, j, l,
|
||||
* m, ,, and . are used for moving their relative directions from the
|
||||
* k key. Thus, u move diagonally up to the left, , moves directly down,
|
||||
* etc. x places a piece at the current position, " " takes it away.
|
||||
* The input can also be from a file. The list is built after the
|
||||
* board setup is ready.
|
||||
*/
|
||||
getstart()
|
||||
{
|
||||
reg char c;
|
||||
reg int x, y;
|
||||
auto char buf[100];
|
||||
|
||||
box(stdscr, '|', '_'); /* box in the screen */
|
||||
move(1, 1); /* move to upper left corner */
|
||||
|
||||
for (;;) {
|
||||
refresh(); /* print current position */
|
||||
if ((c = getch()) == 'q')
|
||||
break;
|
||||
switch (c) {
|
||||
case 'u':
|
||||
case 'i':
|
||||
case 'o':
|
||||
case 'j':
|
||||
case 'l':
|
||||
case 'm':
|
||||
case ',':
|
||||
case '.':
|
||||
adjustyx(c);
|
||||
break;
|
||||
case 'f':
|
||||
mvaddstr(0, 0, "File name: ");
|
||||
getstr(buf);
|
||||
readfile(buf);
|
||||
break;
|
||||
case 'x':
|
||||
addch('X');
|
||||
break;
|
||||
case ' ':
|
||||
addch(' ');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Head != NULL) /* start new list */
|
||||
dellist(Head);
|
||||
Head = malloc(sizeof (LIST));
|
||||
|
||||
/*
|
||||
* loop through the screen looking for 'x's, and add a list
|
||||
* element for each one
|
||||
*/
|
||||
for (y = 1; y < LINES - 1; y++)
|
||||
for (x = 1; x < COLS - 1; x++) {
|
||||
move(y, x);
|
||||
if (inch() == 'x')
|
||||
addlist(y, x);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out the current board position from the linked list
|
||||
*/
|
||||
prboard() {
|
||||
|
||||
reg LIST *hp;
|
||||
|
||||
erase(); /* clear out last position */
|
||||
box(stdscr, '|', '_'); /* box in the screen */
|
||||
|
||||
/*
|
||||
* go through the list adding each piece to the newly
|
||||
* blank board
|
||||
*/
|
||||
for (hp = Head; hp; hp = hp->next)
|
||||
mvaddch(hp->y, hp->x, 'X');
|
||||
|
||||
refresh();
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)macros 8.1 (Berkeley) 8/14/93
|
||||
.\"
|
||||
.\" this is the uncommented version. The commented one is in "macros.coms"
|
||||
.ie t .ds _ \d\(mi\u
|
||||
.el .ds _ _
|
||||
.ds , ,\
|
||||
.ds y (y\*,x) co-ordinates
|
||||
.ds db database
|
||||
.ie n .ds f \fI
|
||||
.el .ds f \fB
|
||||
.ds tc \*ftermcap\fP(5)
|
||||
.ds Es This returns ERR if it would cause the screen to scroll illegally.
|
||||
.ds Nm This has no associated \*(lq\fBmv\fP\*(rq command.
|
||||
.ie t .ds m \fB\s-2\(dg\s+2\fP
|
||||
.el .ds m [*]
|
||||
.\" .hy WINDOW
|
||||
.\".he ''\*(Ln''
|
||||
.\".fo ''\- % \-''
|
||||
.oh '\*(Ln''PS1:19-%'
|
||||
.eh 'PS1:19-%''\*(Ln'
|
||||
.de Un
|
||||
.b
|
||||
\s-2\\$2UNIX\\$1\s+2
|
||||
.ft
|
||||
..
|
||||
.de Ds
|
||||
.sp
|
||||
.lp
|
||||
.ev 1
|
||||
.nf
|
||||
.ft I
|
||||
.in 0
|
||||
.di Df
|
||||
..
|
||||
.de De
|
||||
.di
|
||||
.Df
|
||||
.ne \n(dn+2
|
||||
.ev
|
||||
.ip
|
||||
..
|
||||
.de Dg
|
||||
.di
|
||||
.Df
|
||||
.ne \n(dn+2
|
||||
.ev
|
||||
..
|
||||
.de Fd
|
||||
.br
|
||||
\&\\$4
|
||||
.fi
|
||||
.b
|
||||
\&\\$1(\\$2)
|
||||
.ft
|
||||
\&\\$3
|
||||
.br
|
||||
.nf
|
||||
..
|
||||
.de Vn
|
||||
\&\\$3\c
|
||||
.i "\\$1" \\$2
|
||||
..
|
||||
.de Bq
|
||||
.ie t \&\*(lq\fB\\$1\fP\*(rq
|
||||
.el \&\*(lq\fI\\$1\fP\*(rq
|
||||
..
|
||||
.de $0
|
||||
.(x
|
||||
.in \\n(Xs
|
||||
\\*($n \\$1
|
||||
.)x
|
||||
..
|
||||
.de $1
|
||||
.nr Xs 0
|
||||
..
|
||||
.de $2
|
||||
.nr Xs 3
|
||||
..
|
||||
.de $3
|
||||
.nr Xs 6
|
||||
..
|
||||
.de Fn
|
||||
.if \\n(.$==0 .tm error
|
||||
.nr ll 0
|
||||
.nr dg 0
|
||||
.ft R
|
||||
.if '\\$\\n(.$'.' .nr ll 1
|
||||
.if '\\$\\n(.$',' .nr ll 1
|
||||
.if '\\$\\n(.$')' .nr ll 1
|
||||
.if '\\$\\n(.$').' .nr ll 1
|
||||
.if '\\$\\n(.$';' .nr ll 1
|
||||
.if '\\$\\n(.$':' .nr ll 1
|
||||
.if '\\$\\n(.$'\'s' .nr ll 1
|
||||
.if '\\$\\n(.$'\(dg' .nr ll 1
|
||||
.\" .if '\\$\\n(.$'' .nr ll 1
|
||||
.nr al \\n(.$-\\n(ll
|
||||
.ds ot \f(CB\\$1\fP(
|
||||
.if \\n(al>1 .as ot \fI\\$2\fP
|
||||
.if \\n(al>2 .as ot ", \fI\\$3\fP
|
||||
.if \\n(al>3 .as ot ", \fI\\$4\fP
|
||||
.if \\n(al>4 .as ot ", \fI\\$5\fP
|
||||
.if \\n(al>5 .as ot ", \fI\\$6\fP
|
||||
.if \\n(al>6 .as ot ", \fI\\$7\fP
|
||||
.if \\n(al>7 .as ot ", \fI\\$8\fP
|
||||
.if \\n(al>8 .as ot ", \fI\\$9\fP
|
||||
.as ot )
|
||||
.if \\n(.$>1 \{\
|
||||
. if \\n(ll==0 .as ot ;
|
||||
. if '\\$\\n(.$'\(dg' .as ot ;
|
||||
.\}
|
||||
.if \\n(ll==1 .as ot \\$\\n(.$
|
||||
\\*(ot
|
||||
..
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,157 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)twinkle1.c 8.1 (Berkeley) 6/8/93
|
||||
.\"
|
||||
# include <curses.h>
|
||||
# include <signal.h>
|
||||
|
||||
/*
|
||||
* the idea for this program was a product of the imagination of
|
||||
* Kurt Schoens. Not responsible for minds lost or stolen.
|
||||
*/
|
||||
|
||||
# define NCOLS 80
|
||||
# define NLINES 24
|
||||
# define MAXPATTERNS 4
|
||||
|
||||
typedef struct {
|
||||
int y, x;
|
||||
} LOCS;
|
||||
|
||||
LOCS Layout[NCOLS * NLINES]; /* current board layout */
|
||||
|
||||
int Pattern, /* current pattern number */
|
||||
Numstars; /* number of stars in pattern */
|
||||
|
||||
char *getenv();
|
||||
|
||||
int die();
|
||||
|
||||
main()
|
||||
{
|
||||
srand(getpid()); /* initialize random sequence */
|
||||
|
||||
initscr();
|
||||
signal(SIGINT, die);
|
||||
noecho();
|
||||
nonl();
|
||||
leaveok(stdscr, TRUE);
|
||||
scrollok(stdscr, FALSE);
|
||||
|
||||
for (;;) {
|
||||
makeboard(); /* make the board setup */
|
||||
puton('*'); /* put on '*'s */
|
||||
puton(' '); /* cover up with ' 's */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* On program exit, move the cursor to the lower left corner by
|
||||
* direct addressing, since current location is not guaranteed.
|
||||
* We lie and say we used to be at the upper right corner to guarantee
|
||||
* absolute addressing.
|
||||
*/
|
||||
die()
|
||||
{
|
||||
signal(SIGINT, SIG_IGN);
|
||||
mvcur(0, COLS - 1, LINES - 1, 0);
|
||||
endwin();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Make the current board setup. It picks a random pattern and
|
||||
* calls ison() to determine if the character is on that pattern
|
||||
* or not.
|
||||
*/
|
||||
makeboard()
|
||||
{
|
||||
reg int y, x;
|
||||
reg LOCS *lp;
|
||||
|
||||
Pattern = rand() % MAXPATTERNS;
|
||||
lp = Layout;
|
||||
for (y = 0; y < NLINES; y++)
|
||||
for (x = 0; x < NCOLS; x++)
|
||||
if (ison(y, x)) {
|
||||
lp->y = y;
|
||||
lp->x = x;
|
||||
lp++;
|
||||
}
|
||||
Numstars = lp - Layout;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if (y, x) is on the current pattern.
|
||||
*/
|
||||
ison(y, x)
|
||||
reg int y, x; {
|
||||
|
||||
switch (Pattern) {
|
||||
case 0: /* alternating lines */
|
||||
return !(y & 01);
|
||||
case 1: /* box */
|
||||
if (x >= LINES && y >= NCOLS)
|
||||
return FALSE;
|
||||
if (y < 3 || y >= NLINES - 3)
|
||||
return TRUE;
|
||||
return (x < 3 || x >= NCOLS - 3);
|
||||
case 2: /* holy pattern! */
|
||||
return ((x + y) & 01);
|
||||
case 3: /* bar across center */
|
||||
return (y >= 9 && y <= 15);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
puton(ch)
|
||||
reg char ch;
|
||||
{
|
||||
reg LOCS *lp;
|
||||
reg int r;
|
||||
reg LOCS *end;
|
||||
LOCS temp;
|
||||
|
||||
end = &Layout[Numstars];
|
||||
for (lp = Layout; lp < end; lp++) {
|
||||
r = rand() % Numstars;
|
||||
temp = *lp;
|
||||
*lp = Layout[r];
|
||||
Layout[r] = temp;
|
||||
}
|
||||
|
||||
for (lp = Layout; lp < end; lp++) {
|
||||
mvaddch(lp->y, lp->x, ch);
|
||||
refresh();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)twinkle2.c 8.1 (Berkeley) 6/8/93
|
||||
.\"
|
||||
extern int _putchar();
|
||||
|
||||
main()
|
||||
{
|
||||
reg char *sp;
|
||||
|
||||
srand(getpid()); /* initialize random sequence */
|
||||
|
||||
if (isatty(0)) {
|
||||
gettmode();
|
||||
if ((sp = getenv("TERM")) != NULL)
|
||||
setterm(sp);
|
||||
signal(SIGINT, die);
|
||||
}
|
||||
else {
|
||||
printf("Need a terminal on %d\n", _tty_ch);
|
||||
exit(1);
|
||||
}
|
||||
_puts(TI);
|
||||
_puts(VS);
|
||||
|
||||
noecho();
|
||||
nonl();
|
||||
tputs(CL, NLINES, _putchar);
|
||||
for (;;) {
|
||||
makeboard(); /* make the board setup */
|
||||
puton('*'); /* put on '*'s */
|
||||
puton(' '); /* cover up with ' 's */
|
||||
}
|
||||
}
|
||||
|
||||
puton(ch)
|
||||
char ch;
|
||||
{
|
||||
reg LOCS *lp;
|
||||
reg int r;
|
||||
reg LOCS *end;
|
||||
LOCS temp;
|
||||
static int lasty, lastx;
|
||||
|
||||
end = &Layout[Numstars];
|
||||
for (lp = Layout; lp < end; lp++) {
|
||||
r = rand() % Numstars;
|
||||
temp = *lp;
|
||||
*lp = Layout[r];
|
||||
Layout[r] = temp;
|
||||
}
|
||||
|
||||
for (lp = Layout; lp < end; lp++)
|
||||
/* prevent scrolling */
|
||||
if (!AM || (lp->y < NLINES - 1 || lp->x < NCOLS - 1)) {
|
||||
mvcur(lasty, lastx, lp->y, lp->x);
|
||||
putchar(ch);
|
||||
lasty = lp->y;
|
||||
if ((lastx = lp->x + 1) >= NCOLS)
|
||||
if (AM) {
|
||||
lastx = 0;
|
||||
lasty++;
|
||||
}
|
||||
else
|
||||
lastx = NCOLS - 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
.\" @(#)win_st.c 8.1 (Berkeley) 6/8/93
|
||||
.\"
|
||||
# define WINDOW struct _win_st
|
||||
|
||||
struct _win_st {
|
||||
short _cury, _curx;
|
||||
short _maxy, _maxx;
|
||||
short _begy, _begx;
|
||||
short _flags;
|
||||
short _ch_off;
|
||||
bool _clear;
|
||||
bool _leave;
|
||||
bool _scroll;
|
||||
char **_y;
|
||||
short *_firstch;
|
||||
short *_lastch;
|
||||
struct _win_st *_nextp, *_orig;
|
||||
};
|
||||
|
||||
# define _ENDLINE 001
|
||||
# define _FULLWIN 002
|
||||
# define _SCROLLWIN 004
|
||||
# define _FLUSH 010
|
||||
# define _FULLLINE 020
|
||||
# define _IDLINE 040
|
||||
# define _STANDOUT 0200
|
||||
# define _NOCHANGE -1
|
Loading…
Reference in New Issue