]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.6 - patch 20080531
authorThomas E. Dickey <dickey@invisible-island.net>
Sat, 31 May 2008 23:49:39 +0000 (23:49 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sat, 31 May 2008 23:49:39 +0000 (23:49 +0000)
+ modify wgetch() to use the screen which corresponds to its window
  parameter rather than relying on SP; some dependent functions still
  use SP internally.
+ factor out most use of SP in lib_mouse.c, using parameter.
+ add internal _nc_keyname(), replacing keyname() to associate with a
  particular SCREEN rather than the global SP.
+ add internal _nc_unctrl(), replacing unctrl() to associate with a
  particular SCREEN rather than the global SP.
+ add internal _nc_tracemouse(), replacing _tracemouse() to eliminate
  its associated global buffer _nc_globals.tracemse_buf now in SCREEN.
+ add internal _nc_tracechar(), replacing _tracechar() to use SCREEN in
  preference to the global _nc_globals.tracechr_buf buffer.

18 files changed:
NEWS
dist.mk
ncurses/base/MKkeyname.awk
ncurses/base/MKunctrl.awk
ncurses/base/lib_getch.c
ncurses/base/lib_getstr.c
ncurses/base/lib_mouse.c
ncurses/base/lib_newwin.c
ncurses/base/lib_set_term.c
ncurses/base/lib_slk.c
ncurses/base/lib_ungetch.c
ncurses/base/resizeterm.c
ncurses/base/tries.c
ncurses/curses.priv.h
ncurses/tinfo/lib_data.c
ncurses/trace/lib_traceatr.c
ncurses/trace/lib_tracechr.c
ncurses/trace/lib_tracemse.c

diff --git a/NEWS b/NEWS
index f14402b69ef804a40dfe2fdff592b9de0e6c0cd1..06f7b566fdce47aa4639446c0a5710b0e92f7074 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.1237 2008/05/24 22:23:07 tom Exp $
+-- $Id: NEWS,v 1.1241 2008/05/31 21:52:48 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,20 @@ See the AUTHORS file for the corresponding full names.
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20080531
+       + modify wgetch() to use the screen which corresponds to its window
+         parameter rather than relying on SP; some dependent functions still
+         use SP internally.
+       + factor out most use of SP in lib_mouse.c, using parameter.
+       + add internal _nc_keyname(), replacing keyname() to associate with a
+         particular SCREEN rather than the global SP.
+       + add internal _nc_unctrl(), replacing unctrl() to associate with a
+         particular SCREEN rather than the global SP.
+       + add internal _nc_tracemouse(), replacing _tracemouse() to eliminate
+         its associated global buffer _nc_globals.tracemse_buf now in SCREEN.
+       + add internal _nc_tracechar(), replacing _tracechar() to use SCREEN in
+         preference to the global _nc_globals.tracechr_buf buffer.
+
 20080524
        + modify _nc_keypad() to make it switch temporarily as needed to the
          screen which must be updated.
 20080524
        + modify _nc_keypad() to make it switch temporarily as needed to the
          screen which must be updated.
diff --git a/dist.mk b/dist.mk
index fc57d6af0f42775312fab2fb99619f49da8a0d20..a78cde3d0febac78abf928257b1c7f2f61dd64db 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.643 2008/05/24 12:05:32 tom Exp $
+# $Id: dist.mk,v 1.644 2008/05/31 14:47:34 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -37,7 +37,7 @@ SHELL = /bin/sh
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 6
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 6
-NCURSES_PATCH = 20080524
+NCURSES_PATCH = 20080531
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index c1d9475045d04ca2ebf15f9b3ae1648d954814ec..5711fb85dd442515e5c64d3412be44f84db4b024 100644 (file)
@@ -1,6 +1,6 @@
-# $Id: MKkeyname.awk,v 1.38 2007/08/18 18:41:18 tom Exp $
+# $Id: MKkeyname.awk,v 1.39 2008/05/31 19:54:58 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"), #
 #                                                                            #
 # 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 "#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];"
        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 (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;"
        print "                                         strcpy(p, \"M-\");"
        print "                                         p += 2;"
        print "                                         cc -= 128;"
@@ -141,6 +141,11 @@ END {
        print " return result;"
        print "}"
        print ""
        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 "{"
        print "#if NO_LEAKS"
        print "void _nc_keyname_leaks(void)"
        print "{"
index 1ba511d72323bf2ffcffe39293c2f8cde1ca99c5..4bebf3cf4cc75481ffac3095b9a2b871df13a81a 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: MKunctrl.awk,v 1.21 2008/02/03 20:24:30 tom Exp $
+# $Id: MKunctrl.awk,v 1.22 2008/05/31 19:36:11 tom Exp $
 ##############################################################################
 # Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.                #
 #                                                                            #
 ##############################################################################
 # Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.                #
 #                                                                            #
@@ -46,7 +46,7 @@ BEGIN {
                print ""
        }
 END    {
                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=""
                print "{"
 
                blob=""
@@ -150,8 +150,8 @@ END {
                print  ""
                print  "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
                print  "#if NCURSES_EXT_FUNCS"
                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;
                print  "\t\t && (check >= 128)"
                print  "\t\t && (check < 160))"
                printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
@@ -159,18 +159,18 @@ END       {
                print  "#if USE_WIDEC_SUPPORT"
                print  "\t\tif ((check >= 160)"
                print  "\t\t && (check < 256)"
                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       && (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"
                print  "\t\t       && isprint(check)))))"
                printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
                print  "\t\telse"
@@ -182,4 +182,9 @@ END {
                print  "\t}"
                print  "\treturn (NCURSES_CONST char *)result;"
                print  "}"
                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  "}"
        }
        }
index d9f6b1795c77d83b7579db9a01026b06b40f858f..f77df69e77255f09ee64a1ee27e1890bd90c70f6 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
 
 #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.91 2008/05/31 21:47:48 tom Exp $")
 
 #include <fifo_defs.h>
 
 
 #include <fifo_defs.h>
 
@@ -123,7 +123,7 @@ fifo_pull(SCREEN *sp)
 {
     int ch;
     ch = sp->_fifo[head];
 {
     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();
 
     if (peek == head) {
        h_inc();
@@ -228,7 +228,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
     if (head == -1)
        head = peek = tail;
     t_inc();
     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);
 #ifdef TRACE
     if (USE_TRACEF(TRACE_IEVENT)) {
        _nc_fifo_dump(sp);
@@ -248,9 +248,14 @@ fifo_clear(SCREEN *sp)
 
 static int kgetch(SCREEN *EVENTLIST_2nd(_nc_eventlist * evl));
 
 
 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
+refresh_if_needed(WINDOW *win)
+{
+    if ((is_wintouched(win) || (win->_flags & _HASMOVED))
+       && !(win->_flags & _ISPAD)) {
+       wrefresh(win);
+    }
+}
 
 NCURSES_EXPORT(int)
 _nc_wgetch(WINDOW *win,
 
 NCURSES_EXPORT(int)
 _nc_wgetch(WINDOW *win,
@@ -258,7 +263,7 @@ _nc_wgetch(WINDOW *win,
           int use_meta
           EVENTLIST_2nd(_nc_eventlist * evl))
 {
           int use_meta
           EVENTLIST_2nd(_nc_eventlist * evl))
 {
-    SCREEN *sp = SP;
+    SCREEN *sp = _nc_screen_of(win);
     int ch;
 #ifdef NCURSES_WGETCH_EVENTS
     long event_delay = -1;
     int ch;
 #ifdef NCURSES_WGETCH_EVENTS
     long event_delay = -1;
@@ -272,9 +277,7 @@ _nc_wgetch(WINDOW *win,
     }
 
     if (cooked_key_in_fifo()) {
     }
 
     if (cooked_key_in_fifo()) {
-       if (wgetch_should_refresh(win))
-           wrefresh(win);
-
+       refresh_if_needed(win);
        *result = fifo_pull(sp);
        returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
     }
        *result = fifo_pull(sp);
        returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
     }
@@ -324,8 +327,7 @@ _nc_wgetch(WINDOW *win,
     if (win->_use_keypad != sp->_keypad_on)
        _nc_keypad(sp, win->_use_keypad);
 
     if (win->_use_keypad != sp->_keypad_on)
        _nc_keypad(sp, win->_use_keypad);
 
-    if (wgetch_should_refresh(win))
-       wrefresh(win);
+    refresh_if_needed(win);
 
     if (!win->_notimeout && (win->_delay >= 0 || sp->_cbreak > 1)) {
        if (head == -1) {       /* fifo is empty */
 
     if (!win->_notimeout && (win->_delay >= 0 || sp->_cbreak > 1)) {
        if (head == -1) {       /* fifo is empty */
@@ -388,7 +390,7 @@ _nc_wgetch(WINDOW *win,
             && (((rc = check_mouse_activity(sp, sp->_maxclick
                                             EVENTLIST_2nd(evl))) != 0
                  && !(rc & 4))
             && (((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);
 #ifdef NCURSES_WGETCH_EVENTS
        if ((rc & 4) && !ch == KEY_EVENT) {
            _nc_ungetch(sp, ch);
@@ -467,7 +469,7 @@ _nc_wgetch(WINDOW *win,
        if ((ch < KEY_MIN) && (ch & 0x80))
            ch &= 0x7f;
 
        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);
 
     *result = ch;
     returnCode(ch >= KEY_MIN ? KEY_CODE_YES : OK);
@@ -477,7 +479,7 @@ _nc_wgetch(WINDOW *win,
 NCURSES_EXPORT(int)
 wgetch_events(WINDOW *win, _nc_eventlist * evl)
 {
 NCURSES_EXPORT(int)
 wgetch_events(WINDOW *win, _nc_eventlist * evl)
 {
-    SCREEN *sp = SP;
+    SCREEN *sp = _nc_screen_of(win);
     int code;
     unsigned long value;
 
     int code;
     unsigned long value;
 
@@ -495,7 +497,7 @@ wgetch_events(WINDOW *win, _nc_eventlist * evl)
 NCURSES_EXPORT(int)
 wgetch(WINDOW *win)
 {
 NCURSES_EXPORT(int)
 wgetch(WINDOW *win)
 {
-    SCREEN *sp = SP;
+    SCREEN *sp = _nc_screen_of(win);
     int code;
     unsigned long value;
 
     int code;
     unsigned long value;
 
@@ -564,7 +566,7 @@ kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
            return ch;
        }
 
            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;
 
        while ((ptr != NULL) && (ptr->ch != (unsigned char) ch))
            ptr = ptr->sibling;
 
index 274e878873715ab4c483255a9a530b1633179cfd..8ce18b34f1faef3a0f57458751b1f48f9123c4c5 100644 (file)
@@ -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            *
  *                                                                          *
  * 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>
 
 #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.26 2008/05/31 22:05:15 tom Exp $")
 
 /*
  * This wipes out the last character, no matter whether it was a tab, control
 
 /*
  * 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))
 {
                int maxlen,
                EVENTLIST_1st(_nc_eventlist * evl))
 {
+    SCREEN *sp = _nc_screen_of(win);
     TTY buf;
     bool oldnl, oldecho, oldraw, oldcbreak;
     char erasec;
     TTY buf;
     bool oldnl, oldecho, oldraw, oldcbreak;
     char erasec;
@@ -90,10 +91,10 @@ wgetnstr_events(WINDOW *win,
 
     _nc_get_tty_mode(&buf);
 
 
     _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();
     nl();
     noecho();
     noraw();
@@ -187,10 +188,10 @@ wgetnstr_events(WINDOW *win,
     /* Restore with a single I/O call, to fix minor asymmetry between
      * raw/noraw, etc.
      */
     /* 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);
 
 
     _nc_set_tty_mode(&buf);
 
index aace7deb4c7fc7a334d15a169cc6a5198bdf2195..0151eb39873928f324e594ed0f1049bd6a048f29 100644 (file)
@@ -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            *
  *                                                                          *
  * 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>
 
 
 #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.94 2008/05/31 20:30:10 tom Exp $")
 
 #include <term.h>
 #include <tic.h>
 
 #include <term.h>
 #include <tic.h>
@@ -154,34 +154,34 @@ make an error
 
 #endif                         /* USE_GPM_SUPPORT */
 
 
 #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 */
 
 #undef  NEXT
 static void _nc_mouse_resume(SCREEN *);
 static void _nc_mouse_wrap(SCREEN *);
 
 /* maintain a circular list of mouse events */
 
 #undef  NEXT
-#define NEXT(ep)       ((ep == SP->_mouse_events + EV_MAX - 1) \
-                        ? SP->_mouse_events \
+#define NEXT(ep)       ((ep == sp->_mouse_events + EV_MAX - 1) \
+                        ? sp->_mouse_events \
                         : ep + 1)
 
 #undef  PREV
                         : ep + 1)
 
 #undef  PREV
-#define PREV(ep)       ((ep == SP->_mouse_events) \
-                        ? SP->_mouse_events + EV_MAX - 1 \
+#define PREV(ep)       ((ep == sp->_mouse_events) \
+                        ? sp->_mouse_events + EV_MAX - 1 \
                         : ep - 1)
 
 #ifdef TRACE
 static void
                         : ep - 1)
 
 #ifdef TRACE
 static void
-_trace_slot(const char *tag)
+_trace_slot(SCREEN *sp, const char *tag)
 {
     MEVENT *ep;
 
     _tracef(tag);
 
 {
     MEVENT *ep;
 
     _tracef(tag);
 
-    for (ep = SP->_mouse_events; ep < SP->_mouse_events + EV_MAX; ep++)
+    for (ep = sp->_mouse_events; ep < sp->_mouse_events + EV_MAX; ep++)
        _tracef("mouse event queue slot %ld = %s",
        _tracef("mouse event queue slot %ld = %s",
-               (long) (ep - SP->_mouse_events),
-               _tracemouse(ep));
+               (long) (ep - sp->_mouse_events),
+               _nc_tracemouse(sp, ep));
 }
 #endif
 
 }
 #endif
 
@@ -193,7 +193,7 @@ _trace_slot(const char *tag)
 #  define M_FD(sp) sp->_mouse_fd
 
 static void
 #  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;
 {
     char buf[6];
     unsigned long ignore;
@@ -202,12 +202,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;
     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
 }
 
 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;
     unsigned short fWait = MOU_WAIT;
     /* NOPTRRECT mourt = { 0,0,24,79 }; */
     MOUEVENTINFO mouev;
@@ -234,7 +235,7 @@ mouse_server(unsigned long ignored GCC_UNUSED)
                    sprintf(err, "Error reading mouse queue, rc=%lu.\r\n", rc);
                    break;
                }
                    sprintf(err, "Error reading mouse queue, rc=%lu.\r\n", rc);
                    break;
                }
-               if (!SP->_emxmouse_activated)
+               if (!sp->_emxmouse_activated)
                    goto finish;
 
                /*
                    goto finish;
 
                /*
@@ -246,13 +247,13 @@ mouse_server(unsigned long ignored GCC_UNUSED)
                 */
                if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
                    write_event(mouev.fs & MOUSE_BN1_DOWN,
                 */
                if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
                    write_event(mouev.fs & MOUSE_BN1_DOWN,
-                               SP->_emxmouse_buttons[1], mouev.col, mouev.row);
+                               sp->_emxmouse_buttons[1], mouev.col, mouev.row);
                if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
                    write_event(mouev.fs & MOUSE_BN2_DOWN,
                if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
                    write_event(mouev.fs & MOUSE_BN2_DOWN,
-                               SP->_emxmouse_buttons[3], mouev.col, mouev.row);
+                               sp->_emxmouse_buttons[3], mouev.col, mouev.row);
                if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
                    write_event(mouev.fs & MOUSE_BN3_DOWN,
                if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
                    write_event(mouev.fs & MOUSE_BN3_DOWN,
-                               SP->_emxmouse_buttons[2], mouev.col, mouev.row);
+                               sp->_emxmouse_buttons[2], mouev.col, mouev.row);
 
              finish:
                oldstate = mouev.fs;
 
              finish:
                oldstate = mouev.fs;
@@ -271,81 +272,87 @@ mouse_server(unsigned long ignored GCC_UNUSED)
 
 #if USE_SYSMOUSE
 static void
 
 #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;
 {
     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... */
 
        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;
                work->bstate |= BUTTON1_PRESSED;
-           if (SP->_sysmouse_new_buttons & 2)
+           if (sp->_sysmouse_new_buttons & 2)
                work->bstate |= BUTTON2_PRESSED;
                work->bstate |= BUTTON2_PRESSED;
-           if (SP->_sysmouse_new_buttons & 4)
+           if (sp->_sysmouse_new_buttons & 4)
                work->bstate |= BUTTON3_PRESSED;
        } else {
                work->bstate |= BUTTON3_PRESSED;
        } else {
-           if (SP->_sysmouse_old_buttons & 1)
+           if (sp->_sysmouse_old_buttons & 1)
                work->bstate |= BUTTON1_RELEASED;
                work->bstate |= BUTTON1_RELEASED;
-           if (SP->_sysmouse_old_buttons & 2)
+           if (sp->_sysmouse_old_buttons & 2)
                work->bstate |= BUTTON2_RELEASED;
                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;
                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;
        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.
         */
 
        /*
         * 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
 #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
 }
 
 static void
-enable_xterm_mouse(int enable)
+enable_xterm_mouse(SCREEN *sp, int enable)
 {
 #if USE_EMX_MOUSE
 {
 #if USE_EMX_MOUSE
-    SP->_emxmouse_activated = enable;
+    sp->_emxmouse_activated = enable;
 #else
 #else
-    putp(TPARM_1(SP->_mouse_xtermcap, enable));
+    putp(TPARM_1(sp->_mouse_xtermcap, enable));
 #endif
 #endif
-    SP->_mouse_active = enable;
+    sp->_mouse_active = enable;
 }
 
 #if USE_GPM_SUPPORT
 }
 
 #if USE_GPM_SUPPORT
@@ -366,19 +373,19 @@ allow_gpm_mouse(void)
 }
 
 static bool
 }
 
 static bool
-enable_gpm_mouse(int enable)
+enable_gpm_mouse(SCREEN *sp, int enable)
 {
     bool result;
 
     T((T_CALLED("enable_gpm_mouse(%d)"), enable));
 
 {
     bool result;
 
     T((T_CALLED("enable_gpm_mouse(%d)"), enable));
 
-    if (enable && !SP->_mouse_active) {
+    if (enable && !sp->_mouse_active) {
        /* GPM: initialize connection to gpm server */
        /* 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 =
+       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)));
            (unsigned short) (~((1 << KG_SHIFT) |
                                (1 << KG_SHIFTL) |
                                (1 << KG_SHIFTR)));
@@ -387,14 +394,14 @@ enable_gpm_mouse(int enable)
         * The former is recognized by wscons (SunOS), and the latter by
         * xterm.  Those will not show up in ncurses' traces.
         */
         * 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;
+       result = (my_Gpm_Open(&sp->_mouse_gpm_connect, 0) >= 0);
+       sp->_mouse_active = result;
        T(("GPM open %s", result ? "succeeded" : "failed"));
     } else {
        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();
            /* GPM: close connection to gpm server */
            my_Gpm_Close();
-           SP->_mouse_active = FALSE;
+           sp->_mouse_active = FALSE;
            T(("GPM closed"));
        }
        result = FALSE;
            T(("GPM closed"));
        }
        result = FALSE;
@@ -406,14 +413,14 @@ enable_gpm_mouse(int enable)
 #define xterm_kmous "\033[M"
 
 static void
 #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()) {
 {
     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;
 
 #ifdef HAVE_LIBDL
            void *obj;
 
@@ -425,13 +432,13 @@ initialize_mousetype(void)
                    T(("GPM initialization failed: %s", dlerror()));
                    dlclose(obj);
                } else {
                    T(("GPM initialization failed: %s", dlerror()));
                    dlclose(obj);
                } else {
-                   SP->_mouse_gpm_found = TRUE;
+                   sp->_mouse_gpm_found = TRUE;
                }
            }
 #else /* !HAVE_LIBDL */
                }
            }
 #else /* !HAVE_LIBDL */
-           SP->_mouse_gpm_found = TRUE;
+           sp->_mouse_gpm_found = TRUE;
 #endif
 #endif
-           SP->_mouse_gpm_loaded = TRUE;
+           sp->_mouse_gpm_loaded = TRUE;
        }
 
        /*
        }
 
        /*
@@ -439,10 +446,10 @@ initialize_mousetype(void)
         * maintain our notion of whether the mouse connection is active
         * without testing the file-descriptor.
         */
         * 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;
        }
     }
            returnVoid;
        }
     }
@@ -450,7 +457,7 @@ initialize_mousetype(void)
 
     /* OS/2 VIO */
 #if USE_EMX_MOUSE
 
     /* 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];
        && strstr(cur_term->type.term_names, "xterm") == 0
        && key_mouse) {
        int handles[2];
@@ -461,32 +468,32 @@ initialize_mousetype(void)
        } else {
            int rc;
 
        } else {
            int rc;
 
-           if (!SP->_emxmouse_buttons[0]) {
+           if (!sp->_emxmouse_buttons[0]) {
                char *s = getenv("MOUSE_BUTTONS_123");
 
                char *s = getenv("MOUSE_BUTTONS_123");
 
-               SP->_emxmouse_buttons[0] = 1;
+               sp->_emxmouse_buttons[0] = 1;
                if (s && strlen(s) >= 3) {
                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 {
                } 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. */
            /* 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, sp, 0, 8192);
            if (rc) {
                printf("mouse thread error %d=%#x", rc, rc);
            } else {
            if (rc) {
                printf("mouse thread error %d=%#x", rc, rc);
            } else {
-               SP->_mouse_type = M_XTERM;
+               sp->_mouse_type = M_XTERM;
            }
            returnVoid;
        }
            }
            returnVoid;
        }
@@ -498,14 +505,14 @@ initialize_mousetype(void)
        struct mouse_info the_mouse;
        char *the_device = 0;
 
        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";
 
        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
            /*
             * sysmouse does not have a usable user interface for obtaining
             * mouse events.  The logical way to proceed (reading data on a
@@ -522,10 +529,10 @@ initialize_mousetype(void)
            the_mouse.operation = MOUSE_MODE;
            the_mouse.u.mode.mode = 0;
            the_mouse.u.mode.signal = SIGUSR2;
            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;
                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 */
                {
 
 #if defined(FBIO_MODEINFO) || defined(CONS_MODEINFO)   /* FreeBSD > 2.x */
                {
@@ -535,23 +542,23 @@ initialize_mousetype(void)
 #endif /* FBIO_GETMODE */
                    video_info_t the_video;
 
 #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
                              FBIO_GETMODE,
                              &the_video.vi_mode) != -1
-                       && ioctl(SP->_mouse_fd,
+                       && ioctl(sp->_mouse_fd,
                                 FBIO_MODEINFO,
                                 &the_video) != -1) {
                                 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) */
 
                    }
                }
 #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;
            }
        }
                returnVoid;
            }
        }
@@ -562,37 +569,37 @@ initialize_mousetype(void)
     if (key_mouse != 0) {
        if (!strcmp(key_mouse, xterm_kmous)
            || strstr(cur_term->type.term_names, "xterm") != 0) {
     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) {
        }
     } 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
     }
     returnVoid;
 }
 
 static bool
-_nc_mouse_init(void)
+_nc_mouse_init(SCREEN *sp)
 /* initialize the mouse */
 {
     bool result = FALSE;
     int i;
 
 /* 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"));
 
 
            TR(MY_TRACE, ("_nc_mouse_init() called"));
 
-           SP->_mouse_eventp = SP->_mouse_events;
+           sp->_mouse_eventp = sp->_mouse_events;
            for (i = 0; i < EV_MAX; i++)
            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;
 }
     }
     return result;
 }
@@ -604,12 +611,12 @@ _nc_mouse_init(void)
 static bool
 _nc_mouse_event(SCREEN *sp GCC_UNUSED)
 {
 static bool
 _nc_mouse_event(SCREEN *sp GCC_UNUSED)
 {
-    MEVENT *eventp = SP->_mouse_eventp;
+    MEVENT *eventp = sp->_mouse_eventp;
     bool result = FALSE;
 
     (void) 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
     case M_XTERM:
        /* xterm: never have to query, mouse events are in the keyboard stream */
 #if USE_EMX_MOUSE
@@ -666,7 +673,7 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED)
                eventp->z = 0;
 
                /* bump the next-free pointer into the circular list */
                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;
            }
        }
                result = TRUE;
            }
        }
@@ -675,22 +682,22 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED)
 
 #if USE_SYSMOUSE
     case M_SYSMOUSE:
 
 #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.
             */
 
            /*
             * 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 */
            }
 
            /* bump the next-free pointer into the circular list */
-           SP->_mouse_eventp = eventp = NEXT(eventp);
+           sp->_mouse_eventp = eventp = NEXT(eventp);
            result = TRUE;
        }
        break;
            result = TRUE;
        }
        break;
@@ -709,11 +716,11 @@ _nc_mouse_inline(SCREEN *sp)
 {
     int b;
     bool result = FALSE;
 {
     int b;
     bool result = FALSE;
-    MEVENT *eventp = SP->_mouse_eventp;
+    MEVENT *eventp = sp->_mouse_eventp;
 
     TR(MY_TRACE, ("_nc_mouse_inline() called"));
 
 
     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;
        unsigned char kbuf[4];
        mmask_t prev;
        size_t grabbed;
@@ -847,11 +854,11 @@ _nc_mouse_inline(SCREEN *sp)
        eventp->y = (kbuf[2] - ' ') - 1;
        TR(MY_TRACE,
           ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
        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) (eventp - sp->_mouse_events)));
 
        /* bump the next-free pointer into the circular list */
 
        /* 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
 #if 0                          /* this return would be needed for QNX's mods to lib_getch.c */
        return (TRUE);
 #endif
