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