WINDOW * initscr(void) { #ifdef SIGPOLL void (*savsignal)(int); extern void _ccleanup(int); #else /* SIGPOLL */ int (*savsignal)(); extern int _ccleanup(int); #endif /* SIGPOLL */ #ifdef SIGTSTP extern void _tstp(int); #endif /* SIGTSTP */ static char i_called_before = FALSE; /* Free structures we are about to throw away so we can reuse the memory. */ if (i_called_before && SP) { delscreen(SP); SP = NULL; } if (newscreen(NULL, 0, 0, 0, stdout, stdin) == NULL) { (void) reset_shell_mode(); if (term_errno != -1) termerr(); else curserr(); exit(1); } #ifdef DEBUG if (outf) fprintf(outf, "initscr: term = %s\n", SP); #endif /* DEBUG */ i_called_before = TRUE; #ifdef SIGTSTP /*LINTED*/ if ((savsignal = signal(SIGTSTP, SIG_IGN)) == SIG_DFL) (void) signal(SIGTSTP, _tstp); else (void) signal(SIGTSTP, savsignal); #endif /* SIGTSTP */ /*LINTED*/ if ((savsignal = signal(SIGINT, SIG_IGN)) == SIG_DFL) (void) signal(SIGINT, _ccleanup); else (void) signal(SIGINT, savsignal); /*LINTED*/ if ((savsignal = signal(SIGQUIT, SIG_IGN)) == SIG_DFL) (void) signal(SIGQUIT, _ccleanup); else (void) signal(SIGQUIT, savsignal); return (stdscr); }
/*** SetScreen * * Purpose: * SetScreen () - Set up the editor's internal structures to match the screen * size described by ySize and xSize. Set the hardware to the mode in * Zvideo. * * Input: * * Output: * *************************************************************************/ void SetScreen ( void ) { fChange = ZEROREALLOC (fChange, YSIZE * sizeof (*fChange)); SETFLAG (fDisplay, RSTATUS); if (cWin == 1) { WINXSIZE(pWinCur) = XSIZE; WINYSIZE(pWinCur) = YSIZE; } newscreen (); // SetVideoState(Zvideo); }
/*** pFileToTop - make the specified file the top of the current window * * Search the instance list in the current window for the file. If it is * found, relink it to be the top one. Otherwise, allocate a new instance for * it and place it at the top of the instance list. Also bring the file to * the top of the pFileHead file list. Ensure that it is on the list to begin * with. * * Input: * pFileTmp = file to bring to top * * OutPut: * Returns FALSE if the pFile is invalid or NULL * *************************************************************************/ flagType pFileToTop ( PFILE pFileTmp ) { EVTargs e; PINS pInsLast = (PINS) &pInsCur; PINS pInsTmp = pInsCur; PFILE pFilePrev; assert (_pfilechk()); assert (_pinschk(pInsCur)); /* * if we're about to lose focus, declare it */ if (pFileTmp != pFileHead) { e.pfile = pFileHead; DeclareEvent (EVT_LOSEFOCUS,(EVTargs *)&e); } /* * Move file to head of file list. Ensure, at the same time, that the file * is in fact ON the list, and declare the event if in fact it is moved. */ if (pFileTmp != pFileHead) { for (pFilePrev = pFileHead; pFilePrev && (pFilePrev->pFileNext != pFileTmp); pFilePrev = pFilePrev->pFileNext ) { ; } if (!pFilePrev) { return FALSE; } pFilePrev->pFileNext = pFileTmp->pFileNext; pFileTmp->pFileNext = pFileHead; pFileHead = pFileTmp; e.pfile = pFileHead; DeclareEvent (EVT_GETFOCUS,(EVTargs *)&e); } /* * pFileTmp now points to a file structure for the correct file. Try to find * an instance of the file in the current window. If not in the instance * list, allocate it. If it is in the instance list, remove it. */ while (pInsTmp != NULL) { if (pInsTmp->pFile == pFileTmp) { break; } pInsLast = pInsTmp; pInsTmp = pInsTmp->pNext; } if (pInsTmp == NULL) { pInsTmp = (PINS) ZEROMALLOC (sizeof (*pInsTmp)); pInsTmp->pFile = pFileTmp; #ifdef DEBUG pInsTmp->id = ID_INSTANCE; #endif IncFileRef (pFileTmp); } else { pInsLast->pNext = pInsTmp->pNext; } /* * Regardless, then, of where it came from, place the new instance back onto * the head of the list */ pInsTmp->pNext = pInsCur; WININST(pWinCur) = pInsCur = pInsTmp; SETFLAG(fDisplay, RCURSOR | RSTATUS); newscreen (); return TRUE; }
SCREEN * newterm(char *type, FILE *fout, FILE *fin) { return (newscreen(type, 0, 0, 0, fout, fin)); }