@@ -861,36 +868,36 @@ _nc_mouse_inline(SCREEN *sp)
 }
 
 static void
 }
 
 static void
-mouse_activate(bool on)
+mouse_activate(SCREEN *sp, bool on)
 {
 {
-    if (!on && !SP->_mouse_initialized)
+    if (!on && !sp->_mouse_initialized)
        return;
 
        return;
 
-    if (!_nc_mouse_init())
+    if (!_nc_mouse_init(sp))
        return;
 
     if (on) {
 
        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");
        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:
            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, 1)) {
+               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);
            }
            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:
            break;
 #endif
        case M_NONE:
@@ -899,27 +906,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').
         */
        /* 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 {
 
     } else {
 
-       switch (SP->_mouse_type) {
+       switch (sp->_mouse_type) {
        case M_XTERM:
            TPUTS_TRACE("xterm mouse deinitialization");
        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:
            break;
 #if USE_GPM_SUPPORT
        case M_GPM:
-           enable_gpm_mouse(0);
+           enable_gpm_mouse(sp, 0);
            break;
 #endif
 #if USE_SYSMOUSE
        case M_SYSMOUSE:
            signal(SIGUSR2, SIG_IGN);
            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:
            break;
 #endif
        case M_NONE:
@@ -936,10 +943,10 @@ mouse_activate(bool on)
  **************************************************************************/
 
 static bool
  **************************************************************************/
 
 static bool
-_nc_mouse_parse(int runcount)
+_nc_mouse_parse(SCREEN *sp, int runcount)
 /* parse a run of atomic mouse events into a gesture */
 {
 /* 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;
     MEVENT *ep, *runp, *next, *prev = PREV(eventp);
     int n;
     int b;
@@ -971,10 +978,10 @@ _nc_mouse_parse(int runcount)
     if (runcount == 1) {
        TR(MY_TRACE,
           ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
     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) (prev - sp->_mouse_events)));
        return (prev->id >= NORMAL_EVENT)
        return (prev->id >= NORMAL_EVENT)
-           ? ((prev->bstate & SP->_mouse_mask) ? TRUE : FALSE)
+           ? ((prev->bstate & sp->_mouse_mask) ? TRUE : FALSE)
            : FALSE;
     }
 
            : FALSE;
     }
 
@@ -986,10 +993,10 @@ _nc_mouse_parse(int runcount)
 
 #ifdef TRACE
     if (USE_TRACEF(TRACE_IEVENT)) {
 
 #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",
        _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,
+               (long) (runp - sp->_mouse_events),
+               (long) ((eventp - sp->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
                runcount);
        _nc_unlock_global(tracef);
     }
                runcount);
        _nc_unlock_global(tracef);
     }
@@ -1014,7 +1021,7 @@ _nc_mouse_parse(int runcount)
 #endif
                ) {
                for (b = 1; b <= MAX_BUTTONS; ++b) {
 #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);
                        && (ep->bstate & MASK_PRESS(b))) {
                        ep->bstate &= ~MASK_PRESS(b);
                        ep->bstate |= MASK_CLICK(b);
@@ -1030,10 +1037,10 @@ _nc_mouse_parse(int runcount)
 
 #ifdef TRACE
     if (USE_TRACEF(TRACE_IEVENT)) {
 
 #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",
        _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,
+               (long) (runp - sp->_mouse_events),
+               (long) ((eventp - sp->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
                runcount);
        _nc_unlock_global(tracef);
     }
                runcount);
        _nc_unlock_global(tracef);
     }
@@ -1071,7 +1078,7 @@ _nc_mouse_parse(int runcount)
                if ((ep->bstate & BUTTON_CLICKED)
                    && (follower->bstate & BUTTON_CLICKED)) {
                    for (b = 1; b <= MAX_BUTTONS; ++b) {
                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);
                            && (follower->bstate & MASK_CLICK(b))) {
                            follower->bstate &= ~MASK_CLICK(b);
                            follower->bstate |= MASK_DOUBLE_CLICK(b);
@@ -1086,7 +1093,7 @@ _nc_mouse_parse(int runcount)
                if ((ep->bstate & BUTTON_DOUBLE_CLICKED)
                    && (follower->bstate & BUTTON_CLICKED)) {
                    for (b = 1; b <= MAX_BUTTONS; ++b) {
                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);
                            && (follower->bstate & MASK_CLICK(b))) {
                            follower->bstate &= ~MASK_CLICK(b);
                            follower->bstate |= MASK_TRIPLE_CLICK(b);
@@ -1102,10 +1109,10 @@ _nc_mouse_parse(int runcount)
 
 #ifdef TRACE
     if (USE_TRACEF(TRACE_IEVENT)) {
 
 #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",
        _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,
+               (long) (runp - sp->_mouse_events),
+               (long) ((eventp - sp->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
                runcount);
        _nc_unlock_global(tracef);
     }
                runcount);
        _nc_unlock_global(tracef);
     }
@@ -1116,15 +1123,15 @@ _nc_mouse_parse(int runcount)
      * don't match the current event mask.
      */
     for (; runcount; prev = PREV(eventp), 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)) {
        }
 #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",
        _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,
