diff options
author | 1997-11-26 04:01:02 +0000 | |
---|---|---|
committer | 1997-11-26 04:01:02 +0000 | |
commit | 010b00ebb3f4bdd576ec41ca1d5d0a8994e8fe5b (patch) | |
tree | 5ee5e7213ad9b412a927de7effdcb7c8ce4b489e /lib/libcurses/lib_screen.c | |
parent | libform from ncurses 4.1. Post 4.1 patches to be applied in a separate commit. (diff) | |
download | wireguard-openbsd-010b00ebb3f4bdd576ec41ca1d5d0a8994e8fe5b.tar.xz wireguard-openbsd-010b00ebb3f4bdd576ec41ca1d5d0a8994e8fe5b.zip |
ncurses 4.1 + changes to work with our terminfo libs (instead of
the ncurses ones). Changes are #ifdef EXTERN_TERMINFO.
Post 4.1 patches will be applied in a separate commit.
Diffstat (limited to 'lib/libcurses/lib_screen.c')
-rw-r--r-- | lib/libcurses/lib_screen.c | 77 |
1 files changed, 44 insertions, 33 deletions
diff --git a/lib/libcurses/lib_screen.c b/lib/libcurses/lib_screen.c index 73b4e63b14e..c99bb4849cc 100644 --- a/lib/libcurses/lib_screen.c +++ b/lib/libcurses/lib_screen.c @@ -20,13 +20,13 @@ ***************************************************************************/ -#include "curses.priv.h" +#include <curses.priv.h> -#include <stdio.h> -#include <sys/types.h> #include <sys/stat.h> #include <time.h> -#include "term.h" /* exit_ca_mode, non_rev_rmcup */ +#include <term.h> /* exit_ca_mode, non_rev_rmcup */ + +MODULE_ID("Id: lib_screen.c,v 1.7 1997/02/02 00:41:10 tom Exp $") static time_t dumptime; @@ -35,12 +35,14 @@ WINDOW *getwin(FILE *filep) WINDOW try, *nwin; int n; + T((T_CALLED("getwin(%p)"), filep)); + (void) fread(&try, sizeof(WINDOW), 1, filep); if (ferror(filep)) - return (WINDOW *)NULL; + returnWin(0); - if ((nwin = newwin(try._maxy+1, try._maxx+1, 0, 0)) == (WINDOW *)NULL) - return (WINDOW *)NULL; + if ((nwin = newwin(try._maxy+1, try._maxx+1, 0, 0)) == 0) + returnWin(0); /* * We deliberately do not restore the _parx, _pary, or _parent @@ -50,21 +52,22 @@ WINDOW *getwin(FILE *filep) nwin->_curx = try._curx; nwin->_cury = try._cury; nwin->_maxy = try._maxy; - nwin->_maxx = try._maxx; + nwin->_maxx = try._maxx; nwin->_begy = try._begy; nwin->_begx = try._begx; - nwin->_flags = try._flags; + nwin->_yoffset = try._yoffset; + nwin->_flags = try._flags & ~(_SUBWIN|_ISPAD); nwin->_attrs = try._attrs; - nwin->_bkgd = try._bkgd; + nwin->_bkgd = try._bkgd; nwin->_clear = try._clear; nwin->_scroll = try._scroll; nwin->_leaveok = try._leaveok; nwin->_use_keypad = try._use_keypad; - nwin->_delay = try._delay; - nwin->_immed = try._immed; - nwin->_sync = try._sync; + nwin->_delay = try._delay; + nwin->_immed = try._immed; + nwin->_sync = try._sync; nwin->_regtop = try._regtop; nwin->_regbottom = try._regbottom; @@ -76,45 +79,49 @@ WINDOW *getwin(FILE *filep) if (ferror(filep)) { delwin(nwin); - return((WINDOW *)NULL); + returnWin(0); } } touchwin(nwin); - return nwin; + returnWin(nwin); } int putwin(WINDOW *win, FILE *filep) { int n; + T((T_CALLED("putwin(%p,%p)"), win, filep)); + (void) fwrite(win, sizeof(WINDOW), 1, filep); if (ferror(filep)) - return ERR; + returnCode(ERR); for (n = 0; n < win->_maxy + 1; n++) { (void) fwrite(win->_line[n].text, sizeof(chtype), (size_t)(win->_maxx + 1), filep); if (ferror(filep)) - return(ERR); + returnCode(ERR); } - return(OK); + returnCode(OK); } int scr_restore(const char *file) { FILE *fp; - if ((fp = fopen(file, "r")) == (FILE *)NULL) - return ERR; + T((T_CALLED("scr_restore(%s)"), _nc_visbuf(file))); + + if ((fp = fopen(file, "r")) == 0) + returnCode(ERR); else { delwin(newscr); newscr = getwin(fp); (void) fclose(fp); - return OK; + returnCode(OK); } } @@ -122,14 +129,16 @@ int scr_dump(const char *file) { FILE *fp; - if ((fp = fopen(file, "w")) == (FILE *)NULL) - return ERR; + T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file))); + + if ((fp = fopen(file, "w")) == 0) + returnCode(ERR); else { (void) putwin(newscr, fp); (void) fclose(fp); dumptime = time((time_t *)0); - return OK; + returnCode(OK); } } @@ -138,34 +147,36 @@ int scr_init(const char *file) FILE *fp; struct stat stb; + T((T_CALLED("scr_init(%s)"), _nc_visbuf(file))); + #ifdef exit_ca_mode if (exit_ca_mode && non_rev_rmcup) - return(ERR); + returnCode(ERR); #endif /* exit_ca_mode */ - if ((fp = fopen(file, "r")) == (FILE *)NULL) - return ERR; + if ((fp = fopen(file, "r")) == 0) + returnCode(ERR); else if (fstat(STDOUT_FILENO, &stb) || stb.st_mtime > dumptime) - return ERR; + returnCode(ERR); else { delwin(curscr); curscr = getwin(fp); (void) fclose(fp); - return OK; + returnCode(OK); } } int scr_set(const char *file) { + T((T_CALLED("scr_set(%s)"), _nc_visbuf(file))); + if (scr_init(file) == ERR) - return(ERR); + returnCode(ERR); else { delwin(newscr); newscr = dupwin(curscr); - return(OK); + returnCode(OK); } } - - |