1998-03-01 12:21:12 +08:00
|
|
|
/****************************************************************************
|
ncurses 5.6 - patch 20070310
+ increase size of array in _nc_visbuf2n() to make "tic -v" work
properly in its similar_sgr() function (report/analysis by Peter
Santoro).
+ add --enable-reentrant configure option for ongoing changes to
implement a reentrant version of ncurses:
+ libraries are suffixed with "t"
+ wrap several global variables (curscr, newscr, stdscr, ttytype,
COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES and TABSIZE) as
functions returning values stored in SCREEN or cur_term.
+ move some initialization (LINES, COLS) from lib_setup.c,
i.e., setupterm() to _nc_setupscreen(), i.e., newterm().
2007-03-11 09:07:00 +08:00
|
|
|
* Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
|
1998-03-01 12:21:12 +08:00
|
|
|
* *
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a *
|
|
|
|
* copy of this software and associated documentation files (the *
|
|
|
|
* "Software"), to deal in the Software without restriction, including *
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish, *
|
|
|
|
* distribute, distribute with modifications, sublicense, and/or sell *
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is *
|
|
|
|
* furnished to do so, subject to the following conditions: *
|
|
|
|
* *
|
|
|
|
* The above copyright notice and this permission notice shall be included *
|
|
|
|
* in all copies or substantial portions of the Software. *
|
|
|
|
* *
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
|
|
|
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
|
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
|
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
|
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
|
|
|
* *
|
|
|
|
* Except as contained in this notice, the name(s) of the above copyright *
|
|
|
|
* holders shall not be used in advertising or otherwise to promote the *
|
|
|
|
* sale, use or other dealings in this Software without prior written *
|
|
|
|
* authorization. *
|
|
|
|
****************************************************************************/
|
1997-05-15 12:00:00 +08:00
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
|
|
|
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
2005-10-10 02:41:57 +08:00
|
|
|
* and: Thomas E. Dickey 1996-on *
|
1998-03-01 12:21:12 +08:00
|
|
|
****************************************************************************/
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** lib_data.c
|
|
|
|
**
|
|
|
|
** Common data that may/may not be allocated, but is referenced globally
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <curses.priv.h>
|
|
|
|
|
2007-11-04 08:06:31 +08:00
|
|
|
MODULE_ID("$Id: lib_data.c,v 1.34 2007/10/20 21:49:10 tom Exp $")
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
/*
|
1998-03-01 12:21:12 +08:00
|
|
|
* OS/2's native linker complains if we don't initialize public data when
|
|
|
|
* constructing a dll (reported by J.J.G.Ripoll).
|
1997-05-15 12:00:00 +08:00
|
|
|
*/
|
ncurses 5.6 - patch 20070310
+ increase size of array in _nc_visbuf2n() to make "tic -v" work
properly in its similar_sgr() function (report/analysis by Peter
Santoro).
+ add --enable-reentrant configure option for ongoing changes to
implement a reentrant version of ncurses:
+ libraries are suffixed with "t"
+ wrap several global variables (curscr, newscr, stdscr, ttytype,
COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES and TABSIZE) as
functions returning values stored in SCREEN or cur_term.
+ move some initialization (LINES, COLS) from lib_setup.c,
i.e., setupterm() to _nc_setupscreen(), i.e., newterm().
2007-03-11 09:07:00 +08:00
|
|
|
#if USE_REENTRANT
|
|
|
|
NCURSES_EXPORT(WINDOW *)
|
|
|
|
NCURSES_PUBLIC_VAR(stdscr) (void)
|
|
|
|
{
|
|
|
|
return SP ? SP->_stdscr : 0;
|
|
|
|
}
|
|
|
|
NCURSES_EXPORT(WINDOW *)
|
|
|
|
NCURSES_PUBLIC_VAR(curscr) (void)
|
|
|
|
{
|
|
|
|
return SP ? SP->_curscr : 0;
|
|
|
|
}
|
|
|
|
NCURSES_EXPORT(WINDOW *)
|
|
|
|
NCURSES_PUBLIC_VAR(newscr) (void)
|
|
|
|
{
|
|
|
|
return SP ? SP->_newscr : 0;
|
|
|
|
}
|
|
|
|
#else
|
2005-10-10 02:41:57 +08:00
|
|
|
NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
|
|
|
|
NCURSES_EXPORT_VAR(WINDOW *) curscr = 0;
|
|
|
|
NCURSES_EXPORT_VAR(WINDOW *) newscr = 0;
|
ncurses 5.6 - patch 20070310
+ increase size of array in _nc_visbuf2n() to make "tic -v" work
properly in its similar_sgr() function (report/analysis by Peter
Santoro).
+ add --enable-reentrant configure option for ongoing changes to
implement a reentrant version of ncurses:
+ libraries are suffixed with "t"
+ wrap several global variables (curscr, newscr, stdscr, ttytype,
COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES and TABSIZE) as
functions returning values stored in SCREEN or cur_term.
+ move some initialization (LINES, COLS) from lib_setup.c,
i.e., setupterm() to _nc_setupscreen(), i.e., newterm().
2007-03-11 09:07:00 +08:00
|
|
|
#endif
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The variable 'SP' will be defined as a function on systems that cannot link
|
|
|
|
* data-only modules, since it is used in a lot of places within ncurses and we
|
|
|
|
* cannot guarantee that any application will use any particular function. We
|
|
|
|
* put the WINDOW variables in this module, because it appears that any
|
|
|
|
* application that uses them will also use 'SP'.
|
|
|
|
*
|
|
|
|
* This module intentionally does not reference other ncurses modules, to avoid
|
|
|
|
* module coupling that increases the size of the executable.
|
|
|
|
*/
|
|
|
|
#if BROKEN_LINKER
|
2005-10-10 02:41:57 +08:00
|
|
|
static SCREEN *my_screen;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
NCURSES_EXPORT(SCREEN *)
|
|
|
|
_nc_screen(void)
|
1997-05-15 12:00:00 +08:00
|
|
|
{
|
2002-10-13 11:35:53 +08:00
|
|
|
return my_screen;
|
1997-05-15 12:00:00 +08:00
|
|
|
}
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
NCURSES_EXPORT(int)
|
|
|
|
_nc_alloc_screen(void)
|
1997-05-15 12:00:00 +08:00
|
|
|
{
|
2002-10-13 11:35:53 +08:00
|
|
|
return ((my_screen = typeCalloc(SCREEN, 1)) != 0);
|
1997-05-15 12:00:00 +08:00
|
|
|
}
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
NCURSES_EXPORT(void)
|
2005-10-10 02:41:57 +08:00
|
|
|
_nc_set_screen(SCREEN *sp)
|
1997-05-15 12:00:00 +08:00
|
|
|
{
|
2002-10-13 11:35:53 +08:00
|
|
|
my_screen = sp;
|
1997-05-15 12:00:00 +08:00
|
|
|
}
|
2002-10-13 11:35:53 +08:00
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#else
|
2005-10-10 02:41:57 +08:00
|
|
|
NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
|
1997-05-15 12:00:00 +08:00
|
|
|
#endif
|
2007-04-22 08:57:08 +08:00
|
|
|
/* *INDENT-OFF* */
|
|
|
|
#define CHARS_0s { '\0' }
|
|
|
|
|
|
|
|
#define TGETENT_0 { 0L, FALSE, NULL, NULL, NULL }
|
|
|
|
#define TGETENT_0s { TGETENT_0, TGETENT_0, TGETENT_0, TGETENT_0 }
|
|
|
|
|
|
|
|
NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
|
|
|
|
0, /* have_sigwinch */
|
|
|
|
0, /* cleanup_nested */
|
|
|
|
|
|
|
|
FALSE, /* init_signals */
|
|
|
|
FALSE, /* init_screen */
|
|
|
|
|
|
|
|
NULL, /* comp_sourcename */
|
|
|
|
NULL, /* comp_termtype */
|
|
|
|
|
|
|
|
FALSE, /* have_tic_directory */
|
|
|
|
FALSE, /* keep_tic_directory */
|
|
|
|
TERMINFO, /* tic_directory */
|
|
|
|
|
|
|
|
NULL, /* dbi_list */
|
|
|
|
0, /* dbi_size */
|
|
|
|
|
|
|
|
NULL, /* first_name */
|
|
|
|
NULL, /* keyname_table */
|
|
|
|
|
|
|
|
NULL, /* safeprint_buf */
|
|
|
|
0, /* safeprint_used */
|
|
|
|
|
|
|
|
TGETENT_0s, /* tgetent_cache */
|
|
|
|
0, /* tgetent_index */
|
|
|
|
0, /* tgetent_sequence */
|
|
|
|
|
|
|
|
#if USE_HOME_TERMINFO
|
|
|
|
NULL, /* home_terminfo */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !USE_SAFE_SPRINTF
|
|
|
|
0, /* safeprint_cols */
|
|
|
|
0, /* safeprint_rows */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TRACE
|
|
|
|
FALSE, /* init_trace */
|
|
|
|
CHARS_0s, /* trace_fname */
|
|
|
|
0, /* trace_level */
|
|
|
|
NULL, /* trace_fp */
|
|
|
|
|
|
|
|
NULL, /* tracearg_buf */
|
|
|
|
0, /* tracearg_used */
|
|
|
|
|
|
|
|
NULL, /* tracebuf_ptr */
|
|
|
|
0, /* tracebuf_used */
|
|
|
|
|
|
|
|
CHARS_0s, /* tracechr_buf */
|
|
|
|
|
|
|
|
NULL, /* tracedmp_buf */
|
|
|
|
0, /* tracedmp_used */
|
|
|
|
|
|
|
|
CHARS_0s, /* tracemse_buf */
|
|
|
|
|
|
|
|
NULL, /* tracetry_buf */
|
|
|
|
0, /* tracetry_used */
|
|
|
|
|
|
|
|
#ifndef USE_TERMLIB
|
|
|
|
{ CHARS_0s, CHARS_0s }, /* traceatr_color_buf */
|
|
|
|
0, /* traceatr_color_sel */
|
|
|
|
-1, /* traceatr_color_last */
|
|
|
|
#endif /* USE_TERMLIB */
|
|
|
|
|
|
|
|
#endif /* TRACE */
|
2007-09-02 08:20:31 +08:00
|
|
|
#ifdef USE_PTHREADS
|
2007-11-04 08:06:31 +08:00
|
|
|
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_set_SP */
|
|
|
|
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_use_screen */
|
|
|
|
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_use_window */
|
|
|
|
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_windowlist */
|
2007-09-30 07:30:37 +08:00
|
|
|
PTHREAD_MUTEX_INITIALIZER, /* mutex_tst_tracef */
|
|
|
|
PTHREAD_MUTEX_INITIALIZER, /* mutex_tracef */
|
|
|
|
0, /* nested_tracef */
|
2007-09-02 08:20:31 +08:00
|
|
|
#endif
|
2007-04-22 08:57:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define STACK_FRAME_0 { { 0 }, 0 }
|
|
|
|
#define STACK_FRAME_0s { STACK_FRAME_0 }
|
|
|
|
#define NUM_VARS_0s { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
|
|
|
|
2007-05-13 08:52:59 +08:00
|
|
|
#define RIPOFF_0 { 0,0 }
|
2007-04-22 08:57:08 +08:00
|
|
|
#define RIPOFF_0s { RIPOFF_0 }
|
|
|
|
|
|
|
|
NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
|
|
|
|
TRUE, /* use_env */
|
|
|
|
FALSE, /* filter_mode */
|
|
|
|
A_NORMAL, /* previous_attr */
|
|
|
|
RIPOFF_0s, /* ripoff */
|
|
|
|
NULL, /* rsp */
|
|
|
|
{ /* tparm_state */
|
|
|
|
#ifdef TRACE
|
|
|
|
NULL, /* tname */
|
|
|
|
#endif
|
|
|
|
NULL, /* tparam_base */
|
|
|
|
|
|
|
|
STACK_FRAME_0s, /* stack */
|
|
|
|
0, /* stack_ptr */
|
|
|
|
|
|
|
|
NULL, /* out_buff */
|
|
|
|
0, /* out_size */
|
|
|
|
0, /* out_used */
|
|
|
|
|
|
|
|
NULL, /* fmt_buff */
|
|
|
|
0, /* fmt_size */
|
|
|
|
|
|
|
|
NUM_VARS_0s, /* dynamic_var */
|
|
|
|
NUM_VARS_0s, /* static_vars */
|
|
|
|
},
|
2007-05-27 07:44:27 +08:00
|
|
|
NULL, /* saved_tty */
|
2007-04-22 08:57:08 +08:00
|
|
|
#if BROKEN_LINKER || USE_REENTRANT
|
|
|
|
NULL, /* real_acs_map */
|
2007-07-17 06:24:03 +08:00
|
|
|
0, /* LINES */
|
|
|
|
0, /* COLS */
|
2007-09-30 07:30:37 +08:00
|
|
|
#ifdef TRACE
|
|
|
|
0L, /* _outchars */
|
|
|
|
NULL, /* _tputs_trace */
|
|
|
|
#endif
|
2007-04-22 08:57:08 +08:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
/* *INDENT-ON* */
|