+               (long) (runp - sp->_mouse_events),
+               (long) ((eventp - sp->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
                runcount);
        _nc_unlock_global(tracef);
     }
                runcount);
        _nc_unlock_global(tracef);
     }
@@ -1132,8 +1139,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",
        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) (ep - sp->_mouse_events)));
 #endif /* TRACE */
 
     /* after all this, do we have a valid event? */
 #endif /* TRACE */
 
     /* after all this, do we have a valid event? */
@@ -1141,26 +1148,26 @@ _nc_mouse_parse(int runcount)
 }
 
 static void
 }
 
 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"));
 
 /* 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:
     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:
        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:
        break;
 #endif
 #if USE_SYSMOUSE
     case M_SYSMOUSE:
-       mouse_activate(FALSE);
+       mouse_activate(sp, FALSE);
        break;
 #endif
     case M_NONE:
        break;
 #endif
     case M_NONE:
@@ -1169,29 +1176,29 @@ _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
 }
 
 static void
 }
 
 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"));
 
 /* 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 */
     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 */
        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:
        break;
 #endif
 
 #if USE_SYSMOUSE
     case M_SYSMOUSE:
-       mouse_activate(TRUE);
+       mouse_activate(sp, TRUE);
        break;
 #endif
     case M_NONE:
        break;
 #endif
     case M_NONE:
