Back to index

tetex-bin  3.0
Functions
lib_screen.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Functions

 getwin (FILE *filep)
 putwin (WINDOW *win, FILE *filep)
 scr_restore (const char *file)
 scr_dump (const char *file)
 scr_init (const char *file)
 scr_set (const char *file)

Function Documentation

getwin ( FILE filep)

Definition at line 40 of file lib_screen.c.

{
    WINDOW tmp, *nwin;
    int n;

    T((T_CALLED("getwin(%p)"), filep));

    clearerr(filep);
    (void) fread(&tmp, sizeof(WINDOW), 1, filep);
    if (ferror(filep))
       returnWin(0);

    if (tmp._flags & _ISPAD) {
       nwin = newpad(tmp._maxy + 1, tmp._maxx + 1);
    } else {
       nwin = newwin(tmp._maxy + 1, tmp._maxx + 1, 0, 0);
    }

    /*
     * We deliberately do not restore the _parx, _pary, or _parent
     * fields, because the window hierarchy within which they
     * made sense is probably gone.
     */
    if (nwin != 0) {
       nwin->_curx = tmp._curx;
       nwin->_cury = tmp._cury;
       nwin->_maxy = tmp._maxy;
       nwin->_maxx = tmp._maxx;
       nwin->_begy = tmp._begy;
       nwin->_begx = tmp._begx;
       nwin->_yoffset = tmp._yoffset;
       nwin->_flags = tmp._flags & ~(_SUBWIN);

       nwin->_attrs = tmp._attrs;
       nwin->_nc_bkgd = tmp._nc_bkgd;

       nwin->_notimeout = tmp._notimeout;
       nwin->_clear = tmp._clear;
       nwin->_leaveok = tmp._leaveok;
       nwin->_idlok = tmp._idlok;
       nwin->_idcok = tmp._idcok;
       nwin->_immed = tmp._immed;
       nwin->_scroll = tmp._scroll;
       nwin->_sync = tmp._sync;
       nwin->_use_keypad = tmp._use_keypad;
       nwin->_delay = tmp._delay;

       nwin->_regtop = tmp._regtop;
       nwin->_regbottom = tmp._regbottom;

       if (tmp._flags & _ISPAD)
           nwin->_pad = tmp._pad;

       for (n = 0; n <= nwin->_maxy; n++) {
           clearerr(filep);
           (void) fread(nwin->_line[n].text,
                      sizeof(NCURSES_CH_T),
                      (size_t) (nwin->_maxx + 1),
                      filep);
           if (ferror(filep)) {
              delwin(nwin);
              returnWin(0);
           }
       }
       touchwin(nwin);
    }
    returnWin(nwin);
}

Here is the call graph for this function:

Here is the caller graph for this function:

putwin ( WINDOW win,
FILE filep 
)

Definition at line 110 of file lib_screen.c.

{
    int code = ERR;
    int n;

    T((T_CALLED("putwin(%p,%p)"), win, filep));

    if (win != 0) {
       size_t len = (win->_maxx + 1);

       clearerr(filep);
       if (fwrite(win, sizeof(WINDOW), 1, filep) != 1
           || ferror(filep))
             returnCode(code);

       for (n = 0; n <= win->_maxy; n++) {
           if (fwrite(win->_line[n].text,
                     sizeof(NCURSES_CH_T), len, filep) != len
              || ferror(filep)) {
              returnCode(code);
           }
       }
       code = OK;
    }
    returnCode(code);
}

Here is the call graph for this function:

Here is the caller graph for this function:

scr_dump ( const char *  file)

Definition at line 156 of file lib_screen.c.

{
    FILE *fp = 0;

    T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file)));

    if (_nc_access(file, W_OK) < 0
       || (fp = fopen(file, "wb")) == 0) {
       returnCode(ERR);
    } else {
       (void) putwin(newscr, fp);
       (void) fclose(fp);
       returnCode(OK);
    }
}

Here is the call graph for this function:

scr_init ( const char *  file)

Definition at line 173 of file lib_screen.c.

{
    FILE *fp = 0;

    T((T_CALLED("scr_init(%s)"), _nc_visbuf(file)));

    if (exit_ca_mode && non_rev_rmcup)
       returnCode(ERR);

    if (_nc_access(file, R_OK) < 0
       || (fp = fopen(file, "rb")) == 0) {
       returnCode(ERR);
    } else {
       delwin(curscr);
       SP->_curscr = curscr = getwin(fp);
       (void) fclose(fp);
       returnCode(OK);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

scr_restore ( const char *  file)

Definition at line 138 of file lib_screen.c.

{
    FILE *fp = 0;

    T((T_CALLED("scr_restore(%s)"), _nc_visbuf(file)));

    if (_nc_access(file, R_OK) < 0
       || (fp = fopen(file, "rb")) == 0) {
       returnCode(ERR);
    } else {
       delwin(newscr);
       SP->_newscr = newscr = getwin(fp);
       (void) fclose(fp);
       returnCode(OK);
    }
}

Here is the call graph for this function:

scr_set ( const char *  file)

Definition at line 194 of file lib_screen.c.

{
    T((T_CALLED("scr_set(%s)"), _nc_visbuf(file)));

    if (scr_init(file) == ERR) {
       returnCode(ERR);
    } else {
       delwin(newscr);
       SP->_newscr = newscr = dupwin(curscr);
       returnCode(OK);
    }
}

Here is the call graph for this function: