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

1.1       root        1: # include      "curses.ext"
                      2: /*     @(#) getstr.c: 1.1 10/15/83     (1.10   11/18/82)       */
                      3: 
                      4: /*
                      5:  *     This routine gets a string starting at (_cury,_curx)
                      6:  *
                      7:  * 7/2/81 (Berkeley) @(#)getstr.c      1.4
                      8:  */
                      9: wgetstr(win,str)
                     10: WINDOW *win; 
                     11: char   *str;
                     12: {
                     13:        char myerase, mykill;
                     14:        char rownum[256], colnum[256];
                     15:        int doecho = SP->fl_echoit;
                     16:        int savecb = SP->fl_rawmode;
                     17:        register int cpos = 0;
                     18:        register int ch;
                     19:        register char *cp = str;
                     20: 
                     21: #ifdef DEBUG
                     22:        if (outf) fprintf(outf, "doecho %d, savecb %d\n", doecho, savecb);
                     23: #endif
                     24: 
                     25:        myerase = erasechar();
                     26:        mykill = killchar();
                     27:        noecho(); crmode();
                     28: 
                     29:        for (;;) {
                     30:                rownum[cpos] = win->_cury;
                     31:                colnum[cpos] = win->_curx;
                     32:                if (! (win->_flags&_ISPAD))
                     33:                        wrefresh(win);
                     34:                ch = wgetch(win);
                     35:                if (ch <= 0 ||ch == ERR || ch == '\n' || ch == '\r')
                     36:                        break;
                     37:                if (ch == myerase || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
                     38:                        if (cpos > 0) {
                     39:                                cp--; cpos--;
                     40:                                if (doecho) {
                     41:                                        wmove(win, rownum[cpos], colnum[cpos]);
                     42:                                        wclrtoeol(win);
                     43:                                }
                     44:                        }
                     45:                } else if (ch == mykill) {
                     46:                        cp = str;
                     47:                        cpos = 0;
                     48:                        if (doecho) {
                     49:                                wmove(win, rownum[cpos], colnum[cpos]);
                     50:                                wclrtoeol(win);
                     51:                        }
                     52:                } else {
                     53:                        *cp++ = ch;
                     54:                        cpos++;
                     55:                        if (doecho) {
                     56:                                waddch(win, ch);
                     57:                        }
                     58:                }
                     59:        }
                     60: 
                     61:        *cp = '\0';
                     62: 
                     63:        if (doecho)
                     64:                echo();
                     65:        if (!savecb)
                     66:                nocrmode();
                     67:        waddch(win, '\n');
                     68:        if (win->_flags & _ISPAD);
                     69:                wrefresh(win);
                     70:        if (ch == ERR)
                     71:                return ERR;
                     72:        return OK;
                     73: }

unix.superglobalmegacorp.com

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