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

1.1       root        1: # include      "curses.ext"
                      2: # include      <signal.h>
                      3: /*     @(#) m_addch.c: 1.1 10/15/83    (1.3    12/16/82)       */
                      4: 
                      5: /*
                      6:  *     mini.c contains versions of curses routines for minicurses.
                      7:  *     They work just like their non-mini counterparts but draw on
                      8:  *     std_body rather than stdscr.  This cuts down on overhead but
                      9:  *     restricts what you are allowed to do - you can't get stuff back
                     10:  *     from the screen and you can't use multiple windows or things
                     11:  *     like insert/delete line (the logical ones that affect the screen).
                     12:  *     All this but multiple windows could probably be added if somebody
                     13:  *     wanted to mess with it.
                     14:  *
                     15:  * 3/5/81 (Berkeley) @(#)addch.c       1.3
                     16:  */
                     17: m_addch(c)
                     18: register chtype                c;
                     19: {
                     20:        register int            x, y;
                     21:        char *uctr;
                     22:        register char rawc = c & A_CHARTEXT;
                     23: 
                     24: #ifdef DEBUG
                     25:        if (outf) fprintf(outf, "m_addch: [(%d,%d)] ", stdscr->_cury, stdscr->_curx);
                     26: #endif
                     27:        x = stdscr->_curx;
                     28:        y = stdscr->_cury;
                     29: # ifdef DEBUG
                     30:        if (c == rawc)
                     31:                if(outf) fprintf(outf, "'%c'", rawc);
                     32:        else
                     33:                if(outf) fprintf(outf, "'%c' %o, raw %o", c, c, rawc);
                     34: # endif
                     35:        if (y >= stdscr->_maxy || x >= stdscr->_maxx || y < 0 || x < 0) {
                     36:                return ERR;
                     37:        }
                     38:        switch (rawc) {
                     39:          case '\t':
                     40:          {
                     41:                register int newx;
                     42: 
                     43:                for (newx = x + (8 - (x & 07)); x < newx; x++)
                     44:                        if (m_addch(' ') == ERR)
                     45:                                return ERR;
                     46:                return OK;
                     47:          }
                     48:          default:
                     49:                if (rawc < ' ' || rawc > '~') {
                     50:                        uctr = unctrl(rawc);
                     51:                        m_addch((chtype)uctr[0]|(c&A_ATTRIBUTES));
                     52:                        m_addch((chtype)uctr[1]|(c&A_ATTRIBUTES));
                     53:                        return OK;
                     54:                }
                     55:                if (stdscr->_attrs) {
                     56: #ifdef DEBUG
                     57:                        if(outf) fprintf(outf, "(attrs %o, %o=>%o)", stdscr->_attrs, c, c | stdscr->_attrs);
                     58: #endif
                     59:                        c |= stdscr->_attrs;;
                     60:                }
                     61:                /* This line actually puts it out. */
                     62:                SP->virt_x++;
                     63:                *(SP->curptr++) = c;
                     64:                if (x >= stdscr->_maxx) {
                     65:                        x = 0;
                     66: new_line:
                     67:                        if (++y >= stdscr->_maxy)
                     68:                                if (stdscr->_scroll) {
                     69:                                        _ll_refresh(stdscr->_use_idl);
                     70:                                        _scrdown();
                     71:                                        --y;
                     72:                                }
                     73:                                else {
                     74: # ifdef DEBUG
                     75:                                        int i;
                     76:                                        if(outf) fprintf(outf,
                     77:                                            "ERR because (%d,%d) > (%d,%d)\n",
                     78:                                            x, y, stdscr->_maxx, stdscr->_maxy);
                     79:                                        if(outf) fprintf(outf, "line: '");
                     80:                                        if(outf) for (i=0; i<stdscr->_maxy; i++)
                     81:                                                fprintf(outf, "%c", stdscr->_y[y-1][i]);
                     82:                                        if(outf) fprintf(outf, "'\n");
                     83: # endif
                     84:                                        return ERR;
                     85:                                }
                     86:                        _ll_move(y, x);
                     87:                }
                     88: # ifdef FULLDEBUG
                     89:                if(outf) fprintf(outf, "ADDCH: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, stdscr->_firstch[y], stdscr->_lastch[y]);
                     90: # endif
                     91:                break;
                     92:          case '\n':
                     93: # ifdef DEBUG
                     94:                if (outf) fprintf(outf, "newline, y %d, lengths %d->%d, %d->%d, %d->%d\n", y, y, SP->std_body[y]->length, y+1, SP->std_body[y+1]->length, y+2, SP->std_body[y+2]->length);
                     95: # endif
                     96:                if (SP->std_body[y+1])
                     97:                        SP->std_body[y+1]->length = x;
                     98:                x = 0;
                     99:                goto new_line;
                    100:          case '\r':
                    101:                x = 0;
                    102:                break;
                    103:          case '\b':
                    104:                if (--x < 0)
                    105:                        x = 0;
                    106:                break;
                    107:        }
                    108:        stdscr->_curx = x;
                    109:        stdscr->_cury = y;
                    110: #ifdef DEBUG
                    111:        if (outf) fprintf(outf, " => (%d,%d)]\n", stdscr->_cury, stdscr->_curx);
                    112: #endif
                    113:        return OK;
                    114: }

unix.superglobalmegacorp.com

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