aboutsummaryrefslogtreecommitdiff
path: root/ncurses/base
diff options
context:
space:
mode:
authorRong-En Fan <rafan@FreeBSD.org>2008-11-09 14:08:54 +0000
committerRong-En Fan <rafan@FreeBSD.org>2008-11-09 14:08:54 +0000
commit6181f4622a00a9de81df01cecb5fa73ffdb697bc (patch)
treec963ba08ac935d7f048b78517309fe6fc2f496e6 /ncurses/base
parentc0e48ca1322e978a8f9795a5ddb251df2479f930 (diff)
downloadsrc-6181f4622a00a9de81df01cecb5fa73ffdb697bc.tar.gz
src-6181f4622a00a9de81df01cecb5fa73ffdb697bc.zip
- Import ncurses 5.7-20081102 (5.7 release) onto vendor branchvendor/ncurses/5.7-20081102
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=184798 svn path=/vendor/ncurses/5.7-20081102/; revision=184799; tag=vendor/ncurses/5.7-20081102
Diffstat (limited to 'ncurses/base')
-rw-r--r--ncurses/base/MKkeyname.awk15
-rwxr-xr-xncurses/base/MKlib_gen.sh15
-rw-r--r--ncurses/base/MKunctrl.awk27
-rw-r--r--ncurses/base/lib_addch.c13
-rw-r--r--ncurses/base/lib_delwin.c9
-rw-r--r--ncurses/base/lib_freeall.c33
-rw-r--r--ncurses/base/lib_getch.c101
-rw-r--r--ncurses/base/lib_getstr.c23
-rw-r--r--ncurses/base/lib_initscr.c8
-rw-r--r--ncurses/base/lib_mouse.c548
-rw-r--r--ncurses/base/lib_newterm.c26
-rw-r--r--ncurses/base/lib_newwin.c30
-rw-r--r--ncurses/base/lib_overlay.c17
-rw-r--r--ncurses/base/lib_restart.c4
-rw-r--r--ncurses/base/lib_screen.c16
-rw-r--r--ncurses/base/lib_set_term.c52
-rw-r--r--ncurses/base/lib_slk.c32
-rw-r--r--ncurses/base/lib_slkrefr.c28
-rw-r--r--ncurses/base/lib_ungetch.c8
-rw-r--r--ncurses/base/lib_window.c6
-rw-r--r--ncurses/base/resizeterm.c12
-rw-r--r--ncurses/base/tries.c8
-rw-r--r--ncurses/base/use_window.c36
-rw-r--r--ncurses/base/wresize.c6
24 files changed, 606 insertions, 467 deletions
diff --git a/ncurses/base/MKkeyname.awk b/ncurses/base/MKkeyname.awk
index c1d9475045d0..b35ba2a98027 100644
--- a/ncurses/base/MKkeyname.awk
+++ b/ncurses/base/MKkeyname.awk
@@ -1,6 +1,6 @@
-# $Id: MKkeyname.awk,v 1.38 2007/08/18 18:41:18 tom Exp $
+# $Id: MKkeyname.awk,v 1.40 2008/07/12 18:40:00 tom Exp $
##############################################################################
-# Copyright (c) 1999-2006,2007 Free Software Foundation, Inc. #
+# Copyright (c) 1999-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 "Software"), #
@@ -67,7 +67,7 @@ END {
print "#define SIZEOF_TABLE 256"
print "#define MyTable _nc_globals.keyname_table"
print ""
- print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
+ print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *sp, int c)"
print "{"
print " int i;"
print " char name[20];"
@@ -100,7 +100,7 @@ END {
print " if (MyTable[c] == 0) {"
print " int cc = c;"
print " p = name;"
- print " if (cc >= 128 && (SP == 0 || SP->_use_meta)) {"
+ print " if (cc >= 128 && (sp == 0 || sp->_use_meta)) {"
print " strcpy(p, \"M-\");"
print " p += 2;"
print " cc -= 128;"
@@ -124,7 +124,7 @@ END {
print ""
print " _nc_tracing = 0; /* prevent recursion via keybound() */"
print " for (j = 0; (bound = keybound(c, j)) != 0; ++j) {"
- print " for(k = STRCOUNT; k < NUM_STRINGS(tp); k++) {"
+ print " for(k = STRCOUNT; k < (int) NUM_STRINGS(tp); k++) {"
print " if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {"
print " result = ExtStrname(tp, k, strnames);"
print " break;"
@@ -141,6 +141,11 @@ END {
print " return result;"
print "}"
print ""
+ print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
+ print "{"
+ print "\treturn _nc_keyname(SP, c);"
+ print "}"
+ print ""
print "#if NO_LEAKS"
print "void _nc_keyname_leaks(void)"
print "{"
diff --git a/ncurses/base/MKlib_gen.sh b/ncurses/base/MKlib_gen.sh
index 09857834e7e0..a984e8545eff 100755
--- a/ncurses/base/MKlib_gen.sh
+++ b/ncurses/base/MKlib_gen.sh
@@ -2,7 +2,7 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# ($Id: MKlib_gen.sh,v 1.30 2008/01/05 23:21:10 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.34 2008/08/30 19:20:50 tom Exp $)
#
##############################################################################
# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
@@ -152,7 +152,7 @@ cat >$ED3 <<EOF3
s/ )/)/g
s/ gen_/ /
s/^M_/#undef /
- s/^[ ]*%[ ]*%[ ]*/ /
+ s/^[ ]*@[ ]*@[ ]*/ /
:done
EOF3
@@ -252,7 +252,7 @@ $0 !~ /^P_/ {
dotrace = 0;
}
- call = "%%T((T_CALLED(\""
+ call = "@@T((T_CALLED(\""
args = ""
comma = ""
num = 0;
@@ -338,7 +338,7 @@ $0 !~ /^P_/ {
else if (dotrace)
call = sprintf("return%s( ", returnType);
else
- call = "%%return ";
+ call = "@@return ";
call = call $myfunc "(";
for (i = 1; i < argcount; i++) {
@@ -358,7 +358,7 @@ $0 !~ /^P_/ {
print call ";"
if (match($0, "^void"))
- print "%%returnVoid;"
+ print "@@returnVoid;"
print "}";
}
EOF1
@@ -416,11 +416,14 @@ $preprocessor $TMP 2>/dev/null \
| sed \
-e 's/ / /g' \
-e 's/^ //' \
- -e 's/^_Bool/bool/' \
+ -e 's/_Bool/NCURSES_BOOL/g' \
| $AWK -f $AW2 \
| sed -f $ED3 \
| sed \
-e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \
-e 's/^.*T_CALLED.*returnCode( \((wmove.*) \));/ return \1;/' \
-e 's/gen_//' \
+ -e 's/^[ ]*#/#/' \
+ -e '/#ident/d' \
+ -e '/#line/d' \
| sed -f $ED4
diff --git a/ncurses/base/MKunctrl.awk b/ncurses/base/MKunctrl.awk
index 1ba511d72323..36fbeecb2e76 100644
--- a/ncurses/base/MKunctrl.awk
+++ b/ncurses/base/MKunctrl.awk
@@ -1,4 +1,4 @@
-# $Id: MKunctrl.awk,v 1.21 2008/02/03 20:24:30 tom Exp $
+# $Id: MKunctrl.awk,v 1.23 2008/10/04 21:40:24 tom Exp $
##############################################################################
# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
# #
@@ -46,7 +46,7 @@ BEGIN {
print ""
}
END {
- print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (register chtype ch)"
+ print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *sp, chtype ch)"
print "{"
blob=""
@@ -101,6 +101,7 @@ END {
blob = blob "\"";
print ""
+ printf "#if NCURSES_EXT_FUNCS\n";
if (bigstrings) {
blob = blob "\n/* printable values in 128-255 range */"
printf "static const short unctrl_c1[] = {"
@@ -135,6 +136,7 @@ END {
}
}
print "};"
+ print "#endif /* NCURSES_EXT_FUNCS */"
blob = blob "\"\n"
print ""
@@ -150,8 +152,8 @@ END {
print ""
print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
print "#if NCURSES_EXT_FUNCS"
- print "\t\tif ((SP != 0)"
- print "\t\t && (SP->_legacy_coding > 1)"
+ print "\t\tif ((sp != 0)"
+ print "\t\t && (sp->_legacy_coding > 1)"
print "\t\t && (check >= 128)"
print "\t\t && (check < 160))"
printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
@@ -159,18 +161,18 @@ END {
print "#if USE_WIDEC_SUPPORT"
print "\t\tif ((check >= 160)"
print "\t\t && (check < 256)"
- print "\t\t && ((SP != 0)"
- print "\t\t && ((SP->_legacy_coding > 0)"
- print "\t\t || (SP->_legacy_coding == 0"
+ print "\t\t && ((sp != 0)"
+ print "\t\t && ((sp->_legacy_coding > 0)"
+ print "\t\t || (sp->_legacy_coding == 0"
print "\t\t && (isprint(check) || iswprint(check))))))"
printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
print "\t\telse"
print "#else"
print "\t\tif ((check >= 160)"
print "\t\t && (check < 256)"
- print "\t\t && ((SP != 0)"
- print "\t\t && ((SP->_legacy_coding > 0)"
- print "\t\t || (SP->_legacy_coding == 0"
+ print "\t\t && ((sp != 0)"
+ print "\t\t && ((sp->_legacy_coding > 0)"
+ print "\t\t || (sp->_legacy_coding == 0"
print "\t\t && isprint(check)))))"
printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
print "\t\telse"
@@ -182,4 +184,9 @@ END {
print "\t}"
print "\treturn (NCURSES_CONST char *)result;"
print "}"
+ print ""
+ print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype ch)"
+ print "{"
+ print "\treturn _nc_unctrl(SP, ch);"
+ print "}"
}
diff --git a/ncurses/base/lib_addch.c b/ncurses/base/lib_addch.c
index 17ba6e2bcd6c..20a97a01a011 100644
--- a/ncurses/base/lib_addch.c
+++ b/ncurses/base/lib_addch.c
@@ -36,7 +36,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_addch.c,v 1.111 2008/03/29 18:48:02 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.113 2008/08/16 19:20:04 tom Exp $")
static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
@@ -210,7 +210,7 @@ _nc_build_wch(WINDOW *win, ARG_CH_T ch)
WINDOW_EXT(win, addch_y) = y;
init_mb(state);
- buffer[WINDOW_EXT(win, addch_used)] = CharOf(CHDEREF(ch));
+ buffer[WINDOW_EXT(win, addch_used)] = (char) CharOf(CHDEREF(ch));
WINDOW_EXT(win, addch_used) += 1;
buffer[WINDOW_EXT(win, addch_used)] = '\0';
if ((len = mbrtowc(&result,
@@ -290,12 +290,15 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch)
int len = wcwidth(CharOf(ch));
int i;
int j;
+ wchar_t *chars;
if (len == 0) { /* non-spacing */
if ((x > 0 && y >= 0)
- || ((y = win->_cury - 1) >= 0 &&
- (x = win->_maxx) > 0)) {
- wchar_t *chars = (win->_line[y].text[x - 1].chars);
+ || (win->_maxx >= 0 && win->_cury >= 1)) {
+ if (x > 0 && y >= 0)
+ chars = (win->_line[y].text[x - 1].chars);
+ else
+ chars = (win->_line[y - 1].text[win->_maxx].chars);
for (i = 0; i < CCHARW_MAX; ++i) {
if (chars[i] == 0) {
TR(TRACE_VIRTPUT,
diff --git a/ncurses/base/lib_delwin.c b/ncurses/base/lib_delwin.c
index ba5f180d5f3c..b92c40335958 100644
--- a/ncurses/base/lib_delwin.c
+++ b/ncurses/base/lib_delwin.c
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_delwin.c,v 1.16 2008/05/03 14:13:51 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.17 2008/06/07 14:10:56 tom Exp $")
static bool
cannot_delete(WINDOW *win)
@@ -67,12 +67,10 @@ delwin(WINDOW *win)
T((T_CALLED("delwin(%p)"), win));
- if (_nc_try_global(windowlist) == 0) {
- _nc_lock_window(win);
+ if (_nc_try_global(curses) == 0) {
if (win == 0
|| cannot_delete(win)) {
result = ERR;
- _nc_unlock_window(win);
} else {
if (win->_flags & _SUBWIN)
@@ -80,10 +78,9 @@ delwin(WINDOW *win)
else if (curscr != 0)
touchwin(curscr);
- _nc_unlock_window(win);
result = _nc_freewin(win);
}
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
returnCode(result);
}
diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c
index 4bb7ccc79995..564026582911 100644
--- a/ncurses/base/lib_freeall.c
+++ b/ncurses/base/lib_freeall.c
@@ -40,7 +40,7 @@
extern int malloc_errfd; /* FIXME */
#endif
-MODULE_ID("$Id: lib_freeall.c,v 1.46 2008/05/03 14:13:51 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.54 2008/09/27 13:09:57 tom Exp $")
/*
* Free all ncurses data. This is used for testing only (there's no practical
@@ -58,10 +58,13 @@ _nc_freeall(void)
if (SP->_oldnum_list != 0) {
FreeAndNull(SP->_oldnum_list);
}
+ if (SP->_panelHook.destroy != 0) {
+ SP->_panelHook.destroy(SP->_panelHook.stdscr_pseudo_panel);
+ }
}
#endif
if (SP != 0) {
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
while (_nc_windows != 0) {
bool deleted = FALSE;
@@ -93,23 +96,18 @@ _nc_freeall(void)
break;
}
delscreen(SP);
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
if (cur_term != 0)
del_curterm(cur_term);
-#if USE_WIDEC_SUPPORT
- FreeIfNeeded(_nc_wacs);
-#endif
(void) _nc_printf_string(0, empty_va);
#ifdef TRACE
(void) _nc_trace_buf(-1, 0);
#endif
-
-#if BROKEN_LINKER || USE_REENTRANT
- FreeIfNeeded(_nc_prescreen.real_acs_map);
+#if USE_WIDEC_SUPPORT
+ FreeIfNeeded(_nc_wacs);
#endif
-
_nc_leaks_tinfo();
#if HAVE_LIBDBMALLOC
@@ -131,7 +129,10 @@ _nc_free_and_exit(int code)
_nc_freeall();
#ifdef TRACE
trace(0); /* close trace file, freeing its setbuf */
- free(_nc_varargs("?", 0));
+ {
+ static va_list fake;
+ free(_nc_varargs("?", fake));
+ }
#endif
fclose(stdout);
FreeIfNeeded(last_setbuf);
@@ -143,4 +144,14 @@ NCURSES_EXPORT(void)
_nc_freeall(void)
{
}
+
+NCURSES_EXPORT(void)
+_nc_free_and_exit(int code)
+{
+ if (SP)
+ delscreen(SP);
+ if (cur_term != 0)
+ del_curterm(cur_term);
+ exit(code);
+}
#endif
diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c
index d9f6b1795c77..a3812bee76e8 100644
--- a/ncurses/base/lib_getch.c
+++ b/ncurses/base/lib_getch.c
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.87 2008/05/03 22:42:10 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.99 2008/09/20 19:46:13 tom Exp $")
#include <fifo_defs.h>
@@ -76,6 +76,13 @@ set_escdelay(int value)
}
#endif
+static int
+_nc_use_meta(WINDOW *win)
+{
+ SCREEN *sp = _nc_screen_of(win);
+ return (sp ? sp->_use_meta : 0);
+}
+
#ifdef NCURSES_WGETCH_EVENTS
#define TWAIT_MASK 7
#else
@@ -123,7 +130,7 @@ fifo_pull(SCREEN *sp)
{
int ch;
ch = sp->_fifo[head];
- TR(TRACE_IEVENT, ("pulling %s from %d", _tracechar(ch), head));
+ TR(TRACE_IEVENT, ("pulling %s from %d", _nc_tracechar(sp, ch), head));
if (peek == head) {
h_inc();
@@ -228,7 +235,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
if (head == -1)
head = peek = tail;
t_inc();
- TR(TRACE_IEVENT, ("pushed %s at %d", _tracechar(ch), tail));
+ TR(TRACE_IEVENT, ("pushed %s at %d", _nc_tracechar(sp, ch), tail));
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
_nc_fifo_dump(sp);
@@ -248,9 +255,59 @@ fifo_clear(SCREEN *sp)
static int kgetch(SCREEN *EVENTLIST_2nd(_nc_eventlist * evl));
-#define wgetch_should_refresh(win) (\
- (is_wintouched(win) || (win->_flags & _HASMOVED)) \
- && !(win->_flags & _ISPAD))
+static void
+recur_wrefresh(WINDOW *win)
+{
+#ifdef USE_PTHREADS
+ SCREEN *sp = _nc_screen_of(win);
+ if (_nc_use_pthreads && sp != SP) {
+ SCREEN *save_SP;
+
+ /* temporarily switch to the window's screen to check/refresh */
+ _nc_lock_global(curses);
+ save_SP = SP;
+ _nc_set_screen(sp);
+ recur_wrefresh(win);
+ _nc_set_screen(save_SP);
+ _nc_unlock_global(curses);
+ } else
+#endif
+ if ((is_wintouched(win) || (win->_flags & _HASMOVED))
+ && !(win->_flags & _ISPAD)) {
+ wrefresh(win);
+ }
+}
+
+static int
+recur_wgetnstr(WINDOW *win, char *buf)
+{
+ SCREEN *sp = _nc_screen_of(win);
+ int rc;
+
+ if (sp != 0) {
+#ifdef USE_PTHREADS
+ if (_nc_use_pthreads && sp != SP) {
+ SCREEN *save_SP;
+
+ /* temporarily switch to the window's screen to get cooked input */
+ _nc_lock_global(curses);
+ save_SP = SP;
+ _nc_set_screen(sp);
+ rc = recur_wgetnstr(win, buf);
+ _nc_set_screen(save_SP);
+ _nc_unlock_global(curses);
+ } else
+#endif
+ {
+ sp->_called_wgetch = TRUE;
+ rc = wgetnstr(win, buf, MAXCOLUMNS);
+ sp->_called_wgetch = FALSE;
+ }
+ } else {
+ rc = ERR;
+ }
+ return rc;
+}
NCURSES_EXPORT(int)
_nc_wgetch(WINDOW *win,
@@ -258,7 +315,7 @@ _nc_wgetch(WINDOW *win,
int use_meta
EVENTLIST_2nd(_nc_eventlist * evl))
{
- SCREEN *sp = SP;
+ SCREEN *sp;
int ch;
#ifdef NCURSES_WGETCH_EVENTS
long event_delay = -1;
@@ -267,14 +324,14 @@ _nc_wgetch(WINDOW *win,
T((T_CALLED("_nc_wgetch(%p)"), win));
*result = 0;
+
+ sp = _nc_screen_of(win);
if (win == 0 || sp == 0) {
returnCode(ERR);
}
if (cooked_key_in_fifo()) {
- if (wgetch_should_refresh(win))
- wrefresh(win);
-
+ recur_wrefresh(win);
*result = fifo_pull(sp);
returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
}
@@ -299,9 +356,7 @@ _nc_wgetch(WINDOW *win,
TR(TRACE_IEVENT, ("filling queue in cooked mode"));
- sp->_called_wgetch = TRUE;
- rc = wgetnstr(win, buf, MAXCOLUMNS);
- sp->_called_wgetch = FALSE;
+ rc = recur_wgetnstr(win, buf);
/* ungetch in reverse order */
#ifdef NCURSES_WGETCH_EVENTS
@@ -324,10 +379,9 @@ _nc_wgetch(WINDOW *win,
if (win->_use_keypad != sp->_keypad_on)
_nc_keypad(sp, win->_use_keypad);
- if (wgetch_should_refresh(win))
- wrefresh(win);
+ recur_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;
@@ -353,8 +407,9 @@ _nc_wgetch(WINDOW *win,
returnCode(KEY_CODE_YES);
}
#endif
- if (!rc)
+ if (!rc) {
returnCode(ERR);
+ }
}
/* else go on to read data available */
}
@@ -388,7 +443,7 @@ _nc_wgetch(WINDOW *win,
&& (((rc = check_mouse_activity(sp, sp->_maxclick
EVENTLIST_2nd(evl))) != 0
&& !(rc & 4))
- || !sp->_mouse_parse(runcount)));
+ || !sp->_mouse_parse(sp, runcount)));
#ifdef NCURSES_WGETCH_EVENTS
if ((rc & 4) && !ch == KEY_EVENT) {
_nc_ungetch(sp, ch);
@@ -467,7 +522,7 @@ _nc_wgetch(WINDOW *win,
if ((ch < KEY_MIN) && (ch & 0x80))
ch &= 0x7f;
- T(("wgetch returning : %s", _tracechar(ch)));
+ T(("wgetch returning : %s", _nc_tracechar(sp, ch)));
*result = ch;
returnCode(ch >= KEY_MIN ? KEY_CODE_YES : OK);
@@ -477,14 +532,13 @@ _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
+ _nc_use_meta(win)
EVENTLIST_2nd(evl));
if (code != ERR)
code = value;
@@ -495,14 +549,13 @@ 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)
+ _nc_use_meta(win)
EVENTLIST_2nd((_nc_eventlist *) 0));
if (code != ERR)
code = value;
@@ -564,7 +617,7 @@ kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
return ch;
}
- TR(TRACE_IEVENT, ("ch: %s", _tracechar((unsigned char) ch)));
+ TR(TRACE_IEVENT, ("ch: %s", _nc_tracechar(sp, (unsigned char) ch)));
while ((ptr != NULL) && (ptr->ch != (unsigned char) ch))
ptr = ptr->sibling;
diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c
index 274e87887371..b17df03d2a41 100644
--- a/ncurses/base/lib_getstr.c
+++ b/ncurses/base/lib_getstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,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 *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_getstr.c,v 1.25 2006/01/12 00:33:52 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.27 2008/08/16 19:20:04 tom Exp $")
/*
* This wipes out the last character, no matter whether it was a tab, control
@@ -75,6 +75,7 @@ wgetnstr_events(WINDOW *win,
int maxlen,
EVENTLIST_1st(_nc_eventlist * evl))
{
+ SCREEN *sp = _nc_screen_of(win);
TTY buf;
bool oldnl, oldecho, oldraw, oldcbreak;
char erasec;
@@ -90,10 +91,10 @@ wgetnstr_events(WINDOW *win,
_nc_get_tty_mode(&buf);
- oldnl = SP->_nl;
- oldecho = SP->_echo;
- oldraw = SP->_raw;
- oldcbreak = SP->_cbreak;
+ oldnl = sp->_nl;
+ oldecho = sp->_echo;
+ oldraw = sp->_raw;
+ oldcbreak = sp->_cbreak;
nl();
noecho();
noraw();
@@ -145,7 +146,7 @@ wgetnstr_events(WINDOW *win,
|| (maxlen >= 0 && str - oldstr >= maxlen)) {
beep();
} else {
- *str++ = ch;
+ *str++ = (char) ch;
if (oldecho == TRUE) {
int oldy = win->_cury;
if (waddch(win, (chtype) ch) == ERR) {
@@ -187,10 +188,10 @@ wgetnstr_events(WINDOW *win,
/* Restore with a single I/O call, to fix minor asymmetry between
* raw/noraw, etc.
*/
- SP->_nl = oldnl;
- SP->_echo = oldecho;
- SP->_raw = oldraw;
- SP->_cbreak = oldcbreak;
+ sp->_nl = oldnl;
+ sp->_echo = oldecho;
+ sp->_raw = oldraw;
+ sp->_cbreak = oldcbreak;
_nc_set_tty_mode(&buf);
diff --git a/ncurses/base/lib_initscr.c b/ncurses/base/lib_initscr.c
index ef360c03b642..b2fef0c1d085 100644
--- a/ncurses/base/lib_initscr.c
+++ b/ncurses/base/lib_initscr.c
@@ -45,7 +45,7 @@
#include <sys/termio.h> /* needed for ISC */
#endif
-MODULE_ID("$Id: lib_initscr.c,v 1.36 2008/04/12 18:11:36 tom Exp $")
+MODULE_ID("$Id: lib_initscr.c,v 1.38 2008/08/16 21:20:48 Werner.Fink Exp $")
NCURSES_EXPORT(WINDOW *)
initscr(void)
@@ -57,7 +57,9 @@ initscr(void)
START_TRACE();
T((T_CALLED("initscr()")));
- _nc_lock_global(set_SP);
+ _nc_init_pthreads();
+ _nc_lock_global(curses);
+
/* Portable applications must not call initscr() more than once */
if (!_nc_globals.init_screen) {
_nc_globals.init_screen = TRUE;
@@ -91,7 +93,7 @@ initscr(void)
def_prog_mode();
}
result = stdscr;
- _nc_unlock_global(set_SP);
+ _nc_unlock_global(curses);
returnWin(result);
}
diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c
index aace7deb4c7f..95f29aa69111 100644
--- a/ncurses/base/lib_mouse.c
+++ b/ncurses/base/lib_mouse.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 *
@@ -79,7 +79,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_mouse.c,v 1.88 2007/09/29 21:50:04 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.102 2008/10/18 21:48:55 tom Exp $")
#include <term.h>
#include <tic.h>
@@ -150,38 +150,47 @@ make an error
#define LIBGPM_SONAME "libgpm.so"
#endif
-#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(obj, #name))
+#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(SP->_dlopen_gpm, #name))
#endif /* USE_GPM_SUPPORT */
-static bool _nc_mouse_parse(int);
+static bool _nc_mouse_parse(SCREEN *, int);
static void _nc_mouse_resume(SCREEN *);
static void _nc_mouse_wrap(SCREEN *);
/* maintain a circular list of mouse events */
+#define FirstEV(sp) ((sp)->_mouse_events)
+#define LastEV(sp) ((sp)->_mouse_events + EV_MAX - 1)
+
#undef NEXT
-#define NEXT(ep) ((ep == SP->_mouse_events + EV_MAX - 1) \
- ? SP->_mouse_events \
+#define NEXT(ep) ((ep >= LastEV(sp)) \
+ ? FirstEV(sp) \
: ep + 1)
#undef PREV
-#define PREV(ep) ((ep == SP->_mouse_events) \
- ? SP->_mouse_events + EV_MAX - 1 \
+#define PREV(ep) ((ep <= FirstEV(sp)) \
+ ? LastEV(sp) \
: ep - 1)
+#define IndexEV(sp, ep) (ep - FirstEV(sp))
+
+#define RunParams(sp, eventp, runp) \
+ (long) IndexEV(sp, runp), \
+ (long) (IndexEV(sp, eventp) + (EV_MAX - 1)) % EV_MAX
+
#ifdef TRACE
static void
-_trace_slot(const char *tag)
+_trace_slot(SCREEN *sp, const char *tag)
{
MEVENT *ep;
_tracef(tag);
- for (ep = SP->_mouse_events; ep < SP->_mouse_events + EV_MAX; ep++)
+ for (ep = FirstEV(sp); ep <= LastEV(sp); ep++)
_tracef("mouse event queue slot %ld = %s",
- (long) (ep - SP->_mouse_events),
- _tracemouse(ep));
+ (long) IndexEV(sp, ep),
+ _nc_tracemouse(sp, ep));
}
#endif
@@ -193,7 +202,7 @@ _trace_slot(const char *tag)
# define M_FD(sp) sp->_mouse_fd
static void
-write_event(int down, int button, int x, int y)
+write_event(SCREEN *sp, int down, int button, int x, int y)
{
char buf[6];
unsigned long ignore;
@@ -202,12 +211,13 @@ write_event(int down, int button, int x, int y)
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;
- DosWrite(SP->_emxmouse_wfd, buf, 6, &ignore);
+ DosWrite(sp->_emxmouse_wfd, buf, 6, &ignore);
}
static void
-mouse_server(unsigned long ignored GCC_UNUSED)
+mouse_server(unsigned long param)
{
+ SCREEN *sp = (SCREEN *) param;
unsigned short fWait = MOU_WAIT;
/* NOPTRRECT mourt = { 0,0,24,79 }; */
MOUEVENTINFO mouev;
@@ -234,7 +244,7 @@ mouse_server(unsigned long ignored GCC_UNUSED)
sprintf(err, "Error reading mouse queue, rc=%lu.\r\n", rc);
break;
}
- if (!SP->_emxmouse_activated)
+ if (!sp->_emxmouse_activated)
goto finish;
/*
@@ -245,14 +255,14 @@ mouse_server(unsigned long ignored GCC_UNUSED)
* 3 = middle.
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
- write_event(mouev.fs & MOUSE_BN1_DOWN,
- SP->_emxmouse_buttons[1], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN1_DOWN,
+ sp->_emxmouse_buttons[1], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
- write_event(mouev.fs & MOUSE_BN2_DOWN,
- SP->_emxmouse_buttons[3], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN2_DOWN,
+ sp->_emxmouse_buttons[3], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
- write_event(mouev.fs & MOUSE_BN3_DOWN,
- SP->_emxmouse_buttons[2], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN3_DOWN,
+ sp->_emxmouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
@@ -271,134 +281,199 @@ mouse_server(unsigned long ignored GCC_UNUSED)
#if USE_SYSMOUSE
static void
-handle_sysmouse(int sig GCC_UNUSED)
+sysmouse_server(SCREEN *sp)
{
struct mouse_info the_mouse;
MEVENT *work;
the_mouse.operation = MOUSE_GETINFO;
- if (SP != 0
- && SP->_mouse_fd >= 0
- && SP->_sysmouse_tail < FIFO_SIZE
- && ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
-
- if (SP->_sysmouse_head > SP->_sysmouse_tail) {
- SP->_sysmouse_tail = 0;
- SP->_sysmouse_head = 0;
+ if (sp != 0
+ && sp->_mouse_fd >= 0
+ && sp->_sysmouse_tail < FIFO_SIZE
+ && ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
+
+ if (sp->_sysmouse_head > sp->_sysmouse_tail) {
+ sp->_sysmouse_tail = 0;
+ sp->_sysmouse_head = 0;
}
- work = &(SP->_sysmouse_fifo[SP->_sysmouse_tail]);
+ work = &(sp->_sysmouse_fifo[sp->_sysmouse_tail]);
memset(work, 0, sizeof(*work));
work->id = NORMAL_EVENT; /* there's only one mouse... */
- SP->_sysmouse_old_buttons = SP->_sysmouse_new_buttons;
- SP->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7;
+ sp->_sysmouse_old_buttons = sp->_sysmouse_new_buttons;
+ sp->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7;
- if (SP->_sysmouse_new_buttons) {
- if (SP->_sysmouse_new_buttons & 1)
+ if (sp->_sysmouse_new_buttons) {
+ if (sp->_sysmouse_new_buttons & 1)
work->bstate |= BUTTON1_PRESSED;
- if (SP->_sysmouse_new_buttons & 2)
+ if (sp->_sysmouse_new_buttons & 2)
work->bstate |= BUTTON2_PRESSED;
- if (SP->_sysmouse_new_buttons & 4)
+ if (sp->_sysmouse_new_buttons & 4)
work->bstate |= BUTTON3_PRESSED;
} else {
- if (SP->_sysmouse_old_buttons & 1)
+ if (sp->_sysmouse_old_buttons & 1)
work->bstate |= BUTTON1_RELEASED;
- if (SP->_sysmouse_old_buttons & 2)
+ if (sp->_sysmouse_old_buttons & 2)
work->bstate |= BUTTON2_RELEASED;
- if (SP->_sysmouse_old_buttons & 4)
+ if (sp->_sysmouse_old_buttons & 4)
work->bstate |= BUTTON3_RELEASED;
}
/* for cosmetic bug in syscons.c on FreeBSD 3.[34] */
the_mouse.operation = MOUSE_HIDE;
- ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
the_mouse.operation = MOUSE_SHOW;
- ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
/*
* We're only interested if the button is pressed or released.
* FIXME: implement continuous event-tracking.
*/
- if (SP->_sysmouse_new_buttons != SP->_sysmouse_old_buttons) {
- SP->_sysmouse_tail += 1;
+ if (sp->_sysmouse_new_buttons != sp->_sysmouse_old_buttons) {
+ sp->_sysmouse_tail += 1;
}
- work->x = the_mouse.u.data.x / SP->_sysmouse_char_width;
- work->y = the_mouse.u.data.y / SP->_sysmouse_char_height;
+ work->x = the_mouse.u.data.x / sp->_sysmouse_char_width;
+ work->y = the_mouse.u.data.y / sp->_sysmouse_char_height;
}
}
+
+static void
+handle_sysmouse(int sig GCC_UNUSED)
+{
+ sysmouse_server(SP);
+}
#endif /* USE_SYSMOUSE */
static void
-init_xterm_mouse(void)
+init_xterm_mouse(SCREEN *sp)
{
- SP->_mouse_type = M_XTERM;
- SP->_mouse_xtermcap = tigetstr("XM");
- if (!VALID_STRING(SP->_mouse_xtermcap))
- SP->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
+ sp->_mouse_type = M_XTERM;
+ sp->_mouse_xtermcap = tigetstr("XM");
+ if (!VALID_STRING(sp->_mouse_xtermcap))
+ sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
}
static void
-enable_xterm_mouse(int enable)
+enable_xterm_mouse(SCREEN *sp, int enable)
{
#if USE_EMX_MOUSE
- SP->_emxmouse_activated = enable;
+ sp->_emxmouse_activated = enable;
#else
- putp(TPARM_1(SP->_mouse_xtermcap, enable));
+ putp(TPARM_1(sp->_mouse_xtermcap, enable));
#endif
- SP->_mouse_active = enable;
+ sp->_mouse_active = enable;
}
#if USE_GPM_SUPPORT
-static int
+static bool
allow_gpm_mouse(void)
{
+ bool result = FALSE;
+
/* GPM does printf's without checking if stdout is a terminal */
if (isatty(fileno(stdout))) {
+ char *list = getenv("NCURSES_GPM_TERMS");
char *env = getenv("TERM");
- /* GPM checks the beginning of the $TERM variable to decide if
- * it should pass xterm events through. There is no real advantage
- * in allowing GPM to do this.
- */
- if (env == 0 || strncmp(env, "xterm", 5))
- return TRUE;
+ if (list != 0) {
+ if (env != 0) {
+ result = _nc_name_match(list, env, "|:");
+ }
+ } else {
+ /* GPM checks the beginning of the $TERM variable to decide if it
+ * should pass xterm events through. There is no real advantage in
+ * allowing GPM to do this. Recent versions relax that check, and
+ * pretend that GPM can work with any terminal having the kmous
+ * capability. Perhaps that works for someone. If so, they can
+ * set the environment variable (above).
+ */
+ if (env != 0 && strstr(env, "linux") != 0) {
+ result = TRUE;
+ }
+ }
+ }
+ return result;
+}
+
+#ifdef HAVE_LIBDL
+static void
+unload_gpm_library(SCREEN *sp)
+{
+ if (SP->_dlopen_gpm != 0) {
+ T(("unload GPM library"));
+ sp->_mouse_gpm_loaded = FALSE;
+ sp->_mouse_fd = -1;
+ dlclose(sp->_dlopen_gpm);
+ sp->_dlopen_gpm = 0;
}
- return FALSE;
}
+static void
+load_gpm_library(SCREEN *sp)
+{
+ sp->_mouse_gpm_found = FALSE;
+ if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+ if (GET_DLSYM(gpm_fd) == 0 ||
+ GET_DLSYM(Gpm_Open) == 0 ||
+ GET_DLSYM(Gpm_Close) == 0 ||
+ GET_DLSYM(Gpm_GetEvent) == 0) {
+ T(("GPM initialization failed: %s", dlerror()));
+ unload_gpm_library(sp);
+ } else {
+ sp->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_loaded = TRUE;
+ }
+ }
+}
+#endif
+
static bool
-enable_gpm_mouse(int enable)
+enable_gpm_mouse(SCREEN *sp, bool enable)
{
bool result;
T((T_CALLED("enable_gpm_mouse(%d)"), enable));
- if (enable && !SP->_mouse_active) {
- /* GPM: initialize connection to gpm server */
- SP->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP;
- SP->_mouse_gpm_connect.defaultMask =
- ~(SP->_mouse_gpm_connect.eventMask | GPM_HARD);
- SP->_mouse_gpm_connect.minMod = 0;
- SP->_mouse_gpm_connect.maxMod =
- (unsigned short) (~((1 << KG_SHIFT) |
- (1 << KG_SHIFTL) |
- (1 << KG_SHIFTR)));
- /*
- * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open.
- * The former is recognized by wscons (SunOS), and the latter by
- * xterm. Those will not show up in ncurses' traces.
- */
- result = (my_Gpm_Open(&SP->_mouse_gpm_connect, 0) >= 0);
- SP->_mouse_active = result;
+ if (enable && !sp->_mouse_active) {
+#ifdef HAVE_LIBDL
+ if (sp->_mouse_gpm_found && !sp->_mouse_gpm_loaded) {
+ load_gpm_library(sp);
+ }
+#endif
+ if (sp->_mouse_gpm_loaded) {
+ /* GPM: initialize connection to gpm server */
+ sp->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP;
+ sp->_mouse_gpm_connect.defaultMask =
+ (unsigned short) (~(sp->_mouse_gpm_connect.eventMask | GPM_HARD));
+ sp->_mouse_gpm_connect.minMod = 0;
+ sp->_mouse_gpm_connect.maxMod =
+ (unsigned short) (~((1 << KG_SHIFT) |
+ (1 << KG_SHIFTL) |
+ (1 << KG_SHIFTR)));
+ /*
+ * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open.
+ * The former is recognized by wscons (SunOS), and the latter by
+ * xterm. Those will not show up in ncurses' traces.
+ */
+ result = (my_Gpm_Open(&sp->_mouse_gpm_connect, 0) >= 0);
+ } else {
+ result = FALSE;
+ }
+ sp->_mouse_active = result;
T(("GPM open %s", result ? "succeeded" : "failed"));
} else {
- if (!enable && SP->_mouse_active) {
+ if (!enable && sp->_mouse_active) {
/* GPM: close connection to gpm server */
my_Gpm_Close();
- SP->_mouse_active = FALSE;
+ sp->_mouse_active = FALSE;
T(("GPM closed"));
}
- result = FALSE;
+ result = enable;
+ }
+#ifdef HAVE_LIBDL
+ if (!result) {
+ unload_gpm_library(sp);
}
+#endif
returnBool(result);
}
#endif /* USE_GPM_SUPPORT */
@@ -406,32 +481,20 @@ enable_gpm_mouse(int enable)
#define xterm_kmous "\033[M"
static void
-initialize_mousetype(void)
+initialize_mousetype(SCREEN *sp)
{
T((T_CALLED("initialize_mousetype()")));
/* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
if (allow_gpm_mouse()) {
- if (!SP->_mouse_gpm_loaded) {
+ if (!sp->_mouse_gpm_loaded) {
#ifdef HAVE_LIBDL
- void *obj;
-
- if ((obj = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
- if (GET_DLSYM(gpm_fd) == 0 ||
- GET_DLSYM(Gpm_Open) == 0 ||
- GET_DLSYM(Gpm_Close) == 0 ||
- GET_DLSYM(Gpm_GetEvent) == 0) {
- T(("GPM initialization failed: %s", dlerror()));
- dlclose(obj);
- } else {
- SP->_mouse_gpm_found = TRUE;
- }
- }
+ load_gpm_library(sp);
#else /* !HAVE_LIBDL */
- SP->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_loaded = TRUE;
#endif
- SP->_mouse_gpm_loaded = TRUE;
}
/*
@@ -439,10 +502,10 @@ initialize_mousetype(void)
* maintain our notion of whether the mouse connection is active
* without testing the file-descriptor.
*/
- if (SP->_mouse_gpm_found && enable_gpm_mouse(TRUE)) {
- SP->_mouse_type = M_GPM;
- SP->_mouse_fd = *(my_gpm_fd);
- T(("GPM mouse_fd %d", SP->_mouse_fd));
+ if (sp->_mouse_gpm_found && enable_gpm_mouse(sp, TRUE)) {
+ sp->_mouse_type = M_GPM;
+ sp->_mouse_fd = *(my_gpm_fd);
+ T(("GPM mouse_fd %d", sp->_mouse_fd));
returnVoid;
}
}
@@ -450,7 +513,7 @@ initialize_mousetype(void)
/* OS/2 VIO */
#if USE_EMX_MOUSE
- if (!SP->_emxmouse_thread
+ if (!sp->_emxmouse_thread
&& strstr(cur_term->type.term_names, "xterm") == 0
&& key_mouse) {
int handles[2];
@@ -461,32 +524,32 @@ initialize_mousetype(void)
} else {
int rc;
- if (!SP->_emxmouse_buttons[0]) {
+ if (!sp->_emxmouse_buttons[0]) {
char *s = getenv("MOUSE_BUTTONS_123");
- SP->_emxmouse_buttons[0] = 1;
+ sp->_emxmouse_buttons[0] = 1;
if (s && strlen(s) >= 3) {
- SP->_emxmouse_buttons[1] = s[0] - '0';
- SP->_emxmouse_buttons[2] = s[1] - '0';
- SP->_emxmouse_buttons[3] = s[2] - '0';
+ sp->_emxmouse_buttons[1] = s[0] - '0';
+ sp->_emxmouse_buttons[2] = s[1] - '0';
+ sp->_emxmouse_buttons[3] = s[2] - '0';
} else {
- SP->_emxmouse_buttons[1] = 1;
- SP->_emxmouse_buttons[2] = 3;
- SP->_emxmouse_buttons[3] = 2;
+ sp->_emxmouse_buttons[1] = 1;
+ sp->_emxmouse_buttons[2] = 3;
+ sp->_emxmouse_buttons[3] = 2;
}
}
- SP->_emxmouse_wfd = handles[1];
- M_FD(SP) = handles[0];
+ sp->_emxmouse_wfd = handles[1];
+ M_FD(sp) = handles[0];
/* Needed? */
setmode(handles[0], O_BINARY);
setmode(handles[1], O_BINARY);
/* Do not use CRT functions, we may single-threaded. */
- rc = DosCreateThread((unsigned long *) &SP->_emxmouse_thread,
- mouse_server, 0, 0, 8192);
+ rc = DosCreateThread((unsigned long *) &sp->_emxmouse_thread,
+ mouse_server, (long) sp, 0, 8192);
if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
} else {
- SP->_mouse_type = M_XTERM;
+ sp->_mouse_type = M_XTERM;
}
returnVoid;
}
@@ -498,14 +561,14 @@ initialize_mousetype(void)
struct mouse_info the_mouse;
char *the_device = 0;
- if (isatty(SP->_ifd))
- the_device = ttyname(SP->_ifd);
+ if (isatty(sp->_ifd))
+ the_device = ttyname(sp->_ifd);
if (the_device == 0)
the_device = "/dev/tty";
- SP->_mouse_fd = open(the_device, O_RDWR);
+ sp->_mouse_fd = open(the_device, O_RDWR);
- if (SP->_mouse_fd >= 0) {
+ if (sp->_mouse_fd >= 0) {
/*
* sysmouse does not have a usable user interface for obtaining
* mouse events. The logical way to proceed (reading data on a
@@ -522,10 +585,10 @@ initialize_mousetype(void)
the_mouse.operation = MOUSE_MODE;
the_mouse.u.mode.mode = 0;
the_mouse.u.mode.signal = SIGUSR2;
- if (ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
+ if (ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
signal(SIGUSR2, handle_sysmouse);
the_mouse.operation = MOUSE_SHOW;
- ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
#if defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) /* FreeBSD > 2.x */
{
@@ -535,23 +598,23 @@ initialize_mousetype(void)
#endif /* FBIO_GETMODE */
video_info_t the_video;
- if (ioctl(SP->_mouse_fd,
+ if (ioctl(sp->_mouse_fd,
FBIO_GETMODE,
&the_video.vi_mode) != -1
- && ioctl(SP->_mouse_fd,
+ && ioctl(sp->_mouse_fd,
FBIO_MODEINFO,
&the_video) != -1) {
- SP->_sysmouse_char_width = the_video.vi_cwidth;
- SP->_sysmouse_char_height = the_video.vi_cheight;
+ sp->_sysmouse_char_width = the_video.vi_cwidth;
+ sp->_sysmouse_char_height = the_video.vi_cheight;
}
}
#endif /* defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) */
- if (SP->_sysmouse_char_width <= 0)
- SP->_sysmouse_char_width = 8;
- if (SP->_sysmouse_char_height <= 0)
- SP->_sysmouse_char_height = 16;
- SP->_mouse_type = M_SYSMOUSE;
+ if (sp->_sysmouse_char_width <= 0)
+ sp->_sysmouse_char_width = 8;
+ if (sp->_sysmouse_char_height <= 0)
+ sp->_sysmouse_char_height = 16;
+ sp->_mouse_type = M_SYSMOUSE;
returnVoid;
}
}
@@ -562,37 +625,37 @@ initialize_mousetype(void)
if (key_mouse != 0) {
if (!strcmp(key_mouse, xterm_kmous)
|| strstr(cur_term->type.term_names, "xterm") != 0) {
- init_xterm_mouse();
+ init_xterm_mouse(sp);
}
} else if (strstr(cur_term->type.term_names, "xterm") != 0) {
- if (_nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE) == OK)
- init_xterm_mouse();
+ if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
+ init_xterm_mouse(sp);
}
returnVoid;
}
static bool
-_nc_mouse_init(void)
+_nc_mouse_init(SCREEN *sp)
/* initialize the mouse */
{
bool result = FALSE;
int i;
- if (SP != 0) {
- if (!SP->_mouse_initialized) {
- SP->_mouse_initialized = TRUE;
+ if (sp != 0) {
+ if (!sp->_mouse_initialized) {
+ sp->_mouse_initialized = TRUE;
TR(MY_TRACE, ("_nc_mouse_init() called"));
- SP->_mouse_eventp = SP->_mouse_events;
+ sp->_mouse_eventp = FirstEV(sp);
for (i = 0; i < EV_MAX; i++)
- SP->_mouse_events[i].id = INVALID_EVENT;
+ sp->_mouse_events[i].id = INVALID_EVENT;
- initialize_mousetype();
+ initialize_mousetype(sp);
- T(("_nc_mouse_init() set mousetype to %d", SP->_mouse_type));
+ T(("_nc_mouse_init() set mousetype to %d", sp->_mouse_type));
}
- result = SP->_mouse_initialized;
+ result = sp->_mouse_initialized;
}
return result;
}
@@ -604,12 +667,12 @@ _nc_mouse_init(void)
static bool
_nc_mouse_event(SCREEN *sp GCC_UNUSED)
{
- MEVENT *eventp = SP->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_eventp;
bool result = FALSE;
(void) eventp;
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
/* xterm: never have to query, mouse events are in the keyboard stream */
#if USE_EMX_MOUSE
@@ -666,7 +729,7 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED)
eventp->z = 0;
/* bump the next-free pointer into the circular list */
- SP->_mouse_eventp = eventp = NEXT(eventp);
+ sp->_mouse_eventp = eventp = NEXT(eventp);
result = TRUE;
}
}
@@ -675,22 +738,22 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED)
#if USE_SYSMOUSE
case M_SYSMOUSE:
- if (SP->_sysmouse_head < SP->_sysmouse_tail) {
- *eventp = SP->_sysmouse_fifo[SP->_sysmouse_head];
+ if (sp->_sysmouse_head < sp->_sysmouse_tail) {
+ *eventp = sp->_sysmouse_fifo[sp->_sysmouse_head];
/*
* Point the fifo-head to the next possible location. If there
* are none, reset the indices. This may be interrupted by the
* signal handler, doing essentially the same reset.
*/
- SP->_sysmouse_head += 1;
- if (SP->_sysmouse_head == SP->_sysmouse_tail) {
- SP->_sysmouse_tail = 0;
- SP->_sysmouse_head = 0;
+ sp->_sysmouse_head += 1;
+ if (sp->_sysmouse_head == sp->_sysmouse_tail) {
+ sp->_sysmouse_tail = 0;
+ sp->_sysmouse_head = 0;
}
/* bump the next-free pointer into the circular list */
- SP->_mouse_eventp = eventp = NEXT(eventp);
+ sp->_mouse_eventp = eventp = NEXT(eventp);
result = TRUE;
}
break;
@@ -709,11 +772,11 @@ _nc_mouse_inline(SCREEN *sp)
{
int b;
bool result = FALSE;
- MEVENT *eventp = SP->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_eventp;
TR(MY_TRACE, ("_nc_mouse_inline() called"));
- if (SP->_mouse_type == M_XTERM) {
+ if (sp->_mouse_type == M_XTERM) {
unsigned char kbuf[4];
mmask_t prev;
size_t grabbed;
@@ -751,7 +814,7 @@ _nc_mouse_inline(SCREEN *sp)
* Wheel mice may return buttons 4 and 5 when the wheel is turned.
* We encode those as button presses.
*/
- for (grabbed = 0; grabbed < 3; grabbed += res) {
+ for (grabbed = 0; grabbed < 3; grabbed += (size_t) res) {
/* For VIO mouse we add extra bit 64 to disambiguate button-up. */
#if USE_EMX_MOUSE
@@ -781,9 +844,9 @@ _nc_mouse_inline(SCREEN *sp)
eventp->bstate = MASK_RELEASE(n)
#else
#define PRESS_POSITION(n) \
- eventp->bstate = (prev & MASK_PRESS(n) \
- ? REPORT_MOUSE_POSITION \
- : MASK_PRESS(n))
+ eventp->bstate = (mmask_t) (prev & MASK_PRESS(n) \
+ ? REPORT_MOUSE_POSITION \
+ : MASK_PRESS(n))
#endif
switch (kbuf[0] & 0x3) {
@@ -847,11 +910,11 @@ _nc_mouse_inline(SCREEN *sp)
eventp->y = (kbuf[2] - ' ') - 1;
TR(MY_TRACE,
("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
- _tracemouse(eventp),
- (long) (eventp - SP->_mouse_events)));
+ _nc_tracemouse(sp, eventp),
+ (long) IndexEV(sp, eventp)));
/* bump the next-free pointer into the circular list */
- SP->_mouse_eventp = NEXT(eventp);
+ sp->_mouse_eventp = NEXT(eventp);
#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
return (TRUE);
#endif
@@ -861,36 +924,36 @@ _nc_mouse_inline(SCREEN *sp)
}
static void
-mouse_activate(bool on)
+mouse_activate(SCREEN *sp, bool on)
{
- if (!on && !SP->_mouse_initialized)
+ if (!on && !sp->_mouse_initialized)
return;
- if (!_nc_mouse_init())
+ if (!_nc_mouse_init(sp))
return;
if (on) {
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
#if NCURSES_EXT_FUNCS
keyok(KEY_MOUSE, on);
#endif
TPUTS_TRACE("xterm mouse initialization");
- enable_xterm_mouse(1);
+ enable_xterm_mouse(sp, 1);
break;
#if USE_GPM_SUPPORT
case M_GPM:
- if (enable_gpm_mouse(1)) {
- SP->_mouse_fd = *(my_gpm_fd);
- T(("GPM mouse_fd %d", SP->_mouse_fd));
+ if (enable_gpm_mouse(sp, TRUE)) {
+ sp->_mouse_fd = *(my_gpm_fd);
+ T(("GPM mouse_fd %d", sp->_mouse_fd));
}
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
signal(SIGUSR2, handle_sysmouse);
- SP->_mouse_active = TRUE;
+ sp->_mouse_active = TRUE;
break;
#endif
case M_NONE:
@@ -899,27 +962,27 @@ mouse_activate(bool on)
/* Make runtime binding to cut down on object size of applications that
* do not use the mouse (e.g., 'clear').
*/
- SP->_mouse_event = _nc_mouse_event;
- SP->_mouse_inline = _nc_mouse_inline;
- SP->_mouse_parse = _nc_mouse_parse;
- SP->_mouse_resume = _nc_mouse_resume;
- SP->_mouse_wrap = _nc_mouse_wrap;
+ sp->_mouse_event = _nc_mouse_event;
+ sp->_mouse_inline = _nc_mouse_inline;
+ sp->_mouse_parse = _nc_mouse_parse;
+ sp->_mouse_resume = _nc_mouse_resume;
+ sp->_mouse_wrap = _nc_mouse_wrap;
} else {
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
TPUTS_TRACE("xterm mouse deinitialization");
- enable_xterm_mouse(0);
+ enable_xterm_mouse(sp, 0);
break;
#if USE_GPM_SUPPORT
case M_GPM:
- enable_gpm_mouse(0);
+ enable_gpm_mouse(sp, FALSE);
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
signal(SIGUSR2, SIG_IGN);
- SP->_mouse_active = FALSE;
+ sp->_mouse_active = FALSE;
break;
#endif
case M_NONE:
@@ -936,10 +999,10 @@ mouse_activate(bool on)
**************************************************************************/
static bool
-_nc_mouse_parse(int runcount)
+_nc_mouse_parse(SCREEN *sp, int runcount)
/* parse a run of atomic mouse events into a gesture */
{
- MEVENT *eventp = SP->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_eventp;
MEVENT *ep, *runp, *next, *prev = PREV(eventp);
int n;
int b;
@@ -971,10 +1034,10 @@ _nc_mouse_parse(int runcount)
if (runcount == 1) {
TR(MY_TRACE,
("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
- _tracemouse(prev),
- (long) (prev - SP->_mouse_events)));
+ _nc_tracemouse(sp, prev),
+ (long) IndexEV(sp, prev)));
return (prev->id >= NORMAL_EVENT)
- ? ((prev->bstate & SP->_mouse_mask) ? TRUE : FALSE)
+ ? ((prev->bstate & sp->_mouse_mask) ? TRUE : FALSE)
: FALSE;
}
@@ -986,10 +1049,9 @@ _nc_mouse_parse(int runcount)
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
- _trace_slot("before mouse press/release merge:");
+ _trace_slot(sp, "before mouse press/release merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - SP->_mouse_events),
- (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
+ RunParams(sp, eventp, runp),
runcount);
_nc_unlock_global(tracef);
}
@@ -1014,7 +1076,7 @@ _nc_mouse_parse(int runcount)
#endif
) {
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((SP->_mouse_mask & MASK_CLICK(b))
+ if ((sp->_mouse_mask & MASK_CLICK(b))
&& (ep->bstate & MASK_PRESS(b))) {
ep->bstate &= ~MASK_PRESS(b);
ep->bstate |= MASK_CLICK(b);
@@ -1030,10 +1092,9 @@ _nc_mouse_parse(int runcount)
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
- _trace_slot("before mouse click merge:");
+ _trace_slot(sp, "before mouse click merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - SP->_mouse_events),
- (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
+ RunParams(sp, eventp, runp),
runcount);
_nc_unlock_global(tracef);
}
@@ -1071,7 +1132,7 @@ _nc_mouse_parse(int runcount)
if ((ep->bstate & BUTTON_CLICKED)
&& (follower->bstate & BUTTON_CLICKED)) {
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((SP->_mouse_mask & MASK_DOUBLE_CLICK(b))
+ if ((sp->_mouse_mask & MASK_DOUBLE_CLICK(b))
&& (follower->bstate & MASK_CLICK(b))) {
follower->bstate &= ~MASK_CLICK(b);
follower->bstate |= MASK_DOUBLE_CLICK(b);
@@ -1086,7 +1147,7 @@ _nc_mouse_parse(int runcount)
if ((ep->bstate & BUTTON_DOUBLE_CLICKED)
&& (follower->bstate & BUTTON_CLICKED)) {
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((SP->_mouse_mask & MASK_TRIPLE_CLICK(b))
+ if ((sp->_mouse_mask & MASK_TRIPLE_CLICK(b))
&& (follower->bstate & MASK_CLICK(b))) {
follower->bstate &= ~MASK_CLICK(b);
follower->bstate |= MASK_TRIPLE_CLICK(b);
@@ -1102,10 +1163,9 @@ _nc_mouse_parse(int runcount)
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
- _trace_slot("before mouse event queue compaction:");
+ _trace_slot(sp, "before mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - SP->_mouse_events),
- (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
+ RunParams(sp, eventp, runp),
runcount);
_nc_unlock_global(tracef);
}
@@ -1116,15 +1176,14 @@ _nc_mouse_parse(int runcount)
* don't match the current event mask.
*/
for (; runcount; prev = PREV(eventp), runcount--)
- if (prev->id == INVALID_EVENT || !(prev->bstate & SP->_mouse_mask)) {
- SP->_mouse_eventp = eventp = prev;
+ if (prev->id == INVALID_EVENT || !(prev->bstate & sp->_mouse_mask)) {
+ sp->_mouse_eventp = eventp = prev;
}
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
- _trace_slot("after mouse event queue compaction:");
+ _trace_slot(sp, "after mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - SP->_mouse_events),
- (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
+ RunParams(sp, eventp, runp),
runcount);
_nc_unlock_global(tracef);
}
@@ -1132,8 +1191,8 @@ _nc_mouse_parse(int runcount)
if (ep->id != INVALID_EVENT)
TR(MY_TRACE,
("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
- _tracemouse(ep),
- (long) (ep - SP->_mouse_events)));
+ _nc_tracemouse(sp, ep),
+ (long) IndexEV(sp, ep)));
#endif /* TRACE */
/* after all this, do we have a valid event? */
@@ -1141,26 +1200,26 @@ _nc_mouse_parse(int runcount)
}
static void
-_nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
+_nc_mouse_wrap(SCREEN *sp)
/* release mouse -- called by endwin() before shellout/exit */
{
TR(MY_TRACE, ("_nc_mouse_wrap() called"));
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
- if (SP->_mouse_mask)
- mouse_activate(FALSE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, FALSE);
break;
#if USE_GPM_SUPPORT
/* GPM: pass all mouse events to next client */
case M_GPM:
- if (SP->_mouse_mask)
- mouse_activate(FALSE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, FALSE);
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
- mouse_activate(FALSE);
+ mouse_activate(sp, FALSE);
break;
#endif
case M_NONE:
@@ -1169,29 +1228,29 @@ _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
}
static void
-_nc_mouse_resume(SCREEN *sp GCC_UNUSED)
+_nc_mouse_resume(SCREEN *sp)
/* re-connect to mouse -- called by doupdate() after shellout */
{
TR(MY_TRACE, ("_nc_mouse_resume() called"));
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
/* xterm: re-enable reporting */
- if (SP->_mouse_mask)
- mouse_activate(TRUE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, TRUE);
break;
#if USE_GPM_SUPPORT
case M_GPM:
/* GPM: reclaim our event set */
- if (SP->_mouse_mask)
- mouse_activate(TRUE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, TRUE);
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
- mouse_activate(TRUE);
+ mouse_activate(sp, TRUE);
break;
#endif
case M_NONE:
@@ -1205,14 +1264,13 @@ _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
*
**************************************************************************/
-NCURSES_EXPORT(int)
-getmouse(MEVENT * aevent)
-/* grab a copy of the current mouse event */
+static int
+_nc_getmouse(SCREEN *sp, MEVENT * aevent)
{
T((T_CALLED("getmouse(%p)"), aevent));
- if ((aevent != 0) && (SP != 0) && (SP->_mouse_type != M_NONE)) {
- MEVENT *eventp = SP->_mouse_eventp;
+ if ((aevent != 0) && (sp != 0) && (sp->_mouse_type != M_NONE)) {
+ MEVENT *eventp = sp->_mouse_eventp;
/* compute the current-event pointer */
MEVENT *prev = PREV(eventp);
@@ -1220,8 +1278,8 @@ getmouse(MEVENT * aevent)
*aevent = *prev;
TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
- _tracemouse(prev),
- (long) (prev - SP->_mouse_events)));
+ _nc_tracemouse(sp, prev),
+ (long) IndexEV(sp, prev)));
prev->id = INVALID_EVENT; /* so the queue slot becomes free */
returnCode(OK);
@@ -1229,29 +1287,42 @@ getmouse(MEVENT * aevent)
returnCode(ERR);
}
+/* grab a copy of the current mouse event */
NCURSES_EXPORT(int)
-ungetmouse(MEVENT * aevent)
-/* enqueue a synthesized mouse event to be seen by the next wgetch() */
+getmouse(MEVENT * aevent)
+{
+ return _nc_getmouse(SP, aevent);
+}
+
+static int
+_nc_ungetmouse(SCREEN *sp, MEVENT * aevent)
{
int result = ERR;
T((T_CALLED("ungetmouse(%p)"), aevent));
- if (aevent != 0 && SP != 0) {
- MEVENT *eventp = SP->_mouse_eventp;
+ if (aevent != 0 && sp != 0) {
+ MEVENT *eventp = sp->_mouse_eventp;
/* stick the given event in the next-free slot */
*eventp = *aevent;
/* bump the next-free pointer into the circular list */
- SP->_mouse_eventp = NEXT(eventp);
+ sp->_mouse_eventp = NEXT(eventp);
/* push back the notification event on the keyboard queue */
- result = ungetch(KEY_MOUSE);
+ result = _nc_ungetch(sp, KEY_MOUSE);
}
returnCode(result);
}
+/* enqueue a synthesized mouse event to be seen by the next wgetch() */
+NCURSES_EXPORT(int)
+ungetmouse(MEVENT * aevent)
+{
+ return _nc_ungetmouse(SP, aevent);
+}
+
NCURSES_EXPORT(mmask_t)
mousemask(mmask_t newmask, mmask_t * oldmask)
/* set the mouse event mask */
@@ -1265,7 +1336,7 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
*oldmask = SP->_mouse_mask;
if (newmask || SP->_mouse_initialized) {
- _nc_mouse_init();
+ _nc_mouse_init(SP);
if (SP->_mouse_type != M_NONE) {
result = newmask &
(REPORT_MOUSE_POSITION
@@ -1278,14 +1349,11 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
| BUTTON_DOUBLE_CLICKED
| BUTTON_TRIPLE_CLICKED);
- mouse_activate((bool) (result != 0));
+ mouse_activate(SP, (bool) (result != 0));
SP->_mouse_mask = result;
}
}
- } else {
- if (oldmask)
- *oldmask = SP->_mouse_mask;
}
returnBits(result);
}
diff --git a/ncurses/base/lib_newterm.c b/ncurses/base/lib_newterm.c
index 3620a3fdbf2b..05982b84cee4 100644
--- a/ncurses/base/lib_newterm.c
+++ b/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.69 2008/04/12 18:15:04 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.73 2008/08/16 21:20:48 Werner.Fink Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@@ -125,11 +125,17 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
int errret;
SCREEN *current;
SCREEN *result = 0;
+ TERMINAL *its_term;
START_TRACE();
T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
- _nc_lock_global(set_SP);
+ _nc_init_pthreads();
+ _nc_lock_global(curses);
+
+ current = SP;
+ its_term = (SP ? SP->_term : 0);
+
/* this loads the capability entry, then sets LINES and COLS */
if (setupterm(name, fileno(ofp), &errret) != ERR) {
int slk_format = _nc_globals.slk_format;
@@ -138,7 +144,6 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
* This actually allocates the screen structure, and saves the original
* terminal settings.
*/
- current = SP;
_nc_set_screen(0);
/* allow user to set maximum escape delay from the environment */
@@ -154,6 +159,19 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
_nc_set_screen(current);
result = 0;
} else {
+ assert(SP != 0);
+ /*
+ * 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.
+ *
+ * Restore the terminal-pointer for the pre-existing screen, if
+ * any.
+ */
+ if (current)
+ current->_term = its_term;
+
/* if the terminal type has real soft labels, set those up */
if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
_nc_slk_initialize(stdscr, COLS);
@@ -212,6 +230,6 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
result = SP;
}
}
- _nc_unlock_global(set_SP);
+ _nc_unlock_global(curses);
returnSP(result);
}
diff --git a/ncurses/base/lib_newwin.c b/ncurses/base/lib_newwin.c
index 7f7aa3e04f1e..587e83a92009 100644
--- a/ncurses/base/lib_newwin.c
+++ b/ncurses/base/lib_newwin.c
@@ -42,7 +42,7 @@
#include <curses.priv.h>
#include <stddef.h>
-MODULE_ID("$Id: lib_newwin.c,v 1.50 2008/05/03 16:36:39 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.52 2008/06/07 13:58:09 tom Exp $")
#define window_is(name) ((sp)->_##name == win)
@@ -85,7 +85,7 @@ _nc_freewin(WINDOW *win)
T((T_CALLED("_nc_freewin(%p)"), win));
if (win != 0) {
- if (_nc_try_global(windowlist) == 0) {
+ if (_nc_try_global(curses) == 0) {
q = 0;
for (each_window(p)) {
if (&(p->win) == win) {
@@ -108,7 +108,7 @@ _nc_freewin(WINDOW *win)
}
q = p;
}
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
}
returnCode(result);
@@ -229,8 +229,6 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
returnWin(0);
- _nc_mutex_init(&(wp->mutex_use_window));
-
win = &(wp->win);
if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) {
@@ -238,7 +236,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
returnWin(0);
}
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
win->_curx = 0;
win->_cury = 0;
@@ -313,10 +311,28 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
}
wp->next = _nc_windows;
+ wp->screen = SP;
_nc_windows = wp;
T((T_CREATE("window %p"), win));
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
returnWin(win);
}
+
+/*
+ * 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
+ * SCREEN's, e.g., for multi-threaded applications.
+ */
+NCURSES_EXPORT(SCREEN *)
+_nc_screen_of(WINDOW *win)
+{
+ SCREEN *sp = 0;
+
+ if (win != 0) {
+ WINDOWLIST *wp = (WINDOWLIST *) win;
+ sp = wp->screen;
+ }
+ return (sp);
+}
diff --git a/ncurses/base/lib_overlay.c b/ncurses/base/lib_overlay.c
index 26314de5e5fb..669e8e72c07f 100644
--- a/ncurses/base/lib_overlay.c
+++ b/ncurses/base/lib_overlay.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 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_overlay.c,v 1.25 2008/04/12 17:21:59 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.27 2008/06/07 23:30:34 tom Exp $")
static int
overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
@@ -55,8 +55,7 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
T((T_CALLED("overlap(%p,%p,%d)"), src, dst, flag));
if (src != 0 && dst != 0) {
- _nc_lock_window(src);
- _nc_lock_window(dst);
+ _nc_lock_global(curses);
T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld",
(long) src->_begy,
@@ -93,8 +92,7 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
dmaxrow, dmaxcol,
flag);
}
- _nc_unlock_window(dst);
- _nc_unlock_window(src);
+ _nc_unlock_global(curses);
}
returnCode(rc);
}
@@ -150,9 +148,7 @@ copywin(const WINDOW *src, WINDOW *dst,
src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over));
if (src && dst) {
-
- _nc_lock_window(src);
- _nc_lock_window(dst);
+ _nc_lock_global(curses);
bk = AttrOf(dst->_nc_bkgd);
mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0);
@@ -204,8 +200,7 @@ copywin(const WINDOW *src, WINDOW *dst,
rc = OK;
}
}
- _nc_unlock_window(dst);
- _nc_unlock_window(src);
+ _nc_unlock_global(curses);
}
returnCode(rc);
}
diff --git a/ncurses/base/lib_restart.c b/ncurses/base/lib_restart.c
index 9742ff629fbd..da770d4e7c92 100644
--- a/ncurses/base/lib_restart.c
+++ b/ncurses/base/lib_restart.c
@@ -36,8 +36,6 @@
* Terminfo-only terminal setup routines:
*
* int restartterm(const char *, int, int *)
- * TERMINAL *set_curterm(TERMINAL *)
- * int del_curterm(TERMINAL *)
*/
#include <curses.priv.h>
@@ -48,7 +46,7 @@
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_restart.c,v 1.9 2008/05/03 22:43:52 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.10 2008/06/21 17:31:22 tom Exp $")
NCURSES_EXPORT(int)
restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c
index e6aecbdaab47..4aa58ea2a19c 100644
--- a/ncurses/base/lib_screen.c
+++ b/ncurses/base/lib_screen.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 *
@@ -29,12 +29,14 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996 on *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_screen.c,v 1.30 2007/03/10 23:20:41 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.31 2008/08/16 19:05:37 tom Exp $")
+
+#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */
NCURSES_EXPORT(WINDOW *)
getwin(FILE *filep)
@@ -46,7 +48,11 @@ getwin(FILE *filep)
clearerr(filep);
(void) fread(&tmp, sizeof(WINDOW), 1, filep);
- if (ferror(filep))
+ if (ferror(filep)
+ || tmp._maxy == 0
+ || tmp._maxy > MAX_SIZE
+ || tmp._maxx == 0
+ || tmp._maxx > MAX_SIZE)
returnWin(0);
if (tmp._flags & _ISPAD) {
@@ -115,7 +121,7 @@ putwin(WINDOW *win, FILE *filep)
T((T_CALLED("putwin(%p,%p)"), win, filep));
if (win != 0) {
- size_t len = (win->_maxx + 1);
+ size_t len = (size_t) (win->_maxx + 1);
clearerr(filep);
if (fwrite(win, sizeof(WINDOW), 1, filep) != 1
diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c
index eee1cfc7b259..aff432bb9fd1 100644
--- a/ncurses/base/lib_set_term.c
+++ b/ncurses/base/lib_set_term.c
@@ -44,28 +44,30 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_set_term.c,v 1.108 2008/05/03 22:42:43 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.117 2008/08/04 18:11:12 tom Exp $")
NCURSES_EXPORT(SCREEN *)
set_term(SCREEN *screenp)
{
SCREEN *oldSP;
+ SCREEN *newSP;
T((T_CALLED("set_term(%p)"), screenp));
- _nc_lock_global(set_SP);
+ _nc_lock_global(curses);
oldSP = SP;
_nc_set_screen(screenp);
+ newSP = SP;
- if (SP != 0) {
- set_curterm(SP->_term);
+ if (newSP != 0) {
+ set_curterm(newSP->_term);
#if !USE_REENTRANT
- curscr = SP->_curscr;
- newscr = SP->_newscr;
- stdscr = SP->_stdscr;
- COLORS = SP->_color_count;
- COLOR_PAIRS = SP->_pair_count;
+ curscr = newSP->_curscr;
+ newscr = newSP->_newscr;
+ stdscr = newSP->_stdscr;
+ COLORS = newSP->_color_count;
+ COLOR_PAIRS = newSP->_pair_count;
#endif
} else {
set_curterm(0);
@@ -78,7 +80,7 @@ set_term(SCREEN *screenp)
#endif
}
- _nc_unlock_global(set_SP);
+ _nc_unlock_global(curses);
T((T_RETURN("%p"), oldSP));
return (oldSP);
@@ -125,7 +127,7 @@ delscreen(SCREEN *sp)
T((T_CALLED("delscreen(%p)"), sp));
- _nc_lock_global(set_SP);
+ _nc_lock_global(curses);
if (delink_screen(sp)) {
(void) _nc_freewin(sp->_curscr);
@@ -162,8 +164,6 @@ delscreen(SCREEN *sp)
FreeIfNeeded(sp->_acs_map);
FreeIfNeeded(sp->_screen_acs_map);
- 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
@@ -176,6 +176,7 @@ delscreen(SCREEN *sp)
free(sp->_setbuf);
}
+ del_curterm(sp->_term);
free(sp);
/*
@@ -194,7 +195,7 @@ delscreen(SCREEN *sp)
_nc_set_screen(0);
}
}
- _nc_unlock_global(set_SP);
+ _nc_unlock_global(curses);
returnVoid;
}
@@ -212,7 +213,7 @@ no_mouse_inline(SCREEN *sp GCC_UNUSED)
}
static bool
-no_mouse_parse(int code GCC_UNUSED)
+no_mouse_parse(SCREEN *sp GCC_UNUSED, int code GCC_UNUSED)
{
return TRUE;
}
@@ -321,11 +322,7 @@ _nc_setupscreen(int slines GCC_UNUSED,
SP->_ofp = output;
SP->_cursor = -1; /* cannot know real cursor shape */
-#if NCURSES_NO_PADDING
- SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
- TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
- SP->_no_padding ? " not" : ""));
-#endif
+ SetNoPadding(SP);
#if NCURSES_EXT_FUNCS
SP->_default_color = FALSE;
@@ -362,11 +359,10 @@ _nc_setupscreen(int slines GCC_UNUSED,
* Allow those assumed/default color assumptions to be overridden at
* runtime:
*/
- if (getenv("NCURSES_ASSUMED_COLORS") != 0) {
- char *p = getenv("NCURSES_ASSUMED_COLORS");
+ if ((env = getenv("NCURSES_ASSUMED_COLORS")) != 0) {
int fg, bg;
char sep1, sep2;
- int count = sscanf(p, "%d%c%d%c", &fg, &sep1, &bg, &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;
if (count >= 3) {
@@ -422,11 +418,6 @@ _nc_setupscreen(int slines GCC_UNUSED,
SP->_mouse_wrap = no_mouse_wrap;
SP->_mouse_fd = -1;
- /* initialize the panel hooks */
- SP->_panelHook.top_panel = (struct panel *) 0;
- SP->_panelHook.bottom_panel = (struct panel *) 0;
- SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0;
-
/*
* If we've no magic cookie support, we suppress attributes that xmc would
* affect, i.e., the attributes that affect the rendition of a space.
@@ -515,7 +506,7 @@ _nc_setupscreen(int slines GCC_UNUSED,
/* initialize normal acs before wide, since we use mapping in the latter */
#if !USE_WIDEC_SUPPORT
- if (_nc_unicode_locale() && _nc_locale_breaks_acs()) {
+ if (_nc_unicode_locale() && _nc_locale_breaks_acs(cur_term)) {
acs_chars = NULL;
ena_acs = NULL;
enter_alt_charset_mode = NULL;
@@ -527,7 +518,8 @@ _nc_setupscreen(int slines GCC_UNUSED,
#if USE_WIDEC_SUPPORT
_nc_init_wacs();
- SP->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs());
+ SP->_screen_acs_fix = (_nc_unicode_locale()
+ && _nc_locale_breaks_acs(cur_term));
#endif
env = _nc_get_locale();
SP->_legacy_coding = ((env == 0)
diff --git a/ncurses/base/lib_slk.c b/ncurses/base/lib_slk.c
index 27b21b08d718..662f7e45b116 100644
--- a/ncurses/base/lib_slk.c
+++ b/ncurses/base/lib_slk.c
@@ -45,32 +45,7 @@
#include <ctype.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$Id: lib_slk.c,v 1.31 2008/01/12 20:21:00 tom Exp $")
-
-/*
- * We'd like to move these into the screen context structure, but cannot,
- * because slk_init() is called before initscr()/newterm().
- */
-NCURSES_EXPORT_VAR(int)
-_nc_slk_format = 0; /* one more than format specified in slk_init() */
-
-/*
- * Paint the info line for the PC style SLK emulation.
- */
-static void
-slk_paint_info(WINDOW *win)
-{
- if (win && SP->slk_format == 4) {
- int i;
-
- mvwhline(win, 0, 0, 0, getmaxx(win));
- wmove(win, 0, 0);
-
- for (i = 0; i < SP->_slk->maxlab; i++) {
- mvwprintw(win, 0, SP->_slk->ent[i].ent_x, "F%d", i + 1);
- }
- }
-}
+MODULE_ID("$Id: lib_slk.c,v 1.35 2008/09/27 14:07:33 juergen Exp $")
/*
* Free any memory related to soft labels, return an error.
@@ -145,7 +120,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
memset(SP->_slk->ent[i].form_text, 0, used);
memset(SP->_slk->ent[i].form_text, ' ', max_length);
- SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
+ SP->_slk->ent[i].visible = (char) (i < SP->_slk->maxlab);
}
if (_nc_globals.slk_format >= 3) { /* PC style */
int gap = (cols - 3 * (3 + 4 * max_length)) / 2;
@@ -158,7 +133,6 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
x += max_length;
x += (i == 3 || i == 7) ? gap : 1;
}
- slk_paint_info(stwin);
} else {
if (_nc_globals.slk_format == 2) { /* 4-4 */
int gap = cols - (SP->_slk->maxlab * max_length) - 6;
@@ -212,8 +186,6 @@ slk_restore(void)
return (ERR);
SP->_slk->hidden = FALSE;
SP->_slk->dirty = TRUE;
- /* we have to repaint info line eventually */
- slk_paint_info(SP->_slk->win);
returnCode(slk_refresh());
}
diff --git a/ncurses/base/lib_slkrefr.c b/ncurses/base/lib_slkrefr.c
index c8ca28b9dd84..cb1beba0e2a1 100644
--- a/ncurses/base/lib_slkrefr.c
+++ b/ncurses/base/lib_slkrefr.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 *
@@ -40,7 +40,27 @@
#include <curses.priv.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$Id: lib_slkrefr.c,v 1.15 2006/11/25 22:32:15 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.17 2008/09/27 14:07:53 juergen Exp $")
+
+/*
+ * Paint the info line for the PC style SLK emulation.
+ */
+static void
+slk_paint_info(WINDOW *win)
+{
+ SCREEN *sp = _nc_screen_of(win);
+
+ if (win && sp && (sp->slk_format == 4)) {
+ int i;
+
+ mvwhline(win, 0, 0, 0, getmaxx(win));
+ wmove(win, 0, 0);
+
+ for (i = 0; i < sp->_slk->maxlab; i++) {
+ mvwprintw(win, 0, sp->_slk->ent[i].ent_x, "F%d", i + 1);
+ }
+ }
+}
/*
* Write the soft labels to the soft-key window.
@@ -60,8 +80,10 @@ slk_intern_refresh(SLK * slk)
putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text));
}
} else {
+ if (fmt == 4)
+ slk_paint_info(slk->win);
wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
- if (SP && SP->_slk) {
+ if (SP->_slk) {
wattrset(slk->win, AttrOf(SP->_slk->attr));
}
waddstr(slk->win, slk->ent[i].form_text);
diff --git a/ncurses/base/lib_ungetch.c b/ncurses/base/lib_ungetch.c
index 2eda99017bed..8742f867fa94 100644
--- a/ncurses/base/lib_ungetch.c
+++ b/ncurses/base/lib_ungetch.c
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_ungetch.c,v 1.10 2008/05/03 20:20:58 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.11 2008/05/31 16:44:54 tom Exp $")
#include <fifo_defs.h>
@@ -52,7 +52,7 @@ _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, _nc_tracechar(sp, sp->_fifo[i])));
}
#endif /* TRACE */
@@ -70,7 +70,7 @@ _nc_ungetch(SCREEN *sp, int ch)
h_dec();
sp->_fifo[head] = ch;
- T(("ungetch %s ok", _tracechar(ch)));
+ T(("ungetch %s ok", _nc_tracechar(sp, ch)));
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
_nc_fifo_dump(sp);
@@ -85,6 +85,6 @@ _nc_ungetch(SCREEN *sp, int ch)
NCURSES_EXPORT(int)
ungetch(int ch)
{
- T((T_CALLED("ungetch(%s)"), _tracechar(ch)));
+ T((T_CALLED("ungetch(%s)"), _nc_tracechar(SP, ch)));
returnCode(_nc_ungetch(SP, ch));
}
diff --git a/ncurses/base/lib_window.c b/ncurses/base/lib_window.c
index ac61cb01da99..a3236e206a37 100644
--- a/ncurses/base/lib_window.c
+++ b/ncurses/base/lib_window.c
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_window.c,v 1.24 2008/04/12 22:40:21 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.25 2008/06/07 14:12:56 tom Exp $")
NCURSES_EXPORT(void)
_nc_synchook(WINDOW *win)
@@ -186,7 +186,7 @@ dupwin(WINDOW *win)
if (win != 0) {
- _nc_lock_window(win);
+ _nc_lock_global(curses);
if (win->_flags & _ISPAD) {
nwin = newpad(win->_maxy + 1,
win->_maxx + 1);
@@ -244,7 +244,7 @@ dupwin(WINDOW *win)
nwin->_line[i].lastchar = win->_line[i].lastchar;
}
}
- _nc_unlock_window(win);
+ _nc_unlock_global(curses);
}
returnWin(nwin);
}
diff --git a/ncurses/base/resizeterm.c b/ncurses/base/resizeterm.c
index cf2c998e239f..a94cfc3aaaa8 100644
--- a/ncurses/base/resizeterm.c
+++ b/ncurses/base/resizeterm.c
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: resizeterm.c,v 1.32 2008/05/03 14:28:55 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.34 2008/06/07 13:58:40 tom Exp $")
#define stolen_lines (screen_lines - SP->_lines_avail)
@@ -66,7 +66,7 @@ show_window_sizes(const char *name)
{
WINDOWLIST *wp;
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
_tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
screen_lines, screen_columns);
for (each_window(wp)) {
@@ -77,7 +77,7 @@ show_window_sizes(const char *name)
(long) wp->win._begy,
(long) wp->win._begx);
}
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
#endif
@@ -320,7 +320,7 @@ resize_term(int ToLines, int ToCols)
returnCode(ERR);
}
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
was_stolen = (screen_lines - SP->_lines_avail);
if (is_term_resized(ToLines, ToCols)) {
@@ -378,7 +378,7 @@ resize_term(int ToLines, int ToCols)
SET_LINES(ToLines - was_stolen);
SET_COLS(ToCols);
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
returnCode(result);
}
@@ -418,7 +418,7 @@ resizeterm(int ToLines, int ToCols)
result = resize_term(ToLines, ToCols);
#if USE_SIGWINCH
- ungetch(KEY_RESIZE); /* so application can know this */
+ _nc_ungetch(SP, KEY_RESIZE); /* so application can know this */
clearok(curscr, TRUE); /* screen contents are unknown */
/* ripped-off lines are a special case: if we did not lengthen
diff --git a/ncurses/base/tries.c b/ncurses/base/tries.c
index 983a75ae7882..c4263c7e50eb 100644
--- a/ncurses/base/tries.c
+++ b/ncurses/base/tries.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: tries.c,v 1.25 2007/09/29 20:37:13 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.27 2008/08/16 19:22:55 tom Exp $")
/*
* Expand a keycode into the string that it corresponds to, returning null if
@@ -68,11 +68,11 @@ _nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len)
}
}
if (result != 0) {
- if (ptr != 0 && (result[len] = ptr->ch) == 0)
+ if (ptr != 0 && (result[len] = (char) ptr->ch) == 0)
*((unsigned char *) (result + len)) = 128;
#ifdef TRACE
if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) {
- _tracef("expand_key %s %s", _tracechar(code), _nc_visbuf(result));
+ _tracef("expand_key %s %s", _nc_tracechar(SP, code), _nc_visbuf(result));
_nc_unlock_global(tracef);
}
#endif
diff --git a/ncurses/base/use_window.c b/ncurses/base/use_window.c
index 4d0fdf6705be..f6408c37928e 100644
--- a/ncurses/base/use_window.c
+++ b/ncurses/base/use_window.c
@@ -32,37 +32,7 @@
#include <curses.priv.h>
-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(const WINDOW *win)
-{
- WINDOWLIST *p;
-
- _nc_lock_global(windowlist);
- for (each_window(p)) {
- if (&(p->win) == win) {
- _nc_mutex_lock(&(p->mutex_use_window));
- break;
- }
- }
-}
-
-NCURSES_EXPORT(void)
-_nc_unlock_window(const WINDOW *win)
-{
- WINDOWLIST *p;
-
- for (each_window(p)) {
- if (&(p->win) == win) {
- _nc_mutex_unlock(&(p->mutex_use_window));
- break;
- }
- }
- _nc_unlock_global(windowlist);
-}
-#endif
+MODULE_ID("$Id: use_window.c,v 1.8 2008/06/07 14:13:46 tom Exp $")
NCURSES_EXPORT(int)
use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data)
@@ -70,9 +40,9 @@ use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data)
int code = OK;
T((T_CALLED("use_window(%p,%p,%p)"), win, func, data));
- _nc_lock_window(win);
+ _nc_lock_global(curses);
code = func(win, data);
- _nc_unlock_window(win);
+ _nc_unlock_global(curses);
returnCode(code);
}
diff --git a/ncurses/base/wresize.c b/ncurses/base/wresize.c
index ac808c4d2884..f46085af59fa 100644
--- a/ncurses/base/wresize.c
+++ b/ncurses/base/wresize.c
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: wresize.c,v 1.28 2008/05/03 14:13:51 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.29 2008/06/07 13:59:01 tom Exp $")
static int
cleanup_lines(struct ldat *data, int length)
@@ -54,7 +54,7 @@ repair_subwindows(WINDOW *cmp)
struct ldat *pline = cmp->_line;
int row;
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
for (each_window(wp)) {
WINDOW *tst = &(wp->win);
@@ -77,7 +77,7 @@ repair_subwindows(WINDOW *cmp)
repair_subwindows(tst);
}
}
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
/*