Annotation of 40BSD/lib/libcurses/refresh.c, revision 1.1

1.1     ! root        1: # include      "curses.ext"
        !             2: 
        !             3: # ifndef DEBUG
        !             4: static short   ly, lx;
        !             5: # else
        !             6: short          ly, lx;
        !             7: # endif
        !             8: 
        !             9: wrefresh(win)
        !            10: reg WINDOW     *win;
        !            11: {
        !            12:        reg short       wy;
        !            13: 
        !            14:        /*
        !            15:         * make sure were in visual state
        !            16:         */
        !            17:        if (_endwin) {
        !            18:                _puts(VS);
        !            19:                _puts(TI);
        !            20:                _endwin = FALSE;
        !            21:        }
        !            22:        if (win->_clear || curscr->_clear) {
        !            23:                if ((win->_flags & _FULLWIN) || curscr->_clear) {
        !            24:                        _puts(CL);
        !            25:                        curscr->_curx = curscr->_cury = 0;
        !            26:                        curscr->_clear = FALSE;
        !            27:                        werase(curscr);
        !            28:                }
        !            29:                win->_clear = FALSE;
        !            30:        }
        !            31:        if (!CA) {
        !            32:                if (win->_curx != 0)
        !            33:                        putchar('\n');
        !            34:                werase(curscr);
        !            35:        }
        !            36: # ifdef DEBUG
        !            37:        fprintf(outf, "REFRESH:\n\tfirstch\tlastch\n");
        !            38: # endif
        !            39:        ly = curscr->_cury;
        !            40:        lx = curscr->_curx;
        !            41:        wy = 0;
        !            42:        for (wy = 0; wy < win->_maxy; wy++) {
        !            43: # ifdef DEBUG
        !            44:                fprintf(outf, "%d\t%d\t%d\n", wy, win->_firstch[wy], win->_lastch[wy]);
        !            45: # endif
        !            46:                if (win->_firstch[wy] != _NOCHANGE)
        !            47:                        if (makech(win, wy) == ERR)
        !            48:                            return ERR;
        !            49:                        else
        !            50:                            win->_firstch[wy] = win->_firstch[wy] = _NOCHANGE;
        !            51:        }
        !            52:        if (win->_leave) {
        !            53:                curscr->_cury = ly;
        !            54:                curscr->_curx = lx;
        !            55:                ly -= win->_begy;
        !            56:                lx -= win->_begx;
        !            57:                if (ly >= 0 && ly < win->_maxy && lx >= 0 && lx < win->_maxx) {
        !            58:                        win->_cury = ly;
        !            59:                        win->_curx = lx;
        !            60:                }
        !            61:                else
        !            62:                        win->_cury = win->_curx = 0;
        !            63:        }
        !            64:        else {
        !            65:                mvcur(ly, lx, win->_cury + win->_begy, win->_curx + win->_begx);
        !            66:                curscr->_cury = win->_cury + win->_begy;
        !            67:                curscr->_curx = win->_curx + win->_begx;
        !            68:        }
        !            69:        fflush(stdout);
        !            70:        return OK;
        !            71: }
        !            72: 
        !            73: /*
        !            74:  * make a change on the screen
        !            75:  */
        !            76: # ifndef DEBUG
        !            77: static
        !            78: # endif
        !            79: makech(win, wy)
        !            80: reg WINDOW     *win;
        !            81: short          wy;
        !            82: {
        !            83:        reg char        *nsp, *csp, *sp;
        !            84:        reg short       wx, lch, y;
        !            85:        reg int         nlsp, clsp;     /* last space in lines          */
        !            86: 
        !            87:        wx = win->_firstch[wy];
        !            88:        y = wy + win->_begy;
        !            89:        lch = win->_lastch[wy];
        !            90:        csp = &curscr->_y[wy + win->_begy][wx + win->_begx];
        !            91:        nsp = &win->_y[wy][wx];
        !            92:        if (CE) {
        !            93:                for (sp = &win->_y[wy][win->_maxx - 1]; *sp == ' '; sp--)
        !            94:                        if (sp <= win->_y[wy])
        !            95:                                break;
        !            96:                nlsp = sp - win->_y[wy];
        !            97:        }
        !            98:        sp = CE;
        !            99:        while (wx <= lch) {
        !           100:                if (*nsp != *csp) {
        !           101:                        mvcur(ly, lx, y, wx + win->_begx);
        !           102: # ifdef DEBUG
        !           103:                        fprintf(outf, "MAKECH: 1: wx = %d, lx = %d\n", wx, lx);
        !           104: # endif        
        !           105:                        ly = y;
        !           106:                        lx = wx + win->_begx;
        !           107:                        while (*nsp != *csp && wx <= lch) {
        !           108:                                if (sp && wx >= nlsp && *nsp == ' ') {
        !           109:                                        /*
        !           110:                                         * check for clear to end-of-line
        !           111:                                         */
        !           112:                                        sp = &curscr->_y[ly][COLS - 1];
        !           113:                                        while (*sp == ' ')
        !           114:                                                if (sp-- <= csp)
        !           115:                                                        break;
        !           116:                                        clsp = sp - curscr->_y[ly] - win->_begx;
        !           117: # ifdef DEBUG
        !           118:                                        fprintf(outf, "MAKECH: clsp = %d, nlsp = %d\n", clsp, nlsp);
        !           119: # endif
        !           120:                                        if (clsp - nlsp >= strlen(CE)
        !           121:                                            && clsp < win->_maxx) {
        !           122: # ifdef DEBUG
        !           123:                                                fprintf(outf, "MAKECH: using CE\n");
        !           124: # endif
        !           125:                                                _puts(CE);
        !           126:                                                lx = wx + win->_begx;
        !           127:                                                while (wx++ <= clsp)
        !           128:                                                        *csp++ = ' ';
        !           129:                                                goto ret;
        !           130:                                        }
        !           131:                                        sp = NULL;
        !           132:                                }
        !           133:                                /*
        !           134:                                 * enter/exit standout mode as appropriate
        !           135:                                 */
        !           136:                                if ((*nsp&_STANDOUT) != (curscr->_flags&_STANDOUT)) {
        !           137:                                        if (*nsp & _STANDOUT) {
        !           138:                                                _puts(SO);
        !           139:                                                curscr->_flags |= _STANDOUT;
        !           140:                                        }
        !           141:                                        else {
        !           142:                                                _puts(SE);
        !           143:                                                curscr->_flags &= ~_STANDOUT;
        !           144:                                        }
        !           145:                                }
        !           146:                                wx++;
        !           147:                                if (wx >= win->_maxx && wy == win->_maxy)
        !           148:                                                if (win->_scroll) {
        !           149:                                                    putchar((*csp = *nsp) & 0177);
        !           150:                                                    scroll(win);
        !           151:                                                    if (win->_flags&_FULLWIN)
        !           152:                                                            scroll(curscr);
        !           153:                                                    ly = win->_begy+win->_cury;
        !           154:                                                    lx = win->_begx+win->_curx;
        !           155:                                                    return OK;
        !           156:                                                }
        !           157:                                                else if (win->_flags&_SCROLLWIN) {
        !           158:                                                    lx = --wx;
        !           159:                                                    return ERR;
        !           160:                                                }
        !           161:                                putchar((*csp++ = *nsp++) & 0177);
        !           162:                        }
        !           163: # ifdef DEBUG
        !           164:                        fprintf(outf, "MAKECH: 2: wx = %d, lx = %d\n", wx, lx);
        !           165: # endif        
        !           166:                        if (lx == wx + win->_begx)      /* if no change */
        !           167:                                break;
        !           168:                        lx = wx + win->_begx;
        !           169:                }
        !           170:                else if (wx < lch)
        !           171:                        while (*nsp == *csp) {
        !           172:                                nsp++, csp++;
        !           173:                                ++wx;
        !           174:                        }
        !           175:                else
        !           176:                        break;
        !           177: # ifdef DEBUG
        !           178:                fprintf(outf, "MAKECH: 3: wx = %d, lx = %d\n", wx, lx);
        !           179: # endif        
        !           180:        }
        !           181: ret:
        !           182:        return OK;
        !           183: }

unix.superglobalmegacorp.com

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