ncurses 5.7 - patch 20090905

+ build-fix for building outside source-tree (report by Sven Joachim).
+ fix Debian lintian warning for man/tabs.1 by making section number
  agree with file-suffix (report by Sven Joachim).
+ continue integrating "sp-funcs" by Juergen Pfeifer (incomplete).
This commit is contained in:
Thomas E. Dickey 2009-09-06 00:18:02 +00:00
parent c8e187fc96
commit 8fc9fa113b
14 changed files with 431 additions and 139 deletions

8
NEWS
View File

@ -25,7 +25,7 @@
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
-- $Id: NEWS,v 1.1425 2009/08/29 18:33:51 tom Exp $
-- $Id: NEWS,v 1.1428 2009/09/05 17:51:48 tom Exp $
-------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started
@ -45,6 +45,12 @@ See the AUTHORS file for the corresponding full names.
Changes through 1.9.9e did not credit all contributions;
it is not possible to add this information.
20090905
+ build-fix for building outside source-tree (report by Sven Joachim).
+ fix Debian lintian warning for man/tabs.1 by making section number
agree with file-suffix (report by Sven Joachim).
+ continue integrating "sp-funcs" by Juergen Pfeifer (incomplete).
20090829
+ workaround for bug in g++ 4.1-4.4 warnings for wattrset() macro on
amd64 (Debian #542031).

View File

@ -25,7 +25,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
# $Id: dist.mk,v 1.717 2009/08/29 18:07:46 tom Exp $
# $Id: dist.mk,v 1.718 2009/08/30 18:12:44 tom Exp $
# Makefile for creating ncurses distributions.
#
# This only needs to be used directly as a makefile by developers, but
@ -37,7 +37,7 @@ SHELL = /bin/sh
# These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 5
NCURSES_MINOR = 7
NCURSES_PATCH = 20090829
NCURSES_PATCH = 20090905
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)

View File

@ -1,6 +1,6 @@
# $Id: headers,v 1.9 2007/01/20 19:57:04 Miroslav.Lichvar Exp $
# $Id: headers,v 1.10 2009/09/05 17:46:30 tom Exp $
##############################################################################
# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
# Copyright (c) 1998-2007,2009 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@ -33,7 +33,7 @@ term.h
curses.h
unctrl.h
termcap.h
$(srcdir)/ncurses_dll.h
ncurses_dll.h
@ ticlib
$(srcdir)/tic.h
$(srcdir)/term_entry.h

View File

@ -1,5 +1,5 @@
.\"***************************************************************************
.\" Copyright (c) 2008 Free Software Foundation, Inc. *
.\" Copyright (c) 2008,2009 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@ -26,8 +26,8 @@
.\" authorization. *
.\"***************************************************************************
.\"
.\" $Id: tabs.1,v 1.2 2008/11/15 23:03:45 tom Exp $
.TH @TABS@ 1M ""
.\" $Id: tabs.1,v 1.3 2009/09/05 17:06:08 tom Exp $
.TH @TABS@ 1 ""
.ds n 5
.SH NAME
\fBtabs\fR - set tabs on a terminal

View File

