diff options
Diffstat (limited to 'contrib/ncurses/ncurses/base')
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_addch.c | 5 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_bkgd.c | 6 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_delwin.c | 6 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_freeall.c | 8 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_getch.c | 165 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_initscr.c | 13 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_newterm.c | 17 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_newwin.c | 70 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_overlay.c | 166 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_restart.c | 6 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_set_term.c | 162 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_ungetch.c | 49 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/lib_window.c | 6 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/resizeterm.c | 16 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/use_window.c | 14 | ||||
-rw-r--r-- | contrib/ncurses/ncurses/base/wresize.c | 6 |
16 files changed, 385 insertions, 330 deletions
diff --git a/contrib/ncurses/ncurses/base/lib_addch.c b/contrib/ncurses/ncurses/base/lib_addch.c index 1ef6cc5803d3..17ba6e2bcd6c 100644 --- a/contrib/ncurses/ncurses/base/lib_addch.c +++ b/contrib/ncurses/ncurses/base/lib_addch.c @@ -36,7 +36,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$Id: lib_addch.c,v 1.108 2008/02/03 18:50:27 tom Exp $") +MODULE_ID("$Id: lib_addch.c,v 1.111 2008/03/29 18:48:02 tom Exp $") static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT); @@ -217,7 +217,9 @@ _nc_build_wch(WINDOW *win, ARG_CH_T ch) buffer, WINDOW_EXT(win, addch_used), &state)) > 0) { attr_t attrs = AttrOf(CHDEREF(ch)); + if_EXT_COLORS(int pair = GetPair(CHDEREF(ch))); SetChar(CHDEREF(ch), result, attrs); + if_EXT_COLORS(SetPair(CHDEREF(ch), pair)); WINDOW_EXT(win, addch_used) = 0; } else if (len == -1) { /* @@ -474,6 +476,7 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch) while (*s) { NCURSES_CH_T sch; SetChar(sch, *s++, AttrOf(ch)); + if_EXT_COLORS(SetPair(sch, GetPair(ch))); if (waddch_literal(win, sch) == ERR) return ERR; } diff --git a/contrib/ncurses/ncurses/base/lib_bkgd.c b/contrib/ncurses/ncurses/base/lib_bkgd.c index e6a0cb000b15..c99e0c5fc3a8 100644 --- a/contrib/ncurses/ncurses/base/lib_bkgd.c +++ b/contrib/ncurses/ncurses/base/lib_bkgd.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 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 * @@ -36,7 +36,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_bkgd.c,v 1.35 2006/05/27 19:20:11 tom Exp $") +MODULE_ID("$Id: lib_bkgd.c,v 1.36 2008/03/23 00:09:14 tom Exp $") /* * Set the window's background information. @@ -70,7 +70,7 @@ wbkgrndset(WINDOW *win, const ARG_CH_T ch) if (CharOf(CHDEREF(ch)) == L('\0')) { SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch))); - SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch))); + if_EXT_COLORS(SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch)))); } else { win->_nc_bkgd = CHDEREF(ch); } diff --git a/contrib/ncurses/ncurses/base/lib_delwin.c b/contrib/ncurses/ncurses/base/lib_delwin.c index fc68f9d68dee..ba5f180d5f3c 100644 --- a/contrib/ncurses/ncurses/base/lib_delwin.c +++ b/contrib/ncurses/ncurses/base/lib_delwin.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2001,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -40,7 +40,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_delwin.c,v 1.15 2007/12/22 23:34:26 tom Exp $") +MODULE_ID("$Id: lib_delwin.c,v 1.16 2008/05/03 14:13:51 tom Exp $") static bool cannot_delete(WINDOW *win) @@ -48,7 +48,7 @@ cannot_delete(WINDOW *win) WINDOWLIST *p; bool result = TRUE; - for (p = _nc_windows; p != 0; p = p->next) { + for (each_window(p)) { if (&(p->win) == win) { result = FALSE; } else if ((p->win._flags & _SUBWIN) != 0 diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c index dbf0483f2401..4bb7ccc79995 100644 --- a/contrib/ncurses/ncurses/base/lib_freeall.c +++ b/contrib/ncurses/ncurses/base/lib_freeall.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -40,7 +40,7 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$Id: lib_freeall.c,v 1.45 2007/12/22 23:29:37 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.46 2008/05/03 14:13:51 tom Exp $") /* * Free all ncurses data. This is used for testing only (there's no practical @@ -67,10 +67,10 @@ _nc_freeall(void) bool deleted = FALSE; /* Delete only windows that're not a parent */ - for (p = _nc_windows; p != 0; p = p->next) { + for (each_window(p)) { bool found = FALSE; - for (q = _nc_windows; q != 0; q = q->next) { + for (each_window(q)) { if ((p != q) && (q->win._flags & _SUBWIN) && (&(p->win) == q->win._parent)) { diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c index 11e8052a668c..d9f6b1795c77 100644 --- a/contrib/ncurses/ncurses/base/lib_getch.c +++ b/contrib/ncurses/ncurses/base/lib_getch.c @@ -41,17 +41,19 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_getch.c,v 1.82 2008/01/19 21:07:30 tom Exp $") +MODULE_ID("$Id: lib_getch.c,v 1.87 2008/05/03 22:42:10 tom Exp $") #include <fifo_defs.h> #if USE_REENTRANT +#define GetEscdelay(sp) (sp)->_ESCDELAY NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(ESCDELAY) (void) { - return SP ? SP->_ESCDELAY : 1000; + return SP ? GetEscdelay(SP) : 1000; } #else +#define GetEscdelay(sp) ESCDELAY NCURSES_EXPORT_VAR(int) ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */ #endif @@ -84,20 +86,20 @@ set_escdelay(int value) * Check for mouse activity, returning nonzero if we find any. */ static int -check_mouse_activity(int delay EVENTLIST_2nd(_nc_eventlist * evl)) +check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl)) { int rc; #if USE_SYSMOUSE - if ((SP->_mouse_type == M_SYSMOUSE) - && (SP->_sysmouse_head < SP->_sysmouse_tail)) { + if ((sp->_mouse_type == M_SYSMOUSE) + && (sp->_sysmouse_head < sp->_sysmouse_tail)) { return 2; } #endif - rc = _nc_timed_wait(TWAIT_MASK, delay, (int *) 0 EVENTLIST_2nd(evl)); + rc = _nc_timed_wait(sp, TWAIT_MASK, delay, (int *) 0 EVENTLIST_2nd(evl)); #if USE_SYSMOUSE - if ((SP->_mouse_type == M_SYSMOUSE) - && (SP->_sysmouse_head < SP->_sysmouse_tail) + if ((sp->_mouse_type == M_SYSMOUSE) + && (sp->_sysmouse_head < sp->_sysmouse_tail) && (rc == 0) && (errno == EINTR)) { rc |= 2; @@ -107,9 +109,9 @@ check_mouse_activity(int delay EVENTLIST_2nd(_nc_eventlist * evl)) } static NCURSES_INLINE int -fifo_peek(void) +fifo_peek(SCREEN *sp) { - int ch = SP->_fifo[peek]; + int ch = sp->_fifo[peek]; TR(TRACE_IEVENT, ("peeking at %d", peek)); p_inc(); @@ -117,10 +119,10 @@ fifo_peek(void) } static NCURSES_INLINE int -fifo_pull(void) +fifo_pull(SCREEN *sp) { int ch; - ch = SP->_fifo[head]; + ch = sp->_fifo[head]; TR(TRACE_IEVENT, ("pulling %s from %d", _tracechar(ch), head)); if (peek == head) { @@ -131,7 +133,7 @@ fifo_pull(void) #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { - _nc_fifo_dump(); + _nc_fifo_dump(sp); _nc_unlock_global(tracef); } #endif @@ -139,7 +141,7 @@ fifo_pull(void) } static NCURSES_INLINE int -fifo_push(EVENTLIST_0th(_nc_eventlist * evl)) +fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl)) { int n; int ch = 0; @@ -157,47 +159,47 @@ fifo_push(EVENTLIST_0th(_nc_eventlist * evl)) #ifdef NCURSES_WGETCH_EVENTS if (evl #if USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE - || (SP->_mouse_fd >= 0) + || (sp->_mouse_fd >= 0) #endif ) { - mask = check_mouse_activity(-1 EVENTLIST_2nd(evl)); + mask = check_mouse_activity(sp, -1 EVENTLIST_2nd(evl)); } else mask = 0; if (mask & 4) { T(("fifo_push: ungetch KEY_EVENT")); - ungetch(KEY_EVENT); + _nc_ungetch(sp, KEY_EVENT); return KEY_EVENT; } #elif USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE - if (SP->_mouse_fd >= 0) { - mask = check_mouse_activity(-1 EVENTLIST_2nd(evl)); + if (sp->_mouse_fd >= 0) { + mask = check_mouse_activity(sp, -1 EVENTLIST_2nd(evl)); } #endif #if USE_GPM_SUPPORT || USE_EMX_MOUSE - if ((SP->_mouse_fd >= 0) && (mask & 2)) { - SP->_mouse_event(SP); + if ((sp->_mouse_fd >= 0) && (mask & 2)) { + sp->_mouse_event(sp); ch = KEY_MOUSE; n = 1; } else #endif #if USE_SYSMOUSE - if ((SP->_mouse_type == M_SYSMOUSE) - && (SP->_sysmouse_head < SP->_sysmouse_tail)) { - SP->_mouse_event(SP); + if ((sp->_mouse_type == M_SYSMOUSE) + && (sp->_sysmouse_head < sp->_sysmouse_tail)) { + sp->_mouse_event(sp); ch = KEY_MOUSE; n = 1; - } else if ((SP->_mouse_type == M_SYSMOUSE) + } else if ((sp->_mouse_type == M_SYSMOUSE) && (mask <= 0) && errno == EINTR) { - SP->_mouse_event(SP); + sp->_mouse_event(sp); ch = KEY_MOUSE; n = 1; } else #endif { /* Can block... */ unsigned char c2 = 0; - n = read(SP->_ifd, &c2, 1); + n = read(sp->_ifd, &c2, 1); ch = c2; } @@ -216,20 +218,20 @@ fifo_push(EVENTLIST_0th(_nc_eventlist * evl)) #endif if ((n == -1) || (n == 0)) { - TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno)); + TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", sp->_ifd, n, errno)); ch = ERR; } TR(TRACE_IEVENT, ("read %d characters", n)); - SP->_fifo[tail] = ch; - SP->_fifohold = 0; + sp->_fifo[tail] = ch; + sp->_fifohold = 0; if (head == -1) head = peek = tail; t_inc(); TR(TRACE_IEVENT, ("pushed %s at %d", _tracechar(ch), tail)); #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { - _nc_fifo_dump(); + _nc_fifo_dump(sp); _nc_unlock_global(tracef); } #endif @@ -237,14 +239,14 @@ fifo_push(EVENTLIST_0th(_nc_eventlist * evl)) } static NCURSES_INLINE void -fifo_clear(void) +fifo_clear(SCREEN *sp) { - memset(SP->_fifo, 0, sizeof(SP->_fifo)); + memset(sp->_fifo, 0, sizeof(sp->_fifo)); head = -1; tail = peek = 0; } -static int kgetch(EVENTLIST_0th(_nc_eventlist * evl)); +static int kgetch(SCREEN *EVENTLIST_2nd(_nc_eventlist * evl)); #define wgetch_should_refresh(win) (\ (is_wintouched(win) || (win->_flags & _HASMOVED)) \ @@ -256,6 +258,7 @@ _nc_wgetch(WINDOW *win, int use_meta EVENTLIST_2nd(_nc_eventlist * evl)) { + SCREEN *sp = SP; int ch; #ifdef NCURSES_WGETCH_EVENTS long event_delay = -1; @@ -264,7 +267,7 @@ _nc_wgetch(WINDOW *win, T((T_CALLED("_nc_wgetch(%p)"), win)); *result = 0; - if (win == 0 || SP == 0) { + if (win == 0 || sp == 0) { returnCode(ERR); } @@ -272,7 +275,7 @@ _nc_wgetch(WINDOW *win, if (wgetch_should_refresh(win)) wrefresh(win); - *result = fifo_pull(); + *result = fifo_pull(sp); returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK); } #ifdef NCURSES_WGETCH_EVENTS @@ -287,26 +290,26 @@ _nc_wgetch(WINDOW *win, * the first character to return it. */ if (head == -1 && - !SP->_notty && - !SP->_raw && - !SP->_cbreak && - !SP->_called_wgetch) { - char buf[MAXCOLUMNS], *sp; + !sp->_notty && + !sp->_raw && + !sp->_cbreak && + !sp->_called_wgetch) { + char buf[MAXCOLUMNS], *bufp; int rc; TR(TRACE_IEVENT, ("filling queue in cooked mode")); - SP->_called_wgetch = TRUE; + sp->_called_wgetch = TRUE; rc = wgetnstr(win, buf, MAXCOLUMNS); - SP->_called_wgetch = FALSE; + sp->_called_wgetch = FALSE; /* ungetch in reverse order */ #ifdef NCURSES_WGETCH_EVENTS if (rc != KEY_EVENT) #endif - ungetch('\n'); - for (sp = buf + strlen(buf); sp > buf; sp--) - ungetch(sp[-1]); + _nc_ungetch(sp, '\n'); + for (bufp = buf + strlen(buf); bufp > buf; bufp--) + _nc_ungetch(sp, bufp[-1]); #ifdef NCURSES_WGETCH_EVENTS /* Return it first */ @@ -314,24 +317,24 @@ _nc_wgetch(WINDOW *win, *result = rc; } else #endif - *result = fifo_pull(); + *result = fifo_pull(sp); returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK); } - if (win->_use_keypad != SP->_keypad_on) - _nc_keypad(win->_use_keypad); + if (win->_use_keypad != sp->_keypad_on) + _nc_keypad(sp, win->_use_keypad); if (wgetch_should_refresh(win)) wrefresh(win); - if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) { + if (!win->_notimeout && (win->_delay >= 0 || sp->_cbreak > 1)) { if (head == -1) { /* fifo is empty */ int delay; int rc; TR(TRACE_IEVENT, ("timed delay in wgetch()")); - if (SP->_cbreak > 1) - delay = (SP->_cbreak - 1) * 100; + if (sp->_cbreak > 1) + delay = (sp->_cbreak - 1) * 100; else delay = win->_delay; @@ -342,7 +345,7 @@ _nc_wgetch(WINDOW *win, TR(TRACE_IEVENT, ("delay is %d milliseconds", delay)); - rc = check_mouse_activity(delay EVENTLIST_2nd(evl)); + rc = check_mouse_activity(sp, delay EVENTLIST_2nd(evl)); #ifdef NCURSES_WGETCH_EVENTS if (rc & 4) { @@ -372,23 +375,23 @@ _nc_wgetch(WINDOW *win, int rc; do { - ch = kgetch(EVENTLIST_1st(evl)); + ch = kgetch(sp EVENTLIST_2nd(evl)); if (ch == KEY_MOUSE) { ++runcount; - if (SP->_mouse_inline(SP)) + if (sp->_mouse_inline(sp)) break; } - if (SP->_maxclick < 0) + if (sp->_maxclick < 0) break; } while (ch == KEY_MOUSE - && (((rc = check_mouse_activity(SP->_maxclick + && (((rc = check_mouse_activity(sp, sp->_maxclick EVENTLIST_2nd(evl))) != 0 && !(rc & 4)) - || !SP->_mouse_parse(runcount))); + || !sp->_mouse_parse(runcount))); #ifdef NCURSES_WGETCH_EVENTS if ((rc & 4) && !ch == KEY_EVENT) { - ungetch(ch); + _nc_ungetch(sp, ch); ch = KEY_EVENT; } #endif @@ -396,28 +399,28 @@ _nc_wgetch(WINDOW *win, #ifdef NCURSES_WGETCH_EVENTS /* mouse event sequence ended by an event, report event */ if (ch == KEY_EVENT) { - ungetch(KEY_MOUSE); /* FIXME This interrupts a gesture... */ + _nc_ungetch(sp, KEY_MOUSE); /* FIXME This interrupts a gesture... */ } else #endif { /* mouse event sequence ended by keystroke, store keystroke */ - ungetch(ch); + _nc_ungetch(sp, ch); ch = KEY_MOUSE; } } } else { if (head == -1) - fifo_push(EVENTLIST_1st(evl)); - ch = fifo_pull(); + fifo_push(sp EVENTLIST_2nd(evl)); + ch = fifo_pull(sp); } if (ch == ERR) { #if USE_SIZECHANGE - if (_nc_handle_sigwinch(FALSE)) { - _nc_update_screensize(); + if (_nc_handle_sigwinch(sp)) { + _nc_update_screensize(sp); /* resizeterm can push KEY_RESIZE */ if (cooked_key_in_fifo()) { - *result = fifo_pull(); + *result = fifo_pull(sp); returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK); } } @@ -443,7 +446,7 @@ _nc_wgetch(WINDOW *win, * However, we provide the same visual result as Solaris, moving the * cursor to the left. */ - if (SP->_echo && !(win->_flags & _ISPAD)) { + if (sp->_echo && !(win->_flags & _ISPAD)) { chtype backup = (ch == KEY_BACKSPACE) ? '\b' : ch; if (backup < KEY_MIN) wechochar(win, backup); @@ -452,7 +455,7 @@ _nc_wgetch(WINDOW *win, /* * Simulate ICRNL mode */ - if ((ch == '\r') && SP->_nl) + if ((ch == '\r') && sp->_nl) ch = '\n'; /* Strip 8th-bit if so desired. We do this only for characters that @@ -474,13 +477,14 @@ _nc_wgetch(WINDOW *win, NCURSES_EXPORT(int) wgetch_events(WINDOW *win, _nc_eventlist * evl) { + SCREEN *sp = SP; int code; unsigned long value; T((T_CALLED("wgetch_events(%p,%p)"), win, evl)); code = _nc_wgetch(win, &value, - SP->_use_meta + sp->_use_meta EVENTLIST_2nd(evl)); if (code != ERR) code = value; @@ -491,13 +495,14 @@ wgetch_events(WINDOW *win, _nc_eventlist * evl) NCURSES_EXPORT(int) wgetch(WINDOW *win) { + SCREEN *sp = SP; int code; unsigned long value; T((T_CALLED("wgetch(%p)"), win)); code = _nc_wgetch(win, &value, - (SP ? SP->_use_meta : 0) + (sp ? sp->_use_meta : 0) EVENTLIST_2nd((_nc_eventlist *) 0)); if (code != ERR) code = value; @@ -520,21 +525,21 @@ wgetch(WINDOW *win) */ static int -kgetch(EVENTLIST_0th(_nc_eventlist * evl)) +kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl)) { TRIES *ptr; int ch = 0; - int timeleft = ESCDELAY; + int timeleft = GetEscdelay(sp); TR(TRACE_IEVENT, ("kgetch() called")); - ptr = SP->_keytry; + ptr = sp->_keytry; for (;;) { - if (cooked_key_in_fifo() && SP->_fifo[head] >= KEY_MIN) { + if (cooked_key_in_fifo() && sp->_fifo[head] >= KEY_MIN) { break; } else if (!raw_key_in_fifo()) { - ch = fifo_push(EVENTLIST_1st(evl)); + ch = fifo_push(sp EVENTLIST_2nd(evl)); if (ch == ERR) { peek = head; /* the keys stay uninterpreted */ return ERR; @@ -542,12 +547,12 @@ kgetch(EVENTLIST_0th(_nc_eventlist * evl)) #ifdef NCURSES_WGETCH_EVENTS else if (ch == KEY_EVENT) { peek = head; /* the keys stay uninterpreted */ - return fifo_pull(); /* Remove KEY_EVENT from the queue */ + return fifo_pull(sp); /* Remove KEY_EVENT from the queue */ } #endif } - ch = fifo_peek(); + ch = fifo_peek(sp); if (ch >= KEY_MIN) { /* If not first in queue, somebody put this key there on purpose in * emergency. Consider it higher priority than the unfinished @@ -573,7 +578,7 @@ kgetch(EVENTLIST_0th(_nc_eventlist * evl)) if (ptr->value != 0) { /* sequence terminated */ TR(TRACE_IEVENT, ("end of sequence")); if (peek == tail) - fifo_clear(); + fifo_clear(sp); else head = peek; return (ptr->value); @@ -585,7 +590,7 @@ kgetch(EVENTLIST_0th(_nc_eventlist * evl)) int rc; TR(TRACE_IEVENT, ("waiting for rest of sequence")); - rc = check_mouse_activity(timeleft EVENTLIST_2nd(evl)); + rc = check_mouse_activity(sp, timeleft EVENTLIST_2nd(evl)); #ifdef NCURSES_WGETCH_EVENTS if (rc & 4) { TR(TRACE_IEVENT, ("interrupted by a user event")); @@ -600,7 +605,7 @@ kgetch(EVENTLIST_0th(_nc_eventlist * evl)) } } } - ch = fifo_pull(); + ch = fifo_pull(sp); peek = head; return ch; } diff --git a/contrib/ncurses/ncurses/base/lib_initscr.c b/contrib/ncurses/ncurses/base/lib_initscr.c index 38744738cbb6..ef360c03b642 100644 --- a/contrib/ncurses/ncurses/base/lib_initscr.c +++ b/contrib/ncurses/ncurses/base/lib_initscr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -45,15 +45,19 @@ #include <sys/termio.h> /* needed for ISC */ #endif -MODULE_ID("$Id: lib_initscr.c,v 1.35 2007/04/21 20:43:02 tom Exp $") +MODULE_ID("$Id: lib_initscr.c,v 1.36 2008/04/12 18:11:36 tom Exp $") NCURSES_EXPORT(WINDOW *) initscr(void) { + WINDOW *result; + NCURSES_CONST char *name; START_TRACE(); T((T_CALLED("initscr()"))); + + _nc_lock_global(set_SP); /* Portable applications must not call initscr() more than once */ if (!_nc_globals.init_screen) { _nc_globals.init_screen = TRUE; @@ -86,5 +90,8 @@ initscr(void) /* def_shell_mode - done in newterm/_nc_setupscreen */ def_prog_mode(); } - returnWin(stdscr); + result = stdscr; + _nc_unlock_global(set_SP); + + returnWin(result); } diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c index f52562cec106..3620a3fdbf2b 100644 --- a/contrib/ncurses/ncurses/base/lib_newterm.c +++ b/contrib/ncurses/ncurses/base/lib_newterm.c @@ -48,7 +48,7 @@ #include <term.h> /* clear_screen, cup & friends, cur_term */ #include <tic.h> -MODULE_ID("$Id: lib_newterm.c,v 1.68 2008/01/12 20:24:40 tom Exp $") +MODULE_ID("$Id: lib_newterm.c,v 1.69 2008/04/12 18:15:04 tom Exp $") #ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */ #define ONLCR 0 @@ -123,17 +123,17 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) { int value; int errret; - int slk_format = _nc_globals.slk_format; SCREEN *current; SCREEN *result = 0; START_TRACE(); T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp)); + _nc_lock_global(set_SP); /* this loads the capability entry, then sets LINES and COLS */ - if (setupterm(name, fileno(ofp), &errret) == ERR) { - result = 0; - } else { + 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. @@ -143,11 +143,7 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) /* allow user to set maximum escape delay from the environment */ if ((value = _nc_getenv_num("ESCDELAY")) >= 0) { -#if USE_REENTRANT - SP->_ESCDELAY = value; -#else - ESCDELAY = value; -#endif + set_escdelay(value); } if (_nc_setupscreen(LINES, @@ -216,5 +212,6 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) result = SP; } } + _nc_unlock_global(set_SP); returnSP(result); } diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c index 21ba95f34ed6..7f7aa3e04f1e 100644 --- a/contrib/ncurses/ncurses/base/lib_newwin.c +++ b/contrib/ncurses/ncurses/base/lib_newwin.c @@ -40,42 +40,39 @@ */ #include <curses.priv.h> +#include <stddef.h> -MODULE_ID("$Id: lib_newwin.c,v 1.44 2008/01/13 00:28:13 tom Exp $") +MODULE_ID("$Id: lib_newwin.c,v 1.50 2008/05/03 16:36:39 tom Exp $") -static WINDOW * +#define window_is(name) ((sp)->_##name == win) + +#if USE_REENTRANT +#define remove_window(name) \ + sp->_##name = 0 +#else +#define remove_window(name) \ + sp->_##name = 0; \ + if (win == name) \ + name = 0 +#endif + +static void remove_window_from_screen(WINDOW *win) { - SCREEN **scan = &_nc_screen_chain; - - while (*scan) { - SCREEN *sp = *scan; - if (sp->_curscr == win) { - sp->_curscr = 0; -#if !USE_REENTRANT - if (win == curscr) - curscr = 0; -#endif - } else if (sp->_stdscr == win) { - sp->_stdscr = 0; -#if !USE_REENTRANT - if (win == stdscr) - stdscr = 0; -#endif - } else if (sp->_newscr == win) { - sp->_newscr = 0; -#if !USE_REENTRANT - if (win == newscr) - newscr = 0; -#endif - } else { - scan = &(*scan)->_next_screen; - continue; + SCREEN *sp; + + for (each_screen(sp)) { + if (window_is(curscr)) { + remove_window(curscr); + break; + } else if (window_is(stdscr)) { + remove_window(stdscr); + break; + } else if (window_is(newscr)) { + remove_window(newscr); + break; } - break; } - - return 0; } NCURSES_EXPORT(int) @@ -89,7 +86,8 @@ _nc_freewin(WINDOW *win) if (win != 0) { if (_nc_try_global(windowlist) == 0) { - for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) { + q = 0; + for (each_window(p)) { if (&(p->win) == win) { remove_window_from_screen(win); if (q == 0) @@ -108,6 +106,7 @@ _nc_freewin(WINDOW *win) T(("...deleted win=%p", win)); break; } + q = p; } _nc_unlock_global(windowlist); } @@ -230,14 +229,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags) if ((wp = typeCalloc(WINDOWLIST, 1)) == 0) returnWin(0); -#ifdef USE_PTHREADS - { - pthread_mutexattr_t recattr; - memset(&recattr, 0, sizeof(recattr)); - pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_NORMAL); - pthread_mutex_init(&(wp->mutex_use_window), &recattr); - } -#endif + _nc_mutex_init(&(wp->mutex_use_window)); win = &(wp->win); diff --git a/contrib/ncurses/ncurses/base/lib_overlay.c b/contrib/ncurses/ncurses/base/lib_overlay.c index 22bd2f80ba72..26314de5e5fb 100644 --- a/contrib/ncurses/ncurses/base/lib_overlay.c +++ b/contrib/ncurses/ncurses/base/lib_overlay.c @@ -40,46 +40,46 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_overlay.c,v 1.23 2007/04/07 17:13:52 tom Exp $") +MODULE_ID("$Id: lib_overlay.c,v 1.25 2008/04/12 17:21:59 tom Exp $") static int -overlap(const WINDOW *const s, WINDOW *const d, int const flag) +overlap(const WINDOW *const src, WINDOW *const dst, int const flag) { + int rc = ERR; int sx1, sy1, sx2, sy2; int dx1, dy1, dx2, dy2; int sminrow, smincol; int dminrow, dmincol; int dmaxrow, dmaxcol; - T((T_CALLED("overlap(%p,%p,%d)"), s, d, flag)); + T((T_CALLED("overlap(%p,%p,%d)"), src, dst, flag)); + + if (src != 0 && dst != 0) { + _nc_lock_window(src); + _nc_lock_window(dst); - if (s == 0 || d == 0) { - returnCode(ERR); - } else { T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld", - (long) s->_begy, - (long) s->_begx, - (long) s->_maxy, - (long) s->_maxx)); + (long) src->_begy, + (long) src->_begx, + (long) src->_maxy, + (long) src->_maxx)); T(("dst : begy %ld, begx %ld, maxy %ld, maxx %ld", - (long) d->_begy, - (long) d->_begx, - (long) d->_maxy, - (long) d->_maxx)); - - sx1 = s->_begx; - sy1 = s->_begy; - sx2 = sx1 + s->_maxx; - sy2 = sy1 + s->_maxy; - - dx1 = d->_begx; - dy1 = d->_begy; - dx2 = dx1 + d->_maxx; - dy2 = dy1 + d->_maxy; - - if (dx2 < sx1 || dx1 > sx2 || dy2 < sy1 || dy1 > sy2) { - returnCode(ERR); /* No intersection */ - } else { + (long) dst->_begy, + (long) dst->_begx, + (long) dst->_maxy, + (long) dst->_maxx)); + + sx1 = src->_begx; + sy1 = src->_begy; + sx2 = sx1 + src->_maxx; + sy2 = sy1 + src->_maxy; + + dx1 = dst->_begx; + dy1 = dst->_begy; + dx2 = dx1 + dst->_maxx; + dy2 = dy1 + dst->_maxy; + + if (dx2 >= sx1 && dx1 <= sx2 && dy2 >= sy1 && dy1 <= sy2) { sminrow = max(sy1, dy1) - sy1; smincol = max(sx1, dx1) - sx1; dminrow = max(sy1, dy1) - dy1; @@ -87,13 +87,16 @@ overlap(const WINDOW *const s, WINDOW *const d, int const flag) dmaxrow = min(sy2, dy2) - dy1; dmaxcol = min(sx2, dx2) - dx1; - returnCode(copywin(s, d, - sminrow, smincol, - dminrow, dmincol, - dmaxrow, dmaxcol, - flag)); + rc = copywin(src, dst, + sminrow, smincol, + dminrow, dmincol, + dmaxrow, dmaxcol, + flag); } + _nc_unlock_window(dst); + _nc_unlock_window(src); } + returnCode(rc); } /* @@ -137,6 +140,7 @@ copywin(const WINDOW *src, WINDOW *dst, int dmaxrow, int dmaxcol, int over) { + int rc = ERR; int sx, sy, dx, dy; bool touched; attr_t bk; @@ -145,49 +149,63 @@ copywin(const WINDOW *src, WINDOW *dst, T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"), src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over)); - if (!src || !dst) - returnCode(ERR); - - bk = AttrOf(dst->_nc_bkgd); - mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0); - - /* make sure rectangle exists in source */ - if ((sminrow + dmaxrow - dminrow) > (src->_maxy + 1) || - (smincol + dmaxcol - dmincol) > (src->_maxx + 1)) { - returnCode(ERR); - } - - T(("rectangle exists in source")); - - /* make sure rectangle fits in destination */ - if (dmaxrow > dst->_maxy || dmaxcol > dst->_maxx) { - returnCode(ERR); - } - - T(("rectangle fits in destination")); - - for (dy = dminrow, sy = sminrow; dy <= dmaxrow; sy++, dy++) { - touched = FALSE; - for (dx = dmincol, sx = smincol; dx <= dmaxcol; sx++, dx++) { - if (over) { - if ((CharOf(src->_line[sy].text[sx]) != L(' ')) && - (!CharEq(dst->_line[dy].text[dx], src->_line[sy].text[sx]))) { - dst->_line[dy].text[dx] = src->_line[sy].text[sx]; - SetAttr(dst->_line[dy].text[dx], - (AttrOf(src->_line[sy].text[sx]) & mask) | bk); - touched = TRUE; - } - } else { - if (!CharEq(dst->_line[dy].text[dx], src->_line[sy].text[sx])) { - dst->_line[dy].text[dx] = src->_line[sy].text[sx]; - touched = TRUE; + if (src && dst) { + + _nc_lock_window(src); + _nc_lock_window(dst); + + bk = AttrOf(dst->_nc_bkgd); + mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0); + + /* make sure rectangle exists in source */ + if ((sminrow + dmaxrow - dminrow) <= (src->_maxy + 1) && + (smincol + dmaxcol - dmincol) <= (src->_maxx + 1)) { + + T(("rectangle exists in source")); + + /* make sure rectangle fits in destination */ + if (dmaxrow <= dst->_maxy && dmaxcol <= dst->_maxx) { + + T(("rectangle fits in destination")); + + for (dy = dminrow, sy = sminrow; + dy <= dmaxrow; + sy++, dy++) { + + touched = FALSE; + for (dx = dmincol, sx = smincol; + dx <= dmaxcol; + sx++, dx++) { + if (over) { + if ((CharOf(src->_line[sy].text[sx]) != L(' ')) && + (!CharEq(dst->_line[dy].text[dx], + src->_line[sy].text[sx]))) { + dst->_line[dy].text[dx] = + src->_line[sy].text[sx]; + SetAttr(dst->_line[dy].text[dx], + ((AttrOf(src->_line[sy].text[sx]) & + mask) | bk)); + touched = TRUE; + } + } else { + if (!CharEq(dst->_line[dy].text[dx], + src->_line[sy].text[sx])) { + dst->_line[dy].text[dx] = + src->_line[sy].text[sx]; + touched = TRUE; + } + } + } + if (touched) { + touchline(dst, dminrow, (dmaxrow - dminrow + 1)); + } } + T(("finished copywin")); + rc = OK; } } - if (touched) { - touchline(dst, dminrow, (dmaxrow - dminrow + 1)); - } + _nc_unlock_window(dst); + _nc_unlock_window(src); } - T(("finished copywin")); - returnCode(OK); + returnCode(rc); } diff --git a/contrib/ncurses/ncurses/base/lib_restart.c b/contrib/ncurses/ncurses/base/lib_restart.c index 858ef65a645d..9742ff629fbd 100644 --- a/contrib/ncurses/ncurses/base/lib_restart.c +++ b/contrib/ncurses/ncurses/base/lib_restart.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -48,7 +48,7 @@ #include <term.h> /* lines, columns, cur_term */ -MODULE_ID("$Id: lib_restart.c,v 1.8 2007/10/13 19:59:47 tom Exp $") +MODULE_ID("$Id: lib_restart.c,v 1.9 2008/05/03 22:43:52 tom Exp $") NCURSES_EXPORT(int) restartterm(NCURSES_CONST char *termp, int filenum, int *errret) @@ -88,7 +88,7 @@ restartterm(NCURSES_CONST char *termp, int filenum, int *errret) reset_prog_mode(); #if USE_SIZECHANGE - _nc_update_screensize(); + _nc_update_screensize(SP); #endif result = OK; diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c index e44850c6a15a..eee1cfc7b259 100644 --- a/contrib/ncurses/ncurses/base/lib_set_term.c +++ b/contrib/ncurses/ncurses/base/lib_set_term.c @@ -44,7 +44,7 @@ #include <term.h> /* cur_term */ #include <tic.h> -MODULE_ID("$Id: lib_set_term.c,v 1.103 2008/02/03 20:31:08 tom Exp $") +MODULE_ID("$Id: lib_set_term.c,v 1.108 2008/05/03 22:42:43 tom Exp $") NCURSES_EXPORT(SCREEN *) set_term(SCREEN *screenp) @@ -58,14 +58,25 @@ set_term(SCREEN *screenp) oldSP = SP; _nc_set_screen(screenp); - set_curterm(SP->_term); + if (SP != 0) { + set_curterm(SP->_term); #if !USE_REENTRANT - curscr = SP->_curscr; - newscr = SP->_newscr; - stdscr = SP->_stdscr; - COLORS = SP->_color_count; - COLOR_PAIRS = SP->_pair_count; + curscr = SP->_curscr; + newscr = SP->_newscr; + stdscr = SP->_stdscr; + COLORS = SP->_color_count; + COLOR_PAIRS = SP->_pair_count; #endif + } else { + set_curterm(0); +#if !USE_REENTRANT + curscr = 0; + newscr = 0; + stdscr = 0; + COLORS = 0; + COLOR_PAIRS = 0; +#endif + } _nc_unlock_global(set_SP); @@ -83,90 +94,105 @@ _nc_free_keytry(TRIES * kt) } } +static bool +delink_screen(SCREEN *sp) +{ + SCREEN *last = 0; + SCREEN *temp; + bool result = FALSE; + + for (each_screen(temp)) { + if (temp == sp) { + if (last) + last = sp->_next_screen; + else + _nc_screen_chain = sp->_next_screen; + result = TRUE; + break; + } + last = temp; + } + return result; +} + /* * Free the storage associated with the given SCREEN sp. */ NCURSES_EXPORT(void) delscreen(SCREEN *sp) { - SCREEN **scan = &_nc_screen_chain; int i; T((T_CALLED("delscreen(%p)"), sp)); _nc_lock_global(set_SP); - while (*scan) { - if (*scan == sp) { - *scan = sp->_next_screen; - break; - } - scan = &(*scan)->_next_screen; - } - - (void) _nc_freewin(sp->_curscr); - (void) _nc_freewin(sp->_newscr); - (void) _nc_freewin(sp->_stdscr); - - if (sp->_slk != 0) { - if (sp->_slk->ent != 0) { - for (i = 0; i < sp->_slk->labcnt; ++i) { - FreeIfNeeded(sp->_slk->ent[i].ent_text); - FreeIfNeeded(sp->_slk->ent[i].form_text); + if (delink_screen(sp)) { + + (void) _nc_freewin(sp->_curscr); + (void) _nc_freewin(sp->_newscr); + (void) _nc_freewin(sp->_stdscr); + + if (sp->_slk != 0) { + if (sp->_slk->ent != 0) { + for (i = 0; i < sp->_slk->labcnt; ++i) { + FreeIfNeeded(sp->_slk->ent[i].ent_text); + FreeIfNeeded(sp->_slk->ent[i].form_text); + } + free(sp->_slk->ent); } - free(sp->_slk->ent); + free(sp->_slk); + sp->_slk = 0; } - free(sp->_slk); - sp->_slk = 0; - } - _nc_free_keytry(sp->_keytry); - sp->_keytry = 0; + _nc_free_keytry(sp->_keytry); + sp->_keytry = 0; - _nc_free_keytry(sp->_key_ok); - sp->_key_ok = 0; + _nc_free_keytry(sp->_key_ok); + sp->_key_ok = 0; - FreeIfNeeded(sp->_current_attr); + FreeIfNeeded(sp->_current_attr); - FreeIfNeeded(sp->_color_table); - FreeIfNeeded(sp->_color_pairs); + FreeIfNeeded(sp->_color_table); + FreeIfNeeded(sp->_color_pairs); - FreeIfNeeded(sp->oldhash); - FreeIfNeeded(sp->newhash); - FreeIfNeeded(sp->hashtab); + FreeIfNeeded(sp->oldhash); + FreeIfNeeded(sp->newhash); + FreeIfNeeded(sp->hashtab); - FreeIfNeeded(sp->_acs_map); - FreeIfNeeded(sp->_screen_acs_map); + FreeIfNeeded(sp->_acs_map); + FreeIfNeeded(sp->_screen_acs_map); - del_curterm(sp->_term); + del_curterm(sp->_term); - /* - * If the associated output stream has been closed, we can discard the - * set-buffer. Limit the error check to EBADF, since fflush may fail - * for other reasons than trying to operate upon a closed stream. - */ - if (sp->_ofp != 0 - && sp->_setbuf != 0 - && fflush(sp->_ofp) != 0 - && errno == EBADF) { - free(sp->_setbuf); - } + /* + * If the associated output stream has been closed, we can discard the + * set-buffer. Limit the error check to EBADF, since fflush may fail + * for other reasons than trying to operate upon a closed stream. + */ + if (sp->_ofp != 0 + && sp->_setbuf != 0 + && fflush(sp->_ofp) != 0 + && errno == EBADF) { + free(sp->_setbuf); + } - free(sp); + free(sp); - /* - * If this was the current screen, reset everything that the - * application might try to use (except cur_term, which may have - * multiple references in different screens). - */ - if (sp == SP) { + /* + * If this was the current screen, reset everything that the + * application might try to use (except cur_term, which may have + * multiple references in different screens). + */ + if (sp == SP) { #if !USE_REENTRANT - curscr = 0; - newscr = 0; - stdscr = 0; - COLORS = 0; - COLOR_PAIRS = 0; + curscr = 0; + newscr = 0; + stdscr = 0; + COLORS = 0; + COLOR_PAIRS = 0; #endif - _nc_set_screen(0); + _nc_set_screen(0); + } } _nc_unlock_global(set_SP); @@ -254,7 +280,7 @@ _nc_setupscreen(int slines GCC_UNUSED, /* * We should always check the screensize, just in case. */ - _nc_get_screensize(&slines, &scolumns); + _nc_get_screensize(SP, &slines, &scolumns); SET_LINES(slines); SET_COLS(scolumns); T((T_CREATE("screen %s %dx%d"), termname(), LINES, COLS)); @@ -512,8 +538,6 @@ _nc_setupscreen(int slines GCC_UNUSED, _nc_idcok = TRUE; _nc_idlok = FALSE; - _nc_windows = 0; /* no windows yet */ - SP->oldhash = 0; SP->newhash = 0; diff --git a/contrib/ncurses/ncurses/base/lib_ungetch.c b/contrib/ncurses/ncurses/base/lib_ungetch.c index 9570a33edc5e..2eda99017bed 100644 --- a/contrib/ncurses/ncurses/base/lib_ungetch.c +++ b/contrib/ncurses/ncurses/base/lib_ungetch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2002,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -29,6 +29,7 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * + * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* @@ -40,42 +41,50 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_ungetch.c,v 1.9 2007/09/29 21:49:56 tom Exp $") +MODULE_ID("$Id: lib_ungetch.c,v 1.10 2008/05/03 20:20:58 tom Exp $") #include <fifo_defs.h> #ifdef TRACE NCURSES_EXPORT(void) -_nc_fifo_dump(void) +_nc_fifo_dump(SCREEN *sp) { int i; T(("head = %d, tail = %d, peek = %d", head, tail, peek)); for (i = 0; i < 10; i++) - T(("char %d = %s", i, _tracechar(SP->_fifo[i]))); + T(("char %d = %s", i, _tracechar(sp->_fifo[i]))); } #endif /* TRACE */ NCURSES_EXPORT(int) -ungetch(int ch) +_nc_ungetch(SCREEN *sp, int ch) { - T((T_CALLED("ungetch(%s)"), _tracechar(ch))); + int rc = ERR; - if (tail == -1) - returnCode(ERR); - if (head == -1) { - head = 0; - t_inc() + if (tail != -1) { + if (head == -1) { + head = 0; + t_inc(); peek = tail; /* no raw keys */ - } else - h_dec(); + } else + h_dec(); - SP->_fifo[head] = ch; - T(("ungetch %s ok", _tracechar(ch))); + sp->_fifo[head] = ch; + T(("ungetch %s ok", _tracechar(ch))); #ifdef TRACE - if (USE_TRACEF(TRACE_IEVENT)) { - _nc_fifo_dump(); - _nc_unlock_global(tracef); - } + if (USE_TRACEF(TRACE_IEVENT)) { + _nc_fifo_dump(sp); + _nc_unlock_global(tracef); + } #endif - returnCode(OK); + rc = OK; + } + return rc; +} + +NCURSES_EXPORT(int) +ungetch(int ch) +{ + T((T_CALLED("ungetch(%s)"), _tracechar(ch))); + returnCode(_nc_ungetch(SP, ch)); } diff --git a/contrib/ncurses/ncurses/base/lib_window.c b/contrib/ncurses/ncurses/base/lib_window.c index 530b08e5ed1f..ac61cb01da99 100644 --- a/contrib/ncurses/ncurses/base/lib_window.c +++ b/contrib/ncurses/ncurses/base/lib_window.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -39,7 +39,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_window.c,v 1.23 2007/06/30 23:36:11 tom Exp $") +MODULE_ID("$Id: lib_window.c,v 1.24 2008/04/12 22:40:21 tom Exp $") NCURSES_EXPORT(void) _nc_synchook(WINDOW *win) @@ -186,6 +186,7 @@ dupwin(WINDOW *win) if (win != 0) { + _nc_lock_window(win); if (win->_flags & _ISPAD) { nwin = newpad(win->_maxy + 1, win->_maxx + 1); @@ -243,6 +244,7 @@ dupwin(WINDOW *win) nwin->_line[i].lastchar = win->_line[i].lastchar; } } + _nc_unlock_window(win); } returnWin(nwin); } diff --git a/contrib/ncurses/ncurses/base/resizeterm.c b/contrib/ncurses/ncurses/base/resizeterm.c index eb2dd737f94c..cf2c998e239f 100644 --- a/contrib/ncurses/ncurses/base/resizeterm.c +++ b/contrib/ncurses/ncurses/base/resizeterm.c @@ -41,7 +41,7 @@ #include <curses.priv.h> #include <term.h> -MODULE_ID("$Id: resizeterm.c,v 1.30 2008/01/12 22:26:56 tom Exp $") +MODULE_ID("$Id: resizeterm.c,v 1.32 2008/05/03 14:28:55 tom Exp $") #define stolen_lines (screen_lines - SP->_lines_avail) @@ -69,7 +69,7 @@ show_window_sizes(const char *name) _nc_lock_global(windowlist); _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS, screen_lines, screen_columns); - for (wp = _nc_windows; wp != 0; wp = wp->next) { + for (each_window(wp)) { _tracef(" window %p is %2ld x %2ld at %2ld,%2ld", &(wp->win), (long) wp->win._maxy + 1, @@ -104,7 +104,7 @@ ripped_window(WINDOW *win) ripoff_t *rop; if (win != 0) { - for (rop = ripoff_stack; (rop - ripoff_stack) < N_RIPS; rop++) { + for (each_ripoff(rop)) { if (rop->win == win && rop->line != 0) { result = rop; break; @@ -125,7 +125,7 @@ ripped_bottom(WINDOW *win) ripoff_t *rop; if (win != 0) { - for (rop = ripoff_stack; (rop - ripoff_stack) < N_RIPS; rop++) { + for (each_ripoff(rop)) { if (rop->line < 0) { result -= rop->line; if (rop->win == win) { @@ -148,7 +148,7 @@ child_depth(WINDOW *cmp) if (cmp != 0) { WINDOWLIST *wp; - for (wp = _nc_windows; wp != 0; wp = wp->next) { + for (each_window(wp)) { WINDOW *tst = &(wp->win); if (tst->_parent == cmp) { depth = 1 + child_depth(tst); @@ -251,7 +251,7 @@ decrease_size(int ToLines, int ToCols, int stolen EXTRA_DCLS) found = FALSE; TR(TRACE_UPDATE, ("decreasing size of windows to %dx%d, depth=%d", ToLines, ToCols, depth)); - for (wp = _nc_windows; wp != 0; wp = wp->next) { + for (each_window(wp)) { WINDOW *win = &(wp->win); if (!(win->_flags & _ISPAD)) { @@ -285,7 +285,7 @@ increase_size(int ToLines, int ToCols, int stolen EXTRA_DCLS) found = FALSE; TR(TRACE_UPDATE, ("increasing size of windows to %dx%d, depth=%d", ToLines, ToCols, depth)); - for (wp = _nc_windows; wp != 0; wp = wp->next) { + for (each_window(wp)) { WINDOW *win = &(wp->win); if (!(win->_flags & _ISPAD)) { @@ -428,7 +428,7 @@ resizeterm(int ToLines, int ToCols) * decide which to repaint, since without panels, ncurses does * not know which are really on top. */ - for (rop = ripoff_stack; (rop - ripoff_stack) < N_RIPS; rop++) { + for (each_ripoff(rop)) { if (rop->win != stdscr && rop->win != 0 && rop->line < 0) { diff --git a/contrib/ncurses/ncurses/base/use_window.c b/contrib/ncurses/ncurses/base/use_window.c index 4c9b1375f288..4d0fdf6705be 100644 --- a/contrib/ncurses/ncurses/base/use_window.c +++ b/contrib/ncurses/ncurses/base/use_window.c @@ -32,31 +32,29 @@ #include <curses.priv.h> -MODULE_ID("$Id: use_window.c,v 1.3 2008/01/13 00:36:22 tom Exp $") +MODULE_ID("$Id: use_window.c,v 1.7 2008/05/03 14:09:38 tom Exp $") #ifdef USE_PTHREADS NCURSES_EXPORT(void) -_nc_lock_window(WINDOW *win) +_nc_lock_window(const WINDOW *win) { WINDOWLIST *p; _nc_lock_global(windowlist); - for (p = _nc_windows; p != 0; p = p->next) { + for (each_window(p)) { if (&(p->win) == win) { _nc_mutex_lock(&(p->mutex_use_window)); break; } } - _nc_unlock_global(windowlist); } NCURSES_EXPORT(void) -_nc_unlock_window(WINDOW *win) +_nc_unlock_window(const WINDOW *win) { WINDOWLIST *p; - _nc_lock_global(windowlist); - for (p = _nc_windows; p != 0; p = p->next) { + for (each_window(p)) { if (&(p->win) == win) { _nc_mutex_unlock(&(p->mutex_use_window)); break; @@ -67,7 +65,7 @@ _nc_unlock_window(WINDOW *win) #endif NCURSES_EXPORT(int) -use_window(WINDOW *win, NCURSES_CALLBACK func, void *data) +use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data) { int code = OK; diff --git a/contrib/ncurses/ncurses/base/wresize.c b/contrib/ncurses/ncurses/base/wresize.c index f756f0f237f7..ac808c4d2884 100644 --- a/contrib/ncurses/ncurses/base/wresize.c +++ b/contrib/ncurses/ncurses/base/wresize.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -32,7 +32,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: wresize.c,v 1.27 2007/12/22 23:20:53 tom Exp $") +MODULE_ID("$Id: wresize.c,v 1.28 2008/05/03 14:13:51 tom Exp $") static int cleanup_lines(struct ldat *data, int length) @@ -56,7 +56,7 @@ repair_subwindows(WINDOW *cmp) _nc_lock_global(windowlist); - for (wp = _nc_windows; wp != 0; wp = wp->next) { + for (each_window(wp)) { WINDOW *tst = &(wp->win); if (tst->_parent == cmp) { |