Annotation of researchv10no/ncurses/screen/addch.c, revision 1.1.1.1

1.1       root        1: # include      "curses.ext"
                      2: /*     @(#) addch.c: 1.1 10/15/83      (1.5    11/18/82)       */
                      3: 
                      4: /*
                      5:  *     This routine prints the character in the current position.
                      6:  *     Think of it as putc.
                      7:  *
                      8:  * 3/5/81 (Berkeley) @(#)addch.c       1.3
                      9:  */
                     10: waddch(win, c)
                     11: register WINDOW        *win;
                     12: register chtype                c;
                     13: {
                     14:        register int            x, y;
                     15:        char *uctr;
                     16:        register char rawc = c & A_CHARTEXT;
                     17: 
                     18:        x = win->_curx;
                     19:        y = win->_cury;
                     20: # ifdef DEBUG
                     21:        if (outf)
                     22:                if (c == rawc)
                     23:                        fprintf(outf, "'%c'", rawc);
                     24:                else
                     25:                        fprintf(outf, "'%c' %o, raw %o", c, c, rawc);
                     26: # endif
                     27:        if (y >= win->_maxy || x >= win->_maxx || y < 0 || x < 0)
                     28:        {
                     29: # ifdef DEBUG
                     30: if(outf)
                     31: {
                     32: fprintf(outf,"off edge, (%d,%d) not in (%d,%d)\n",y,x,win->_maxy,win->_maxx);
                     33: }
                     34: # endif
                     35:                return ERR;
                     36:        }
                     37:        switch( rawc )
                     38:        {
                     39:        case '\t':
                     40:                {
                     41:                        register int newx;
                     42: 
                     43:                        for( newx = x + (8 - (x & 07)); x < newx; x++ )
                     44:                        {
                     45:                                if( waddch(win, ' ') == ERR )
                     46:                                {
                     47:                                        return ERR;
                     48:                                }
                     49:                        }
                     50:                        return OK;
                     51:                }
                     52:          default:
                     53:                if( rawc < ' ' || rawc > '~' )
                     54:                {
                     55:                        uctr = unctrl(rawc);
                     56:                        waddch(win, (chtype)uctr[0]|(c&A_ATTRIBUTES));
                     57:                        waddch(win, (chtype)uctr[1]|(c&A_ATTRIBUTES));
                     58:                        return OK;
                     59:                }
                     60:                if( win->_attrs )
                     61:                {
                     62: #ifdef DEBUG
                     63: if(outf) fprintf(outf, "(attrs %o, %o=>%o)", win->_attrs, c, c | win->_attrs);
                     64: #endif DEBUG
                     65:                        c |= win->_attrs;;
                     66:                }
                     67:                if( win->_y[y][x] != c )
                     68:                {
                     69:                        if( win->_firstch[y] == _NOCHANGE )
                     70:                        {
                     71:                                win->_firstch[y] = win->_lastch[y] = x;
                     72:                        }
                     73:                        else
                     74:                        {
                     75:                                if( x < win->_firstch[y] )
                     76:                                {
                     77:                                        win->_firstch[y] = x;
                     78:                                }
                     79:                                else
                     80:                                {
                     81:                                        if( x > win->_lastch[y] )
                     82:                                        {
                     83:                                                win->_lastch[y] = x;
                     84:                                        }
                     85:                                }
                     86:                        }
                     87:                }
                     88:                win->_y[y][x++] = c;
                     89:                if (x >= win->_maxx)
                     90:                {
                     91:                        x = 0;
                     92: new_line:
                     93:                        if (++y > win->_bmarg)
                     94:                        {
                     95:                                if (win->_scroll && !(win->_flags&_ISPAD))
                     96:                                {
                     97: #ifdef DEBUG
                     98:        if(outf)
                     99:        {
                    100:                fprintf( outf, "Calling wrefresh( 0%o ) & _tscroll(  0%o  )\n",
                    101:                                win, win );
                    102:        }
                    103: #endif DEBUG
                    104:                                        wrefresh(win);
                    105:                                        _tscroll( win );
                    106:                                        --y;
                    107:                                }
                    108:                                else
                    109:                                {
                    110: # ifdef DEBUG
                    111:                                        int i;
                    112:                                        if(outf)
                    113:                                        {
                    114:                                            fprintf(outf,
                    115:                                            "ERR because (%d,%d) > (%d,%d)\n",
                    116:                                            x, y, win->_maxx, win->_maxy);
                    117:                                            fprintf(outf, "line: '");
                    118:                                            for (i=0; i<win->_maxy; i++)
                    119:                                                fprintf(outf, "%c",
                    120:                                                        win->_y[y-1][i]);
                    121:                                            fprintf(outf, "'\n");
                    122:                                        }
                    123: # endif        DEBUG
                    124:                                        return ERR;
                    125:                                }
                    126:                        }
                    127:                }
                    128: # ifdef DEBUG
                    129:                if(outf) fprintf(outf, "ADDCH: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
                    130: # endif        DEBUG
                    131:                break;
                    132:          case '\n':
                    133:                wclrtoeol(win);
                    134:                x = 0;
                    135:                goto new_line;
                    136:          case '\r':
                    137:                x = 0;
                    138:                break;
                    139:          case '\b':
                    140:                if (--x < 0)
                    141:                        x = 0;
                    142:                break;
                    143:        }
                    144:        win->_curx = x;
                    145:        win->_cury = y;
                    146:        return OK;
                    147: }

unix.superglobalmegacorp.com

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