Annotation of coherent/d/bin/nroff/drv/aps5.c,v, revision 1.1.1.1

1.1       root        1: head     1.1;
                      2: access   ;
                      3: symbols  ;
                      4: locks    ;
                      5: comment  @ * @;
                      6: 
                      7: 
                      8: 1.1
                      9: date     91.02.04.16.45.30;  author bin;  state Exp;
                     10: branches ;
                     11: next   ;
                     12: 
                     13: 
                     14: desc
                     15: @init ver prov by stevesf
                     16: @
                     17: 
                     18: 
                     19: 
                     20: 1.1
                     21: log
                     22: @Initial revision
                     23: @
                     24: text
                     25: @/* (-lgl
                     26:  *     The information contained herein is a trade secret of Mark Williams
                     27:  *     Company, and  is confidential information.  It is provided  under a
                     28:  *     license agreement,  and may be  copied or disclosed  only under the
                     29:  *     terms of  that agreement.  Any  reproduction or disclosure  of this
                     30:  *     material without the express written authorization of Mark Williams
                     31:  *     Company or persuant to the license agreement is unlawful.
                     32:  * 
                     33:  *     troff-nroff Version 002
                     34:  *     Copyright (c) 1984-1986.
                     35:  *     An unpublished work by Mark Williams Company, Chicago.
                     36:  *     All rights reserved.
                     37:  -lgl) */
                     38: /*
                     39:  * Nroff/Troff.
                     40:  * Driver for the APS-5.
                     41:  */
                     42: #include <stdio.h>
                     43: #include <ctype.h>
                     44: #include "roff.h"
                     45: #include "code.h"
                     46: #include "env.h"
                     47: #include "font.h"
                     48: 
                     49: /*
                     50:  * Commands to the APS-5.
                     51:  */
                     52: 
                     53: /*
                     54:  * Device parameters.
                     55:  */
                     56: int    ntroff  =       TROFF;          /* Programme is TROFF type */
                     57: long   sinmul  =       720;            /* Multiplier for inch */
                     58: long   sindiv  =       1;              /* Divisor for inch */
                     59: long   semmul  =       1;              /* Multiplier for em space */
                     60: long   semdiv  =       1;              /* Divisor for em space */
                     61: long   senmul  =       1;              /* Multiplier for en space */
                     62: long   sendiv  =       2;              /* Divisor for en space */
                     63: long   snrmul  =       1;              /* Narrow space (mul) */
                     64: long   snrdiv  =       6;              /* Narrow space (div) */
                     65: long   sdwmul  =       1;              /* Digit width (mul) */
                     66: long   sdwdiv  =       2;              /* Digit width (div) */
                     67: long   swdmul  =       1;              /* Multiplier for width tables */
                     68: long   swddiv  =       36;             /* Divisor for width tables */
                     69: long   shrmul  =       1;              /* Horizontal resolution (mul) */
                     70: long   shrdiv  =       1;              /* Horizontal resolution (div) */
                     71: long   svrmul  =       1;              /* Vertical resolution (mul) */
                     72: long   svrdiv  =       1;              /* Vertical resolution (div) */
                     73: 
                     74: /*
                     75:  * For mapping user fonts to real fonts.
                     76:  */
                     77: FTB fontab[] ={
                     78:        'R',  '\0', TTTY, 0, 0,
                     79:        'I',  '\0', TTTY, 0, 1,
                     80:        'B',  '\0', TTTY, 1, 0,
                     81:        '\0'
                     82: };
                     83: 
                     84: /*
                     85:  * To convert from internal character set to the on required by
                     86:  * the APS-5.
                     87:  */
                     88: char intaps[] ={
                     89:        0000, 0076, 0065, 0066, 0067, 0070, 0071, 0072, 0073, 0074,
                     90:        0075, 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0010, 0011,
                     91:        0012, 0013, 0014, 0015, 0016, 0017, 0020, 0021, 0022, 0023,
                     92:        0024, 0025, 0026, 0027, 0030, 0031, 0032, 0033, 0034, 0035,
                     93:        0036, 0037, 0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047,
                     94:        0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057, 0060, 0061,
                     95:        0062, 0063, 0064, 0073, 0000, 0000, 0077, 0112, 0101, 0114,
                     96:        0115, 0000, 0000, 0105, 0117, 0104, 0116, 0102, 0103, 0000,
                     97:        0000, 0000, 0110, 0000, 0000, 0000, 0000, 0000, 0120, 0000,
                     98:        0000, 0000, 0000, 0106, 0107, 0000, 0000, 0000
                     99: };
                    100: 
                    101: /*
                    102:  * Width table.
                    103:  */
                    104: char widtab[] ={
                    105:          0,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    106:         12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    107:         12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    108:         12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    109:         12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    110:         12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    111:         12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    112:         12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    113:         12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
                    114:         12,   12,   12,   12,   12
                    115: };
                    116: 
                    117: /*
                    118:  * Set up the non constant parameters that are dependent on a
                    119:  * particular device.  Namely pointsize and font.
                    120:  */
                    121: devparm()
                    122: {
                    123: }
                    124: 
                    125: /*
                    126:  * Given a font, consisting of the font number and flags indicating
                    127:  * whether the font will be in bold or italics, set the current font
                    128:  * to the one given.
                    129:  */
                    130: devfont(font, bold, ital)
                    131: {
                    132:        fonwidt = widtab;
                    133:        fontype = TTTY;
                    134:        bolmode = bold;
                    135:        itlmode = ital;
                    136: }
                    137: 
                    138: /*
                    139:  * Change the pointsize to the one specified.
                    140:  */
                    141: devpsze(n)
                    142: {
                    143:        psz = n;
                    144: }
                    145: 
                    146: /*
                    147:  * Change the vertical spacing.
                    148:  */
                    149: devvlsp(n)
                    150: {
                    151:        vls = n;
                    152: }
                    153: 
                    154: /*
                    155:  * Given a pointer to a buffer containing stream directives
                    156:  * and a pointer to the end of the buffer, print the buffer
                    157:  * out.
                    158:  */
                    159: flushl(buffer, bufend)
                    160: CODE *buffer;
                    161: CODE *bufend;
                    162: {
                    163:        static int hres, vres, font, bold, ital;
                    164:        register CODE *cp;
                    165:        register int n;
                    166: 
                    167:        for (cp=buffer; cp<bufend; cp++) {
                    168:                switch (cp->c_code) {
                    169:                case DNULL:
                    170:                        continue;
                    171:                case DHMOV:
                    172:                        hres += cp->c_iarg;
                    173:                        continue;
                    174:                case DVMOV:
                    175:                        vres += cp->c_iarg;
                    176:                        continue;
                    177:                case DTYPE:
                    178:                        bold = cp->c_car1;
                    179:                        ital = cp->c_car2;
                    180:                        continue;
                    181:                case DFONT:
                    182:                        font = cp->c_iarg;
                    183:                        continue;
                    184:                case DPSZE:
                    185:                        continue;
                    186:                case DSPAR:
                    187:                        hres = 0;
                    188:                        vres += cp->c_iarg;
                    189:                        if (vres >= 0) {
                    190:                                n = (vres+10) / 20;
                    191:                                vres -= n*20;
                    192:                                while (n--)
                    193:                                        putchar('\n');
                    194:                        } else {
                    195:                                n = (-vres+9)/20;
                    196:                                vres += n*20;
                    197:                                while (n--)
                    198:                                        printf("\033-");
                    199:                        }
                    200:                        continue;
                    201:                default:
                    202:                        if (vres >= 0) {
                    203:                                n = (vres+10) / 20;
                    204:                                while (n--)
                    205:                                        putchar('\n');
                    206:                        } else {
                    207:                                n = (-vres+9)/20;
                    208:                                while (n--)
                    209:                                        printf("\033-");
                    210:                        }
                    211:                        vres = 0;
                    212:                        if (hres >= 0) {
                    213:                                n = (hres+6) / 12;
                    214:                                hres -= n*12;
                    215:                                while (n--)
                    216:                                        putchar(' ');
                    217:                        } else {
                    218:                                n = (-hres+5)/12;
                    219:                                hres += n*12;
                    220:                                while (n--)
                    221:                                        putchar('\b');
                    222:                        }
                    223:                        n = cp->c_code;
                    224:                        if (n<=0 || n>=sizeof intasc)
                    225:                                panic("Bad directive %d", n);
                    226:                        n = intasc[n];
                    227:                        if (ital || bold)
                    228:                                if (isascii(n) && (isupper(n) || islower(n)))
                    229:                                        printf("_\b");
                    230:                        putchar(n);
                    231:                        hres += cp->c_move-12;
                    232:                }
                    233:        }
                    234: }
                    235: @

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.