@@ -1205,14 +1212,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));
 
 {
     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);
 
        /* compute the current-event pointer */
        MEVENT *prev = PREV(eventp);
 
@@ -1220,8 +1226,8 @@ getmouse(MEVENT * aevent)
        *aevent = *prev;
 
        TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
        *aevent = *prev;
 
        TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
-                         _tracemouse(prev),
-                         (long) (prev - SP->_mouse_events)));
+                         _nc_tracemouse(sp, prev),
+                         (long) (prev - sp->_mouse_events)));
 
        prev->id = INVALID_EVENT;       /* so the queue slot becomes free */
        returnCode(OK);
 
        prev->id = INVALID_EVENT;       /* so the queue slot becomes free */
        returnCode(OK);
@@ -1229,29 +1235,42 @@ getmouse(MEVENT * aevent)
     returnCode(ERR);
 }
 
     returnCode(ERR);
 }
 
+/* grab a copy of the current mouse event */
 NCURSES_EXPORT(int)
 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));
 
 {
     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 */
 
        /* 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 */
 
        /* push back the notification event on the keyboard queue */
-       result = ungetch(KEY_MOUSE);
+       result = _nc_ungetch(sp, KEY_MOUSE);
     }
     returnCode(result);
 }
 
     }
     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 */
 NCURSES_EXPORT(mmask_t)
 mousemask(mmask_t newmask, mmask_t * oldmask)
 /* set the mouse event mask */
@@ -1265,7 +1284,7 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
            *oldmask = SP->_mouse_mask;
 
        if (newmask || SP->_mouse_initialized) {
            *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
            if (SP->_mouse_type != M_NONE) {
                result = newmask &
                    (REPORT_MOUSE_POSITION
@@ -1278,7 +1297,7 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
                     | BUTTON_DOUBLE_CLICKED
                     | BUTTON_TRIPLE_CLICKED);
 
                     | BUTTON_DOUBLE_CLICKED
                     | BUTTON_TRIPLE_CLICKED);
 
-               mouse_activate((bool) (result != 0));
+               mouse_activate(SP, (bool) (result != 0));
 
                SP->_mouse_mask = result;
            }
 
                SP->_mouse_mask = result;
            }
index 7f7aa3e04f1e8ca01f66e88008ebd9fc2f41ef10..78a18b88631e95760ec8bc75b4a5b110c0f03713 100644 (file)
@@ -42,7 +42,7 @@
 #include <curses.priv.h>
 #include <stddef.h>
 
 #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.51 2008/05/31 21:50:09 tom Exp $")
 
 #define window_is(name) ((sp)->_##name == win)
 
 
 #define window_is(name) ((sp)->_##name == win)
 
@@ -313,6 +313,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
     }
 
     wp->next = _nc_windows;
     }
 
     wp->next = _nc_windows;
+    wp->screen = SP;
     _nc_windows = wp;
 
     T((T_CREATE("window %p"), win));
     _nc_windows = wp;
 
     T((T_CREATE("window %p"), win));
@@ -320,3 +321,20 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
     _nc_unlock_global(windowlist);
     returnWin(win);
 }
     _nc_unlock_global(windowlist);
     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);
+}
index eee1cfc7b2590b463e4695e5483c77a8851f91ed..2403044dc8823811584afcfeb7a7b7abef058e08 100644 (file)
@@ -44,7 +44,7 @@
 #include <term.h>              /* cur_term */
 #include <tic.h>
 
 #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.109 2008/05/31 20:11:26 tom Exp $")
 
 NCURSES_EXPORT(SCREEN *)
 set_term(SCREEN *screenp)
 
 NCURSES_EXPORT(SCREEN *)
 set_term(SCREEN *screenp)
@@ -212,7 +212,7 @@ no_mouse_inline(SCREEN *sp GCC_UNUSED)
 }
 
 static bool
 }
 
 static bool
-no_mouse_parse(int code GCC_UNUSED)
+no_mouse_parse(SCREEN *sp GCC_UNUSED, int code GCC_UNUSED)
 {
     return TRUE;
 }
 {
     return TRUE;
 }
index 27b21b08d718c5498a09aa740ffc235aae1c3bde..d45a7d2b3cdb9a20e298145b4c5184f0e20c59ce 100644 (file)
@@ -45,7 +45,7 @@
 #include <ctype.h>
 #include <term.h>              /* num_labels, label_*, plab_norm */
 
 #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 $")
+MODULE_ID("$Id: lib_slk.c,v 1.33 2008/05/31 22:05:57 tom Exp $")
 
 /*
  * We'd like to move these into the screen context structure, but cannot,
 
 /*
  * We'd like to move these into the screen context structure, but cannot,
@@ -60,14 +60,16 @@ _nc_slk_format = 0;         /* one more than format specified in slk_init() */
 static void
 slk_paint_info(WINDOW *win)
 {
 static void
 slk_paint_info(WINDOW *win)
 {
-    if (win && SP->slk_format == 4) {
+    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);
 
        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);
+       for (i = 0; i < sp->_slk->maxlab; i++) {
+           mvwprintw(win, 0, sp->_slk->ent[i].ent_x, "F%d", i + 1);
        }
     }
 }
        }
     }
 }
index 2eda99017bed066b226bd0c51998fee640aacf6f..8742f867fa946f8e3fa099386f6ba818006862da 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
 
 #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>
 
 
 #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++)
     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 */
 
 }
 #endif /* TRACE */
 
@@ -70,7 +70,7 @@ _nc_ungetch(SCREEN *sp, int ch)
            h_dec();
 
        sp->_fifo[head] = 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);
 #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)
 {
 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));
 }
     returnCode(_nc_ungetch(SP, ch));
 }
