Annotation of 43BSDReno/usr.bin/window/tth19.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * This code is derived from software contributed to Berkeley by
        !             6:  * Edward Wang at The University of California, Berkeley.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms are permitted provided
        !             9:  * that: (1) source distributions retain this entire copyright notice and
        !            10:  * comment, and (2) distributions including binaries display the following
        !            11:  * acknowledgement:  ``This product includes software developed by the
        !            12:  * University of California, Berkeley and its contributors'' in the
        !            13:  * documentation or other materials provided with the distribution and in
        !            14:  * all advertising materials mentioning features or use of this software.
        !            15:  * Neither the name of the University nor the names of its contributors may
        !            16:  * be used to endorse or promote products derived from this software without
        !            17:  * specific prior written permission.
        !            18:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            19:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            20:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            21:  */
        !            22: 
        !            23: #ifndef lint
        !            24: static char sccsid[] = "@(#)tth19.c    3.25 (Berkeley) 6/6/90";
        !            25: #endif /* not lint */
        !            26: 
        !            27: #include "ww.h"
        !            28: #include "tt.h"
        !            29: #include "char.h"
        !            30: 
        !            31: /*
        !            32: kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith:
        !            33:        cr=^M:nl=^J:bl=^G:al=1*\EL:am:le=^H:bs:cd=\EJ:ce=\EK:
        !            34:        cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:dl=1*\EM:do=\EB:
        !            35:        ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:ms:
        !            36:        ta=^I:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:
        !            37:        kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:
        !            38:        kn#8:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:
        !            39:        l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER:
        !            40:        es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1:
        !            41: */
        !            42: 
        !            43: #define NCOL   80
        !            44: #define NROW   24
        !            45: 
        !            46: #define G (WWM_GRP << WWC_MSHIFT)
        !            47: short h19_frame[16] = {
        !            48:        ' ',    '`'|G,  'a'|G,  'e'|G,
        !            49:        '`'|G,  '`'|G,  'f'|G,  'v'|G,
        !            50:        'a'|G,  'd'|G,  'a'|G,  'u'|G,
        !            51:        'c'|G,  't'|G,  's'|G,  'b'|G
        !            52: };
        !            53: 
        !            54: extern struct tt_str *gen_VS;
        !            55: extern struct tt_str *gen_VE;
        !            56: 
        !            57: int h19_msp10c;
        !            58: 
        !            59: #define PAD(ms10) { \
        !            60:        register i; \
        !            61:        for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
        !            62:                ttputc('\0'); \
        !            63: }
        !            64: #define ICPAD() PAD((NCOL - tt.tt_col) * 1)    /* 0.1 ms per char */
        !            65: #define ILPAD() PAD((NROW - tt.tt_row) * 10)   /* 1 ms per char */
        !            66: 
        !            67: #define H19_SETINSERT(m) ttesc((tt.tt_insert = (m)) ? '@' : 'O')
        !            68: 
        !            69: h19_setmodes(new)
        !            70: register new;
        !            71: {
        !            72:        register diff;
        !            73: 
        !            74:        diff = new ^ tt.tt_modes;
        !            75:        if (diff & WWM_REV)
        !            76:                ttesc(new & WWM_REV ? 'p' : 'q');
        !            77:        if (diff & WWM_GRP)
        !            78:                ttesc(new & WWM_REV ? 'F' : 'G');
        !            79:        tt.tt_modes = new;
        !            80: }
        !            81: 
        !            82: h19_insline(n)
        !            83: {
        !            84:        while (--n >= 0) {
        !            85:                ttesc('L');
        !            86:                ILPAD();
        !            87:        }
        !            88: }
        !            89: 
        !            90: h19_delline(n)
        !            91: {
        !            92:        while (--n >= 0) {
        !            93:                ttesc('M');
        !            94:                ILPAD();
        !            95:        }
        !            96: }
        !            97: 
        !            98: h19_putc(c)
        !            99: register char c;
        !           100: {
        !           101:        if (tt.tt_nmodes != tt.tt_modes)
        !           102:                (*tt.tt_setmodes)(tt.tt_nmodes);
        !           103:        if (tt.tt_insert)
        !           104:                H19_SETINSERT(0);
        !           105:        ttputc(c);
        !           106:        if (++tt.tt_col == NCOL)
        !           107:                tt.tt_col = NCOL - 1;
        !           108: }
        !           109: 
        !           110: h19_write(p, n)
        !           111: register char *p;
        !           112: register n;
        !           113: {
        !           114:        if (tt.tt_nmodes != tt.tt_modes)
        !           115:                (*tt.tt_setmodes)(tt.tt_nmodes);
        !           116:        if (tt.tt_insert)
        !           117:                H19_SETINSERT(0);
        !           118:        ttwrite(p, n);
        !           119:        tt.tt_col += n;
        !           120:        if (tt.tt_col == NCOL)
        !           121:                tt.tt_col = NCOL - 1;
        !           122: }
        !           123: 
        !           124: h19_move(row, col)
        !           125: register char row, col;
        !           126: {
        !           127:        if (tt.tt_row == row) {
        !           128:                if (tt.tt_col == col)
        !           129:                        return;
        !           130:                if (col == 0) {
        !           131:                        ttctrl('m');
        !           132:                        goto out;
        !           133:                }
        !           134:                if (tt.tt_col == col - 1) {
        !           135:                        ttesc('C');
        !           136:                        goto out;
        !           137:                }
        !           138:                if (tt.tt_col == col + 1) {
        !           139:                        ttctrl('h');
        !           140:                        goto out;
        !           141:                }
        !           142:        }
        !           143:        if (tt.tt_col == col) {
        !           144:                if (tt.tt_row == row + 1) {
        !           145:                        ttesc('A');
        !           146:                        goto out;
        !           147:                }
        !           148:                if (tt.tt_row == row - 1) {
        !           149:                        ttctrl('j');
        !           150:                        goto out;
        !           151:                }
        !           152:        }
        !           153:        if (col == 0 && row == 0) {
        !           154:                ttesc('H');
        !           155:                goto out;
        !           156:        }
        !           157:        ttesc('Y');
        !           158:        ttputc(' ' + row);
        !           159:        ttputc(' ' + col);
        !           160: out:
        !           161:        tt.tt_col = col;
        !           162:        tt.tt_row = row;
        !           163: }
        !           164: 
        !           165: h19_start()
        !           166: {
        !           167:        if (gen_VS)
        !           168:                ttxputs(gen_VS);
        !           169:        ttesc('w');
        !           170:        ttesc('E');
        !           171:        tt.tt_col = tt.tt_row = 0;
        !           172:        tt.tt_insert = 0;
        !           173:        tt.tt_nmodes = tt.tt_modes = 0;
        !           174: }
        !           175: 
        !           176: h19_end()
        !           177: {
        !           178:        if (tt.tt_insert)
        !           179:                H19_SETINSERT(0);
        !           180:        if (gen_VE)
        !           181:                ttxputs(gen_VE);
        !           182:        ttesc('v');
        !           183: }
        !           184: 
        !           185: h19_clreol()
        !           186: {
        !           187:        ttesc('K');
        !           188: }
        !           189: 
        !           190: h19_clreos()
        !           191: {
        !           192:        ttesc('J');
        !           193: }
        !           194: 
        !           195: h19_clear()
        !           196: {
        !           197:        ttesc('E');
        !           198: }
        !           199: 
        !           200: h19_inschar(c)
        !           201: register char c;
        !           202: {
        !           203:        if (tt.tt_nmodes != tt.tt_modes)
        !           204:                (*tt.tt_setmodes)(tt.tt_nmodes);
        !           205:        if (!tt.tt_insert)
        !           206:                H19_SETINSERT(1);
        !           207:        ttputc(c);
        !           208:        if (tt.tt_insert)
        !           209:                ICPAD();
        !           210:        if (++tt.tt_col == NCOL)
        !           211:                tt.tt_col = NCOL - 1;
        !           212: }
        !           213: 
        !           214: h19_delchar(n)
        !           215: {
        !           216:        while (--n >= 0)
        !           217:                ttesc('N');
        !           218: }
        !           219: 
        !           220: h19_scroll_down(n)
        !           221: {
        !           222:        h19_move(NROW - 1, 0);
        !           223:        while (--n >= 0)
        !           224:                ttctrl('j');
        !           225: }
        !           226: 
        !           227: h19_scroll_up(n)
        !           228: {
        !           229:        h19_move(0, 0);
        !           230:        while (--n >= 0)
        !           231:                ttesc('I');
        !           232: }
        !           233: 
        !           234: tt_h19()
        !           235: {
        !           236:        float cpms = (float) wwbaud / 10000;    /* char per ms */
        !           237: 
        !           238:        h19_msp10c = 10 / cpms;                 /* ms per 10 char */
        !           239:        gen_VS = ttxgetstr("vs");
        !           240:        gen_VE = ttxgetstr("ve");
        !           241: 
        !           242:        tt.tt_start = h19_start;
        !           243:        tt.tt_end = h19_end;
        !           244: 
        !           245:        tt.tt_insline = h19_insline;
        !           246:        tt.tt_delline = h19_delline;
        !           247:        tt.tt_inschar = h19_inschar;
        !           248:        tt.tt_delchar = h19_delchar;
        !           249:        tt.tt_clreol = h19_clreol;
        !           250:        tt.tt_clreos = h19_clreos;
        !           251:        tt.tt_clear = h19_clear;
        !           252:        tt.tt_move = h19_move;
        !           253:        tt.tt_write = h19_write;
        !           254:        tt.tt_putc = h19_putc;
        !           255:        tt.tt_scroll_down = h19_scroll_down;
        !           256:        tt.tt_scroll_up = h19_scroll_up;
        !           257:        tt.tt_setmodes = h19_setmodes;
        !           258: 
        !           259:        tt.tt_ncol = NCOL;
        !           260:        tt.tt_nrow = NROW;
        !           261:        tt.tt_availmodes = WWM_REV|WWM_GRP;
        !           262:        tt.tt_frame = h19_frame;
        !           263:        return 0;
        !           264: }

unix.superglobalmegacorp.com

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