Home | History | Annotate | Line # | Download | only in PSD.doc
appen.C revision 1.6
      1  1.6     wiz .\"	$NetBSD: appen.C,v 1.6 2002/10/01 19:06:39 wiz Exp $
      2  1.4   perry .\"
      3  1.1     cgd .\" Copyright (c) 1980, 1993
      4  1.1     cgd .\"	The Regents of the University of California.  All rights reserved.
      5  1.1     cgd .\"
      6  1.1     cgd .\" Redistribution and use in source and binary forms, with or without
      7  1.1     cgd .\" modification, are permitted provided that the following conditions
      8  1.1     cgd .\" are met:
      9  1.1     cgd .\" 1. Redistributions of source code must retain the above copyright
     10  1.1     cgd .\"    notice, this list of conditions and the following disclaimer.
     11  1.1     cgd .\" 2. Redistributions in binary form must reproduce the above copyright
     12  1.1     cgd .\"    notice, this list of conditions and the following disclaimer in the
     13  1.1     cgd .\"    documentation and/or other materials provided with the distribution.
     14  1.1     cgd .\" 3. All advertising materials mentioning features or use of this software
     15  1.1     cgd .\"    must display the following acknowledgement:
     16  1.1     cgd .\"	This product includes software developed by the University of
     17  1.1     cgd .\"	California, Berkeley and its contributors.
     18  1.1     cgd .\" 4. Neither the name of the University nor the names of its contributors
     19  1.1     cgd .\"    may be used to endorse or promote products derived from this software
     20  1.1     cgd .\"    without specific prior written permission.
     21  1.1     cgd .\"
     22  1.1     cgd .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23  1.1     cgd .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  1.1     cgd .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  1.1     cgd .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26  1.1     cgd .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  1.1     cgd .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  1.1     cgd .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  1.1     cgd .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  1.1     cgd .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.1     cgd .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.1     cgd .\" SUCH DAMAGE.
     33  1.1     cgd .\"
     34  1.3     cgd .\"	@(#)appen.C	8.1 (Berkeley) 6/8/93
     35  1.1     cgd .\"
     36  1.1     cgd .ie t .oh '\*(Ln Appendix A''PS1:19-%'
     37  1.1     cgd .eh 'PS1:19-%''\*(Ln Appendix A'
     38  1.1     cgd .el .he ''\fIAppendix A\fR''
     39  1.1     cgd .bp
     40  1.1     cgd .(x
     41  1.1     cgd .ti 0
     42  1.1     cgd .b "Appendix A"
     43  1.1     cgd .)x
     44  1.1     cgd .sh 1 "Examples" 1
     45  1.1     cgd .pp
     46  1.1     cgd Here we present a few examples
     47  1.1     cgd of how to use the package.
     48  1.1     cgd They attempt to be representative,
     49  1.6     wiz though not comprehensive.
     50  1.6     wiz Further examples can be found in the games section
     51  1.5  simonb of the source tree and in various utilities that use the screen such as
     52  1.1     cgd .i systat(1) .
     53  1.1     cgd .sh 2 "Screen Updating"
     54  1.1     cgd .pp
     55  1.1     cgd The following examples are intended to demonstrate
     56  1.1     cgd the basic structure of a program
     57  1.1     cgd using the screen updating sections of the package.
     58  1.1     cgd Several of the programs require calculational sections
     59  1.1     cgd which are irrelevant of to the example,
     60  1.1     cgd and are therefore usually not included.
     61  1.1     cgd It is hoped that the data structure definitions
     62  1.1     cgd give enough of an idea to allow understanding
     63  1.1     cgd of what the relevant portions do.
     64  1.1     cgd .sh 3 "Simple Character Output"
     65  1.1     cgd .pp
     66  1.1     cgd This program demonstrates how to set up a window and output characters to it.
     67  1.6     wiz Also, it demonstrates how one might control the output to the window.
     68  1.6     wiz If you run this program, you will get a demonstration of the character output
     69  1.1     cgd chracteristics discussed in the above Character Output section.
     70  1.1     cgd .(l I
     71  1.1     cgd .so t2.gr
     72  1.1     cgd .)l
     73  1.1     cgd .sh 3 "A Small Screen Manipulator"
     74  1.1     cgd .pp
     75  1.5  simonb The next example follows the lines of the previous one but extends then to
     76  1.6     wiz demonstrate the various othe uses of the package.
     77  1.6     wiz Make sure you understand how this program works as it encompasses most of
     78  1.6     wiz anything you will need to do with the package.
     79  1.1     cgd .(l I
     80  1.1     cgd .so t3.gr
     81  1.1     cgd .)l
     82  1.1     cgd .sh 3 "Twinkle"
     83  1.1     cgd .pp
     84  1.1     cgd This is a moderately simple program which prints
     85  1.1     cgd patterns on the screen.
     86  1.1     cgd It switches between patterns of asterisks,
     87  1.1     cgd putting them on one by one in random order,
     88  1.1     cgd and then taking them off in the same fashion.
     89  1.1     cgd It is more efficient to write this
     90  1.1     cgd using only the motion optimization,
     91  1.1     cgd as is demonstrated below.
     92  1.1     cgd .(l I
     93  1.1     cgd .so twinkle1.gr
     94  1.1     cgd .)l
     95  1.1     cgd .sh 3 "Life"
     96  1.1     cgd .pp
     97  1.1     cgd This program fragment models the famous computer pattern game of life
     98  1.1     cgd (Scientific American, May, 1974).
     99  1.1     cgd The calculational routines create a linked list of structures
    100  1.1     cgd defining where each piece is.
    101  1.1     cgd Nothing here claims to be optimal,
    102  1.1     cgd merely demonstrative.
    103  1.1     cgd This code, however,
    104  1.1     cgd is a very good place to use the screen updating routines,
    105  1.1     cgd as it allows them to worry about what the last position looked like,
    106  1.1     cgd so you don't have to.
    107  1.1     cgd It also demonstrates some of the input routines.
    108  1.1     cgd .(l I
    109  1.1     cgd .so life.gr
    110  1.1     cgd .)l
    111  1.1     cgd .sh 2 "Motion optimization"
    112  1.1     cgd .pp
    113  1.1     cgd The following example shows how motion optimization
    114  1.1     cgd is written on its own.
    115  1.1     cgd Programs which flit from one place to another without
    116  1.1     cgd regard for what is already there
    117  1.1     cgd usually do not need the overhead of both space and time
    118  1.1     cgd associated with screen updating.
    119  1.1     cgd They should instead use motion optimization.
    120  1.1     cgd .sh 3 "Twinkle"
    121  1.1     cgd .pp
    122  1.1     cgd The
    123  1.1     cgd .b twinkle
    124  1.1     cgd program
    125  1.1     cgd is a good candidate for simple motion optimization.
    126  1.1     cgd Here is how it could be written
    127  1.1     cgd (only the routines that have been changed are shown):
    128  1.1     cgd .(l
    129  1.1     cgd .so twinkle2.gr
    130  1.1     cgd .)l
    131