Annotation of researchv10no/ncurses/screen/_delay.c, revision 1.1

1.1     ! root        1: /* Copyright (c) 1979 Regents of the University of California */
        !             2: /*     @(#) _delay.c: 1.1 10/15/83     (1.9    3/6/83) */
        !             3: #include <ctype.h>
        !             4: #include "curses.h"
        !             5: #include "term.h"
        !             6: #ifdef NONSTANDARD
        !             7: # include "ns_curses.h"
        !             8: #endif
        !             9: 
        !            10: /*
        !            11:  * The following array gives the number of tens of milliseconds per
        !            12:  * character for each speed as returned by gtty.  Thus since 300
        !            13:  * baud returns a 7, there are 33.3 milliseconds per char at 300 baud.
        !            14:  */
        !            15: static
        !            16: short  tmspc10[] = {
        !            17:        /* 0   50    75   110 134.5 150  200  300   baud */
        !            18:           0, 2000, 1333, 909, 743, 666, 500, 333,
        !            19:        /* 600 1200 1800 2400 4800 9600 19200 38400 baud */
        !            20:           166, 83,  55,  41,  20,  10,   5,    2
        !            21: };
        !            22: 
        !            23: /*
        !            24:  * Insert a delay into the output stream for "delay/10" milliseconds.
        !            25:  * Round up by a half a character frame, and then do the delay.
        !            26:  * Too bad there are no user program accessible programmed delays.
        !            27:  * Transmitting pad characters slows many terminals down and also
        !            28:  * loads the system.
        !            29:  */
        !            30: _delay(delay, outc)
        !            31: register int delay;
        !            32: int (*outc)();
        !            33: {
        !            34:        register int mspc10;
        !            35:        register int pc;
        !            36:        register int outspeed;
        !            37: 
        !            38: #ifndef        NONSTANDARD
        !            39: # ifdef USG
        !            40:        outspeed = cur_term->Nttyb.c_cflag&CBAUD;
        !            41: # else
        !            42:        outspeed = cur_term->Nttyb.sg_ospeed;
        !            43: # endif
        !            44: #else          NONSTANDARD
        !            45:        outspeed = outputspeed(cur_term);
        !            46: #endif         NONSTANDARD
        !            47:        if (outspeed <= 0 || outspeed >= (sizeof tmspc10 / sizeof tmspc10[0]))
        !            48:                return ERR;
        !            49: 
        !            50:        mspc10 = tmspc10[outspeed];
        !            51:        delay += mspc10 / 2;
        !            52:        if (pad_char)
        !            53:                pc = *pad_char;
        !            54:        else
        !            55:                pc = 0;
        !            56:        for (delay /= mspc10; delay > 0; delay--)
        !            57:                (*outc)(pc);
        !            58:        return OK;
        !            59: }

unix.superglobalmegacorp.com

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