index cf2c998e239f405989b9d340e85841c4046a0a26..f7ef2042ebeb8194af79273206b1a25232b07be7 100644 (file)
@@ -41,7 +41,7 @@
 #include <curses.priv.h>
 #include <term.h>
 
 #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.33 2008/05/31 16:51:12 tom Exp $")
 
 #define stolen_lines (screen_lines - SP->_lines_avail)
 
 
 #define stolen_lines (screen_lines - SP->_lines_avail)
 
@@ -418,7 +418,7 @@ resizeterm(int ToLines, int ToCols)
            result = resize_term(ToLines, ToCols);
 
 #if USE_SIGWINCH
            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
            clearok(curscr, TRUE);      /* screen contents are unknown */
 
            /* ripped-off lines are a special case: if we did not lengthen
index 983a75ae788258bf833421ab25bd44ac52561930..54e4d9831ebc97dff0ea0fd543adb1ca8636ec54 100644 (file)
@@ -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            *
  *                                                                          *
  * 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>
 
 
 #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.26 2008/05/31 16:54:22 tom Exp $")
 
 /*
  * Expand a keycode into the string that it corresponds to, returning null if
 
 /*
  * Expand a keycode into the string that it corresponds to, returning null if
@@ -72,7 +72,7 @@ _nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len)
            *((unsigned char *) (result + len)) = 128;
 #ifdef TRACE
        if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) {
            *((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
            _nc_unlock_global(tracef);
        }
 #endif
index b6447723c5db80156b6cab9b1cc075fdbe4daf82..3d152456a00f0901a594b7c72c41a8dd04a69b7f 100644 (file)
@@ -34,7 +34,7 @@
 
 
 /*
 
 
 /*
- * $Id: curses.priv.h,v 1.375 2008/05/24 23:08:27 tom Exp $
+ * $Id: curses.priv.h,v 1.382 2008/05/31 21:41:41 tom Exp $
  *
  *     curses.priv.h
  *
  *
  *     curses.priv.h
  *
@@ -603,8 +603,6 @@ typedef struct {
        char            *tracedmp_buf;
        size_t          tracedmp_used;
 
        char            *tracedmp_buf;
        size_t          tracedmp_used;
 
-       char            tracemse_buf[TRACEMSE_MAX];
-
        unsigned char   *tracetry_buf;
        size_t          tracetry_used;
 
        unsigned char   *tracetry_buf;
        size_t          tracetry_used;
 
@@ -796,7 +794,7 @@ struct screen {
        int             _maxclick;
        bool            (*_mouse_event) (SCREEN *);
        bool            (*_mouse_inline)(SCREEN *);
        int             _maxclick;
        bool            (*_mouse_event) (SCREEN *);
        bool            (*_mouse_inline)(SCREEN *);
-       bool            (*_mouse_parse) (int);
+       bool            (*_mouse_parse) (SCREEN *, int);
        void            (*_mouse_resume)(SCREEN *);
        void            (*_mouse_wrap)  (SCREEN *);
        int             _mouse_fd;      /* file-descriptor, if any */
        void            (*_mouse_resume)(SCREEN *);
        void            (*_mouse_wrap)  (SCREEN *);
        int             _mouse_fd;      /* file-descriptor, if any */
@@ -873,6 +871,11 @@ struct screen {
        long            _outchars;
        const char      *_tputs_trace;
 #endif
        long            _outchars;
        const char      *_tputs_trace;
 #endif
+#endif
+
+#ifdef TRACE
+       char            tracechr_buf[40];
+       char            tracemse_buf[TRACEMSE_MAX];
 #endif
        /*
         * ncurses/ncursesw are the same up to this point.
 #endif
        /*
         * ncurses/ncursesw are the same up to this point.
@@ -889,8 +892,9 @@ extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
 extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
        WINDOWLIST {
 extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
        WINDOWLIST {
-       WINDOW  win;    /* first, so WINDOW_EXT() works */
+       WINDOW  win;            /* first, so WINDOW_EXT() works */
        WINDOWLIST *next;
        WINDOWLIST *next;
+       SCREEN *screen;         /* screen containing the window */
 #ifdef _XOPEN_SOURCE_EXTENDED
        char addch_work[(MB_LEN_MAX * 9) + 1];
        unsigned addch_used;    /* number of bytes in addch_work[] */
 #ifdef _XOPEN_SOURCE_EXTENDED
        char addch_work[(MB_LEN_MAX * 9) + 1];
        unsigned addch_used;    /* number of bytes in addch_work[] */
@@ -1533,10 +1537,15 @@ extern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned);
 extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *);
 
 /* elsewhere ... */
 extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *);
 
 /* elsewhere ... */
-extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry(ENTRY *, TERMTYPE *);
+extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *);
+extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int);
+extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
+extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *);
 extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
 extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
 extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
 extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
 extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
 extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
+extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int);
+extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *);
 extern NCURSES_EXPORT(int) _nc_access (const char *, int);
 extern NCURSES_EXPORT(int) _nc_baudrate (int);
 extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
 extern NCURSES_EXPORT(int) _nc_access (const char *, int);
 extern NCURSES_EXPORT(int) _nc_baudrate (int);
 extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
@@ -1546,10 +1555,10 @@ extern NCURSES_EXPORT(int) _nc_ospeed (int);
 extern NCURSES_EXPORT(int) _nc_outch (int);
 extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
 extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int);
 extern NCURSES_EXPORT(int) _nc_outch (int);
 extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
 extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int);
-extern NCURSES_EXPORT(int) _nc_timed_wait(SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
 extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, int (*)(int));
 extern NCURSES_EXPORT(void) _nc_flush (void);
 extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, int (*)(int));
 extern NCURSES_EXPORT(void) _nc_flush (void);
-extern NCURSES_EXPORT(void) _nc_free_entry(ENTRY *, TERMTYPE *);
+extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE *);
 extern NCURSES_EXPORT(void) _nc_freeall (void);
 extern NCURSES_EXPORT(void) _nc_hash_map (void);
 extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
 extern NCURSES_EXPORT(void) _nc_freeall (void);
 extern NCURSES_EXPORT(void) _nc_hash_map (void);
 extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
