1/*- 2 * Copyright (c) 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1993, 1994, 1995, 1996 5 * Keith Bostic. All rights reserved. 6 * 7 * See the LICENSE file for redistribution information. 8 */ 9 10#include "config.h" 11 12#ifndef lint 13static const char sccsid[] = "@(#)tk_screen.c 8.9 (Berkeley) 5/24/96"; 14#endif /* not lint */ 15 16#include <sys/types.h> 17#include <sys/queue.h> 18 19#include <bitstring.h> 20#include <errno.h> 21#include <signal.h> 22#include <stdio.h> 23#include <stdlib.h> 24#include <string.h> 25#include <termios.h> 26#include <unistd.h> 27 28#include "../common/common.h" 29#include "tki.h" 30 31/* 32 * tk_screen -- 33 * Initialize/shutdown the Tcl/Tk screen. 34 * 35 * PUBLIC: int tk_screen __P((SCR *, u_int32_t)); 36 */ 37int 38tk_screen(sp, flags) 39 SCR *sp; 40 u_int32_t flags; 41{ 42 TK_PRIVATE *tkp; 43 44 tkp = TKP(sp); 45 46 /* See if we're already in the right mode. */ 47 if (LF_ISSET(SC_VI) && F_ISSET(sp, SC_SCR_VI)) 48 return (0); 49 50 /* Ex isn't possible. */ 51 if (LF_ISSET(SC_EX)) 52 return (1); 53 54 /* Initialize terminal based information. */ 55 if (tk_term_init(sp)) 56 return (1); 57 58 /* Put up the first file name. */ 59 if (tk_rename(sp)) 60 return (1); 61 62 F_SET(tkp, TK_SCR_VI_INIT); 63 return (0); 64} 65 66/* 67 * tk_quit -- 68 * Shutdown the screens. 69 * 70 * PUBLIC: int tk_quit __P((GS *)); 71 */ 72int 73tk_quit(gp) 74 GS *gp; 75{ 76 TK_PRIVATE *tkp; 77 int rval; 78 79 /* Clean up the terminal mappings. */ 80 rval = tk_term_end(gp); 81 82 tkp = GTKP(gp); 83 F_CLR(tkp, TK_SCR_VI_INIT); 84 85 return (rval); 86} 87