386BSD 0.1 development
authorWilliam F. Jolitz <wjolitz@soda.berkeley.edu>
Wed, 17 Apr 1991 17:38:17 +0000 (09:38 -0800)
committerWilliam F. Jolitz <wjolitz@soda.berkeley.edu>
Wed, 17 Apr 1991 17:38:17 +0000 (09:38 -0800)
Work on file usr/othersrc/share/doc/ps1/18.curses/appen.A
Work on file usr/othersrc/share/doc/ps1/18.curses/appen.B
Work on file usr/othersrc/share/doc/ps1/18.curses/doc.III
Work on file usr/othersrc/share/doc/ps1/18.curses/appen.C
Work on file usr/othersrc/share/doc/ps1/18.curses/doc.IV
Work on file usr/othersrc/share/doc/ps1/18.curses/doc.II
Work on file usr/othersrc/share/doc/ps1/18.curses/doc.I
Work on file usr/othersrc/share/doc/ps1/18.curses/c_macros
Work on file usr/othersrc/share/doc/ps1/18.curses/intro.4
Work on file usr/othersrc/share/doc/ps1/18.curses/intro.3
Work on file usr/othersrc/share/doc/ps1/18.curses/intro.2
Work on file usr/othersrc/share/doc/ps1/18.curses/intro.1
Work on file usr/othersrc/share/doc/ps1/18.curses/intro.0
Work on file usr/othersrc/share/doc/ps1/18.curses/twinkle1.c
Work on file usr/othersrc/share/doc/ps1/18.curses/macros
Work on file usr/othersrc/share/doc/ps1/18.curses/life.c
Work on file usr/othersrc/share/doc/ps1/18.curses/twinkle2.c
Work on file usr/othersrc/share/doc/ps1/18.curses/intro.5
Work on file usr/othersrc/share/doc/ps1/18.curses/win_st.c

Co-Authored-By: Lynne Greer Jolitz <ljolitz@cardio.ucsf.edu>
Synthesized-from: 386BSD-0.1

