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