@ -47,13 +47,18 @@
#endif
#ifndef CUR
#define CUR SP_TERMTYPE
#define CUR SP_TERMTYPE
#endif
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
MODULE_ID("$Id: lib_newterm.c,v 1.77 2009/05/10 00:48:29 tom Exp $")
MODULE_ID("$Id: lib_newterm.c,v 1.78 2009/08/30 19:02:28 tom Exp $")
#ifdef USE_TERM_DRIVER
#define NumLabels InfoOf(SP_PARM).numlabels
#else
#define NumLabels num_labels
#endif
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@ -68,16 +73,17 @@ MODULE_ID("$Id: lib_newterm.c,v 1.77 2009/05/10 00:48:29 tom Exp $")
* is supposed to behave as if it calls newterm, we do it here.
*/
static NCURSES_INLINE int
_nc_initscr(void)
_nc_initscr(NCURSES_SP_DCL0)
{
int result = ERR;
TERMINAL *term = TerminalOf(SP_PARM);
/* for extended XPG4 conformance requires cbreak() at this point */
/* (SVr4 curses does this anyway) */
if (cbreak() == OK) {
if (NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG) == OK) {
TTY buf;
buf = cur_term->Nttyb;
buf = term->Nttyb;
#ifdef TERMIOS
buf.c_lflag &= ~(ECHO | ECHONL);
buf.c_iflag &= ~(ICRNL | INLCR | IGNCR);
@ -87,8 +93,9 @@ _nc_initscr(void)
#else
memset(&buf, 0, sizeof(buf));
#endif
if ((result = _nc_set_tty_mode(&buf)) == OK)
cur_term->Nttyb = buf;
result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
if (result == OK)
term->Nttyb = buf;
}
return result;
}
@ -103,8 +110,14 @@ NCURSES_EXPORT(void)
NCURSES_SP_NAME(filter) (NCURSES_SP_DCL0)
{
START_TRACE();
T((T_CALLED("filter")));
T((T_CALLED("filter(%p)"), SP_PARM));
#if NCURSES_SP_FUNCS
if (IsPreScreen(SP_PARM)) {
SP_PARM->_filtered = TRUE;
}
#else
_nc_prescreen.filter_mode = TRUE;
#endif
returnVoid;
}
@ -112,7 +125,10 @@ NCURSES_SP_NAME(filter) (NCURSES_SP_DCL0)
NCURSES_EXPORT(void)
filter(void)
{
NCURSES_SP_NAME(filter) (CURRENT_SCREEN);
START_TRACE();
T((T_CALLED("filter()")));
_nc_prescreen.filter_mode = TRUE;
returnVoid;
}
#endif
@ -125,8 +141,14 @@ NCURSES_EXPORT(void)
NCURSES_SP_NAME(nofilter) (NCURSES_SP_DCL0)
{
START_TRACE();
T((T_CALLED("nofilter")));
T((T_CALLED("nofilter(%p)"), SP_PARM));
#if NCURSES_SP_FUNCS
if (IsPreScreen(SP_PARM)) {
SP_PARM->_filtered = FALSE;
}
#else
_nc_prescreen.filter_mode = FALSE;
#endif
returnVoid;
}
@ -134,7 +156,10 @@ NCURSES_SP_NAME(nofilter) (NCURSES_SP_DCL0)
NCURSES_EXPORT(void)
nofilter(void)
{
NCURSES_SP_NAME(nofilter) (CURRENT_SCREEN);
START_TRACE();
T((T_CALLED("nofilter()")));
_nc_prescreen.filter_mode = FALSE;
returnVoid;
}
#endif
#endif /* NCURSES_EXT_FUNCS */
@ -147,12 +172,19 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
{
int value;
int errret;
SCREEN *current;
SCREEN *result = 0;
SCREEN *current;
TERMINAL *its_term;
FILE *_ofp = ofp ? ofp : stdout;
FILE *_ifp = ifp ? ifp : stdin;
int cols;
int numlab;
#ifdef USE_TERM_DRIVER
TERMINAL *new_term;
#endif
START_TRACE();
T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
T((T_CALLED("newterm(%p, \"%s\", %p,%p)"), SP_PARM, name, ofp, ifp));
_nc_init_pthreads();
_nc_lock_global(curses);
@ -161,34 +193,48 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
its_term = (SP_PARM ? SP_PARM->_term : 0);
/* this loads the capability entry, then sets LINES and COLS */
if (setupterm(name, fileno(ofp), &errret) != ERR) {
if (setupterm(name, fileno(_ofp), &errret) != ERR) {
int slk_format = _nc_globals.slk_format;
/*
* This actually allocates the screen structure, and saves the original
* terminal settings.
*/
_nc_set_screen(0);
#ifdef USE_TERM_DRIVER
assert(new_term != 0);
#endif
/* allow user to set maximum escape delay from the environment */
if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
set_escdelay(value);
}
/*
* This actually allocates the screen structure, and saves the original
* terminal settings.
*/
if (_nc_setupscreen(LINES,
COLS,
ofp,
_ofp,
_nc_prescreen.filter_mode,
slk_format) == ERR) {
_nc_set_screen(current);
result = 0;
} else {
#ifdef USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB;
#endif
assert(SP_PARM != 0);
cols = *(ptrCols(SP_PARM));
#ifdef USE_TERM_DRIVER
TCB = (TERMINAL_CONTROL_BLOCK *) new_term;
TCB->csp = SP_PARM;
#endif
numlab = NumLabels;
/*
* In setupterm() we did a set_curterm(), but it was before we set
* SP. So the "current" screen's terminal pointer was overwritten
* with a different terminal. Later, in _nc_setupscreen(), we set
* SP and the terminal pointer in the new screen.
* CURRENT_SCREEN. So the "current" screen's terminal pointer was
* overwritten with a different terminal. Later, in
* _nc_setupscreen(), we set CURRENT_SCREEN and the terminal
* pointer in the new screen.
*
* Restore the terminal-pointer for the pre-existing screen, if
* any.
@ -200,33 +246,38 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
_nc_slk_initialize(stdscr, COLS);
SP->_ifd = fileno(ifp);
typeahead(fileno(ifp));
SP_PARM->_ifd = fileno(_ifp);
NCURSES_SP_NAME(typeahead) (NCURSES_SP_ARGx fileno(_ifp));
#ifdef TERMIOS
SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
!(cur_term->Ottyb.c_iflag & ISTRIP));
SP_PARM->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
!(cur_term->Ottyb.c_iflag & ISTRIP));
#else
SP->_use_meta = FALSE;
SP_PARM->_use_meta = FALSE;
#endif
SP->_endwin = FALSE;
SP_PARM->_endwin = FALSE;
#ifndef USE_TERM_DRIVER
/*
* Check whether we can optimize scrolling under dumb terminals in
* case we do not have any of these capabilities, scrolling
* optimization will be useless.
*/
SP->_scrolling = ((scroll_forward && scroll_reverse) ||
((parm_rindex ||
parm_insert_line ||
insert_line) &&
(parm_index ||
parm_delete_line ||
delete_line)));
SP_PARM->_scrolling = ((scroll_forward && scroll_reverse) ||
((parm_rindex ||
parm_insert_line ||
insert_line) &&
(parm_index ||
parm_delete_line ||
delete_line)));
#endif
baudrate(); /* sets a field in the SP structure */
NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets a field in the screen structure */
SP->_keytry = 0;
SP_PARM->_keytry = 0;
/* compute movement costs so we can do better move optimization */
#ifdef USE_TERM_DRIVER
TCBOf(SP_PARM)->drv->scinit(SP_PARM);
#else
/*
* Check for mismatched graphic-rendition capabilities. Most SVr4
* terminfo trees contain entries that have rmul or rmso equated to
@ -237,21 +288,21 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
* shouldn't be looking at this detail.
*/
#define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode))
SP->_use_rmso = SGR0_TEST(exit_standout_mode);
SP->_use_rmul = SGR0_TEST(exit_underline_mode);
SP_PARM->_use_rmso = SGR0_TEST(exit_standout_mode);
SP_PARM->_use_rmul = SGR0_TEST(exit_underline_mode);
/* compute movement costs so we can do better move optimization */
_nc_mvcur_init();
/* initialize terminal to a sane state */
_nc_screen_init();
#endif
/* Initialize the terminal line settings. */
_nc_initscr();
_nc_initscr(NCURSES_SP_ARG);
_nc_signal_handler(TRUE);
result = SP;
result = SP_PARM;
}
}
_nc_unlock_global(curses);

View File

@ -43,7 +43,7 @@
#include <curses.priv.h>
#include <stddef.h>
MODULE_ID("$Id: lib_newwin.c,v 1.58 2009/06/06 17:53:11 tom Exp $")
MODULE_ID("$Id: lib_newwin.c,v 1.59 2009/08/30 16:35:23 tom Exp $")
#define window_is(name) ((sp)->_##name == win)
@ -62,6 +62,17 @@ remove_window_from_screen(WINDOW *win)
{
SCREEN *sp;
#ifdef USE_SP_WINDOWLIST
if ((sp = _nc_screen_of(win)) != 0) {
if (window_is(curscr)) {
remove_window(curscr);
} else if (window_is(stdscr)) {
remove_window(stdscr);
} else if (window_is(newscr)) {
remove_window(newscr);
}
}
#else
for (each_screen(sp)) {
if (window_is(curscr)) {
remove_window(curscr);
@ -74,6 +85,7 @@ remove_window_from_screen(WINDOW *win)
break;
}
}
#endif
}
NCURSES_EXPORT(int)
@ -82,17 +94,20 @@ _nc_freewin(WINDOW *win)
WINDOWLIST *p, *q;
int i;
int result = ERR;
#ifdef USE_SP_WINDOWLIST
SCREEN *sp = _nc_screen_of(win); /* pretend this is parameter */
#endif
T((T_CALLED("_nc_freewin(%p)"), win));
if (win != 0) {
if (_nc_try_global(curses) == 0) {
if (_nc_nonsp_try_global(curses) == 0) {
q = 0;
for (each_window(SP, p)) {
for (each_window(SP_PARM, p)) {
if (&(p->win) == win) {
remove_window_from_screen(win);
if (q == 0)
WindowList(SP) = p->next;
WindowList(SP_PARM) = p->next;
else
q->next = p->next;
@ -109,7 +124,7 @@ _nc_freewin(WINDOW *win)
}
q = p;
}
_nc_unlock_global(curses);
_nc_nonsp_unlock_global(curses);
}
}
returnCode(result);
@ -123,7 +138,8 @@ NCURSES_SP_NAME(newwin) (NCURSES_SP_DCLx
NCURSES_CH_T *ptr;
int i;
T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
T((T_CALLED("newwin(%p, %d,%d,%d,%d)"), SP_PARM, num_lines, num_columns,
begy, begx));
if (begy < 0 || begx < 0 || num_lines < 0 || num_columns < 0)
returnWin(0);
@ -157,21 +173,24 @@ NCURSES_SP_NAME(newwin) (NCURSES_SP_DCLx
NCURSES_EXPORT(WINDOW *)
newwin(int num_lines, int num_columns, int begy, int begx)
{
return NCURSES_SP_NAME(newwin) (CURRENT_SCREEN,
num_lines, num_columns,
begy, begx);
WINDOW *win;
_nc_sp_lock_global(curses);
win = NCURSES_SP_NAME(newwin) (CURRENT_SCREEN,
num_lines, num_columns, begy, begx);
_nc_sp_unlock_global(curses);
return (win);
}
#endif
NCURSES_EXPORT(WINDOW *)
derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
{
#if NCURSES_SP_FUNCS
SCREEN *sp = CURRENT_SCREEN;
#endif
WINDOW *win;
int i;
int flags = _SUBWIN;
#if NCURSES_SP_FUNCS
SCREEN *sp = _nc_screen_of(orig);
#endif
T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), orig, num_lines, num_columns,
begy, begx));
@ -261,7 +280,7 @@ NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx
returnWin(0);
}
_nc_lock_global(curses);
_nc_nonsp_lock_global(curses);
win->_curx = 0;
win->_cury = 0;
@ -343,20 +362,10 @@ NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx
T((T_CREATE("window %p"), win));
_nc_unlock_global(curses);
_nc_nonsp_unlock_global(curses);
returnWin(win);
}
#if NCURSES_SP_FUNCS
NCURSES_EXPORT(WINDOW *)
_nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
{
return NCURSES_SP_NAME(_nc_makenew) (CURRENT_SCREEN,
num_lines, num_columns,
begy, begx, flags);
}
#endif
/*
* wgetch() and other functions with a WINDOW* parameter may use a SCREEN*
* internally, and it is useful to allow those to be invoked without switching

View File

@ -45,7 +45,7 @@
#define _POSIX_SOURCE
#endif
MODULE_ID("$Id: lib_restart.c,v 1.11 2009/05/02 20:47:42 tom Exp $")
MODULE_ID("$Id: lib_restart.c,v 1.12 2009/08/30 17:59:13 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
@ -54,10 +54,13 @@ NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
int *errret)
{
int result;
#ifdef USE_TERM_DRIVER
TERMINAL *new_term;
#endif
T((T_CALLED("restartterm(%p,%s,%d,%p)"), SP_PARM, termp, filenum, errret));
if (setupterm(termp, filenum, errret) != OK) {
if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) {
result = ERR;
} else if (SP_PARM != 0) {
int saveecho = SP_PARM->_echo;
@ -65,6 +68,9 @@ NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
int saveraw = SP_PARM->_raw;
int savenl = SP_PARM->_nl;
#ifdef USE_TERM_DRIVER
SP_PARM->_term = new_term;
#endif
if (saveecho) {
NCURSES_SP_NAME(echo) (NCURSES_SP_ARG);
} else {

View File

@ -42,14 +42,21 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
#include <tic.h>
#ifndef CUR
#define CUR SP_TERMTYPE
#endif
MODULE_ID("$Id: lib_set_term.c,v 1.124 2009/06/27 21:36:14 tom Exp $")
MODULE_ID("$Id: lib_set_term.c,v 1.126 2009/09/05 18:18:10 tom Exp $")
#ifdef USE_TERM_DRIVER
#define MaxColors InfoOf(sp).maxcolors
#define NumLabels InfoOf(sp).numlabels
#else
#define MaxColors max_colors
#define NumLabels num_labels
#endif
NCURSES_EXPORT(SCREEN *)
set_term(SCREEN *screenp)
@ -66,7 +73,7 @@ set_term(SCREEN *screenp)
newSP = SP;
if (newSP != 0) {
set_curterm(newSP->_term);
TINFO_SET_CURTERM(newSP, newSP->_term);
#if !USE_REENTRANT
curscr = newSP->_curscr;
newscr = newSP->_newscr;
@ -75,7 +82,7 @@ set_term(SCREEN *screenp)
COLOR_PAIRS = newSP->_pair_count;
#endif
} else {
set_curterm(0);
TINFO_SET_CURTERM(oldSP, 0);
#if !USE_REENTRANT
curscr = 0;
newscr = 0;
@ -134,6 +141,19 @@ delscreen(SCREEN *sp)
_nc_lock_global(curses);
if (delink_screen(sp)) {
#ifdef USE_SP_RIPOFF
ripoff_t *rop;
if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) {
for (rop = safe_ripoff_stack;
rop != safe_ripoff_sp && (rop - safe_ripoff_stack) < N_RIPS;
rop++) {
if (rop->win) {
(void) delwin(rop->win);
rop->win = 0;
}
}
}
#endif
(void) _nc_freewin(sp->_curscr);
(void) _nc_freewin(sp->_newscr);
@ -181,7 +201,7 @@ delscreen(SCREEN *sp)
free(sp->_setbuf);
}
del_curterm(sp->_term);
NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx sp->_term);
free(sp);
/*
@ -253,6 +273,41 @@ extract_fgbg(char *src, int *result)
}
#endif
#if NCURSES_SP_FUNCS
/*
* In case of handling multiple screens, we need to have a screen before
* initialization in setupscreen takes place. This is to extend the substitute
* for some of the stuff in _nc_prescreen, especially for slk and ripoff
* handling which should be done per screen.
*/
NCURSES_EXPORT(SCREEN *)
new_prescr(void)
{
SCREEN *sp = _nc_alloc_screen_sp();
if (sp) {
sp->rsp = sp->rippedoff;
sp->_filtered = _nc_prescreen.filter_mode;
sp->_use_env = _nc_prescreen.use_env;
#if NCURSES_NO_PADDING
sp->_no_padding = _nc_prescreen._no_padding;
#endif
sp->slk_format = 0;
sp->_slk = 0;
sp->_prescreen = TRUE;
SP_PRE_INIT(sp);
#if USE_REENTRANT
sp->_TABSIZE = _nc_prescreen._TABSIZE;
sp->_ESCDELAY = _nc_prescreen._ESCDELAY;
#endif
_nc_set_screen(sp);
}
return sp;
}
#endif
#define ReturnScreenError() _nc_set_screen(0); \
returnCode(ERR)
/* OS-independent screen initializations */
NCURSES_EXPORT(int)
_nc_setupscreen(int slines GCC_UNUSED,
@ -303,6 +358,9 @@ _nc_setupscreen(int slines GCC_UNUSED,
if (filtered) {
slines = 1;
SET_LINES(slines);
#ifdef USE_TERM_DRIVER
CallDriver(sp, setfilter);
#else
clear_screen = 0;
cursor_down = parm_down_cursor = 0;
cursor_address = 0;
@ -310,6 +368,7 @@ _nc_setupscreen(int slines GCC_UNUSED,
row_address = 0;
cursor_home = carriage_return;
#endif
T(("filter screensize %dx%d", LINES, COLS));
}
#ifdef __DJGPP__
@ -375,9 +434,9 @@ _nc_setupscreen(int slines GCC_UNUSED,
char sep1, sep2;
int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
if (count >= 1) {
SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK;
SP->_default_fg = (fg >= 0 && fg < MaxColors) ? fg : C_MASK;
if (count >= 3) {
SP->_default_bg = (bg >= 0 && bg < max_colors) ? bg : C_MASK;
SP->_default_bg = (bg >= 0 && bg < MaxColors) ? bg : C_MASK;
}
TR(TRACE_CHARPUT | TRACE_MOVE,
("from environment assumed fg=%d, bg=%d",
@ -401,20 +460,20 @@ _nc_setupscreen(int slines GCC_UNUSED,
p = extract_fgbg(p, &(SP->_default_bg));
TR(TRACE_CHARPUT | TRACE_MOVE, ("decoded fg=%d, bg=%d",
SP->_default_fg, SP->_default_bg));
if (SP->_default_fg >= max_colors) {
if (SP->_default_fg >= MaxColors) {
if (set_a_foreground != ABSENT_STRING
&& !strcmp(set_a_foreground, "\033[3%p1%dm")) {
set_a_foreground = "\033[3%?%p1%{8}%>%t9%e%p1%d%;m";
} else {
SP->_default_fg %= max_colors;
SP->_default_fg %= MaxColors;
}
}
if (SP->_default_bg >= max_colors) {
if (SP->_default_bg >= MaxColors) {
if (set_a_background != ABSENT_STRING
&& !strcmp(set_a_background, "\033[4%p1%dm")) {
set_a_background = "\033[4%?%p1%{8}%>%t9%e%p1%d%;m";
} else {
SP->_default_bg %= max_colors;
SP->_default_bg %= MaxColors;
}
}
}
@ -575,7 +634,7 @@ _nc_setupscreen(int slines GCC_UNUSED,
formats (4-4 or 3-2-3) for which there may be some hardware
support. */
if (rop->hook == _nc_slk_initialize)
if (!(num_labels <= 0 || !SLK_STDFMT(slk_format)))
if (!(NumLabels <= 0 || !SLK_STDFMT(slk_format)))
continue;
if (rop->hook) {
int count;

View File

@ -45,7 +45,7 @@
#define CUR SP_TERMTYPE
#endif
MODULE_ID("$Id: resizeterm.c,v 1.40 2009/07/04 18:38:49 tom Exp $")
MODULE_ID("$Id: resizeterm.c,v 1.41 2009/08/30 16:18:58 tom Exp $")
/*
* If we're trying to be reentrant, do not want any local statics.
@ -230,9 +230,9 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS)
if (rop->hook == _nc_slk_initialize)
_nc_format_slks(
#if NCURSES_SP_FUNCS
_nc_screen_of(win),
_nc_screen_of(win),
#endif
ToCols);
ToCols);
} else if (win->_begy >= bottom) {
/*
* If it is below the bottom of the new screen, move up by the same
@ -351,7 +351,7 @@ NCURSES_SP_NAME(resize_term) (NCURSES_SP_DCLx int ToLines, int ToCols)
returnCode(ERR);
}
_nc_lock_global(curses);
_nc_nonsp_lock_global(curses);
was_stolen = (screen_lines(SP_PARM) - SP_PARM->_lines_avail);
if (NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_ARGx ToLines, ToCols)) {
@ -418,7 +418,7 @@ NCURSES_SP_NAME(resize_term) (NCURSES_SP_DCLx int ToLines, int ToCols)
SET_LINES(ToLines - was_stolen);
SET_COLS(ToCols);
_nc_unlock_global(curses);
_nc_nonsp_unlock_global(curses);
returnCode(result);
}
@ -428,9 +428,9 @@ NCURSES_EXPORT(int)
resize_term(int ToLines, int ToCols)
{
int res = ERR;
_nc_lock_global(curses);
_nc_sp_lock_global(curses);
res = NCURSES_SP_NAME(resize_term) (CURRENT_SCREEN, ToLines, ToCols);
_nc_unlock_global(curses);
_nc_sp_unlock_global(curses);
return (res);
}
#endif

View File

@ -35,7 +35,7 @@
/*
* $Id: curses.priv.h,v 1.435 2009/08/22 22:33:25 tom Exp $
* $Id: curses.priv.h,v 1.436 2009/08/30 18:13:54 tom Exp $
*
* curses.priv.h
*
@ -481,6 +481,36 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
#endif /* USE_PTHREADS */
/*
* When using sp-funcs, locks are targeted to SCREEN-level granularity.
* So the locking is done in the non-sp-func (which calls the sp-func) rather
* than in the sp-func itself.
*
* Use the _nc_nonsp_XXX functions in the function using "NCURSES_SP_NAME()".
* Use the _nc_sp_XXX functions in the function using "#if NCURSES_SP_FUNCS".
*/
#if NCURSES_SP_FUNCS
#define _nc_nonsp_lock_global(name) /* nothing */
#define _nc_nonsp_try_global(name) 0
#define _nc_nonsp_unlock_global(name) /* nothing */
#define _nc_sp_lock_global(name) _nc_lock_global(name)
#define _nc_sp_try_global(name) _nc_try_global(name)
#define _nc_sp_unlock_global(name) _nc_unlock_global(name)
#else
#define _nc_nonsp_lock_global(name) _nc_lock_global(name)
#define _nc_nonsp_try_global(name) _nc_try_global(name)
#define _nc_nonsp_unlock_global(name) _nc_unlock_global(name)
#define _nc_sp_lock_global(name) /* nothing */
#define _nc_sp_try_global(name) 0
#define _nc_sp_unlock_global(name) /* nothing */
#endif
#if HAVE_GETTIMEOFDAY
# define PRECISE_GETTIME 1
# define TimeType struct timeval
@ -2057,7 +2087,6 @@ extern NCURSES_EXPORT(WINDOW *) _nc_stdscr_of(SCREEN*);
extern NCURSES_EXPORT(int) _nc_outc_wrapper(SCREEN*,int);
#if USE_REENTRANT
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_ttytype)(SCREEN*);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_TABSIZE)(SCREEN*);
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname)(SCREEN*);
#endif

View File

@ -40,7 +40,7 @@
#include <term_entry.h> /* TTY, cur_term */
#include <termcap.h> /* ospeed */
MODULE_ID("$Id: lib_cur_term.c,v 1.24 2009/08/22 22:37:13 tom Exp $")
MODULE_ID("$Id: lib_cur_term.c,v 1.26 2009/09/05 18:05:27 tom Exp $")
#undef CUR
#define CUR termp->type.

View File

@ -52,9 +52,7 @@
#include <locale.h>
#endif
#include <term.h> /* lines, columns, cur_term */
MODULE_ID("$Id: lib_setup.c,v 1.117 2009/06/06 17:56:31 tom Exp $")
MODULE_ID("$Id: lib_setup.c,v 1.119 2009/09/05 20:10:02 tom Exp $")
/****************************************************************************
*
@ -110,37 +108,58 @@ MODULE_ID("$Id: lib_setup.c,v 1.117 2009/06/06 17:56:31 tom Exp $")
* Wrap global variables in this module.
*/
#if USE_REENTRANT
NCURSES_EXPORT(char *)
NCURSES_PUBLIC_VAR(ttytype) (void)
{
static char empty[] = "";
return cur_term ? cur_term->type.term_names : empty;
char *result = empty;
#if NCURSES_SP_FUNCS
if (CURRENT_SCREEN) {
TERMINAL *termp = TerminalOf(CURRENT_SCREEN);
if (termp != 0) {
result = termp->type.term_names;
}
}
#else
if (cur_term != 0) {
result = cur_term->type.term_names;
}
#endif
return result;
}
NCURSES_EXPORT(int *)
_nc_ptr_Lines(SCREEN *sp)
{
return ptrLines(sp);
}
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(LINES) (void)
{
return *_nc_ptr_Lines(CURRENT_SCREEN);
}
NCURSES_EXPORT(int *)
_nc_ptr_Cols(SCREEN *sp)
{
return ptrCols(sp);
}
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(COLS) (void)
{
return *_nc_ptr_Cols(CURRENT_SCREEN);
}
NCURSES_EXPORT(int *)
_nc_ptr_Tabsize(SCREEN *sp)
{
return ptrTabsize(sp);
}
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(TABSIZE) (void)
{
@ -205,12 +224,14 @@ _nc_handle_sigwinch(SCREEN *sp)
NCURSES_EXPORT(void)
NCURSES_SP_NAME(use_env) (NCURSES_SP_DCLx bool f)
{
T((T_CALLED("use_env()")));
T((T_CALLED("use_env(%p,%d)"), SP_PARM, (int) f));
#if NCURSES_SP_FUNCS
if (IsPreScreen(SP_PARM)) {
SP_PARM->_use_env = f;
} else {
_nc_prescreen.use_env = f;
}
#else
_nc_prescreen.use_env = f;
#endif
returnVoid;
}
@ -218,14 +239,39 @@ NCURSES_SP_NAME(use_env) (NCURSES_SP_DCLx bool f)
NCURSES_EXPORT(void)
use_env(bool f)
{
NCURSES_SP_NAME(use_env) (CURRENT_SCREEN, f);
T((T_CALLED("use_env(%d)"), (int) f));
_nc_prescreen.use_env = f;
returnVoid;
}
#endif
NCURSES_EXPORT(void)
_nc_get_screensize(SCREEN *sp, int *linep, int *colp)
_nc_get_screensize(SCREEN *sp,
#ifdef USE_TERM_DRIVER
TERMINAL * termp,
#endif
int *linep, int *colp)
/* Obtain lines/columns values from the environment and/or terminfo entry */
{
#ifdef USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB;
int my_tabsize;
assert(termp != 0 && linep != 0 && colp != 0);
TCB = (TERMINAL_CONTROL_BLOCK *) termp;
my_tabsize = TCB->info.tabsize;
TCB->drv->size(TCB, linep, colp);
#if USE_REENTRANT
if (sp != 0) {
sp->_TABSIZE = my_tabsize;
}
#else
TABSIZE = my_tabsize;
#endif
T(("TABSIZE = %d", my_tabsize));
#else /* !USE_TERM_DRIVER */
TERMINAL *termp = cur_term;
int my_tabsize;
@ -325,19 +371,31 @@ _nc_get_screensize(SCREEN *sp, int *linep, int *colp)
TABSIZE = my_tabsize;
#endif
T(("TABSIZE = %d", TABSIZE));
#endif /* USE_TERM_DRIVER */
}
#if USE_SIZECHANGE
NCURSES_EXPORT(void)
_nc_update_screensize(SCREEN *sp)
{
TERMINAL *termp = cur_term;
int old_lines = lines;
int new_lines;
int old_cols = columns;
int new_cols;
_nc_get_screensize(sp, &new_lines, &new_cols);
#ifdef USE_TERM_DRIVER
int old_lines;
int old_cols;
assert(sp != 0);
CallDriver_2(sp, getsize, &old_lines, &old_cols);
#else
TERMINAL *termp = cur_term;
int old_lines = lines;
int old_cols = columns;
#endif
TINFO_GET_SIZE(sp, sp->_term, &new_lines, &new_cols);
/*
* See is_term_resized() and resizeterm().
@ -375,6 +433,7 @@ _nc_update_screensize(SCREEN *sp)
exit(EXIT_FAILURE);\
}
#ifndef USE_TERM_DRIVER
#if USE_DATABASE || USE_TERMCAP
/*
* Return 1 if entry found, 0 if not found, -1 if database not accessible,
@ -434,6 +493,7 @@ do_prototype(TERMINAL * termp)
}
}
}
#endif /* !USE_TERM_DRIVER */
/*
* Find the locale which is in effect.
@ -513,18 +573,37 @@ _nc_locale_breaks_acs(TERMINAL * termp)
return 0;
}
/*
* This entrypoint is called from tgetent() to allow a special case of reusing
* the same TERMINAL data (see comment).
*/
NCURSES_EXPORT(int)
_nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
TINFO_SETUP_TERM(TERMINAL ** tp,
NCURSES_CONST char *tname,
int Filedes,
int *errret,
bool reuse)
{
TERMINAL *termp;
#ifdef USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB = 0;
#else
int status;
#endif
TERMINAL *termp;
SCREEN *sp = 0;
int code = ERR;
START_TRACE();
#ifdef USE_TERM_DRIVER
T((T_CALLED("_nc_setupterm_ex(%p,%s,%d,%p)"),
tp, _nc_visbuf(tname), Filedes, errret));
if (tp == 0) {
ret_error0(TGETENT_ERR,
"Invalid parameter, internal error.\n");
} else
termp = *tp;
#else
termp = cur_term;
T((T_CALLED("setupterm(%s,%d,%p)"), _nc_visbuf(tname), Filedes, errret));
#endif
if (tname == 0) {
tname = getenv("TERM");
@ -565,20 +644,34 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
* properly with this feature).
*/
if (reuse
&& (termp = cur_term) != 0
&& (termp != 0)
&& termp->Filedes == Filedes
&& termp->_termname != 0
&& !strcmp(termp->_termname, tname)
&& _nc_name_match(termp->type.term_names, tname, "|")) {
T(("reusing existing terminal information and mode-settings"));
code = OK;
} else {
#ifdef USE_TERM_DRIVER
termp = (TERMINAL *) typeCalloc(TERMINAL_CONTROL_BLOCK, 1);
#else
termp = typeCalloc(TERMINAL, 1);
#endif
if (termp == 0) {
ret_error0(TGETENT_ERR,
"Not enough memory to create terminal structure.\n");
}
#ifdef USE_TERM_DRIVER
TCB = (TERMINAL_CONTROL_BLOCK *) termp;
code = _nc_get_driver(TCB, tname, errret);
if (code == OK) {
termp->Filedes = Filedes;
termp->_termname = strdup(tname);
} else {
ret_error0(TGETENT_ERR,
"Could not find any driver to handle this terminal.\n");
}
#else
#if USE_DATABASE || USE_TERMCAP
status = grab_entry(tname, &termp->type);
#else
@ -626,25 +719,57 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
def_prog_mode();
baudrate();
}
code = OK;
#endif
}
#ifdef USE_TERM_DRIVER
*tp = termp;
NCURSES_SP_NAME(set_curterm) (sp, termp);
TCB->drv->init(TCB);
#else
sp = SP;
#endif
/*
* We should always check the screensize, just in case.
*/
_nc_get_screensize(SP, ptrLines(SP), ptrCols(SP));
TINFO_GET_SIZE(sp, termp, ptrLines(sp), ptrCols(sp));
if (errret)
*errret = TGETENT_YES;
#ifndef USE_TERM_DRIVER
if (generic_type) {
ret_error(TGETENT_NO, "'%s': I need something more specific.\n", tname);
}
if (hard_copy) {
ret_error(TGETENT_YES, "'%s': I can't handle hardcopy terminals.\n", tname);
}
returnCode(OK);
#endif
returnCode(code);
}
#ifdef USE_TERM_DRIVER
/*
* This entrypoint is called from tgetent() to allow a special case of reusing
* the same TERMINAL data (see comment).
*/
NCURSES_EXPORT(int)
_nc_setupterm(NCURSES_CONST char *tname,
int Filedes,
int *errret,
bool reuse)
{
int res;
TERMINAL *termp;
res = TINFO_SETUP_TERM(&termp, tname, Filedes, errret, reuse);
if (ERR != res)
NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN_PRE, termp);
return res;
}
#endif
/*
* setupterm(termname, Filedes, errret)
*

View File

@ -50,7 +50,7 @@
#define CUR SP_TERMTYPE
#endif
MODULE_ID("$Id: lib_termcap.c,v 1.69 2009/07/11 18:14:21 tom Exp $")
MODULE_ID("$Id: lib_termcap.c,v 1.70 2009/08/30 17:16:00 tom Exp $")
NCURSES_EXPORT_VAR(char *) UP = 0;
NCURSES_EXPORT_VAR(char *) BC = 0;
@ -93,15 +93,13 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
START_TRACE();
T((T_CALLED("tgetent()")));
#ifdef USE_TERM_DRIVER
_nc_setupterm_ex(&termp, (NCURSES_CONST char *) name,
TINFO_SETUP_TERM(&termp, (NCURSES_CONST char *) name,
STDOUT_FILENO, &errcode, TRUE);
#ifdef USE_TERM_DRIVER
if (termp == 0 ||
!((TERMINAL_CONTROL_BLOCK *) termp)->drv->isTerminfo)
return (errcode);
#else
_nc_setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode, TRUE);
#endif
/*

View File

@ -159,10 +159,15 @@
#define CUR SP_TERMTYPE
#endif
MODULE_ID("$Id: lib_mvcur.c,v 1.120 2009/05/10 00:52:29 tom Exp $")
MODULE_ID("$Id: lib_mvcur.c,v 1.121 2009/08/30 16:52:00 tom Exp $")
#define WANT_CHAR(sp, y, x) (sp)->_newscr->_line[y].text[x] /* desired state */
#if NCURSES_SP_FUNCS
#define BAUDRATE(sp) sp->_term->_baudrate /* bits per second */
#else
#define BAUDRATE(sp) cur_term->_baudrate /* bits per second */
#endif
#if defined(MAIN) || defined(NCURSES_TEST)
#include <sys/time.h>
@ -279,6 +284,9 @@ NCURSES_EXPORT(void)
NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_DCL0)
/* what to do at initialization time and after each shellout */
{
if (SP_PARM && !IsTermInfo(SP_PARM))
return;
/* initialize screen for cursor access */
if (enter_ca_mode) {
NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx
@ -451,7 +459,6 @@ NCURSES_EXPORT(void)
_nc_mvcur_init(void)
{
NCURSES_SP_NAME(_nc_mvcur_init) (CURRENT_SCREEN);
_nc_mvcur_resume();
}
#endif
@ -460,7 +467,10 @@ NCURSES_SP_NAME(_nc_mvcur_wrap) (NCURSES_SP_DCL0)
/* wrap up cursor-addressing mode */
{
/* leave cursor at screen bottom */
mvcur(-1, -1, screen_lines(CURRENT_SCREEN) - 1, 0);
TINFO_MVCUR(NCURSES_SP_ARGx -1, -1, screen_lines(SP_PARM) - 1, 0);
if (SP_PARM && !IsTermInfo(SP_PARM))
return;
/* set cursor to normal mode */
if (SP_PARM->_cursor != -1) {
@ -932,16 +942,15 @@ onscreen_mvcur(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew, bool ovw)
return (ERR);
}
/* optimized cursor move from (yold, xold) to (ynew, xnew) */
NCURSES_EXPORT(int)
NCURSES_SP_NAME(mvcur) (NCURSES_SP_DCLx
int yold, int xold, int ynew, int xnew)
TINFO_MVCUR(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew)
/* optimized cursor move from (yold, xold) to (ynew, xnew) */
{
NCURSES_CH_T oldattr;
int code;
TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%d,%d,%d,%d)"),
yold, xold, ynew, xnew));
TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("_nc_tinfo_mvcur(%p,%d,%d,%d,%d)"),
SP_PARM, yold, xold, ynew, xnew));
if (SP_PARM == 0) {
code = ERR;
@ -1032,7 +1041,7 @@ NCURSES_SP_NAME(mvcur) (NCURSES_SP_DCLx
returnCode(code);
}
#if NCURSES_SP_FUNCS
#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER)
NCURSES_EXPORT(int)
mvcur(int yold, int xold, int ynew, int xnew)
{