19 files changed:
usr/othersrc/share/doc/ps1/18.curses/appen.A [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/appen.B [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/appen.C [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/c_macros [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/doc.I [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/doc.II [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/doc.III [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/doc.IV [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/intro.0 [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/intro.1 [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/intro.2 [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/intro.3 [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/intro.4 [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/intro.5 [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/life.c [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/macros [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/twinkle1.c [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/twinkle2.c [new file with mode: 0644]
usr/othersrc/share/doc/ps1/18.curses/win_st.c [new file with mode: 0644]

diff --git a/usr/othersrc/share/doc/ps1/18.curses/appen.A b/usr/othersrc/share/doc/ps1/18.curses/appen.A
new file mode 100644 (file)
index 0000000..59941f5
--- /dev/null
@@ -0,0 +1,191 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.ie t .oh '\*(Ln Appendix A''PS1:18-%'
+.eh 'PS1:18-%''\*(Ln Appendix A'
+.el .he ''\fIAppendix A\fR''
+.bp
+.(x
+.sp 2
+.in 0
+.bi Appendixes
+.sp
+.b "Appendix A"
+.)x
+.nr * 1
+.sh 1 "Capabilities from termcap" 1
+.sh 2 Disclaimer
+.pp
+The description of terminals is a difficult business,
+and we only attempt to summarize the capabilities here:
+for a full description see
+.b termcap (5).
+.sh 2 Overview
+.pp
+Capabilities from
+.b termcap
+are of three kinds:
+string valued options,
+numeric valued options,
+and boolean options.
+The string valued options are the most complicated,
+since they may include padding information,
+which we describe now.
+.pp
+Intelligent terminals often require padding on intelligent operations
+at high (and sometimes even low) speed.
+This is specified by a number before the string in the capability,
+and has meaning for the capabilities which have a
+.b P
+at the front of their comment.
+This normally is a number of milliseconds to pad the operation.
+In the current system which has no true programmable delays,
+we do this by sending a sequence of pad characters
+(normally nulls, but can be changed
+(specified by
+.i PC )).
+In some cases, the pad is better computed as some number of milliseconds
+times the number of affected lines
+(to the bottom of the screen usually,
+except when terminals have insert modes which will shift several lines.)
+This is specified as,
+i e.g. ,
+.b 12* .
+before the capability,
+to say 12 milliseconds per affected whatever
+(currently always line).
+Capabilities where this makes sense say
+.b P* .
+.sp
+.sh 2 "Variables Set By setterm()"
+.TS H
+c s s s
+l l l l.
+variables set by \fIsetterm()\fR
+
+Type   Name    Pad     Description
+_
+.TH
+char * AL      P*      Add new blank Line
+bool   AM              Automatic Margins
+char * BC              Back Cursor movement
+bool   BS              BackSpace works
+char * BT      P       Back Tab
+bool   CA              Cursor Addressable
+char * CD      P*      Clear to end of Display
+char * CE      P       Clear to End of line
+char * CL      P*      CLear screen
+char * CM      P       Cursor Motion
+char * DC      P*      Delete Character
+char * DL      P*      Delete Line sequence
+char * DM              Delete Mode (enter)
+char * DO              DOwn line sequence
+char * ED              End Delete mode
+bool   EO              can Erase Overstrikes with \' \'
+char * EI              End Insert mode
+char * HO              HOme cursor
+bool   HZ              HaZeltine ~ braindamage
+char * IC      P       Insert Character
+bool   IN              Insert-Null blessing
+char * IM              enter Insert Mode (IC usually set, too)
+char * IP      P*      Pad after char Inserted using IM+IE
+char * LL              quick to Last Line, column 0
+char * MA              ctrl character MAp for cmd mode
+bool   MI              can Move in Insert mode
+bool   NC              No Cr: \er sends \er\en then eats \en
+char * ND              Non-Destructive space
+bool   OS              OverStrike works
+char   PC              Pad Character
+char * SE              Standout End (may leave space)
+char * SF      P       Scroll Forwards
+char * SO              Stand Out begin (may leave space)
+char * SR      P       Scroll in Reverse
+char * TA      P       TAb (not ^I or with padding)
+char * TE              Terminal address enable Ending sequence
+char * TI              Terminal address enable Initialization
+char * UC              Underline a single Character
+char * UE              Underline Ending sequence
+bool   UL              UnderLining works even though !OS
+char * UP              UPline
+char * US              Underline Starting sequence
+char * VB              Visible Bell
+char * VE              Visual End sequence
+char * VS              Visual Start sequence
+bool   XN              a Newline gets eaten after wrap
+.TE
+Names starting with
+.bi X
+are reserved for severely nauseous glitches
+.pp
+For purposes of
+.Fn standout ,
+if
+.Fn SG
+is not 0,
+.Fn SO
+is set to
+.Fn NULL ,
+and if
+.Fn UG
+is not
+.Fn 0 ,
+.Fn US
+is set to
+.Fn NULL .
+If, after this,
+.Fn SO
+is
+.Fn NULL ,
+and
+.Fn US
+is not,
+.Fn SO
+is set to be
+.Fn US ,
+and
+.Fn SE
+is set to be
+.Fn UE .
+.sh 2 "Variables Set By gettmode()"
+.TS H
+c s s
+l l l.
+variables set by \fIgettmode()\fR
+
+type   name    description
+_
+.TH
+bool   NONL    Term can't hack linefeeds doing a CR
+bool   GT      Gtty indicates Tabs
+bool   UPPERCASE       Terminal generates only uppercase letters
+.TE
diff --git a/usr/othersrc/share/doc/ps1/18.curses/appen.B b/usr/othersrc/share/doc/ps1/18.curses/appen.B
new file mode 100644 (file)
index 0000000..df0b687
--- /dev/null
@@ -0,0 +1,201 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.ie t .oh '\*(Ln Appendix B''PS1:18-%'
+.eh 'PS1:18-%''\*(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 .
diff --git a/usr/othersrc/share/doc/ps1/18.curses/appen.C b/usr/othersrc/share/doc/ps1/18.curses/appen.C
new file mode 100644 (file)
index 0000000..45408f4
--- /dev/null
@@ -0,0 +1,110 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.ie t .oh '\*(Ln Appendix C''PS1:18-%'
+.eh 'PS1:18-%''\*(Ln Appendix C'
+.el .he ''\fIAppendix C\fR''
+.bp
+.(x
+.ti 0
+.b "Appendix C"
+.)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.
+.sh 1 "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.
+The rest is left as an exercise to the reader,
+and will not be on the final.
+.sh 2 "Twinkle"
+.pp
+This is a moderately simple program which prints
+pretty patterns on the screen
+that might even hold your interest for 30 seconds or more.
+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 2 "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 1 "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 2 "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
diff --git a/usr/othersrc/share/doc/ps1/18.curses/c_macros b/usr/othersrc/share/doc/ps1/18.curses/c_macros
new file mode 100644 (file)
index 0000000..d949daa
--- /dev/null
@@ -0,0 +1,70 @@
+.\" Copyright (c) 1980 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    6.3 (Berkeley) 4/17/91
+.\"
+'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
diff --git a/usr/othersrc/share/doc/ps1/18.curses/doc.I b/usr/othersrc/share/doc/ps1/18.curses/doc.I
new file mode 100644 (file)
index 0000000..a460934
--- /dev/null
@@ -0,0 +1,349 @@
+.\" Copyright (c) 1980 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       6.3 (Berkeley) 4/17/91
+.\"
+.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).
diff --git a/usr/othersrc/share/doc/ps1/18.curses/doc.II b/usr/othersrc/share/doc/ps1/18.curses/doc.II
new file mode 100644 (file)
index 0000000..471b4fc
--- /dev/null
@@ -0,0 +1,142 @@
+.\" Copyright (c) 1980 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      6.3 (Berkeley) 4/17/91
+.\"
+.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
diff --git a/usr/othersrc/share/doc/ps1/18.curses/doc.III b/usr/othersrc/share/doc/ps1/18.curses/doc.III
new file mode 100644 (file)
index 0000000..c2daa5a
--- /dev/null
@@ -0,0 +1,343 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.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.
diff --git a/usr/othersrc/share/doc/ps1/18.curses/doc.IV b/usr/othersrc/share/doc/ps1/18.curses/doc.IV
new file mode 100644 (file)
index 0000000..a726ad3
--- /dev/null
@@ -0,0 +1,110 @@
+.\" Copyright (c) 1980 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      6.3 (Berkeley) 4/17/91
+.\"
+.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.
diff --git a/usr/othersrc/share/doc/ps1/18.curses/intro.0 b/usr/othersrc/share/doc/ps1/18.curses/intro.0
new file mode 100644 (file)
index 0000000..5aebba0
--- /dev/null
@@ -0,0 +1,96 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.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"
+.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.
+.sp 2
+Revised 16 April 1986
diff --git a/usr/othersrc/share/doc/ps1/18.curses/intro.1 b/usr/othersrc/share/doc/ps1/18.curses/intro.1
new file mode 100644 (file)
index 0000000..4747950
--- /dev/null
@@ -0,0 +1,281 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.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 (hopefully) with nearly as much ease as is necessary to simply print
+or read things.
+.pp
+The package is split into three parts:
+(1) Screen updating;
+(2) Screen updating with user input;
+and
+(3) Cursor motion optimization.
+.pp
+It is possible to use the motion optimization
+without using either of the other two,
+and screen updating and input can be done
+without any programmer knowledge of the motion optimization,
+or indeed the \*(et \*(db itself.
+.sh 2 "Terminology (or, Words You Can Say to Sound Brilliant)"
+.pp
+In this document,
+the following terminology is kept to with reasonable consistency:
+.de Ip
+.sp
+.in 5n
+.ti 0n
+.bi "\\$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
+.bi terminal
+.bi 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 Things"
+.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.
+The header file
+.b <curses.h>
+needs to include
+.b <sgtty.h> ,
+so the one should not do so oneself\**.
+.(f
+\**
+The screen package also uses the Standard I/O library,
+so
+.b <curses.h>
+includes
+.b <stdio.h> .
+It is redundant
+(but harmless)
+for the programmer to do it, too.
+.)f
+Also,
+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 let the package worry about the best way to do this.
+.sh 2 "Naming Conventions"
+.pp
+As hinted above,
+the routines can use several windows,
+but two are automatically given:
+.Vn curscr ,
+which knows what the terminal looks like,
+and
+.Vn stdscr ,
+which is what the programmer wants the terminal to look like next.
+The user should never really 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 deal with
+.Vn stdscr
+as a default.
+.)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 clumsyness,
+most I/O routines can be preceded by the prefix
+.Bq mv
+and the desired \*y then can 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 such pointers are need,
+they are always the first parameters passed.
diff --git a/usr/othersrc/share/doc/ps1/18.curses/intro.2 b/usr/othersrc/share/doc/ps1/18.curses/intro.2
new file mode 100644 (file)
index 0000000..939b3df
--- /dev/null
@@ -0,0 +1,90 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.sh 1 Variables
+.pp
+Many variables which are used to describe the terminal environment
+are available to the programmer. They are:
+.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{
+error flag returned by routines when things go right.
+T}
+.TE
+.pp
+There are also several
+.q #define
+constants and types
+which are of general usefulness:
+.sp
+.ev 1
+.ta 11n
+.(b L
+.nf
+reg    storage class ``register'' (\fIe.g.\fP, \fIreg int i;\fR\|)
+bool   boolean type, actually a ``char'' (\fIe.g.\fP, \fIbool doneit;\fR\|)
+TRUE   boolean ``true'' flag (1).
+FALSE  boolean ``false'' flag (0).
+.fi
+.ev
+.)b
+.lp
diff --git a/usr/othersrc/share/doc/ps1/18.curses/intro.3 b/usr/othersrc/share/doc/ps1/18.curses/intro.3
new file mode 100644 (file)
index 0000000..82c9bee
--- /dev/null
@@ -0,0 +1,230 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.sh 1 Usage
+.pp
+This is a description of how to actually use the screen package.
+In it, we assume all updating, reading, etc.
+is applied to
+.Vn stdscr .
+All instructions will work on any window,
+with changing the function name and parameters as mentioned above.
+.sh 2 "Starting up"
+.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
+Now that the screen windows have been allocated,
+you can set them up for the run.
+If you want to, say, allow the window to scroll,
+use
+.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.
+New windows of your own can be created, too, by using the functions
+.Fn newwin
+and
+.Fn subwin .
+.Fn delwin
+will allow you to get rid of old windows.
+If you wish to change the official size of the terminal by hand,
+just set the variables
+.Vn LINES
+and
+.Vn COLS
+to be what you want,
+and then call
+.Fn initscr .
+This is best done before,
+but can be done either before or after,
+the first call to
+.Fn initscr ,
+as it will always delete any existing
+.Vn stdscr
+and/or
+.Vn curscr
+before creating new ones.
+.pp
+.sh 2 "The Nitty-Gritty"
+.sh 3 Output
+.pp
+Now that we have set things up,
+we will want to actually update the terminal.
+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 when scrolling is not allowed.
+As mentioned above, you can combine the two into
+.Fn mvaddch
+to do both things in one fell swoop.
+.pp
+The other output functions,
+such as
+.Fn addstr
+and
+.Fn printw ,
+all call
+.Fn addch
+to add characters to the window.
+.pp
+After you have put on the window what you want there,
+when you want the portion of the terminal covered by the window
+to be made to look like it,
+you must call
+.Fn refresh .
+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
+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
+.Vn curscr
+thinks it looks like.
+This is useful for implementing a command
+which would redraw the screen in case it get messed up.
+.sh 3 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 3 Miscellaneous
+.pp
+All sorts of fun functions exists for maintaining and changing information
+about the windows.
+For the most part,
+the descriptions in section 5.4. should suffice.
+.sh 2 "Finishing up"
+.pp
+In order to do 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.
+Thus,
+anytime after the call to initscr,
+.Fn endwin
+should be called before exiting.
diff --git a/usr/othersrc/share/doc/ps1/18.curses/intro.4 b/usr/othersrc/share/doc/ps1/18.curses/intro.4
new file mode 100644 (file)
index 0000000..fb379d0
--- /dev/null
@@ -0,0 +1,249 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.sh 1 "Cursor Motion Optimization: Standing Alone"
+.pp
+It is possible to use the cursor optimization functions of this screen package
+without the overhead and additional size of the screen updating functions.
+The screen updating functions are designed for uses
+where parts of the screen are changed,
+but the overall image remains the same.
+This includes such programs as
+.b rogue
+and
+.b vi \**.
+.(f
+\**
+.b rogue
+actually uses these functions,
+.b vi
+does not.
+.)f
+Certain other programs
+will find it difficult to use these functions in this manner
+without considerable unnecessary program overhead.
+For such applications,
+such as some
+.q "\fIcrt hacks\fR\|" \**
+.(f
+\**
+Graphics programs designed to run on character-oriented terminals.
+I could name many,
+but they come and go,
+so the list would be quickly out of date.
+Recently, there have been programs such as
+.b rain ,
+.b rocket ,
+and
+.b gun .
+.)f
+and optimizing
+.b more (1)-type
+programs,
+all that is needed is the motion optimizations.
+This, therefore, is a description
+of what some of what goes on at the lower levels of this screen package.
+The descriptions assume a certain amount of familiarity
+with programming problems and some finer points of C.
+None of it is terribly difficult,
+but you should be forewarned.
+.sh 2 "Terminal Information"
+.pp
+In order to use a terminal's
+features to the best of a program's abilities,
+it must first know what they are\**.
+.(f
+\**
+If this comes as any surprise to you,
+there's this tower in Paris they're thinking of junking
+that I can let you have for a song.
+.)f
+The \*(tc \*(db describes these,
+but a certain amount of decoding is necessary,
+and there are, of course,
+both efficient and inefficient ways of reading them in.
+The algorithm that the uses is taken from
+.b vi
+and is hideously efficient.
+It reads them
+in a tight loop
+into a set of variables
+whose names are two uppercase letters with some mnemonic value.
+For example,
+.Vn HO
+is a string which moves the cursor to the "home" position\**.
+.(f
+\**
+These names are identical to those variables
+used in the
+.b termcap (5)
+\*(db to describe each capability.
+See Appendix A for a complete list of those read,
+and the
+.b termcap (5)
+manual page
+for a full description.
+.)f
+As there are two types of variables involving ttys,
+there are two routines.
+The first,
+.Fn gettmode ,
+sets some variables based upon the tty modes accessed by
+.b gtty (2)
+and
+.b stty (2) .
+The second,
+.Fn setterm ,
+a larger task by reading in the descriptions from the \*(tc \*(db.
+This is the way these routines are used by
+.Fn initscr :
+.(b
+.(l I
+\*fif\fP (isatty(0)) {
+       gettmode();
+       \*fif\fP ((sp=getenv("TERM")) != NULL)
+               setterm(sp);
+       \*felse\fP
+              setterm(Def\*_term);
+}
+\*felse\fP
+       setterm(Def\*_term);
+\*_puts(TI);
+\*_puts(VS);
+.)l
+.)b
+.pp
+.Fn isatty
+checks to see if file descriptor 0 is a terminal\**.
+.(f
+\**
+.Fn isatty
+is defined in the default C library function routines.
+It does a
+.b gtty (2)
+on the descriptor and checks the return value.
+.)f
+If it is,
+.Fn gettmode
+sets the terminal description modes from a
+.b gtty (2) .
+.Fn getenv
+is then called to get the name of the terminal,
+and that value (if there is one) is passed to
+.Fn setterm ,
+which reads in the variables from \*(tc
+associated with that terminal.
+.Fn getenv "" (
+returns a pointer to a string containing the name of the terminal,
+which we save in the character pointer
+.Vn sp .)
+If
+.Fn isatty
+returns false,
+the default terminal
+.Vn Def\*_term
+is used.
+The
+.Vn TI
+and
+.Vn VS
+sequences initialize the terminal
+.Fn \*_puts "" (
+is a macro which uses
+.Fn tputs
+(see
+.b termcap (3))
+and 
+.Fn \*_putchar ""
+to put out a string).
+.Fn endwin
+undoes these things.
+.sh 2 "Movement Optimizations, or, Getting Over Yonder"
+.pp
+Now that we have all this useful information,
+it would be nice to do something with it\**.
+.(f
+\**
+Actually,
+it
+.i can
+be emotionally fulfilling just to get the information.
+This is usually only true, however,
+if you have the social life of a kumquat.
+.)f
+The most difficult thing to do properly is motion optimization.
+When you consider how many different features various terminals have
+(tabs, backtabs, non-destructive space, home sequences, absolute tabs, .....)
+you can see that deciding how to get from here to there
+can be a decidedly non-trivial task.
+The editor
+.b vi
+uses many of these features,
+and the routines it uses to do this take up many pages of code.
+Fortunately, I was able to liberate them with the author's permission,
+and use them here.
+.pp
+After using
+.Fn gettmode
+and
+.Fn setterm
+to get the terminal descriptions,
+the function
+.Fn mvcur
+deals with this task.
+It usage is simple:
+you 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,
+like Cleveland.
+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
diff --git a/usr/othersrc/share/doc/ps1/18.curses/intro.5 b/usr/othersrc/share/doc/ps1/18.curses/intro.5
new file mode 100644 (file)
index 0000000..2c58951
--- /dev/null
@@ -0,0 +1,60 @@
+.\" Copyright (c) 1980 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     6.3 (Berkeley) 4/17/91
+.\"
+.sh 1 "The Functions"
+.pp
+In the following definitions,
+.q \*m
+means that the
+.q function
+is really a
+.q #define
+macro with arguments.
+This means that it will not show up in stack traces in the debugger,
+or, in the case of such functions as
+.Fn addch ,
+it will show up as it's
+.Bq w
+counterpart.
+The arguments are given to show the order and type of each.
+Their names are not mandatory,
+just suggestive.
+.ta 11m,17m,25m,33m,41m,49m,57m,65m,73m
+.sh 2 "Output Functions"
+.so doc.I
+.sh 2 "Input Functions"
+.so doc.II
+.sh 2 "Miscellaneous Functions"
+.so doc.III
+.sh 2 Details
+.so doc.IV
diff --git a/usr/othersrc/share/doc/ps1/18.curses/life.c b/usr/othersrc/share/doc/ps1/18.curses/life.c
new file mode 100644 (file)
index 0000000..f115228
--- /dev/null
@@ -0,0 +1,163 @@
+.\" Copyright (c) 1980 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      6.3 (Berkeley) 4/17/91
+.\"
+# 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();
+}
diff --git a/usr/othersrc/share/doc/ps1/18.curses/macros b/usr/othersrc/share/doc/ps1/18.curses/macros
new file mode 100644 (file)
index 0000000..2634451
--- /dev/null
@@ -0,0 +1,110 @@
+.\" Copyright (c) 1980 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      6.3 (Berkeley) 4/17/91
+.\"
+.\" 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:18-%'
+.eh 'PS1:18-%''\*(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
+.ne \n(dn+2
+.Df
+.ev
+.ip
+..
+.de Fd
+.br
+\&\\$4
+.fi
+.b
+\&\\$1(\\$2)
+.ft
+\&\\$3
+.br
+.nf
+..
+.de Vn
+\&\\$3\c
+.i "\\$1" \\$2
+..
+.de Fn
+\&\\$3\c
+.i "\\$1(\\$4)" \\$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
+..
diff --git a/usr/othersrc/share/doc/ps1/18.curses/twinkle1.c b/usr/othersrc/share/doc/ps1/18.curses/twinkle1.c
new file mode 100644 (file)
index 0000000..ed35e51
--- /dev/null
@@ -0,0 +1,157 @@
+.\" Copyright (c) 1980 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  6.3 (Berkeley) 4/17/91
+.\"
+# 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();
+       }
+}
diff --git a/usr/othersrc/share/doc/ps1/18.curses/twinkle2.c b/usr/othersrc/share/doc/ps1/18.curses/twinkle2.c
new file mode 100644 (file)
index 0000000..fc1ca86
--- /dev/null
@@ -0,0 +1,96 @@
+.\" Copyright (c) 1980 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  6.3 (Berkeley) 4/17/91
+.\"
+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;
+               }
+}
diff --git a/usr/othersrc/share/doc/ps1/18.curses/win_st.c b/usr/othersrc/share/doc/ps1/18.curses/win_st.c
new file mode 100644 (file)
index 0000000..ce5ab66
--- /dev/null
@@ -0,0 +1,58 @@
+.\" Copyright (c) 1980 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    6.3 (Berkeley) 4/17/91
+.\"
+# 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