index ff61d69a7e8c984159c045415498d0a29ecb22ef..ae8cd16e1919689cf762f3ae4e286a71b1f5475d 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_data.c,v 1.44 2008/05/24 23:09:21 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.47 2008/05/31 19:44:36 tom Exp $")
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
@@ -168,8 +168,6 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
     NULL,                      /* tracedmp_buf */
     0,                         /* tracedmp_used */
 
     NULL,                      /* tracedmp_buf */
     0,                         /* tracedmp_used */
 
-    CHARS_0s,                  /* tracemse_buf */
-
     NULL,                      /* tracetry_buf */
     0,                         /* tracetry_used */
 
     NULL,                      /* tracetry_buf */
     0,                         /* tracetry_used */
 
index 108eb8b4d33559e448a6c55bd7b01dd187636b27..566e75454cf5e7c2e0f1dd211f00e383b665a523 100644 (file)
@@ -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            *
  *                                                                          *
  * 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>
 #include <term.h>              /* acs_chars */
 
 #include <curses.priv.h>
 #include <term.h>              /* acs_chars */
 
-MODULE_ID("$Id: lib_traceatr.c,v 1.59 2007/06/09 17:22:10 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.60 2008/05/31 16:53:15 tom Exp $")
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
@@ -255,7 +255,7 @@ _tracechtype2(int bufnum, chtype ch)
     if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
        (void) _nc_trace_bufcat(bufnum, found);
     } else
     if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
        (void) _nc_trace_bufcat(bufnum, found);
     } else
-       (void) _nc_trace_bufcat(bufnum, _tracechar((int)ChCharOf(ch)));
+       (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, (int)ChCharOf(ch)));
 
     if (ChAttrOf(ch) != A_NORMAL) {
        (void) _nc_trace_bufcat(bufnum, " | ");
 
     if (ChAttrOf(ch) != A_NORMAL) {
        (void) _nc_trace_bufcat(bufnum, " | ");
@@ -311,14 +311,14 @@ _tracecchar_t2 (int bufnum, const cchar_t *ch)
                if (PUTC_n <= 0) {
                    if (PUTC_ch != L'\0') {
                        /* it could not be a multibyte sequence */
                if (PUTC_n <= 0) {
                    if (PUTC_ch != L'\0') {
                        /* it could not be a multibyte sequence */
-                       (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(ch->chars[PUTC_i])));
+                       (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, UChar(ch->chars[PUTC_i])));
                    }
                    break;
                }
                for (n = 0; n < PUTC_n; n++) {
                    if (n)
                        (void) _nc_trace_bufcat(bufnum, ", ");
                    }
                    break;
                }
                for (n = 0; n < PUTC_n; n++) {
                    if (n)
                        (void) _nc_trace_bufcat(bufnum, ", ");
-                   (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(PUTC_buf[n])));
+                   (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, UChar(PUTC_buf[n])));
                }
            }
            (void) _nc_trace_bufcat(bufnum, " }");
                }
            }
            (void) _nc_trace_bufcat(bufnum, " }");
index 479756ac59beee19b3b92988f31ee65ec04d5663..9846dc1d7bc74c8c7303d1e84348edac606952bc 100644 (file)
 
 #include <ctype.h>
 
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracechr.c,v 1.13 2007/04/21 23:16:37 tom Exp $")
+MODULE_ID("$Id: lib_tracechr.c,v 1.17 2008/05/31 19:57:47 tom Exp $")
 
 #ifdef TRACE
 
 #ifdef TRACE
-#define MyBuffer _nc_globals.tracechr_buf
 
 NCURSES_EXPORT(char *)
 
 NCURSES_EXPORT(char *)
-_tracechar(int ch)
+_nc_tracechar(SCREEN *sp, int ch)
 {
     NCURSES_CONST char *name;
 {
     NCURSES_CONST char *name;
+    char *MyBuffer = ((sp != 0)
+                     ? sp->tracechr_buf
+                     : _nc_globals.tracechr_buf);
 
     if (ch > KEY_MIN || ch < 0) {
 
     if (ch > KEY_MIN || ch < 0) {
-       name = keyname(ch);
+       name = _nc_keyname(sp, ch);
        if (name == 0 || *name == '\0')
            name = "NULL";
        (void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch);
        if (name == 0 || *name == '\0')
            name = "NULL";
        (void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch);
@@ -62,13 +64,19 @@ _tracechar(int ch)
         */
        (void) sprintf(MyBuffer, "%#03o", ch);
     } else {
         */
        (void) sprintf(MyBuffer, "%#03o", ch);
     } else {
-       name = unctrl((chtype) ch);
+       name = _nc_unctrl(sp, (chtype) ch);
        if (name == 0 || *name == 0)
            name = "null";      /* shouldn't happen */
        (void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch);
     }
     return (MyBuffer);
 }
        if (name == 0 || *name == 0)
            name = "null";      /* shouldn't happen */
        (void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch);
     }
     return (MyBuffer);
 }
+
+NCURSES_EXPORT(char *)
+_tracechar(int ch)
+{
+    return _nc_tracechar(SP, ch);
+}
 #else
 empty_module(_nc_lib_tracechr)
 #endif
 #else
 empty_module(_nc_lib_tracechr)
 #endif
index 5edcc13a6ffae5a4b39087ec62f975c2b6ea3ec4..3b060894eba8d9681c5fd8c40a51b1576d975e0f 100644 (file)
@@ -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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_tracemse.c,v 1.13 2007/04/21 21:23:00 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.14 2008/05/31 17:20:25 tom Exp $")
 
 #ifdef TRACE
 
 
 #ifdef TRACE
 
-#define my_buffer _nc_globals.tracemse_buf
+#define my_buffer sp->tracemse_buf
 
 NCURSES_EXPORT(char *)
 
 NCURSES_EXPORT(char *)
-_tracemouse(MEVENT const *ep)
+_nc_tracemouse(SCREEN *sp, MEVENT const *ep)
 {
     (void) sprintf(my_buffer, TRACEMSE_FMT,
                   ep->id,
 {
     (void) sprintf(my_buffer, TRACEMSE_FMT,
                   ep->id,
@@ -114,6 +114,12 @@ _tracemouse(MEVENT const *ep)
     return (my_buffer);
 }
 
     return (my_buffer);
 }
 
+NCURSES_EXPORT(char *)
+_tracemouse(MEVENT const *ep)
+{
+    return _nc_tracemouse(SP, ep);
+}
+
 #else /* !TRACE */
 empty_module(_nc_lib_tracemouse)
 #endif
 #else /* !TRACE */
 empty_module(_nc_lib_tracemouse)
 #endif