Home | History | Annotate | Line # | Download | only in PSD.doc
appen.C revision 1.4
      1  1.4  perry .\"	$NetBSD: appen.C,v 1.4 1998/01/09 04:12:04 perry 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.1    cgd though not comprehensive.  Further examples can be found in the games section
     50  1.1    cgd of the source tree and in various utilities that use the screen such as
     51  1.1    cgd .i systat(1) .
     52  1.1    cgd .sh 2 "Screen Updating"
     53  1.1    cgd .pp
     54  1.1    cgd The following examples are intended to demonstrate
     55  1.1    cgd the basic structure of a program
     56  1.1    cgd using the screen updating sections of the package.
     57  1.1    cgd Several of the programs require calculational sections
     58  1.1    cgd which are irrelevant of to the example,
     59  1.1    cgd and are therefore usually not included.
     60  1.1    cgd It is hoped that the data structure definitions
     61  1.1    cgd give enough of an idea to allow understanding
     62  1.1    cgd of what the relevant portions do.
     63  1.1    cgd .sh 3 "Simple Character Output"
     64  1.1    cgd .pp
     65  1.1    cgd This program demonstrates how to set up a window and output characters to it.
     66  1.1    cgd Also, it demonstrates how one might control the output to the window.  If
     67  1.1    cgd you run this program, you will get a demonstration of the character output
     68  1.1    cgd chracteristics discussed in the above Character Output section.
     69  1.1    cgd .(l I
     70  1.1    cgd .so t2.gr
     71  1.1    cgd .)l
     72  1.1    cgd .sh 3 "A Small Screen Manipulator"
     73  1.1    cgd .pp
     74  1.1    cgd The next example follows the lines of the previous one but extends then to
     75  1.1    cgd demonstrate the various othe uses of the package.  Make sure you understand
     76  1.1    cgd how this program works as it encompasses most of anything you will
     77  1.1    cgd need to do with the package.
     78  1.1    cgd .(l I
     79  1.1    cgd .so t3.gr
     80  1.1    cgd .)l
     81  1.1    cgd .sh 3 "Twinkle"
     82  1.1    cgd .pp
     83  1.1    cgd This is a moderately simple program which prints
     84  1.1    cgd patterns on the screen.
     85  1.1    cgd It switches between patterns of asterisks,
     86  1.1    cgd putting them on one by one in random order,
     87  1.1    cgd and then taking them off in the same fashion.
     88  1.1    cgd It is more efficient to write this
     89  1.1    cgd using only the motion optimization,
     90  1.1    cgd as is demonstrated below.
     91  1.1    cgd .(l I
     92  1.1    cgd .so twinkle1.gr
     93  1.1    cgd .)l
     94  1.1    cgd .sh 3 "Life"
     95  1.1    cgd .pp
     96  1.1    cgd This program fragment models the famous computer pattern game of life
     97  1.1    cgd (Scientific American, May, 1974).
     98  1.1    cgd The calculational routines create a linked list of structures
     99  1.1    cgd defining where each piece is.
    100  1.1    cgd Nothing here claims to be optimal,
    101  1.1    cgd merely demonstrative.
    102  1.1    cgd This code, however,
    103  1.1    cgd is a very good place to use the screen updating routines,
    104  1.1    cgd as it allows them to worry about what the last position looked like,
    105  1.1    cgd so you don't have to.
    106  1.1    cgd It also demonstrates some of the input routines.
    107  1.1    cgd .(l I
    108  1.1    cgd .so life.gr
    109  1.1    cgd .)l
    110  1.1    cgd .sh 2 "Motion optimization"
    111  1.1    cgd .pp
    112  1.1    cgd The following example shows how motion optimization
    113  1.1    cgd is written on its own.
    114  1.1    cgd Programs which flit from one place to another without
    115  1.1    cgd regard for what is already there
    116  1.1    cgd usually do not need the overhead of both space and time
    117  1.1    cgd associated with screen updating.
    118  1.1    cgd They should instead use motion optimization.
    119  1.1    cgd .sh 3 "Twinkle"
    120  1.1    cgd .pp
    121  1.1    cgd The
    122  1.1    cgd .b twinkle
    123  1.1    cgd program
    124  1.1    cgd is a good candidate for simple motion optimization.
    125  1.1    cgd Here is how it could be written
    126  1.1    cgd (only the routines that have been changed are shown):
    127  1.1    cgd .(l
    128  1.1    cgd .so twinkle2.gr
    129  1.1    cgd .)l
    130