Annotation of 41BSD/lib/libcurses/addch.c, revision 1.1

1.1     ! root        1: # include      "curses.ext"
        !             2: 
        !             3: /*
        !             4:  *     This routine adds the character to the current position
        !             5:  */
        !             6: waddch(win, c)
        !             7: reg WINDOW     *win;
        !             8: char           c;
        !             9: {
        !            10:        reg int         x, y;
        !            11: 
        !            12:        x = win->_curx;
        !            13:        y = win->_cury;
        !            14: # ifdef FULLDEBUG
        !            15:        fprintf(outf, "ADDCH('%c') at (%d, %d)\n", c, y, x);
        !            16: # endif
        !            17:        if (y >= win->_maxy || x >= win->_maxx || y < 0 || x < 0)
        !            18:                return ERR;
        !            19:        switch (c) {
        !            20:          case '\t':
        !            21:          {
        !            22:                reg int         newx;
        !            23: 
        !            24:                --x;
        !            25:                for (newx = x + (8 - (x & 07)) + 1; x <= newx; x++)
        !            26:                        if (waddch(win, ' ') == ERR)
        !            27:                                return ERR;
        !            28:                return OK;
        !            29:          }
        !            30:          default:
        !            31: # ifdef FULLDEBUG
        !            32:                fprintf(outf, "ADDCH: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
        !            33: # endif
        !            34:                if (win->_flags & _STANDOUT)
        !            35:                        c |= _STANDOUT;
        !            36:                if (win->_y[y][x] != c) {
        !            37:                        if (win->_firstch[y] == _NOCHANGE)
        !            38:                                win->_firstch[y] = win->_lastch[y] = x;
        !            39:                        else if (x < win->_firstch[y])
        !            40:                                win->_firstch[y] = x;
        !            41:                        else if (x > win->_lastch[y])
        !            42:                                win->_lastch[y] = x;
        !            43:                }
        !            44:                win->_y[y][x++] = c;
        !            45:                if (x >= win->_maxx) {
        !            46: newline:
        !            47:                        x = 0;
        !            48: nonewline:
        !            49:                        if (++y + 1 == win->_maxy)
        !            50:                                if (win->_scroll) {
        !            51:                                        wrefresh(win);
        !            52:                                        scroll(win);
        !            53:                                        --y;
        !            54:                                }
        !            55:                                else
        !            56:                                        return ERR;
        !            57:                }
        !            58: # ifdef FULLDEBUG
        !            59:                fprintf(outf, "ADDCH: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
        !            60: # endif
        !            61:                break;
        !            62:          case '\n':
        !            63:                clrtoeol();
        !            64:                if (NONL)
        !            65:                        goto nonewline;
        !            66:                else
        !            67:                        goto newline;
        !            68:          case '\r':
        !            69:                x = 0;
        !            70:                break;
        !            71:          case '\b':
        !            72:                if (--x < 0)
        !            73:                        x = 0;
        !            74:                break;
        !            75:        }
        !            76:        win->_curx = x;
        !            77:        win->_cury = y;
        !            78:        return OK;
        !            79: }

unix.superglobalmegacorp.com

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