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

1.1       root        1: # include      "curses.ext"
                      2: # include      <signal.h>
                      3: /*     @(#) makenew.c: 1.1 10/15/83    (1.17   3/16/83)        */
                      4: 
                      5: char   *calloc();
                      6: char   *malloc();
                      7: extern char    *getenv();
                      8: 
                      9: extern WINDOW  *makenew();
                     10: 
                     11: /*
                     12:  *     This routine sets up a window buffer and returns a pointer to it.
                     13:  */
                     14: WINDOW *
                     15: makenew(num_lines, num_cols, begy, begx)
                     16: int    num_lines, num_cols, begy, begx;
                     17: {
                     18: 
                     19:        register int    i;
                     20:        register WINDOW *win;
                     21:        register int    by, bx, nlines, ncols;
                     22:        char *malloc(), *calloc();
                     23: 
                     24:        by = begy;
                     25:        bx = begx;
                     26:        nlines = num_lines;
                     27:        ncols = num_cols;
                     28: 
                     29:        if (nlines <= 0 || ncols <= 0 || by > LINES || bx > COLS)
                     30:                return NULL;
                     31: 
                     32: # ifdef        DEBUG
                     33:        if(outf) fprintf(outf, "MAKENEW(%d, %d, %d, %d)\n", nlines, ncols, by, bx);
                     34: # endif
                     35:        if ((win = (WINDOW *) calloc(1, sizeof (WINDOW))) == NULL)
                     36:                return NULL;
                     37: # ifdef DEBUG
                     38:        if(outf) fprintf(outf, "MAKENEW: nlines = %d\n", nlines);
                     39: # endif
                     40:        if ((win->_y = (chtype **) calloc(nlines, sizeof (chtype *))) == NULL) {
                     41:                cfree((char *)win);
                     42:                return (WINDOW *) NULL;
                     43:        }
                     44:        if ((win->_firstch = (short *) calloc(nlines, sizeof (short))) == NULL) {
                     45:                cfree((char *)win);
                     46:                cfree((char *)win->_y);
                     47:        }
                     48:        if ((win->_lastch = (short *) calloc(nlines, sizeof (short))) == NULL) {
                     49:                cfree((char *)win);
                     50:                cfree((char *)win->_y);
                     51:                cfree((char *)win->_firstch);
                     52:        }
                     53: # ifdef DEBUG
                     54:        if(outf) fprintf(outf, "MAKENEW: ncols = %d\n", ncols);
                     55: # endif
                     56:        win->_cury = win->_curx = 0;
                     57:        win->_clear = (nlines == LINES && ncols == COLS);
                     58:        win->_maxy = nlines;
                     59:        win->_maxx = ncols;
                     60:        win->_begy = by;
                     61:        win->_begx = bx;
                     62:        win->_scroll = win->_leave = win->_use_idl = FALSE;
                     63:        win->_tmarg = 0;
                     64:        win->_bmarg = nlines - 1;
                     65:        for (i = 0; i < nlines; i++)
                     66:                win->_firstch[i] = win->_lastch[i] = _NOCHANGE;
                     67:        if (bx + ncols == COLS) {
                     68:                win->_flags |= _ENDLINE;
                     69:                /* Full window: scrolling heuristics (linefeed) work */
                     70:                if (nlines == LINES && ncols == COLS &&
                     71:                    by == 0 && bx == 0 && scroll_forward)
                     72:                        win->_flags |= _FULLWIN;
                     73:                /* Scrolling window: it might scroll on us by accident */
                     74:                if (by + nlines == LINES && auto_right_margin)
                     75:                        win->_flags |= _SCROLLWIN;
                     76:        }
                     77: # ifdef DEBUG
                     78:        if(outf) fprintf(outf, "MAKENEW: win->_clear = %d\n", win->_clear);
                     79:        if(outf) fprintf(outf, "MAKENEW: win->_leave = %d\n", win->_leave);
                     80:        if(outf) fprintf(outf, "MAKENEW: win->_scroll = %d\n", win->_scroll);
                     81:        if(outf) fprintf(outf, "MAKENEW: win->_flags = %0.2o\n", win->_flags);
                     82:        if(outf) fprintf(outf, "MAKENEW: win->_maxy = %d\n", win->_maxy);
                     83:        if(outf) fprintf(outf, "MAKENEW: win->_maxx = %d\n", win->_maxx);
                     84:        if(outf) fprintf(outf, "MAKENEW: win->_begy = %d\n", win->_begy);
                     85:        if(outf) fprintf(outf, "MAKENEW: win->_begx = %d\n", win->_begx);
                     86: # endif
                     87:        return win;
                     88: }

unix.superglobalmegacorp.com

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