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