This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / share / doc / ps1 / 18.curses / appen.C
CommitLineData
15637ed4
RG
1.\" Copyright (c) 1980 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
78ed81a3 32.\" from: @(#)appen.C 6.3 (Berkeley) 4/17/91
33.\" appen.C,v 1.2 1993/08/01 18:23:16 mycroft Exp
15637ed4
RG
34.\"
35.ie t .oh '\*(Ln Appendix C''PS1:18-%'
36.eh 'PS1:18-%''\*(Ln Appendix C'
37.el .he ''\fIAppendix C\fR''
38.bp
39.(x
40.ti 0
41.b "Appendix C"
42.)x
43.sh 1 "Examples" 1
44.pp
45Here we present a few examples
46of how to use the package.
47They attempt to be representative,
48though not comprehensive.
49.sh 1 "Screen Updating"
50.pp
51The following examples are intended to demonstrate
52the basic structure of a program
53using the screen updating sections of the package.
54Several of the programs require calculational sections
55which are irrelevant of to the example,
56and are therefore usually not included.
57It is hoped that the data structure definitions
58give enough of an idea to allow understanding
59of what the relevant portions do.
60The rest is left as an exercise to the reader,
61and will not be on the final.
62.sh 2 "Twinkle"
63.pp
64This is a moderately simple program which prints
65pretty patterns on the screen
66that might even hold your interest for 30 seconds or more.
67It switches between patterns of asterisks,
68putting them on one by one in random order,
69and then taking them off in the same fashion.
70It is more efficient to write this
71using only the motion optimization,
72as is demonstrated below.
73.(l I
74.so twinkle1.gr
75.)l
76.sh 2 "Life"
77.pp
78This program fragment models the famous computer pattern game of life
79(Scientific American, May, 1974).
80The calculational routines create a linked list of structures
81defining where each piece is.
82Nothing here claims to be optimal,
83merely demonstrative.
84This code, however,
85is a very good place to use the screen updating routines,
86as it allows them to worry about what the last position looked like,
87so you don't have to.
88It also demonstrates some of the input routines.
89.(l I
90.so life.gr
91.)l
92.sh 1 "Motion optimization"
93.pp
94The following example shows how motion optimization
95is written on its own.
96Programs which flit from one place to another without
97regard for what is already there
98usually do not need the overhead of both space and time
99associated with screen updating.
100They should instead use motion optimization.
101.sh 2 "Twinkle"
102.pp
103The
104.b twinkle
105program
106is a good candidate for simple motion optimization.
107Here is how it could be written
108(only the routines that have been changed are shown):
109.(l
110.so twinkle2.gr
111.)l