]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/lib_endwin.c
ncurses 4.1
[ncurses.git] / ncurses / lib_endwin.c
1
2 /***************************************************************************
3 *                            COPYRIGHT NOTICE                              *
4 ****************************************************************************
5 *                ncurses is copyright (C) 1992-1995                        *
6 *                          Zeyd M. Ben-Halim                               *
7 *                          zmbenhal@netcom.com                             *
8 *                          Eric S. Raymond                                 *
9 *                          esr@snark.thyrsus.com                           *
10 *                                                                          *
11 *        Permission is hereby granted to reproduce and distribute ncurses  *
12 *        by any means and for any fee, whether alone or as part of a       *
13 *        larger distribution, in source or in binary form, PROVIDED        *
14 *        this notice is included with any such distribution, and is not    *
15 *        removed from any of its header files. Mention of ncurses in any   *
16 *        applications linked with it is highly appreciated.                *
17 *                                                                          *
18 *        ncurses comes AS IS with no warranty, implied or expressed.       *
19 *                                                                          *
20 ***************************************************************************/
21
22
23 /*
24 **      lib_endwin.c
25 **
26 **      The routine endwin().
27 **
28 */
29
30 #include <curses.priv.h>
31 #include <term.h>
32
33 MODULE_ID("$Id: lib_endwin.c,v 1.10 1997/02/02 00:36:41 tom Exp $")
34
35 int
36 endwin(void)
37 {
38         T((T_CALLED("endwin()")));
39
40         SP->_endwin = TRUE;
41
42         _nc_mouse_wrap(SP);
43
44         /* SP->_curs{row,col} may be used later in _nc_mvcur_wrap,save_curs */
45         mvcur(-1, -1, SP->_cursrow = screen_lines - 1, SP->_curscol = 0);
46
47         curs_set(1);    /* set cursor to normal mode */
48
49         if (SP->_coloron == TRUE && orig_pair)
50                 putp(orig_pair);
51
52         _nc_mvcur_wrap();       /* wrap up cursor addressing */
53
54         if (SP  &&  (SP->_current_attr != A_NORMAL))
55             vidattr(A_NORMAL);
56
57         /*
58          * Reset terminal's tab counter.  There's a long-time bug that
59          * if you exit a "curses" program such as vi or more, tab
60          * forward, and then backspace, the cursor doesn't go to the
61          * right place.  The problem is that the kernel counts the
62          * escape sequences that reset things as column positions.
63          * Utter a \r to reset this invisibly.
64          */
65         _nc_outch('\r');
66
67         returnCode(reset_shell_mode());
68 }