Annotation of researchv10no/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:  * 3/5/81 (Berkeley) @(#)addch.c       1.3
        !             7:  */
        !             8: waddch(win, c)
        !             9: reg WINDOW     *win;
        !            10: char           c;
        !            11: {
        !            12:        reg int         x, y;
        !            13: 
        !            14:        x = win->_curx;
        !            15:        y = win->_cury;
        !            16: # ifdef FULLDEBUG
        !            17:        fprintf(outf, "ADDCH('%c') at (%d, %d)\n", c, y, x);
        !            18: # endif
        !            19:        if (y >= win->_maxy || x >= win->_maxx || y < 0 || x < 0)
        !            20:                return ERR;
        !            21:        switch (c) {
        !            22:          case '\t':
        !            23:          {
        !            24:                reg int         newx;
        !            25: 
        !            26:                for (newx = x + (8 - (x & 07)); x < newx; x++)
        !            27:                        if (waddch(win, ' ') == ERR)
        !            28:                                return ERR;
        !            29:                return OK;
        !            30:          }
        !            31:          default:
        !            32: # ifdef FULLDEBUG
        !            33:                fprintf(outf, "ADDCH: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
        !            34: # endif
        !            35:                if (win->_flags & _STANDOUT)
        !            36:                        c |= _STANDOUT;
        !            37:                if (win->_y[y][x] != c) {
        !            38:                        if (win->_firstch[y] == _NOCHANGE)
        !            39:                                win->_firstch[y] = win->_lastch[y] = x;
        !            40:                        else if (x < win->_firstch[y])
        !            41:                                win->_firstch[y] = x;
        !            42:                        else if (x > win->_lastch[y])
        !            43:                                win->_lastch[y] = x;
        !            44:                }
        !            45:                win->_y[y][x++] = c;
        !            46:                if (x >= win->_maxx) {
        !            47:                        x = 0;
        !            48: newline:
        !            49:                        if (++y >= 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:                wclrtoeol(win);
        !            64:                if (!NONL)
        !            65:                        x = 0;
        !            66:                goto newline;
        !            67:          case '\r':
        !            68:                x = 0;
        !            69:                break;
        !            70:          case '\b':
        !            71:                if (--x < 0)
        !            72:                        x = 0;
        !            73:                break;
        !            74:        }
        !            75:        win->_curx = x;
        !            76:        win->_cury = y;
        !            77:        return OK;
        !            78: }

unix.superglobalmegacorp.com

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