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

1.1     ! root        1: /*     @(#) writechars.c: 1.1 10/15/83 (1.21   2/11/83)        */
        !             2: 
        !             3: #include "curses.ext"
        !             4: 
        !             5: char *tparm();
        !             6: 
        !             7: extern int     _outch();
        !             8: 
        !             9: _writechars (start, end)
        !            10: register char  *start, *end; 
        !            11: {
        !            12:        register int c;
        !            13:        register char *p;
        !            14:        extern int didntdobotright;     /* did not output char in corner */
        !            15: 
        !            16: #ifdef DEBUG
        !            17:        if(outf) fprintf(outf, "_writechars(%d:'", end-start+1);
        !            18:        if(outf) fwrite(start, sizeof (char), end-start+1, outf);
        !            19:        if(outf) fprintf(outf, "').\n");
        !            20: #endif DEBUG
        !            21:        _setmode ();
        !            22:        _sethl();
        !            23:        while( start <= end )
        !            24:        {
        !            25: #ifdef FULLDEBUG
        !            26:                if(outf) fprintf(outf, "wc loop: repeat_char '%s', SP->phys_irm %d, *start '%c'\n", repeat_char, SP->phys_irm, *start);
        !            27: #endif FULLDEBUG
        !            28:                if (repeat_char && SP->phys_irm != 1 &&
        !            29:                        ((p=start+1),*start==*p++) && (*start==*p++) &&
        !            30:                        (*start==*p++) && (*start==*p++) && p<=end) {
        !            31:                        /* We have a run of at least 5 characters */
        !            32:                        c = 5;
        !            33:                        while (p <= end && *start == *p++)
        !            34:                                c++;
        !            35:                        SP->phys_x += c;
        !            36:                        /* Don't assume anything about how repeat and auto
        !            37:                         * margins interact.  The concept is different. */
        !            38:                        while (SP->phys_x >= columns-1 && auto_right_margin) {
        !            39:                                c--; p--; SP->phys_x--;
        !            40:                        }
        !            41: #ifdef DEBUG
        !            42:                        if(outf) fprintf(outf, "using repeat, count %d, char '%c'\n", c, *start);
        !            43: #endif DEBUG
        !            44:                        tputs(tparm(repeat_char, *start, c), c, _outch);
        !            45:                        start = p-1;
        !            46:                        if (*start == start[-1])
        !            47:                                start++;
        !            48:                        continue;
        !            49:                }
        !            50:                c = *start++;
        !            51: #ifdef DEBUG
        !            52:                if (outf) fprintf(outf, "c is '%c', phys_x %d, phys_y %d\n", c, SP->phys_x, SP->phys_y);
        !            53: #endif DEBUG
        !            54:                if(SP->phys_irm == 1 && insert_character)
        !            55:                {
        !            56:                        tputs(insert_character, columns-SP->phys_x, _outch);
        !            57:                }
        !            58:                /*
        !            59:                 * If transparent_underline && !erase_overstrike,
        !            60:                 * should probably do clr_eol.  No such terminal yet.
        !            61:                 */
        !            62:                if(transparent_underline && erase_overstrike &&
        !            63:                   c == '_' && SP->phys_irm != 1)
        !            64:                {
        !            65:                        _outch (' ');
        !            66:                        tputs(cursor_left, 1, _outch);
        !            67:                }                       
        !            68:                if( ++SP->phys_x >= columns && auto_right_margin )
        !            69:                {
        !            70:                                                  /* Have to on c100 anyway..*/
        !            71:                        if( SP->phys_y >= lines-1 /*&& !eat_newline_glitch*/ )
        !            72:                        {
        !            73:                                /*
        !            74:                                 * We attempted to put something in the last
        !            75:                                 * position of the last line.  Since this will
        !            76:                                 * cause a scroll (we only get here if the
        !            77:                                 * terminal has auto_right_margin) we refuse
        !            78:                                 * to put it out.
        !            79:                                 */
        !            80: #ifdef DEBUG
        !            81:                                if(outf) fprintf(outf,"Avoiding lower right corner\n");
        !            82: #endif
        !            83:                                didntdobotright = 1;
        !            84:                                SP->phys_x--;
        !            85:                                return;
        !            86:                        }
        !            87:                        SP->phys_x = 0;
        !            88:                        SP->phys_y++;
        !            89:                }
        !            90:                if( tilde_glitch && c == '~' )
        !            91:                {
        !            92:                        _outch('`');
        !            93:                }
        !            94:                else
        !            95:                {
        !            96:                        _outch (c);
        !            97:                }
        !            98:                /* Only 1 line can be affected by insert char here */
        !            99:                if( SP->phys_irm == 1 && insert_padding )
        !           100:                {
        !           101:                        tputs(insert_padding, 1, _outch);
        !           102:                }
        !           103:                if( eat_newline_glitch && SP->phys_x == 0 )
        !           104:                {
        !           105:                        /*
        !           106:                         * This handles both C100 and VT100, which are
        !           107:                         * different.  We don't output carriage_return
        !           108:                         * and cursor_down because it might confuse a
        !           109:                         * terminal that is looking for return and linefeed.
        !           110:                         */
        !           111:                        _outch('\r');
        !           112:                        _outch('\n');
        !           113:                }
        !           114:        }
        !           115: }

unix.superglobalmegacorp.com

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