]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.7 - patch 20090418
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 19 Apr 2009 00:38:07 +0000 (00:38 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 19 Apr 2009 00:38:07 +0000 (00:38 +0000)
+ continue integrating "sp-funcs" by Juergen Pfeifer (incomplete).

46 files changed:
NEWS
dist.mk
form/frm_win.c
include/MKterm.h.awk.in
include/curses.h.in
include/curses.tail
include/curses.wide
include/nc_alloc.h
include/ncurses_dll.h
include/unctrl.h.in
ncurses/base/MKunctrl.awk
ncurses/base/lib_addch.c
ncurses/base/lib_freeall.c
ncurses/base/lib_getch.c
ncurses/base/lib_insch.c
ncurses/base/lib_mvwin.c
ncurses/base/lib_newterm.c
ncurses/base/lib_newwin.c
ncurses/base/lib_pad.c
ncurses/base/lib_printw.c
ncurses/base/lib_redrawln.c
ncurses/base/lib_ungetch.c
ncurses/base/lib_window.c
ncurses/base/resizeterm.c
ncurses/base/safe_sprintf.c
ncurses/curses.priv.h
ncurses/tinfo/MKfallback.sh
ncurses/tinfo/alloc_ttype.c
ncurses/tinfo/init_keytry.c
ncurses/tinfo/lib_cur_term.c
ncurses/tinfo/lib_has_cap.c
ncurses/tinfo/lib_setup.c
ncurses/tinfo/parse_entry.c
ncurses/tinfo/write_entry.c
ncurses/trace/lib_traceatr.c
ncurses/trace/lib_tracechr.c
ncurses/trace/lib_tracedmp.c
ncurses/tty/hardscroll.c
ncurses/tty/hashmap.c
ncurses/tty/lib_mvcur.c
ncurses/tty/lib_tstp.c
ncurses/tty/lib_twait.c
ncurses/tty/tty_update.c
ncurses/widechar/lib_get_wch.c
ncurses/widechar/lib_unget_wch.c
ncurses/widechar/lib_wunctrl.c

diff --git a/NEWS b/NEWS
index cfd83aa963a099b872650c68281e0f14c9f04844..d19470753cc58d9b15d030cd40a6f69584e7b931 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.1380 2009/04/11 22:00:37 tom Exp $
+-- $Id: NEWS,v 1.1381 2009/04/18 18:42:28 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,9 @@ 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.
 
+20090418
+       + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete).
+
 20090411
        + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete).
          This change finishes merging for menu and panel libraries, does
diff --git a/dist.mk b/dist.mk
index f4ac795bd35335e760ee0450c70ff8144236c5d5..a60f70ef807485ae74383b3cf8fead6abbc46aa2 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.693 2009/04/11 20:38:16 tom Exp $
+# $Id: dist.mk,v 1.694 2009/04/18 15:21:05 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -37,7 +37,7 @@ SHELL = /bin/sh
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 7
-NCURSES_PATCH = 20090411
+NCURSES_PATCH = 20090418
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index 2258f0a6195b1cc022df4de73ba0ec5f583dd04e..468e2fa27893240ee01678d7571881288ba762ef 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +32,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_win.c,v 1.13 2004/12/11 22:15:27 tom Exp $")
+MODULE_ID("$Id: frm_win.c,v 1.14 2009/04/18 18:38:57 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -50,9 +50,18 @@ set_form_win(FORM *form, WINDOW *win)
 
   if (form && (form->status & _POSTED))
     RETURN(E_POSTED);
+  else
+    {
+#if NCURSES_SP_FUNCS
+      FORM *f = Normalize_Form(form);
 
-  Normalize_Form(form)->win = win;
-  RETURN(E_OK);
+      f->win = win ? win : Get_Form_Screen(f)->_stdscr;
+      RETURN(E_OK);
+#else
+      Normalize_Form(form)->win = win;
+      RETURN(E_OK);
+#endif
+    }
 }
 
 /*---------------------------------------------------------------------------
@@ -66,12 +75,18 @@ set_form_win(FORM *form, WINDOW *win)
 NCURSES_EXPORT(WINDOW *)
 form_win(const FORM *form)
 {
+  WINDOW *result;
   const FORM *f;
 
   T((T_CALLED("form_win(%p)"), form));
 
   f = Normalize_Form(form);
-  returnWin(f->win ? f->win : stdscr);
+#if NCURSES_SP_FUNCS
+  result = (f->win ? f->win : Get_Form_Screen(f)->_stdscr);
+#else
+  result = (f->win ? f->win : stdscr);
+#endif
+  returnWin(result);
 }
 
 /* frm_win.c ends here */
index c0e826bf6eb25f699fec6dd793cc15877a7f5559..31ee34c9feda3a93fd6aa5cbb1d9bb1de94369e8 100644 (file)
@@ -34,7 +34,7 @@ BEGIN         {
                    print  "/*    and: Thomas E. Dickey                        1995-on                  */"
                    print  "/****************************************************************************/"
                    print  ""
-                   print  "/* $Id: MKterm.h.awk.in,v 1.53 2009/02/28 21:27:45 tom Exp $ */"
+                   print  "/* $Id: MKterm.h.awk.in,v 1.54 2009/04/18 20:44:15 tom Exp $ */"
                    print  ""
                    print  "/*"
                    print  "**  term.h -- Definition of struct term"
@@ -317,6 +317,35 @@ END                {
                        print  "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
                        print  "#endif /* NCURSES_TERMCAP_H_incl */"
                        print  ""
+                       print  "/*"
+                       print  " * Include curses.h before term.h to enable these extensions."
+                       print  " */"
+                       print  "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)"
+                       print  ""
+                       print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tigetstr) (SCREEN*, NCURSES_CONST char *);"
+                       print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(putp) (SCREEN*, const char *);"
+                       print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetflag) (SCREEN*, NCURSES_CONST char *);"
+                       print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetnum) (SCREEN*, NCURSES_CONST char *);"
+                       print  ""
+                       print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
+                       print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, ...);     /* special */"
+                       print  "#else"
+                       print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);    /* special */"
+                       print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm_varargs) (SCREEN*, NCURSES_CONST char *, ...);     /* special */"
+                       print  "#endif"
+                       print  ""
+                       print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
+                       print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgetstr) (SCREEN*, NCURSES_CONST char *, char **);"
+                       print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);"
+                       print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);"
+                       print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);"
+                       print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);"
+                       print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, int (*)(int));"
+                       print  ""
+                       print  "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);"
+                       print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);"
+                       print  "#endif /* NCURSES_SP_FUNCS */"
+                       print  ""
                        print  "#ifdef __cplusplus"
                        print  "}"
                        print  "#endif"
index 23201e00ed70cf4a127c448b13b4948675c5760d..0c722bdd4922a1e809379ebacf259a87fe580916 100644 (file)
@@ -32,7 +32,7 @@
  *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
-/* $Id: curses.h.in,v 1.195 2009/03/21 21:04:57 tom Exp $ */
+/* $Id: curses.h.in,v 1.196 2009/04/18 19:57:58 tom Exp $ */
 
 #ifndef __NCURSES_H
 #define __NCURSES_H
@@ -146,7 +146,6 @@ typedef unsigned @cf_cv_typeof_mmask_t@ mmask_t;
 #endif
 
 #include <stdio.h>
-#include <unctrl.h>
 #include <stdarg.h>    /* we need va_list */
 #ifdef _XOPEN_SOURCE_EXTENDED
 #include <stddef.h>    /* we want wchar_t */
@@ -896,6 +895,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented *
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, short, short*, short*, short*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented */
@@ -921,12 +921,11 @@ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemente
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented */
 extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented */
-extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, NCURSES_CONST char *, FILE *, FILE *); /* implemented */
+extern NCURSES_EXPORT(SCREEN*) NCURSES_SP_NAME(newterm) (SCREEN*, NCURSES_CONST char *, FILE *, FILE *); /* implemented */
 extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented */
@@ -935,7 +934,9 @@ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented *
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented */
@@ -966,6 +967,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, i
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*);
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined)(SCREEN*, const char *);
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool);
+extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int);
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int);
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*);
index 53602afc927befad99085710b12d2a32f4d089f9..fb2b8c84f3c64c1634365c5f5972d9af3b2ae455 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: curses.tail,v 1.17 2008/11/23 00:12:12 tom Exp $ */
+/* $Id: curses.tail,v 1.18 2009/04/18 21:30:52 tom Exp $ */
 /*
  * vile:cmode:
  * This file is part of ncurses, designed to be appended after curses.h.in
@@ -94,14 +94,22 @@ typedef struct
 }
 MEVENT;
 
-extern NCURSES_EXPORT(bool) has_mouse (void);
-extern NCURSES_EXPORT(int) getmouse (MEVENT *);
-extern NCURSES_EXPORT(int) ungetmouse (MEVENT *);
+extern NCURSES_EXPORT(bool)    has_mouse(void);
+extern NCURSES_EXPORT(int)     getmouse (MEVENT *);
+extern NCURSES_EXPORT(int)     ungetmouse (MEVENT *);
 extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
-extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int);
-extern NCURSES_EXPORT(int) mouseinterval (int);
-extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
-extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool);              /* generated */
+extern NCURSES_EXPORT(bool)    wenclose (const WINDOW *, int, int);
+extern NCURSES_EXPORT(int)     mouseinterval (int);
+extern NCURSES_EXPORT(bool)    wmouse_trafo (const WINDOW*, int*, int*, bool);
+extern NCURSES_EXPORT(bool)    mouse_trafo (int*, int*, bool);              /* generated */
+
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(bool)    NCURSES_SP_NAME(has_mouse) (SCREEN*);
+extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *);
+extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *);
+extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *);
+extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(mouseinterval) (SCREEN*, int);
+#endif
 
 #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
 
@@ -110,6 +118,10 @@ extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool);              /* gene
 extern NCURSES_EXPORT(int) mcprint (char *, int);      /* direct data to printer */
 extern NCURSES_EXPORT(int) has_key (int);              /* do we have given key? */
 
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int);    /* do we have given key? */
+#endif
+
 /* Debugging : use with libncurses_g.a */
 
 extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
@@ -161,6 +173,8 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
 #define OPTIMIZE_ALL           0xff    /* enable all optimizations (dflt) */
 #endif
 
+#include <unctrl.h>
+
 #ifdef __cplusplus
 
 #ifndef NCURSES_NOMACROS
index 7d11403471e9ed77b9ca22cee4ebd1822d696184..520875e7cebce936ff1a4d4daedc695c4eab1a9c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: curses.wide,v 1.36 2008/11/29 18:44:08 tom Exp $ */
+/* $Id: curses.wide,v 1.37 2009/04/18 21:34:06 tom Exp $ */
 /*
  * vile:cmode:
  * This file is part of ncurses, designed to be appended after curses.h.in
@@ -167,6 +167,12 @@ extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *);          /* implemented */
 extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *);                   /* implemented */
 extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int);        /* implemented */
 
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*);           /* implemented */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t);        /* implemented */
+extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented */
+#endif
+
 #ifndef NCURSES_NOMACROS
 
 /*
index f521bffe9f0a0303cc2928dbd070a7ac0d7ef06c..ab9f4a243acdcdeb56b5319caace21d6db5789c1 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,7 +29,7 @@
 /****************************************************************************
  *  Author: Thomas E. Dickey                    1996-on                     *
  ****************************************************************************/
-/* $Id: nc_alloc.h,v 1.16 2008/09/27 22:30:33 tom Exp $ */
+/* $Id: nc_alloc.h,v 1.17 2009/04/18 20:48:19 tom Exp $ */
 
 #ifndef NC_ALLOC_included
 #define NC_ALLOC_included 1
@@ -74,9 +74,15 @@ extern NCURSES_EXPORT(void) _nc_free_tic(int) GCC_NORETURN;
 extern NCURSES_EXPORT(void) _nc_free_tparm(void);
 extern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void);
 extern NCURSES_EXPORT(void) _nc_leaks_tic(void);
-#define ExitProgram(code) _nc_free_and_exit(code)
+
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
 #endif
 
+#define ExitProgram(code) _nc_free_and_exit(code)
+
+#endif /* NO_LEAKS, etc */
+
 #ifndef HAVE_NC_FREEALL
 #define HAVE_NC_FREEALL 0
 #endif
index 9c6835a225ce8a7cb6e701c81bc97015c5db5693..047d5c7d390ba97140ce0aa413d073918b9e3299 100644 (file)
@@ -25,7 +25,7 @@
  * sale, use or other dealings in this Software without prior written       *
  * authorization.                                                           *
  ****************************************************************************/
-/* $Id: ncurses_dll.h,v 1.7 2009/03/21 18:55:22 tom Exp $ */
+/* $Id: ncurses_dll.h,v 1.8 2009/04/04 22:26:27 tom Exp $ */
 
 #ifndef NCURSES_DLL_H_incl
 #define NCURSES_DLL_H_incl 1
@@ -37,7 +37,7 @@
 #undef NCURSES_DLL
 #define NCURSES_STATIC
 
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) || defined(__MINGW32__)
 #  if defined(NCURSES_DLL)
 #    if defined(NCURSES_STATIC)
 #      undef NCURSES_STATIC
index 70d74b7714b1a45b1130b2afb0076772436a5cad..e08bc813881d4f2373df1ffc51ac0c5e53b8b678 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +39,7 @@
  * as ^?. Printable characters are displayed as is.
  */
 
-/* $Id: unctrl.h.in,v 1.10 2001/03/24 21:53:25 tom Exp $ */
+/* $Id: unctrl.h.in,v 1.11 2009/04/18 21:00:52 tom Exp $ */
 
 #ifndef NCURSES_UNCTRL_H_incl
 #define NCURSES_UNCTRL_H_incl  1
@@ -56,6 +56,10 @@ extern "C" {
 #undef unctrl
 NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype);
 
+#if @NCURSES_SP_FUNCS@
+NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 36fbeecb2e765f8443207aa1542d30b0ff99504f..2c37d442c9d38e8818bc7066591878ade3d41ac6 100644 (file)
@@ -1,6 +1,6 @@
-# $Id: MKunctrl.awk,v 1.23 2008/10/04 21:40:24 tom Exp $
+# $Id: MKunctrl.awk,v 1.25 2009/04/18 23:43:49 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.                #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -46,9 +46,8 @@ BEGIN {
                print ""
        }
 END    {
-               print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *sp, chtype ch)"
+               print "NCURSES_EXPORT(NCURSES_CONST char *) safe_unctrl(SCREEN *sp, chtype ch)"
                print "{"
-
                blob=""
                offset=0
                if (bigstrings) {
@@ -187,6 +186,6 @@ END {
                print  ""
                print  "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype ch)"
                print  "{"
-               print  "\treturn _nc_unctrl(SP, ch);"
+               print  "\treturn safe_unctrl(CURRENT_SCREEN, ch);"
                print  "}"
        }
index 12aadd7a6911d4739e55430e3414de566a31688a..714e3e7e562956f8a11bcb1518a623e7d982c948 100644 (file)
@@ -36,7 +36,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_addch.c,v 1.115 2009/01/17 20:37:32 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.118 2009/04/18 23:53:04 tom Exp $")
 
 static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
 
@@ -261,6 +261,9 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch)
      * Build up multibyte characters until we have a wide-character.
      */
     if_WIDEC({
+#if NCURSES_SP_FUNCS
+       SCREEN *sp = _nc_screen_of(win);
+#endif
        if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) {
            int len = _nc_build_wch(win, CHREF(ch));
 
@@ -270,7 +273,8 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch)
                /* handle EILSEQ (i.e., when len >= -1) */
                if (is8bits(CharOf(ch))) {
                    int rc = OK;
-                   const char *s = unctrl((chtype) CharOf(ch));
+                   const char *s = NCURSES_SP_NAME(unctrl)
+                     (NCURSES_SP_ARGx (chtype) CharOf(ch));
 
                    if (s[1] != '\0') {
                        while (*s != '\0') {
@@ -405,8 +409,11 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
 {
     NCURSES_SIZE_T x, y;
     chtype t = CharOf(ch);
-    const char *s = unctrl(t);
-
+#if USE_WIDEC_SUPPORT || NCURSES_SP_FUNCS || USE_REENTRANT
+    SCREEN *sp = _nc_screen_of(win);
+#endif
+    const char *s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx t);
+    int tabsize = 8;
     /*
      * If we are using the alternate character set, forget about locale.
      * Otherwise, if unctrl() returns a single-character or the locale
@@ -415,14 +422,14 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
     if ((AttrOf(ch) & A_ALTCHARSET)
        || (
 #if USE_WIDEC_SUPPORT
-              (SP != 0 && SP->_legacy_coding) &&
+              (sp != 0 && sp->_legacy_coding) &&
 #endif
               s[1] == 0
        )
        || (
               isprint(t)
 #if USE_WIDEC_SUPPORT
-              || ((SP == 0 || !SP->_legacy_coding) &&
+              || ((sp == 0 || !sp->_legacy_coding) &&
                   (WINDOW_EXT(win, addch_used)
                    || !_nc_is_charable(CharOf(ch))))
 #endif
@@ -438,8 +445,12 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
 
     switch (t) {
     case '\t':
-       x += (TABSIZE - (x % TABSIZE));
-
+#if USE_REENTRANT
+       tabsize = sp->_TABSIZE;
+#else
+       tabsize = TABSIZE;
+#endif
+       x += (tabsize - (x % tabsize));
        /*
         * Space-fill the tab on the bottom line so that we'll get the
         * "correct" cursor position.
index 61991816361424d739cdd8f26ce1c13db5914194..5856dd547cd85f527f70dd4922fcb8fbd13d4b8b 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 extern int malloc_errfd;       /* FIXME */
 #endif
 
-MODULE_ID("$Id: lib_freeall.c,v 1.55 2008/12/06 23:52:29 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.56 2009/04/18 17:18:56 tom Exp $")
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
  * use for it as an extension).
  */
 NCURSES_EXPORT(void)
-_nc_freeall(void)
+NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
 {
     WINDOWLIST *p, *q;
     static va_list empty_va;
 
     T((T_CALLED("_nc_freeall()")));
 #if NO_LEAKS
-    if (SP != 0) {
-       if (SP->_oldnum_list != 0) {
-           FreeAndNull(SP->_oldnum_list);
+    if (SP_PARM != 0) {
+       if (SP_PARM->_oldnum_list != 0) {
+           FreeAndNull(SP_PARM->_oldnum_list);
        }
-       if (SP->_panelHook.destroy != 0) {
-           SP->_panelHook.destroy(SP->_panelHook.stdscr_pseudo_panel);
+       if (SP_PARM->_panelHook.destroy != 0) {
+           SP_PARM->_panelHook.destroy(SP_PARM->_panelHook.stdscr_pseudo_panel);
        }
     }
 #endif
-    if (SP != 0) {
+    if (SP_PARM != 0) {
        _nc_lock_global(curses);
 
        while (_nc_windows != 0) {
@@ -95,7 +95,7 @@ _nc_freeall(void)
            if (!deleted)
                break;
        }
-       delscreen(SP);
+       delscreen(SP_PARM);
        _nc_unlock_global(curses);
     }
 
@@ -119,12 +119,20 @@ _nc_freeall(void)
     returnVoid;
 }
 
+#if NCURSES_SP_FUNCS
 NCURSES_EXPORT(void)
-_nc_free_and_exit(int code)
+_nc_freeall(void)
+{
+    NCURSES_SP_NAME(_nc_freeall) (CURRENT_SCREEN);
+}
+#endif
+
+NCURSES_EXPORT(void)
+NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code)
 {
-    char *last_setbuf = (SP != 0) ? SP->_setbuf : 0;
+    char *last_setbuf = (SP_PARM != 0) ? SP_PARM->_setbuf : 0;
 
-    _nc_freeall();
+    NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_ARG);
 #ifdef TRACE
     trace(0);                  /* close trace file, freeing its setbuf */
     {
@@ -144,12 +152,21 @@ _nc_freeall(void)
 }
 
 NCURSES_EXPORT(void)
-_nc_free_and_exit(int code)
+NCURSES_SP_NAME(_nc_free_and_exit) (SCREEN *SP_PARM, int code)
 {
-    if (SP)
-       delscreen(SP);
-    if (cur_term != 0)
-       del_curterm(cur_term);
+    if (SP_PARM) {
+       delscreen(SP_PARM);
+       if (SP_PARM->_term)
+           NCURSES_SP_NAME(_nc_del_curterm) (SP_PARM, SP_PARM->_term);
+    }
     exit(code);
 }
 #endif
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+_nc_free_and_exit(int code)
+{
+    NCURSES_SP_NAME(_nc_free_and_exit) (CURRENT_SCREEN, code);
+}
+#endif
index cfec16e61815a61bc7b1767e9905d8c40af35bc0..63e64fa44496375cfd78c48b814261f2b760060a 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.101 2009/02/28 19:16:40 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.102 2009/04/18 20:32:33 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -185,7 +185,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
 
     if (mask & TW_EVENT) {
        T(("fifo_push: ungetch KEY_EVENT"));
-       _nc_ungetch(sp, KEY_EVENT);
+       safe_ungetch(sp, KEY_EVENT);
        return KEY_EVENT;
     }
 #elif USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE
@@ -372,9 +372,9 @@ _nc_wgetch(WINDOW *win,
 #ifdef NCURSES_WGETCH_EVENTS
        if (rc != KEY_EVENT)
 #endif
-           _nc_ungetch(sp, '\n');
+           safe_ungetch(sp, '\n');
        for (bufp = buf + strlen(buf); bufp > buf; bufp--)
-           _nc_ungetch(sp, bufp[-1]);
+           safe_ungetch(sp, bufp[-1]);
 
 #ifdef NCURSES_WGETCH_EVENTS
        /* Return it first */
@@ -456,7 +456,7 @@ _nc_wgetch(WINDOW *win,
                 || !sp->_mouse_parse(sp, runcount)));
 #ifdef NCURSES_WGETCH_EVENTS
        if ((rc & TW_EVENT) && !(ch == KEY_EVENT)) {
-           _nc_ungetch(sp, ch);
+           safe_ungetch(sp, ch);
            ch = KEY_EVENT;
        }
 #endif
@@ -464,12 +464,12 @@ _nc_wgetch(WINDOW *win,
 #ifdef NCURSES_WGETCH_EVENTS
            /* mouse event sequence ended by an event, report event */
            if (ch == KEY_EVENT) {
-               _nc_ungetch(sp, KEY_MOUSE);     /* FIXME This interrupts a gesture... */
+               safe_ungetch(sp, KEY_MOUSE);    /* FIXME This interrupts a gesture... */
            } else
 #endif
            {
                /* mouse event sequence ended by keystroke, store keystroke */
-               _nc_ungetch(sp, ch);
+               safe_ungetch(sp, ch);
                ch = KEY_MOUSE;
            }
        }
index 9166ea5240e7f3adf62c9631bca98ffd50847dfa..d813740e43c5f92bbb578d35a41fe6c10760973d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +43,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_insch.c,v 1.25 2008/02/03 00:14:37 tom Exp $")
+MODULE_ID("$Id: lib_insch.c,v 1.27 2009/04/18 23:53:33 tom Exp $")
 
 /*
  * Insert the given character, updating the current location to simplify
@@ -56,10 +56,19 @@ _nc_insert_ch(WINDOW *win, chtype ch)
     NCURSES_CH_T wch;
     int count;
     NCURSES_CONST char *s;
-
+#if NCURSES_SP_FUNCS || USE_REENTRANT
+    SCREEN *sp = _nc_screen_of(win);
+#endif
+    int tabsize =
+#if USE_REENTRANT
+    sp->_TABSIZE
+#else
+    TABSIZE
+#endif
+     ;
     switch (ch) {
     case '\t':
-       for (count = (TABSIZE - (win->_curx % TABSIZE)); count > 0; count--) {
+       for (count = (tabsize - (win->_curx % tabsize)); count > 0; count--) {
            if ((code = _nc_insert_ch(win, ' ')) != OK)
                break;
        }
@@ -93,7 +102,7 @@ _nc_insert_ch(WINDOW *win, chtype ch)
                win->_curx++;
            }
        } else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) {
-           s = unctrl(ChCharOf(ch));
+           s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx ChCharOf(ch));
            while (*s != '\0') {
                code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s));
                if (code != OK)
@@ -114,7 +123,7 @@ _nc_insert_ch(WINDOW *win, chtype ch)
            } else if (count == -1) {
                /* handle EILSEQ */
                if (is8bits(ch)) {
-                   s = unctrl(ChCharOf(ch));
+                   s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx ChCharOf(ch));
                    while (*s != '\0') {
                        code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s));
                        if (code != OK)
index e4dad4a746f08ec811e5f6fd333676639af552f5..090d8fe730abc6cd6cb89aeda7246866bb4200a5 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_mvwin.c,v 1.14 2006/02/25 22:53:46 tom Exp $")
+MODULE_ID("$Id: lib_mvwin.c,v 1.15 2009/04/18 18:25:37 tom Exp $")
 
 NCURSES_EXPORT(int)
 mvwin(WINDOW *win, int by, int bx)
@@ -96,8 +96,8 @@ mvwin(WINDOW *win, int by, int bx)
     }
 #endif
 
-    if (by + win->_maxy > screen_lines - 1
-       || bx + win->_maxx > screen_columns - 1
+    if (by + win->_maxy > screen_lines(CURRENT_SCREEN) - 1
+       || bx + win->_maxx > screen_columns(CURRENT_SCREEN) - 1
        || by < 0
        || bx < 0)
        returnCode(ERR);
index f781a11004457b0576916c8822dfe37bd770a948..8dd70e0f672c336b5dc71bde5641898920df3493 100644 (file)
@@ -49,7 +49,7 @@
 #include <term.h>              /* clear_screen, cup & friends, cur_term */
 #include <tic.h>
 
-MODULE_ID("$Id: lib_newterm.c,v 1.74 2009/02/15 00:37:10 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.75 2009/04/18 19:22:08 tom Exp $")
 
 #ifndef ONLCR                  /* Allows compilation under the QNX 4.2 OS */
 #define ONLCR 0
@@ -136,8 +136,10 @@ nofilter(void)
 #endif /* NCURSES_EXT_FUNCS */
 
 NCURSES_EXPORT(SCREEN *)
-NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx NCURSES_CONST char *name, FILE
-                         *ofp, FILE *ifp)
+NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
+                         NCURSES_CONST char *name,
+                         FILE *ofp,
+                         FILE *ifp)
 {
     int value;
     int errret;
index 086dd1023d3e21ab7b20b848680933cfb7f36ecd..e7a30bf937ce3501e9263399e5708490044dd88e 100644 (file)
@@ -43,7 +43,7 @@
 #include <curses.priv.h>
 #include <stddef.h>
 
-MODULE_ID("$Id: lib_newwin.c,v 1.53 2009/02/15 00:38:00 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.54 2009/04/18 21:02:34 tom Exp $")
 
 #define window_is(name) ((sp)->_##name == win)
 
@@ -131,7 +131,7 @@ NCURSES_SP_NAME(newwin) (NCURSES_SP_DCLx
     if (num_lines == 0)
        num_lines = SP_PARM->_lines_avail - begy;
     if (num_columns == 0)
-       num_columns = screen_columns - begx;
+       num_columns = screen_columns(SP_PARM) - begx;
 
     if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
        returnWin(0);
@@ -155,7 +155,8 @@ NCURSES_SP_NAME(newwin) (NCURSES_SP_DCLx
 NCURSES_EXPORT(WINDOW *)
 newwin(int num_lines, int num_columns, int begy, int begx)
 {
-    return NCURSES_SP_NAME(newwin) (CURRENT_SCREEN, num_lines, num_columns,
+    return NCURSES_SP_NAME(newwin) (CURRENT_SCREEN,
+                                   num_lines, num_columns,
                                    begy, begx);
 }
 #endif
@@ -222,7 +223,12 @@ dimension_limit(int value)
 }
 
 NCURSES_EXPORT(WINDOW *)
-_nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
+NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx
+                             int num_lines,
+                             int num_columns,
+                             int begy,
+                             int begx,
+                             int flags)
 {
     int i;
     WINDOWLIST *wp;
@@ -231,7 +237,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
 
     T((T_CALLED("_nc_makenew(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
 
-    if (SP == 0)
+    if (SP_PARM == 0)
        returnWin(0);
 
     if (!dimension_limit(num_lines) || !dimension_limit(num_columns))
@@ -255,14 +261,16 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
     win->_maxx = num_columns - 1;
     win->_begy = begy;
     win->_begx = begx;
-    win->_yoffset = SP->_topstolen;
+    win->_yoffset = SP_PARM->_topstolen;
 
     win->_flags = flags;
     WINDOW_ATTRS(win) = A_NORMAL;
     SetChar(win->_nc_bkgd, BLANK_TEXT, BLANK_ATTR);
 
-    win->_clear = is_pad ? FALSE : (num_lines == screen_lines
-                                   && num_columns == screen_columns);
+    win->_clear = (is_pad
+                  ? FALSE
+                  : (num_lines == screen_lines(SP_PARM)
+                     && num_columns == screen_columns(SP_PARM)));
     win->_idlok = FALSE;
     win->_idcok = TRUE;
     win->_scroll = FALSE;
@@ -311,18 +319,18 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
        if_USE_SCROLL_HINTS(win->_line[i].oldindex = i);
     }
 
-    if (!is_pad && (begx + num_columns == screen_columns)) {
+    if (!is_pad && (begx + num_columns == screen_columns(SP_PARM))) {
        win->_flags |= _ENDLINE;
 
-       if (begx == 0 && num_lines == screen_lines && begy == 0)
+       if (begx == 0 && num_lines == screen_lines(SP_PARM) && begy == 0)
            win->_flags |= _FULLWIN;
 
-       if (begy + num_lines == screen_lines)
+       if (begy + num_lines == screen_lines(SP_PARM))
            win->_flags |= _SCROLLWIN;
     }
 
     wp->next = _nc_windows;
-    wp->screen = SP;
+    wp->screen = SP_PARM;
     _nc_windows = wp;
 
     T((T_CREATE("window %p"), win));
@@ -331,6 +339,16 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
     returnWin(win);
 }
 
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(WINDOW *)
+_nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
+{
+    return NCURSES_SP_NAME(_nc_makenew) (CURRENT_SCREEN,
+                                        num_lines, num_columns,
+                                        begy, begx, flags);
+}
+#endif
+
 /*
  * wgetch() and other functions with a WINDOW* parameter may use a SCREEN*
  * internally, and it is useful to allow those to be invoked without switching
index 7f9b8a84c6dbe61110c46f3277c151f18c42f301..43d9ed7e33691e8fedf48b90cf1b6748cc04e09e 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_pad.c,v 1.42 2009/02/15 00:38:48 tom Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.43 2009/04/18 18:25:37 tom Exp $")
 
 NCURSES_EXPORT(WINDOW *)
 NCURSES_SP_NAME(newpad) (NCURSES_SP_DCLx int l, int c)
@@ -172,8 +172,8 @@ pnoutrefresh(WINDOW *win,
        pmaxcol = pmincol + smaxcol - smincol;
     }
 
-    if (smaxrow >= screen_lines
-       || smaxcol >= screen_columns
+    if (smaxrow >= screen_lines(CURRENT_SCREEN)
+       || smaxcol >= screen_columns(CURRENT_SCREEN)
        || sminrow > smaxrow
        || smincol > smaxcol)
        returnCode(ERR);
index 62ae921e650ddf6f66a5ecd4cb2bfbe975d3008d..cb43b2f5b7bf4f2f22dbaac866d573f0c07b7d2b 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2005,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_printw.c,v 1.18 2006/12/17 19:21:39 tom Exp $")
+MODULE_ID("$Id: lib_printw.c,v 1.19 2009/04/18 18:45:55 tom Exp $")
 
 NCURSES_EXPORT(int)
 printw(const char *fmt,...)
@@ -128,10 +128,14 @@ vwprintw(WINDOW *win, const char *fmt, va_list argp)
 {
     char *buf;
     int code = ERR;
+#if NCURSES_SP_FUNCS
+    SCREEN *sp = _nc_screen_of(win);
+#endif
 
     T((T_CALLED("vwprintw(%p,%s,va_list)"), win, _nc_visbuf(fmt)));
 
-    if ((buf = _nc_printf_string(fmt, argp)) != 0) {
+    buf = NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_ARGx fmt, argp);
+    if (buf != 0) {
        code = waddstr(win, buf);
     }
     returnCode(code);
index 6b0905f07d67a8d1476eeb3cb850000d21922d5e..b04a488ba554bdf8914fbc15140b54d6f70eebd0 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_redrawln.c,v 1.12 2007/10/13 20:08:56 tom Exp $")
+MODULE_ID("$Id: lib_redrawln.c,v 1.13 2009/04/18 18:46:00 tom Exp $")
 
 NCURSES_EXPORT(int)
 wredrawln(WINDOW *win, int beg, int num)
@@ -47,37 +47,40 @@ wredrawln(WINDOW *win, int beg, int num)
     int i;
     int end;
     size_t len;
+    SCREEN *sp;
 
     T((T_CALLED("wredrawln(%p,%d,%d)"), win, beg, num));
 
     if (win == 0)
        returnCode(ERR);
 
+    sp = _nc_screen_of(win);
+
     if (beg < 0)
        beg = 0;
 
     if (touchline(win, beg, num) == ERR)
        returnCode(ERR);
 
-    if (touchline(curscr, beg + win->_begy, num) == ERR)
+    if (touchline(sp->_curscr, beg + win->_begy, num) == ERR)
        returnCode(ERR);
 
     end = beg + num;
-    if (end > curscr->_maxy + 1)
-       end = curscr->_maxy + 1;
+    if (end > sp->_curscr->_maxy + 1)
+       end = sp->_curscr->_maxy + 1;
     if (end > win->_maxy + 1)
        end = win->_maxy + 1;
 
     len = (win->_maxx + 1);
-    if (len > (size_t) (curscr->_maxx + 1))
-       len = (size_t) (curscr->_maxx + 1);
-    len *= sizeof(curscr->_line[0].text[0]);
+    if (len > (size_t) (sp->_curscr->_maxx + 1))
+       len = (size_t) (sp->_curscr->_maxx + 1);
+    len *= sizeof(sp->_curscr->_line[0].text[0]);
 
     for (i = beg; i < end; i++) {
        int crow = i + win->_begy;
 
-       memset(curscr->_line[crow].text + win->_begx, 0, len);
-       _nc_make_oldhash(crow);
+       memset(sp->_curscr->_line[crow].text + win->_begx, 0, len);
+       NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx crow);
     }
 
     returnCode(OK);
index 1f022b2da951cd3390e96343be52ce01eb5d9182..54a8998fbbb3f6d4b53c4028d7c88c3d030a5477 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_ungetch.c,v 1.12 2009/02/15 00:46:58 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.13 2009/04/18 20:30:12 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -58,10 +58,12 @@ _nc_fifo_dump(SCREEN *sp)
 #endif /* TRACE */
 
 NCURSES_EXPORT(int)
-_nc_ungetch(SCREEN *sp, int ch)
+safe_ungetch(SCREEN *sp, int ch)
 {
     int rc = ERR;
 
+    T((T_CALLED("ungetch(%p,%s)"), sp, _nc_tracechar(sp, ch)));
+
     if (tail != -1) {
        if (head == -1) {
            head = 0;
@@ -80,20 +82,11 @@ _nc_ungetch(SCREEN *sp, int ch)
 #endif
        rc = OK;
     }
-    return rc;
-}
-
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(ungetch) (NCURSES_SP_DCLx int ch)
-{
-    T((T_CALLED("ungetch(%s)"), _nc_tracechar(SP_PARM, ch)));
-    returnCode(_nc_ungetch(SP_PARM, ch));
+    returnCode(rc);
 }
 
-#if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
 ungetch(int ch)
 {
-    return NCURSES_SP_NAME(ungetch) (CURRENT_SCREEN, ch);
+    return safe_ungetch(CURRENT_SCREEN, ch);
 }
-#endif
index a3236e206a3788ee9a653a4316b3acfeb5cf8c61..2261a1f056ecff7334ddd336467c1f2fb755b9d7 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_window.c,v 1.25 2008/06/07 14:12:56 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.26 2009/04/18 18:46:09 tom Exp $")
 
 NCURSES_EXPORT(void)
 _nc_synchook(WINDOW *win)
@@ -185,16 +185,20 @@ dupwin(WINDOW *win)
     T((T_CALLED("dupwin(%p)"), win));
 
     if (win != 0) {
-
+#if NCURSES_SP_FUNCS
+       SCREEN *sp = _nc_screen_of(win);
+#endif
        _nc_lock_global(curses);
        if (win->_flags & _ISPAD) {
-           nwin = newpad(win->_maxy + 1,
-                         win->_maxx + 1);
+           nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx
+                                           win->_maxy + 1,
+                                           win->_maxx + 1);
        } else {
-           nwin = newwin(win->_maxy + 1,
-                         win->_maxx + 1,
-                         win->_begy,
-                         win->_begx);
+           nwin = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx
+                                           win->_maxy + 1,
+                                           win->_maxx + 1,
+                                           win->_begy,
+                                           win->_begx);
        }
 
        if (nwin != 0) {
index a94cfc3aaaa8512e464e13497c76c23d8fdfdee1..0f3ea72b7fb9cbc0c28fa8d80b21fa2f36c30943 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,7 +41,7 @@
 #include <curses.priv.h>
 #include <term.h>
 
-MODULE_ID("$Id: resizeterm.c,v 1.34 2008/06/07 13:58:40 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.35 2009/04/18 20:32:33 tom Exp $")
 
 #define stolen_lines (screen_lines - SP->_lines_avail)
 
@@ -68,7 +68,7 @@ show_window_sizes(const char *name)
 
     _nc_lock_global(curses);
     _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
-           screen_lines, screen_columns);
+           screen_lines(CURRENT_SCREEN), screen_columns(CURRENT_SCREEN));
     for (each_window(wp)) {
        _tracef("  window %p is %2ld x %2ld at %2ld,%2ld",
                &(wp->win),
@@ -91,8 +91,8 @@ is_term_resized(int ToLines, int ToCols)
     T((T_CALLED("is_term_resized(%d, %d)"), ToLines, ToCols));
     returnCode(ToLines > 0
               && ToCols > 0
-              && (ToLines != screen_lines
-                  || ToCols != screen_columns));
+              && (ToLines != screen_lines(CURRENT_SCREEN)
+                  || ToCols != screen_columns(CURRENT_SCREEN)));
 }
 
 /*
@@ -314,7 +314,7 @@ resize_term(int ToLines, int ToCols)
 
     T((T_CALLED("resize_term(%d,%d) old(%d,%d)"),
        ToLines, ToCols,
-       screen_lines, screen_columns));
+       screen_lines(CURRENT_SCREEN), screen_columns(CURRENT_SCREEN)));
 
     if (SP == 0) {
        returnCode(ERR);
@@ -322,10 +322,10 @@ resize_term(int ToLines, int ToCols)
 
     _nc_lock_global(curses);
 
-    was_stolen = (screen_lines - SP->_lines_avail);
+    was_stolen = (screen_lines(CURRENT_SCREEN) - SP->_lines_avail);
     if (is_term_resized(ToLines, ToCols)) {
-       int myLines = CurLines = screen_lines;
-       int myCols = CurCols = screen_columns;
+       int myLines = CurLines = screen_lines(CURRENT_SCREEN);
+       int myCols = CurCols = screen_columns(CURRENT_SCREEN);
 
 #ifdef TRACE
        if (USE_TRACEF(TRACE_UPDATE)) {
@@ -333,13 +333,13 @@ resize_term(int ToLines, int ToCols)
            _nc_unlock_global(tracef);
        }
 #endif
-       if (ToLines > screen_lines) {
+       if (ToLines > screen_lines(CURRENT_SCREEN)) {
            increase_size(myLines = ToLines, myCols, was_stolen EXTRA_ARGS);
            CurLines = myLines;
            CurCols = myCols;
        }
 
-       if (ToCols > screen_columns) {
+       if (ToCols > screen_columns(CURRENT_SCREEN)) {
            increase_size(myLines, myCols = ToCols, was_stolen EXTRA_ARGS);
            CurLines = myLines;
            CurCols = myCols;
@@ -350,8 +350,8 @@ resize_term(int ToLines, int ToCols)
            decrease_size(ToLines, ToCols, was_stolen EXTRA_ARGS);
        }
 
-       screen_lines = lines = ToLines;
-       screen_columns = columns = ToCols;
+       screen_lines(CURRENT_SCREEN) = lines = ToLines;
+       screen_columns(CURRENT_SCREEN) = columns = ToCols;
 
        SP->_lines_avail = lines - was_stolen;
 
@@ -398,7 +398,7 @@ resizeterm(int ToLines, int ToCols)
 
     T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"),
        ToLines, ToCols,
-       screen_lines, screen_columns));
+       screen_lines(CURRENT_SCREEN), screen_columns(CURRENT_SCREEN)));
 
     if (SP != 0) {
        result = OK;
@@ -418,7 +418,7 @@ resizeterm(int ToLines, int ToCols)
            result = resize_term(ToLines, ToCols);
 
 #if USE_SIGWINCH
-           _nc_ungetch(SP, KEY_RESIZE);        /* so application can know this */
+           safe_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
index 8935b1e08ffbe7f56b7aaadf176e1b30e06a8089..283b3291081d4b54894688608454a12c2b19317b 100644 (file)
@@ -33,7 +33,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: safe_sprintf.c,v 1.21 2009/03/28 20:44:12 tom Exp $")
+MODULE_ID("$Id: safe_sprintf.c,v 1.22 2009/04/18 18:46:46 tom Exp $")
 
 #if USE_SAFE_SPRINTF
 
@@ -214,7 +214,9 @@ _nc_printf_length(const char *fmt, va_list ap)
  * Wrapper for vsprintf that allocates a buffer big enough to hold the result.
  */
 NCURSES_EXPORT(char *)
-_nc_printf_string(const char *fmt, va_list ap)
+NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
+                                   const char *fmt,
+                                   va_list ap)
 {
     char *result = 0;
 
@@ -237,11 +239,11 @@ _nc_printf_string(const char *fmt, va_list ap)
 #define MyCols _nc_globals.safeprint_cols
 #define MyRows _nc_globals.safeprint_rows
 
-       if (screen_lines > MyRows || screen_columns > MyCols) {
-           if (screen_lines > MyRows)
-               MyRows = screen_lines;
-           if (screen_columns > MyCols)
-               MyCols = screen_columns;
+       if (screen_lines(SP_PARM) > MyRows || screen_columns(SP_PARM) > MyCols) {
+           if (screen_lines(SP_PARM) > MyRows)
+               MyRows = screen_lines(SP_PARM);
+           if (screen_columns(SP_PARM) > MyCols)
+               MyCols = screen_columns(SP_PARM);
            my_length = (MyRows * (MyCols + 1)) + 1;
            my_buffer = typeRealloc(char, my_length, my_buffer);
        }
@@ -262,3 +264,11 @@ _nc_printf_string(const char *fmt, va_list ap)
     }
     return result;
 }
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(char *)
+_nc_printf_string(const char *fmt, va_list ap)
+{
+    return NCURSES_SP_NAME(_nc_printf_string) (CURRENT_SCREEN, fmt, ap);
+}
+#endif
index 95f66529bdab3d7d7a7a333b0fa1490443896ccb..0903813e76c22aafcd49d98a61d0fa317abec65a 100644 (file)
@@ -35,7 +35,7 @@
 
 
 /*
- * $Id: curses.priv.h,v 1.403 2009/02/28 20:55:48 tom Exp $
+ * $Id: curses.priv.h,v 1.407 2009/04/18 23:42:28 tom Exp $
  *
  *     curses.priv.h
  *
@@ -333,17 +333,17 @@ extern NCURSES_EXPORT(void)     _nc_set_no_padding(SCREEN *);
 #define SET_SCREEN_PAIR(s,p)   SetPair(SCREEN_ATTRS(s), p)
 
 #if USE_REENTRANT
-NCURSES_EXPORT(int *) _nc_ptr_Lines (void);
-NCURSES_EXPORT(int *) _nc_ptr_Cols (void);
-#define ptrLines() (SP ? &(SP->_LINES) : &(_nc_prescreen._LINES))
-#define ptrCols()  (SP ? &(SP->_COLS)  : &(_nc_prescreen._COLS))
-#define SET_LINES(value) *_nc_ptr_Lines() = value
-#define SET_COLS(value)  *_nc_ptr_Cols() = value
+NCURSES_EXPORT(int *)        _nc_ptr_Lines (void);
+NCURSES_EXPORT(int *)        _nc_ptr_Cols (void);
+#define ptrLines(sp)         (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES))
+#define ptrCols(sp)          (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS))
+#define SET_LINES(value)     *_nc_ptr_Lines() = value
+#define SET_COLS(value)      *_nc_ptr_Cols() = value
 #else
-#define ptrLines() &LINES
-#define ptrCols()  &COLS
-#define SET_LINES(value) LINES = value
-#define SET_COLS(value)  COLS = value
+#define ptrLines(sp)         &LINES
+#define ptrCols(sp)          &COLS
+#define SET_LINES(value)     LINES = value
+#define SET_COLS(value)      COLS = value
 #endif
 
 #define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \
@@ -526,10 +526,10 @@ typedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int);
 typedef int (*TYPE_Gpm_Close) (void);
 typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
 
-#define my_gpm_fd       SP->_mouse_gpm_fd
-#define my_Gpm_Open     SP->_mouse_Gpm_Open
-#define my_Gpm_Close    SP->_mouse_Gpm_Close
-#define my_Gpm_GetEvent SP->_mouse_Gpm_GetEvent
+#define my_gpm_fd       SP_PARM->_mouse_gpm_fd
+#define my_Gpm_Open     SP_PARM->_mouse_Gpm_Open
+#define my_Gpm_Close    SP_PARM->_mouse_Gpm_Close
+#define my_Gpm_GetEvent SP_PARM->_mouse_Gpm_GetEvent
 #else
 /* link statically to GPM */
 #define my_gpm_fd       &gpm_fd
@@ -980,6 +980,20 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
 #define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
 
+#define SP_PRE_INIT(sp)                         \
+    sp->_cursrow = -1;                          \
+    sp->_curscol = -1;                          \
+    sp->_nl = TRUE;                             \
+    sp->_raw = FALSE;                           \
+    sp->_cbreak = 0;                            \
+    sp->_echo = TRUE;                           \
+    sp->_fifohead = -1;                         \
+    sp->_endwin = TRUE;                         \
+    sp->_cursor = -1;                           \
+    sp->_windowlist = 0;                        \
+    sp->_outch = NCURSES_SP_NAME(_nc_outch);    \
+    sp->jump = 0                                \
+
 /* usually in <limits.h> */
 #ifndef UCHAR_MAX
 #define UCHAR_MAX 255
@@ -1576,9 +1590,6 @@ extern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *);
 #define _nc_handle_sigwinch(a) /* nothing */
 #endif
 
-/* lib_ungetch.c */
-extern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int);
-
 /* lib_wacs.c */
 #if USE_WIDEC_SUPPORT
 extern NCURSES_EXPORT(void) _nc_init_wacs(void);
@@ -1615,7 +1626,6 @@ extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *);
 /* elsewhere ... */
 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);
@@ -1722,13 +1732,15 @@ extern NCURSES_EXPORT_VAR(SCREEN *) SP;
 
 #define CURRENT_SCREEN SP
 
+#define CURRENT_SCREEN_PRE      (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr())
+
 /*
  * We don't want to use the lines or columns capabilities internally, because
  * if the application is running multiple screens under X, it's quite possible
  * they could all have type xterm but have different sizes!  So...
  */
-#define screen_lines   SP->_lines
-#define screen_columns SP->_columns
+#define screen_lines(sp)       (sp)->_lines
+#define screen_columns(sp)     (sp)->_columns
 
 extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
 
@@ -1763,6 +1775,10 @@ extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int));
 #define TW_ANY     (TW_INPUT | TW_MOUSE)
 #define TW_EVENT   4
 
+#define IsTermInfo(sp) TRUE
+#define HasTInfoTerminal(sp) ((0!=TerminalOf(sp)) && IsTermInfo(sp))
+#define IsValidTIScreen(sp)  (HasTInfoTerminal(sp))
+
 /*
  * Exported entrypoints beyond the published API
  */
@@ -1794,18 +1810,30 @@ extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_scr_restore)(SCREEN*, const
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_scr_init)(SCREEN*,const char*);
 
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_restartterm)(SCREEN*,NCURSES_CONST char*,int,int*);
+extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int));
 extern NCURSES_EXPORT(bool)     NCURSES_SP_NAME(_nc_is_term_resized)(SCREEN*,int,int);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_resize_term)(SCREEN*,int,int);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_resizeterm)(SCREEN*,int,int);
 
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(_nc_outch)(SCREEN*, int ch);
+extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(_nc_outch)(SCREEN*, int);
 extern NCURSES_EXPORT(void)    NCURSES_SP_NAME(_nc_flush)(SCREEN*);
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_freeall)(SCREEN*);
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int);
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_hash_map)(SCREEN*);
+extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int);
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_make_oldhash)(SCREEN*, int i);
+extern NCURSES_EXPORT(char *)   NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list);
 extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char *);
 extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const char *, const char *);
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_set_buffer)(SCREEN*, FILE *, bool);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_tputs)(SCREEN*,const char*,int,int(*)(SCREEN*, int));
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_savetty)(SCREEN*);
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_screen_wrap)(SCREEN*);
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_resetty)(SCREEN*);
+extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int);
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_scroll_oldhash)(SCREEN*, int n, int top, int bot);
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_scroll_optimize)(SCREEN*);
 
 extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_mcprint)(SCREEN*,char*, int);
 extern NCURSES_EXPORT(char *)   NCURSES_SP_NAME(_nc_tgetstr)(SCREEN*,NCURSES_CONST char*,char**);
@@ -1817,6 +1845,11 @@ extern NCURSES_EXPORT(char *)   NCURSES_SP_NAME(_nc_tigetstr)(SCREEN*, NCURSES_C
 extern NCURSES_EXPORT(void)     _nc_cookie_init(SCREEN *sp);
 extern NCURSES_EXPORT(int)      _nc_tinfo_doupdate(SCREEN *sp);
 extern NCURSES_EXPORT(int)      _nc_tinfo_mcprint(SCREEN*,char*,int);
+
+#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
+extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_linedump)(SCREEN*);
+#endif
+
 #if USE_WIDEC_SUPPORT
 extern NCURSES_EXPORT(wchar_t *) NCURSES_SP_NAME(_nc_wunctrl)(SCREEN*, cchar_t *);
 #endif
@@ -1829,6 +1862,23 @@ extern NCURSES_EXPORT(int)       NCURSES_SP_NAME(mouseinterval) (SCREEN*, int);
 extern NCURSES_EXPORT(bool)    NCURSES_SP_NAME(has_mouse) (SCREEN*);
 #endif /* NCURSES_SP_FUNCS */
 
+#if NCURSES_SP_FUNCS
+
+#define safe_keyname NCURSES_SP_NAME(keyname)
+#define safe_unctrl  NCURSES_SP_NAME(unctrl)
+#define safe_ungetch NCURSES_SP_NAME(ungetch)
+
+#else
+
+#define safe_keyname _nc_keyname
+#define safe_unctrl  _nc_unctrl
+#define safe_ungetch _nc_ungetch
+
+extern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int);
+extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
+
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 9feab3507cc0ecb288dc261b8953fcdfe6c94a26..6172c54d88b99f49c6b554e57b03e2c81250ed3b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright (c) 1998-2001,2006 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.                #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -26,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKfallback.sh,v 1.13 2006/07/15 16:54:20 tom Exp $
+# $Id: MKfallback.sh,v 1.14 2009/04/18 21:01:38 tom Exp $
 #
 # MKfallback.sh -- create fallback table for entry reads
 #
@@ -63,7 +63,6 @@ cat <<EOF
  */
 
 #include <curses.priv.h>
-#include <term.h>
 
 EOF
 
index b2b06d1b79ce7a347860dc6c93bb1121c73b103e..0d147ead7bd88f37afd778002c555fa52abfc949 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999-2006,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +43,7 @@
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: alloc_ttype.c,v 1.17 2008/10/12 16:12:00 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.18 2009/04/18 21:01:38 tom Exp $")
 
 #if NCURSES_XNAMES
 /*
@@ -147,10 +147,10 @@ realign_data(TERMTYPE *to, char **ext_Names,
 /*
  * Returns the first index in ext_Names[] for the given token-type
  */
-static int
+static unsigned
 _nc_first_ext_name(TERMTYPE *tp, int token_type)
 {
-    int first;
+    unsigned first;
 
     switch (token_type) {
     case BOOLEAN:
@@ -160,7 +160,7 @@ _nc_first_ext_name(TERMTYPE *tp, int token_type)
        first = tp->ext_Booleans;
        break;
     case STRING:
-       first = tp->ext_Booleans + tp->ext_Numbers;
+       first = (unsigned) (tp->ext_Booleans + tp->ext_Numbers);
        break;
     default:
        first = 0;
@@ -172,17 +172,17 @@ _nc_first_ext_name(TERMTYPE *tp, int token_type)
 /*
  * Returns the last index in ext_Names[] for the given token-type
  */
-static int
+static unsigned
 _nc_last_ext_name(TERMTYPE *tp, int token_type)
 {
-    int last;
+    unsigned last;
 
     switch (token_type) {
     case BOOLEAN:
        last = tp->ext_Booleans;
        break;
     case NUMBER:
-       last = tp->ext_Booleans + tp->ext_Numbers;
+       last = (unsigned) (tp->ext_Booleans + tp->ext_Numbers);
        break;
     default:
     case STRING:
@@ -204,7 +204,7 @@ _nc_find_ext_name(TERMTYPE *tp, char *name, int token_type)
 
     for (j = first; j < last; j++) {
        if (!strcmp(name, tp->ext_Names[j])) {
-           return j;
+           return (int) j;
        }
     }
     return -1;
@@ -244,7 +244,7 @@ _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
     int first, last;
 
     if ((first = _nc_find_ext_name(tp, name, token_type)) >= 0) {
-       last = NUM_EXT_NAMES(tp) - 1;
+       last = (int) NUM_EXT_NAMES(tp) - 1;
        for (j = first; j < last; j++) {
            tp->ext_Names[j] = tp->ext_Names[j + 1];
        }
@@ -254,22 +254,22 @@ _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
            last = tp->num_Booleans - 1;
            for (j = first; j < last; j++)
                tp->Booleans[j] = tp->Booleans[j + 1];
-           tp->ext_Booleans -= 1;
-           tp->num_Booleans -= 1;
+           tp->ext_Booleans--;
+           tp->num_Booleans--;
            break;
        case NUMBER:
            last = tp->num_Numbers - 1;
            for (j = first; j < last; j++)
                tp->Numbers[j] = tp->Numbers[j + 1];
-           tp->ext_Numbers -= 1;
-           tp->num_Numbers -= 1;
+           tp->ext_Numbers--;
+           tp->num_Numbers--;
            break;
        case STRING:
            last = tp->num_Strings - 1;
            for (j = first; j < last; j++)
                tp->Strings[j] = tp->Strings[j + 1];
-           tp->ext_Strings -= 1;
-           tp->num_Strings -= 1;
+           tp->ext_Strings--;
+           tp->num_Strings--;
            break;
        }
        return TRUE;
@@ -307,22 +307,22 @@ _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
 
     switch (token_type) {
     case BOOLEAN:
-       tp->ext_Booleans += 1;
-       tp->num_Booleans += 1;
+       tp->ext_Booleans++;
+       tp->num_Booleans++;
        tp->Booleans = typeRealloc(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans);
        for (k = tp->num_Booleans - 1; k > j; k--)
            tp->Booleans[k] = tp->Booleans[k - 1];
        break;
     case NUMBER:
-       tp->ext_Numbers += 1;
-       tp->num_Numbers += 1;
+       tp->ext_Numbers++;
+       tp->num_Numbers++;
        tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
        for (k = tp->num_Numbers - 1; k > j; k--)
            tp->Numbers[k] = tp->Numbers[k - 1];
        break;
     case STRING:
-       tp->ext_Strings += 1;
-       tp->num_Strings += 1;
+       tp->ext_Strings++;
+       tp->num_Strings++;
        tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
        for (k = tp->num_Strings - 1; k > j; k--)
            tp->Strings[k] = tp->Strings[k - 1];
@@ -345,7 +345,7 @@ adjust_cancels(TERMTYPE *to, TERMTYPE *from)
 
     for (j = first; j < last;) {
        char *name = to->ext_Names[j];
-       unsigned j_str = to->num_Strings - first - to->ext_Strings;
+       int j_str = to->num_Strings - first - to->ext_Strings;
 
        if (to->Strings[j + j_str] == CANCELLED_STRING) {
            if ((k = _nc_find_ext_name(from, to->ext_Names[j], BOOLEAN)) >= 0) {
index 2f6fe4f6fad791972a16f5f79669b6162b3ad085..9fbb5d1ed84fb90e3c19cc43ab5ce77a8cbf3dfb 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999-2006,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  ****************************************************************************/
 
 #include <curses.priv.h>
-
-#include <term.h>
-/* keypad_xmit, keypad_local, meta_on, meta_off */
-/* cursor_visible,cursor_normal,cursor_invisible */
-
 #include <tic.h>               /* struct tinfo_fkeys */
 
 #include <term_entry.h>
 
-MODULE_ID("$Id: init_keytry.c,v 1.12 2008/05/24 21:44:51 tom Exp $")
+MODULE_ID("$Id: init_keytry.c,v 1.13 2009/04/18 18:53:37 tom Exp $")
 
 /*
 **      _nc_init_keytry()
@@ -102,7 +97,8 @@ _nc_init_keytry(SCREEN *sp)
                if (name != 0
                    && *name == 'k'
                    && value != 0
-                   && key_defined(value) == 0) {
+                   && NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx
+                                                    value) == 0) {
                    (void) _nc_add_to_try(&(sp->_keytry),
                                          value,
                                          n - STRCOUNT + KEY_MAX);
index e1dd2ceea09b6ed3b877c623f4a2eb2156a643a3..5dc53fca9b001fc87ec2b0fe5ecc9b20eec71c35 100644 (file)
@@ -40,7 +40,7 @@
 #include <term_entry.h>                /* TTY, cur_term */
 #include <termcap.h>           /* ospeed */
 
-MODULE_ID("$Id: lib_cur_term.c,v 1.20 2009/03/14 14:39:32 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.21 2009/04/18 21:02:22 tom Exp $")
 
 #undef CUR
 #define CUR termp->type.
@@ -88,7 +88,7 @@ set_curterm(TERMINAL * termp)
 }
 
 NCURSES_EXPORT(int)
-del_curterm(TERMINAL * termp)
+NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL * termp)
 {
     int rc = ERR;
 
@@ -107,3 +107,13 @@ del_curterm(TERMINAL * termp)
 
     returnCode(rc);
 }
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+del_curterm(TERMINAL * termp)
+{
+    int rc = ERR;
+    rc = NCURSES_SP_NAME(del_curterm) (CURRENT_SCREEN, termp);
+    return (rc);
+}
+#endif
index a501453f2f79d1423568d768c1746d97712ce823..546ba605c33ba5ab8fded303f5366def077b3c15 100644 (file)
 
 #include <curses.priv.h>
 
-#include <term.h>
-
-MODULE_ID("$Id: lib_has_cap.c,v 1.5 2009/02/15 00:47:12 tom Exp $")
+MODULE_ID("$Id: lib_has_cap.c,v 1.6 2009/04/18 17:28:45 tom Exp $")
 
 NCURSES_EXPORT(bool)
 NCURSES_SP_NAME(has_ic) (NCURSES_SP_DCL0)
 {
-    T((T_CALLED("has_ic()")));
-    returnCode(cur_term &&
-              (insert_character || parm_ich
-               || (enter_insert_mode && exit_insert_mode))
-              && (delete_character || parm_dch));
+    bool code = FALSE;
+
+    T((T_CALLED("has_ic(%p)"), SP_PARM));
+
+    if (IsValidTIScreen(SP_PARM) && IsTermInfo(SP_PARM)) {
+       code = ((insert_character || parm_ich
+                || (enter_insert_mode && exit_insert_mode))
+               && (delete_character || parm_dch)) ? TRUE : FALSE;
+    }
+
+    returnCode(code);
 }
 
 #if NCURSES_SP_FUNCS
@@ -67,10 +71,14 @@ has_ic(void)
 NCURSES_EXPORT(bool)
 NCURSES_SP_NAME(has_il) (NCURSES_SP_DCL0)
 {
-    T((T_CALLED("has_il()")));
-    returnCode(cur_term
-              && (insert_line || parm_insert_line)
-              && (delete_line || parm_delete_line));
+    bool code = FALSE;
+    T((T_CALLED("has_il(%p)"), SP_PARM));
+    if (IsValidTIScreen(SP_PARM) && IsTermInfo(SP_PARM)) {
+       code = ((insert_line || parm_insert_line)
+               && (delete_line || parm_delete_line)) ? TRUE : FALSE;
+    }
+
+    returnCode(code);
 }
 
 #if NCURSES_SP_FUNCS
index eb8dff76e99a3cdb09582f1059736fd4d162d3fd..9968083c9ff10cb91448ff480696ced5d4318a63 100644 (file)
@@ -54,7 +54,7 @@
 
 #include <term.h>              /* lines, columns, cur_term */
 
-MODULE_ID("$Id: lib_setup.c,v 1.113 2009/02/14 22:21:40 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.114 2009/04/18 23:52:03 tom Exp $")
 
 /****************************************************************************
  *
@@ -119,7 +119,7 @@ NCURSES_PUBLIC_VAR(ttytype) (void)
 NCURSES_EXPORT(int *)
 _nc_ptr_Lines(void)
 {
-    return ptrLines();
+    return ptrLines(CURRENT_SCREEN);
 }
 NCURSES_EXPORT(int)
 NCURSES_PUBLIC_VAR(LINES) (void)
@@ -129,7 +129,7 @@ NCURSES_PUBLIC_VAR(LINES) (void)
 NCURSES_EXPORT(int *)
 _nc_ptr_Cols(void)
 {
-    return ptrCols();
+    return ptrCols(CURRENT_SCREEN);
 }
 NCURSES_EXPORT(int)
 NCURSES_PUBLIC_VAR(COLS) (void)
@@ -626,7 +626,7 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
     /*
      * We should always check the screensize, just in case.
      */
-    _nc_get_screensize(SP, ptrLines(), ptrCols());
+    _nc_get_screensize(SP, ptrLines(SP), ptrCols(SP));
 
     if (errret)
        *errret = TGETENT_YES;
index cf7a5f409d7c372dc689e3abf9d4a843c7d6553f..cfa7b356eebaea04a8b203f2621a7806186dc22a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -48,7 +48,7 @@
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: parse_entry.c,v 1.69 2008/08/16 21:52:03 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.70 2009/04/18 21:01:38 tom Exp $")
 
 #ifdef LINT
 static short const parametrized[] =
@@ -84,13 +84,13 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
     case NUMBER:
        first = tp->ext_Booleans;
        last = tp->ext_Numbers + first;
-       offset = tp->ext_Booleans + tp->ext_Numbers;
+       offset = (unsigned) (tp->ext_Booleans + tp->ext_Numbers);
        tindex = tp->num_Numbers;
        break;
     case STRING:
-       first = tp->ext_Booleans + tp->ext_Numbers;
+       first = (unsigned) (tp->ext_Booleans + tp->ext_Numbers);
        last = tp->ext_Strings + first;
-       offset = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
+       offset = (unsigned) (tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings);
        tindex = tp->num_Strings;
        break;
     case CANCEL:
@@ -137,27 +137,31 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
            break;
        }
     }
+
+#define for_each_value(max) \
+       for (last = (unsigned) (max - 1); last > tindex; last--)
+
     if (!found) {
        switch (token_type) {
        case BOOLEAN:
-           tp->ext_Booleans += 1;
-           tp->num_Booleans += 1;
+           tp->ext_Booleans++;
+           tp->num_Booleans++;
            tp->Booleans = typeRealloc(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans);
-           for (last = tp->num_Booleans - 1; last > tindex; last--)
+           for_each_value(tp->num_Booleans)
                tp->Booleans[last] = tp->Booleans[last - 1];
            break;
        case NUMBER:
-           tp->ext_Numbers += 1;
-           tp->num_Numbers += 1;
+           tp->ext_Numbers++;
+           tp->num_Numbers++;
            tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
-           for (last = tp->num_Numbers - 1; last > tindex; last--)
+           for_each_value(tp->num_Numbers)
                tp->Numbers[last] = tp->Numbers[last - 1];
            break;
        case STRING:
-           tp->ext_Strings += 1;
-           tp->num_Strings += 1;
+           tp->ext_Strings++;
+           tp->num_Strings++;
            tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
-           for (last = tp->num_Strings - 1; last > tindex; last--)
+           for_each_value(tp->num_Strings)
                tp->Strings[last] = tp->Strings[last - 1];
            break;
        }
@@ -170,7 +174,7 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
 
     temp.nte_name = tp->ext_Names[offset];
     temp.nte_type = token_type;
-    temp.nte_index = tindex;
+    temp.nte_index = (short) tindex;
     temp.nte_link = -1;
 
     return &temp;
@@ -444,7 +448,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
 
            case NUMBER:
                entryp->tterm.Numbers[entry_ptr->nte_index] =
-                   _nc_curr_token.tk_valnumber;
+                   (short) _nc_curr_token.tk_valnumber;
                break;
 
            case STRING:
@@ -788,7 +792,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
        for (base = other_non_function_keys;
             (cp = strchr(base, ',')) != 0;
             base = cp + 1) {
-           size_t len = cp - base;
+           size_t len = (unsigned) (cp - base);
 
            for (ap = ko_xlate; ap->from; ap++) {
                if (len == strlen(ap->from)
index b53bb210230d7070b821f85b4c838c4283a09bca..a89da90531a8876ade785b12091c326fe1397327 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -54,7 +54,7 @@
 #define TRACE_OUT(p)           /*nothing */
 #endif
 
-MODULE_ID("$Id: write_entry.c,v 1.72 2008/08/03 19:24:00 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.73 2009/04/18 21:01:38 tom Exp $")
 
 static int total_written;
 
@@ -171,7 +171,11 @@ make_db_root(const char *path)
        struct stat statbuf;
 
        if ((rc = stat(path, &statbuf)) < 0) {
-           rc = mkdir(path, 0777);
+           rc = mkdir(path
+#if !defined(__MINGW32__)
+                      ,0777
+#endif
+               );
        } else if (_nc_access(path, R_OK | W_OK | X_OK) < 0) {
            rc = -1;            /* permission denied */
        } else if (!(S_ISDIR(statbuf.st_mode))) {
@@ -338,6 +342,7 @@ _nc_write_entry(TERMTYPE *const tp)
 
            while (*other_names != '\0') {
                ptr = other_names++;
+               assert(ptr < buffer + sizeof(buffer) - 1);
                while (*other_names != '|' && *other_names != '\0')
                    other_names++;
 
@@ -385,7 +390,6 @@ _nc_write_entry(TERMTYPE *const tp)
     }
     while (*other_names != '\0') {
        ptr = other_names++;
-       assert(ptr < buffer + sizeof(buffer) - 1);
        while (*other_names != '|' && *other_names != '\0')
            other_names++;
 
@@ -468,18 +472,18 @@ fake_write(char *dst,
           unsigned want,
           unsigned size)
 {
-    int have = (limit - *offset);
+    unsigned have = (limit - *offset);
 
     want *= size;
     if (have > 0) {
-       if ((int) want > have)
+       if (want > have)
            want = have;
        memcpy(dst + *offset, src, want);
        *offset += want;
     } else {
        want = 0;
     }
-    return (int) (want / size);
+    return (want / size);
 }
 
 #define Write(buf, size, count) fake_write(buffer, offset, limit, (char *) buf, count, size)
@@ -487,14 +491,15 @@ fake_write(char *dst,
 #undef LITTLE_ENDIAN           /* BSD/OS defines this as a feature macro */
 #define HI(x)                  ((x) / 256)
 #define LO(x)                  ((x) % 256)
-#define LITTLE_ENDIAN(p, x)    (p)[0] = LO(x), (p)[1] = HI(x)
+#define LITTLE_ENDIAN(p, x)    (p)[0] = (unsigned char)LO(x),  \
+                                (p)[1] = (unsigned char)HI(x)
 
 #define WRITE_STRING(str) (Write(str, sizeof(char), strlen(str) + 1) == strlen(str) + 1)
 
 static int
 compute_offsets(char **Strings, unsigned strmax, short *offsets)
 {
-    size_t nextfree = 0;
+    int nextfree = 0;
     unsigned i;
 
     for (i = 0; i < strmax; i++) {
@@ -503,8 +508,8 @@ compute_offsets(char **Strings, unsigned strmax, short *offsets)
        } else if (Strings[i] == CANCELLED_STRING) {
            offsets[i] = -2;
        } else {
-           offsets[i] = nextfree;
-           nextfree += strlen(Strings[i]) + 1;
+           offsets[i] = (short) nextfree;
+           nextfree += (int) strlen(Strings[i]) + 1;
            TRACE_OUT(("put Strings[%d]=%s(%d)", (int) i,
                       _nc_visbuf(Strings[i]), (int) nextfree));
        }
@@ -536,8 +541,8 @@ convert_shorts(unsigned char *buf, short *Numbers, unsigned count)
 static unsigned
 extended_Booleans(TERMTYPE *tp)
 {
-    unsigned short result = 0;
-    unsigned short i;
+    unsigned result = 0;
+    unsigned i;
 
     for (i = 0; i < tp->ext_Booleans; ++i) {
        if (tp->Booleans[BOOLCOUNT + i] == TRUE)
@@ -549,8 +554,8 @@ extended_Booleans(TERMTYPE *tp)
 static unsigned
 extended_Numbers(TERMTYPE *tp)
 {
-    unsigned short result = 0;
-    unsigned short i;
+    unsigned result = 0;
+    unsigned i;
 
     for (i = 0; i < tp->ext_Numbers; ++i) {
        if (tp->Numbers[NUMCOUNT + i] != ABSENT_NUMERIC)
@@ -597,7 +602,7 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
     size_t namelen, boolmax, nummax, strmax;
     char zero = '\0';
     size_t i;
-    short nextfree;
+    int nextfree;
     short offsets[MAX_ENTRY_SIZE / 2];
     unsigned char buf[MAX_ENTRY_SIZE];
     unsigned last_bool = BOOLWRITE;
@@ -690,7 +695,7 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
 
 #if NCURSES_XNAMES
     if (extended_object(tp)) {
-       unsigned extcnt = NUM_EXT_NAMES(tp);
+       unsigned extcnt = (unsigned) NUM_EXT_NAMES(tp);
 
        if (even_boundary(nextfree))
            return (ERR);
index 50920f2405e8342c92efc254206501b8c37c1c6b..368ecd7967278525c53635057a807c8d0d655a8f 100644 (file)
@@ -38,9 +38,8 @@
  */
 
 #include <curses.priv.h>
-#include <term.h>              /* acs_chars */
 
-MODULE_ID("$Id: lib_traceatr.c,v 1.64 2009/02/28 21:10:20 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.65 2009/04/18 18:06:31 tom Exp $")
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
@@ -187,6 +186,9 @@ _nc_altcharset_name(attr_t attr, chtype ch)
        unsigned int val;
        const char *name;
     } ALT_NAMES;
+#if NCURSES_SP_FUNCS
+    SCREEN *sp = CURRENT_SCREEN;
+#endif
     static const ALT_NAMES names[] =
     {
        {'l', "ACS_ULCORNER"},  /* upper left corner */
@@ -261,8 +263,9 @@ _tracechtype2(int bufnum, chtype ch)
        if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
            (void) _nc_trace_bufcat(bufnum, found);
        } else
-           (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN,
-                                   (int) ChCharOf(ch)));
+           (void) _nc_trace_bufcat(bufnum,
+                                   _nc_tracechar(CURRENT_SCREEN,
+                                                 (int) ChCharOf(ch)));
 
        if (ChAttrOf(ch) != A_NORMAL) {
            (void) _nc_trace_bufcat(bufnum, " | ");
index 79cf03b4870cfb96e4f88dac050648b2be7eec24..a1f9f5aa27069bdb8b22e5e3d3b8a9e3922e9b56 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +39,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracechr.c,v 1.19 2008/08/03 15:39:29 tom Exp $")
+MODULE_ID("$Id: lib_tracechr.c,v 1.20 2009/04/18 22:48:29 tom Exp $")
 
 #ifdef TRACE
 
@@ -52,7 +52,7 @@ _nc_tracechar(SCREEN *sp, int ch)
                      : _nc_globals.tracechr_buf);
 
     if (ch > KEY_MIN || ch < 0) {
-       name = _nc_keyname(sp, ch);
+       name = safe_keyname(SP_PARM, ch);
        if (name == 0 || *name == '\0')
            name = "NULL";
        (void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch);
@@ -64,7 +64,7 @@ _nc_tracechar(SCREEN *sp, int ch)
         */
        (void) sprintf(MyBuffer, "%#03o", ch);
     } else {
-       name = _nc_unctrl(sp, (chtype) ch);
+       name = safe_unctrl(SP_PARM, (chtype) ch);
        if (name == 0 || *name == 0)
            name = "null";      /* shouldn't happen */
        (void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch);
@@ -75,7 +75,7 @@ _nc_tracechar(SCREEN *sp, int ch)
 NCURSES_EXPORT(char *)
 _tracechar(int ch)
 {
-    return _nc_tracechar(SP, ch);
+    return _nc_tracechar(CURRENT_SCREEN, ch);
 }
 #else
 EMPTY_MODULE(_nc_lib_tracechr)
index 58732a06c24623397dabeddafe81410fa88ad726..c7fcbf2e0d56c7bc57208a719ec511110401d6dd 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +39,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracedmp.c,v 1.31 2008/08/16 19:30:56 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.32 2009/04/18 21:01:38 tom Exp $")
 
 #ifdef TRACE
 
@@ -68,7 +68,7 @@ _tracedump(const char *name, WINDOW *win)
     if (width < win->_maxx)
        ++width;
     if (++width + 1 > (int) my_length) {
-       my_length = 2 * (width + 1);
+       my_length = (unsigned) (2 * (width + 1));
        my_buffer = typeRealloc(char, my_length, my_buffer);
     }
 
@@ -82,7 +82,7 @@ _tracedump(const char *name, WINDOW *win)
         * we map those to '.' and '?' respectively.
         */
        for (j = 0; j < width; ++j) {
-           chtype test = CharOf(win->_line[n].text[j]);
+           chtype test = (chtype) CharOf(win->_line[n].text[j]);
            ep[j] = (char) ((UChar(test) == test
 #if USE_WIDEC_SUPPORT
                             && (win->_line[n].text[j].chars[1] == 0)
@@ -111,7 +111,7 @@ _tracedump(const char *name, WINDOW *win)
            if (multicolumn) {
                ep = my_buffer;
                for (j = 0; j < width; ++j) {
-                   int test = WidecExt(win->_line[n].text[j]);
+                   chtype test = WidecExt(win->_line[n].text[j]);
                    if (test) {
                        ep[j] = (char) (test + '0');
                    } else {
@@ -153,7 +153,7 @@ _tracedump(const char *name, WINDOW *win)
 
        for (i = 0; i < 4; ++i) {
            const char *hex = " 123456789ABCDEF";
-           attr_t mask = (0xf << ((i + 4) * 4));
+           attr_t mask = (attr_t) (0xf << ((i + 4) * 4));
 
            haveattrs = FALSE;
            for (j = 0; j < width; ++j)
index 2c40997fb6b1c090f5932458b2e72736f61d1b78..af0b66c42b933c1527ba5e1d6c38c5133fbf7074 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -147,90 +147,96 @@ AUTHOR
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: hardscroll.c,v 1.42 2008/08/03 23:49:30 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.43 2009/04/18 21:41:30 tom Exp $")
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
 # undef screen_lines
-# define screen_lines MAXLINES
-NCURSES_EXPORT_VAR(int)
-oldnums[MAXLINES];
-# define OLDNUM(n)     oldnums[n]
+# define screen_lines(sp) MAXLINES
+NCURSES_EXPORT_VAR (int)
+  oldnums[MAXLINES];
+# define OLDNUM(sp,n)  oldnums[n]
 # define _tracef       printf
 # undef TR
 # define TR(n, a)      if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); }
 
-extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
+extern                         NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
 
 #else /* no debug */
 
 /* OLDNUM(n) indicates which line will be shifted to the position n.
    if OLDNUM(n) == _NEWINDEX, then the line n in new, not shifted from
    somewhere. */
-NCURSES_EXPORT_VAR(int *)
-_nc_oldnums = 0;               /* obsolete: keep for ABI compat */
+NCURSES_EXPORT_VAR (int *)
+  _nc_oldnums = 0;             /* obsolete: keep for ABI compat */
 
 # if USE_HASHMAP
-#  define oldnums       SP->_oldnum_list
-#  define OLDNUM(n)    oldnums[n]
+#  define oldnums(sp)   (sp)->_oldnum_list
+#  define OLDNUM(sp,n) oldnums(sp)[n]
 # else                         /* !USE_HASHMAP */
-#  define OLDNUM(n)    newscr->_line[n].oldindex
+#  define OLDNUM(sp,n) sp->_newscr->_line[n].oldindex
 # endif                                /* !USE_HASHMAP */
 
-#define OLDNUM_SIZE     SP->_oldnum_size
+#define OLDNUM_SIZE(sp) (sp)->_oldnum_size
 
 #endif /* defined(SCROLLDEBUG) || defined(HASHDEBUG) */
 
 NCURSES_EXPORT(void)
-_nc_scroll_optimize(void)
+NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_DCL0)
 /* scroll optimization to transform curscr to newscr */
 {
     int i;
     int start, end, shift;
 
-    TR(TRACE_ICALLS, (T_CALLED("_nc_scroll_optimize")));
+    TR(TRACE_ICALLS, (T_CALLED("_nc_scroll_optimize(%p)"), SP_PARM));
 
 #if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
 #if USE_HASHMAP
     /* get enough storage */
-    if (OLDNUM_SIZE < screen_lines) {
-       int *new_oldnums = typeRealloc(int, screen_lines, oldnums);
+    if (OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM)) {
+       int *new_oldnums = typeRealloc(int, screen_lines(SP_PARM), oldnums(SP_PARM));
        if (!new_oldnums)
            return;
-       oldnums = new_oldnums;
-       OLDNUM_SIZE = screen_lines;
+       oldnums(SP_PARM) = new_oldnums;
+       OLDNUM_SIZE(SP_PARM) = screen_lines(SP_PARM);
     }
     /* calculate the indices */
-    _nc_hash_map();
+    NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_ARG);
 #endif
 #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
 
 #ifdef TRACE
     if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) {
-       _nc_linedump();
+       NCURSES_SP_NAME(_nc_linedump) (NCURSES_SP_ARG);
        _nc_unlock_global(tracef);
     }
 #endif /* TRACE */
 
     /* pass 1 - from top to bottom scrolling up */
-    for (i = 0; i < screen_lines;) {
-       while (i < screen_lines && (OLDNUM(i) == _NEWINDEX || OLDNUM(i) <= i))
+    for (i = 0; i < screen_lines(SP_PARM);) {
+       while (i < screen_lines(SP_PARM)
+              && (OLDNUM(SP_PARM, i) == _NEWINDEX || OLDNUM(SP_PARM, i) <= i))
            i++;
-       if (i >= screen_lines)
+       if (i >= screen_lines(SP_PARM))
            break;
 
-       shift = OLDNUM(i) - i;  /* shift > 0 */
+       shift = OLDNUM(SP_PARM, i) - i;         /* shift > 0 */
        start = i;
 
        i++;
-       while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
-              == shift)
+       while (i < screen_lines(SP_PARM)
+              && OLDNUM(SP_PARM, i) != _NEWINDEX
+              && OLDNUM(SP_PARM, i) - i == shift)
            i++;
        end = i - 1 + shift;
 
        TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift));
 #if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
-       if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR) {
+       if (NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_ARGx
+                                         shift,
+                                         start,
+                                         end,
+                                         screen_lines(SP_PARM) - 1) == ERR) {
            TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll"));
            continue;
        }
@@ -238,23 +244,33 @@ _nc_scroll_optimize(void)
     }
 
     /* pass 2 - from bottom to top scrolling down */
-    for (i = screen_lines - 1; i >= 0;) {
-       while (i >= 0 && (OLDNUM(i) == _NEWINDEX || OLDNUM(i) >= i))
+    for (i = screen_lines(SP_PARM) - 1; i >= 0;) {
+       while (i >= 0
+              && (OLDNUM(SP_PARM, i) == _NEWINDEX
+                  || OLDNUM(SP_PARM, i) >= i)) {
            i--;
+       }
        if (i < 0)
            break;
 
-       shift = OLDNUM(i) - i;  /* shift < 0 */
+       shift = OLDNUM(SP_PARM, i) - i;         /* shift < 0 */
        end = i;
 
        i--;
-       while (i >= 0 && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift)
+       while (i >= 0
+              && OLDNUM(SP_PARM, i) != _NEWINDEX
+              && OLDNUM(SP_PARM, i) - i == shift) {
            i--;
+       }
        start = i + 1 - (-shift);
 
        TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift));
 #if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
-       if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR) {
+       if (NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_ARGx
+                                         shift,
+                                         start,
+                                         end,
+                                         screen_lines(SP_PARM) - 1) == ERR) {
            TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll"));
            continue;
        }
@@ -263,24 +279,41 @@ _nc_scroll_optimize(void)
     TR(TRACE_ICALLS, (T_RETURN("")));
 }
 
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+_nc_scroll_optimize(void)
+{
+    NCURSES_SP_NAME(_nc_scroll_optimize) (CURRENT_SCREEN);
+}
+#endif
+
 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
 NCURSES_EXPORT(void)
-_nc_linedump(void)
+NCURSES_SP_NAME(_nc_linedump) (NCURSES_SP_DCL0)
 /* dump the state of the real and virtual oldnum fields */
 {
     int n;
     char *buf = 0;
-    size_t want = (screen_lines + 1) * 4;
+    size_t want = (screen_lines(SP_PARM) + 1) * 4;
 
     if ((buf = typeMalloc(char, want)) != 0) {
 
        (void) strcpy(buf, "virt");
-       for (n = 0; n < screen_lines; n++)
-           (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
+       for (n = 0; n < screen_lines(SP_PARM); n++)
+           (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(SP_PARM, n));
        TR(TRACE_UPDATE | TRACE_MOVE, (buf));
        free(buf);
     }
 }
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+_nc_linedump(void)
+{
+    NCURSES_SP_NAME(_nc_linedump) (CURRENT_SCREEN);
+}
+#endif
+
 #endif /* defined(TRACE) || defined(SCROLLDEBUG) */
 
 #ifdef SCROLLDEBUG
index 9b60df62d5cfbd1941f38c933cd4da544c35e65e..05c379199c217f4aa513b1f8d4f1aef5ccc7ff95 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -68,9 +68,8 @@ AUTHOR
 *****************************************************************************/
 
 #include <curses.priv.h>
-#include <term.h>              /* for back_color_erase */
 
-MODULE_ID("$Id: hashmap.c,v 1.56 2007/10/13 18:47:25 Miroslav.Lichvar Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.57 2009/04/18 19:03:50 tom Exp $")
 
 #ifdef HASHDEBUG
 
@@ -83,25 +82,25 @@ MODULE_ID("$Id: hashmap.c,v 1.56 2007/10/13 18:47:25 Miroslav.Lichvar Exp $")
 int oldnums[MAXLINES], reallines[MAXLINES];
 static NCURSES_CH_T oldtext[MAXLINES][TEXTWIDTH];
 static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH];
-# define OLDNUM(n)     oldnums[n]
-# define OLDTEXT(n)    oldtext[n]
-# define NEWTEXT(m)    newtext[m]
-# define PENDING(n)     1
+# define OLDNUM(sp,n)  oldnums[n]
+# define OLDTEXT(sp,n) oldtext[n]
+# define NEWTEXT(sp,m) newtext[m]
+# define PENDING(sp,n)  1
 
 #else /* !HASHDEBUG */
 
-# define OLDNUM(n)     SP->_oldnum_list[n]
-# define OLDTEXT(n)    curscr->_line[n].text
-# define NEWTEXT(m)    newscr->_line[m].text
-# define TEXTWIDTH     (curscr->_maxx+1)
-# define PENDING(n)     (newscr->_line[n].firstchar != _NOCHANGE)
+# define OLDNUM(sp,n)  (sp)->_oldnum_list[n]
+# define OLDTEXT(sp,n) (sp)->_curscr->_line[n].text
+# define NEWTEXT(sp,m) (sp)->_newscr->_line[m].text
+# define TEXTWIDTH(sp) ((sp)->_curscr->_maxx+1)
+# define PENDING(sp,n)  ((sp)->_newscr->_line[n].firstchar != _NOCHANGE)
 
 #endif /* !HASHDEBUG */
 
-#define oldhash                (SP->oldhash)
-#define newhash                (SP->newhash)
-#define hashtab                (SP->hashtab)
-#define lines_alloc    (SP->hashtab_len)
+#define oldhash(sp)    ((sp)->oldhash)
+#define newhash(sp)    ((sp)->newhash)
+#define hashtab(sp)    ((sp)->hashtab)
+#define lines_alloc(sp)        ((sp)->hashtab_len)
 
 #if USE_WIDEC_SUPPORT
 #define HASH_VAL(ch) (ch.chars[0])
@@ -112,12 +111,12 @@ static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH];
 static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
 
 static NCURSES_INLINE unsigned long
-hash(NCURSES_CH_T * text)
+hash(SCREEN *sp, NCURSES_CH_T * text)
 {
     int i;
     NCURSES_CH_T ch;
     unsigned long result = 0;
-    for (i = TEXTWIDTH; i > 0; i--) {
+    for (i = TEXTWIDTH(sp); i > 0; i--) {
        ch = *text++;
        result += (result << 5) + HASH_VAL(ch);
     }
@@ -126,12 +125,12 @@ hash(NCURSES_CH_T * text)
 
 /* approximate update cost */
 static int
-update_cost(NCURSES_CH_T * from, NCURSES_CH_T * to)
+update_cost(SCREEN *sp, NCURSES_CH_T * from, NCURSES_CH_T * to)
 {
     int cost = 0;
     int i;
 
-    for (i = TEXTWIDTH; i > 0; i--, from++, to++)
+    for (i = TEXTWIDTH(sp); i > 0; i--, from++, to++)
        if (!(CharEq(*from, *to)))
            cost++;
 
@@ -139,7 +138,7 @@ update_cost(NCURSES_CH_T * from, NCURSES_CH_T * to)
 }
 
 static int
-update_cost_from_blank(NCURSES_CH_T * to)
+update_cost_from_blank(SCREEN *sp, NCURSES_CH_T * to)
 {
     int cost = 0;
     int i;
@@ -148,7 +147,7 @@ update_cost_from_blank(NCURSES_CH_T * to)
     if (back_color_erase)
        SetPair(blank, GetPair(stdscr->_nc_bkgd));
 
-    for (i = TEXTWIDTH; i > 0; i--, to++)
+    for (i = TEXTWIDTH(sp); i > 0; i--, to++)
        if (!(CharEq(blank, *to)))
            cost++;
 
@@ -160,14 +159,14 @@ update_cost_from_blank(NCURSES_CH_T * to)
  * effective. 'blank' indicates whether the line 'to' would become blank.
  */
 static NCURSES_INLINE bool
-cost_effective(const int from, const int to, const bool blank)
+cost_effective(SCREEN *sp, const int from, const int to, const bool blank)
 {
     int new_from;
 
     if (from == to)
        return FALSE;
 
-    new_from = OLDNUM(from);
+    new_from = OLDNUM(sp, from);
     if (new_from == _NEWINDEX)
        new_from = from;
 
@@ -175,16 +174,17 @@ cost_effective(const int from, const int to, const bool blank)
      * On the left side of >= is the cost before moving;
      * on the right side -- cost after moving.
      */
-    return (((blank ? update_cost_from_blank(NEWTEXT(to))
-             : update_cost(OLDTEXT(to), NEWTEXT(to)))
-            + update_cost(OLDTEXT(new_from), NEWTEXT(from)))
-           >= ((new_from == from ? update_cost_from_blank(NEWTEXT(from))
-                : update_cost(OLDTEXT(new_from), NEWTEXT(from)))
-               + update_cost(OLDTEXT(from), NEWTEXT(to)))) ? TRUE : FALSE;
+    return (((blank ? update_cost_from_blank(sp, NEWTEXT(sp, to))
+             : update_cost(sp, OLDTEXT(sp, to), NEWTEXT(sp, to)))
+            + update_cost(sp, OLDTEXT(sp, new_from), NEWTEXT(sp, from)))
+           >= ((new_from == from ? update_cost_from_blank(sp, NEWTEXT(sp, from))
+                : update_cost(sp, OLDTEXT(sp, new_from), NEWTEXT(sp, from)))
+               + update_cost(sp, OLDTEXT(sp, from), NEWTEXT(sp, to))))
+       ? TRUE : FALSE;
 }
 
 static void
-grow_hunks(void)
+grow_hunks(SCREEN *sp)
 {
     int start, end, shift;
     int back_limit, forward_limit;     /* limits for cells to fill */
@@ -200,35 +200,36 @@ grow_hunks(void)
     back_ref_limit = 0;
 
     i = 0;
-    while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
+    while (i < screen_lines(sp) && OLDNUM(sp, i) == _NEWINDEX)
        i++;
-    for (; i < screen_lines; i = next_hunk) {
+    for (; i < screen_lines(sp); i = next_hunk) {
        start = i;
-       shift = OLDNUM(i) - i;
+       shift = OLDNUM(sp, i) - i;
 
        /* get forward limit */
        i = start + 1;
-       while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
-              == shift)
+       while (i < screen_lines(sp)
+              && OLDNUM(sp, i) != _NEWINDEX
+              && OLDNUM(sp, i) - i == shift)
            i++;
        end = i;
-       while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
+       while (i < screen_lines(sp) && OLDNUM(sp, i) == _NEWINDEX)
            i++;
        next_hunk = i;
        forward_limit = i;
-       if (i >= screen_lines || OLDNUM(i) >= i)
+       if (i >= screen_lines(sp) || OLDNUM(sp, i) >= i)
            forward_ref_limit = i;
        else
-           forward_ref_limit = OLDNUM(i);
+           forward_ref_limit = OLDNUM(sp, i);
 
        i = start - 1;
        /* grow back */
        if (shift < 0)
            back_limit = back_ref_limit + (-shift);
        while (i >= back_limit) {
-           if (newhash[i] == oldhash[i + shift]
-               || cost_effective(i + shift, i, shift < 0)) {
-               OLDNUM(i) = i + shift;
+           if (newhash(sp)[i] == oldhash(sp)[i + shift]
+               || cost_effective(sp, i + shift, i, shift < 0)) {
+               OLDNUM(sp, i) = i + shift;
                TR(TRACE_UPDATE | TRACE_MOVE,
                   ("connected new line %d to old line %d (backward continuation)",
                    i, i + shift));
@@ -246,9 +247,9 @@ grow_hunks(void)
        if (shift > 0)
            forward_limit = forward_ref_limit - shift;
        while (i < forward_limit) {
-           if (newhash[i] == oldhash[i + shift]
-               || cost_effective(i + shift, i, shift > 0)) {
-               OLDNUM(i) = i + shift;
+           if (newhash(sp)[i] == oldhash(sp)[i + shift]
+               || cost_effective(sp, i + shift, i, shift > 0)) {
+               OLDNUM(sp, i) = i + shift;
                TR(TRACE_UPDATE | TRACE_MOVE,
                   ("connected new line %d to old line %d (forward continuation)",
                    i, i + shift));
@@ -268,51 +269,53 @@ grow_hunks(void)
 }
 
 NCURSES_EXPORT(void)
-_nc_hash_map(void)
+NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_DCL0)
 {
-    HASHMAP *sp;
+    HASHMAP *hsp;
     register int i;
     int start, shift, size;
 
-    if (screen_lines > lines_alloc) {
-       if (hashtab)
-           free(hashtab);
-       hashtab = typeMalloc(HASHMAP, (screen_lines + 1) * 2);
-       if (!hashtab) {
-           if (oldhash) {
-               FreeAndNull(oldhash);
+    if (screen_lines(SP_PARM) > lines_alloc(SP_PARM)) {
+       if (hashtab(SP_PARM))
+           free(hashtab(SP_PARM));
+       hashtab(SP_PARM) = typeMalloc(HASHMAP, (screen_lines(SP_PARM) + 1) * 2);
+       if (!hashtab(SP_PARM)) {
+           if (oldhash(SP_PARM)) {
+               FreeAndNull(oldhash(SP_PARM));
            }
-           lines_alloc = 0;
+           lines_alloc(SP_PARM) = 0;
            return;
        }
-       lines_alloc = screen_lines;
+       lines_alloc(SP_PARM) = screen_lines(SP_PARM);
     }
 
-    if (oldhash && newhash) {
+    if (oldhash(SP_PARM) && newhash(SP_PARM)) {
        /* re-hash only changed lines */
-       for (i = 0; i < screen_lines; i++) {
-           if (PENDING(i))
-               newhash[i] = hash(NEWTEXT(i));
+       for (i = 0; i < screen_lines(SP_PARM); i++) {
+           if (PENDING(SP_PARM, i))
+               newhash(SP_PARM)[i] = hash(SP_PARM, NEWTEXT(SP_PARM, i));
        }
     } else {
        /* re-hash all */
-       if (oldhash == 0)
-           oldhash = typeCalloc(unsigned long, (unsigned) screen_lines);
-       if (newhash == 0)
-           newhash = typeCalloc(unsigned long, (unsigned) screen_lines);
-       if (!oldhash || !newhash)
+       if (oldhash(SP_PARM) == 0)
+           oldhash(SP_PARM) = typeCalloc(unsigned long,
+                                           (unsigned) screen_lines(SP_PARM));
+       if (newhash(SP_PARM) == 0)
+           newhash(SP_PARM) = typeCalloc(unsigned long,
+                                           (unsigned) screen_lines(SP_PARM));
+       if (!oldhash(SP_PARM) || !newhash(SP_PARM))
            return;             /* malloc failure */
-       for (i = 0; i < screen_lines; i++) {
-           newhash[i] = hash(NEWTEXT(i));
-           oldhash[i] = hash(OLDTEXT(i));
+       for (i = 0; i < screen_lines(SP_PARM); i++) {
+           newhash(SP_PARM)[i] = hash(SP_PARM, NEWTEXT(SP_PARM, i));
+           oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i));
        }
     }
 
 #ifdef HASH_VERIFY
-    for (i = 0; i < screen_lines; i++) {
-       if (newhash[i] != hash(NEWTEXT(i)))
+    for (i = 0; i < screen_lines(SP_PARM); i++) {
+       if (newhash(SP_PARM)[i] != hash(SP_PARM, NEWTEXT(SP_PARM, i)))
            fprintf(stderr, "error in newhash[%d]\n", i);
-       if (oldhash[i] != hash(OLDTEXT(i)))
+       if (oldhash(SP_PARM)[i] != hash(SP_PARM, OLDTEXT(SP_PARM, i)))
            fprintf(stderr, "error in oldhash[%d]\n", i);
     }
 #endif
@@ -320,28 +323,29 @@ _nc_hash_map(void)
     /*
      * Set up and count line-hash values.
      */
-    memset(hashtab, '\0', sizeof(*hashtab) * (screen_lines + 1) * 2);
-    for (i = 0; i < screen_lines; i++) {
-       unsigned long hashval = oldhash[i];
+    memset(hashtab(SP_PARM), '\0',
+          sizeof(*(hashtab(SP_PARM))) * (screen_lines(SP_PARM) + 1) * 2);
+    for (i = 0; i < screen_lines(SP_PARM); i++) {
+       unsigned long hashval = oldhash(SP_PARM)[i];
 
-       for (sp = hashtab; sp->hashval; sp++)
-           if (sp->hashval == hashval)
+       for (hsp = hashtab(SP_PARM); hsp->hashval; hsp++)
+           if (hsp->hashval == hashval)
                break;
-       sp->hashval = hashval;  /* in case this is a new entry */
-       sp->oldcount++;
-       sp->oldindex = i;
+       hsp->hashval = hashval; /* in case this is a new entry */
+       hsp->oldcount++;
+       hsp->oldindex = i;
     }
-    for (i = 0; i < screen_lines; i++) {
-       unsigned long hashval = newhash[i];
+    for (i = 0; i < screen_lines(SP_PARM); i++) {
+       unsigned long hashval = newhash(SP_PARM)[i];
 
-       for (sp = hashtab; sp->hashval; sp++)
-           if (sp->hashval == hashval)
+       for (hsp = hashtab(SP_PARM); hsp->hashval; hsp++)
+           if (hsp->hashval == hashval)
                break;
-       sp->hashval = hashval;  /* in case this is a new entry */
-       sp->newcount++;
-       sp->newindex = i;
+       hsp->hashval = hashval; /* in case this is a new entry */
+       hsp->newcount++;
+       hsp->newindex = i;
 
-       OLDNUM(i) = _NEWINDEX;  /* initialize old indices array */
+       OLDNUM(SP_PARM, i) = _NEWINDEX;         /* initialize old indices array */
     }
 
     /*
@@ -351,16 +355,16 @@ _nc_hash_map(void)
      * extending hunks by cost_effective. Otherwise, it does not
      * have any side effects.
      */
-    for (sp = hashtab; sp->hashval; sp++)
-       if (sp->oldcount == 1 && sp->newcount == 1
-           && sp->oldindex != sp->newindex) {
+    for (hsp = hashtab(SP_PARM); hsp->hashval; hsp++)
+       if (hsp->oldcount == 1 && hsp->newcount == 1
+           && hsp->oldindex != hsp->newindex) {
            TR(TRACE_UPDATE | TRACE_MOVE,
               ("new line %d is hash-identical to old line %d (unique)",
-               sp->newindex, sp->oldindex));
-           OLDNUM(sp->newindex) = sp->oldindex;
+               hsp->newindex, hsp->oldindex));
+           OLDNUM(SP_PARM, hsp->newindex) = hsp->oldindex;
        }
 
-    grow_hunks();
+    grow_hunks(SP_PARM);
 
     /*
      * Eliminate bad or impossible shifts -- this includes removing
@@ -368,58 +372,83 @@ _nc_hash_map(void)
      * those which are to be moved too far, they are likely to destroy
      * more than carry.
      */
-    for (i = 0; i < screen_lines;) {
-       while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
+    for (i = 0; i < screen_lines(SP_PARM);) {
+       while (i < screen_lines(SP_PARM) && OLDNUM(SP_PARM, i) == _NEWINDEX)
            i++;
-       if (i >= screen_lines)
+       if (i >= screen_lines(SP_PARM))
            break;
        start = i;
-       shift = OLDNUM(i) - i;
+       shift = OLDNUM(SP_PARM, i) - i;
        i++;
-       while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
-              == shift)
+       while (i < screen_lines(SP_PARM)
+              && OLDNUM(SP_PARM, i) != _NEWINDEX
+              && OLDNUM(SP_PARM, i) - i == shift)
            i++;
        size = i - start;
        if (size < 3 || size + min(size / 8, 2) < abs(shift)) {
            while (start < i) {
-               OLDNUM(start) = _NEWINDEX;
+               OLDNUM(SP_PARM, start) = _NEWINDEX;
                start++;
            }
        }
     }
 
     /* After clearing invalid hunks, try grow the rest. */
-    grow_hunks();
+    grow_hunks(SP_PARM);
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+_nc_hash_map(void)
+{
+    NCURSES_SP_NAME(_nc_hash_map) (CURRENT_SCREEN);
 }
+#endif
 
+NCURSES_EXPORT(void)
+NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_DCLx int i)
+{
+    if (oldhash(SP_PARM))
+       oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i));
+}
+
+#if NCURSES_SP_FUNCS
 NCURSES_EXPORT(void)
 _nc_make_oldhash(int i)
 {
-    if (oldhash)
-       oldhash[i] = hash(OLDTEXT(i));
+    NCURSES_SP_NAME(_nc_make_oldhash) (CURRENT_SCREEN, i);
 }
+#endif
 
 NCURSES_EXPORT(void)
-_nc_scroll_oldhash(int n, int top, int bot)
+NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_DCLx int n, int top, int bot)
 {
     size_t size;
     int i;
 
-    if (!oldhash)
+    if (!oldhash(SP_PARM))
        return;
 
-    size = sizeof(*oldhash) * (bot - top + 1 - abs(n));
+    size = sizeof(*(oldhash(SP_PARM))) * (bot - top + 1 - abs(n));
     if (n > 0) {
-       memmove(oldhash + top, oldhash + top + n, size);
+       memmove(oldhash(SP_PARM) + top, oldhash(SP_PARM) + top + n, size);
        for (i = bot; i > bot - n; i--)
-           oldhash[i] = hash(OLDTEXT(i));
+           oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i));
     } else {
-       memmove(oldhash + top - n, oldhash + top, size);
+       memmove(oldhash(SP_PARM) + top - n, oldhash(SP_PARM) + top, size);
        for (i = top; i < top - n; i++)
-           oldhash[i] = hash(OLDTEXT(i));
+           oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i));
     }
 }
 
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+_nc_scroll_oldhash(int n, int top, int bot)
+{
+    NCURSES_SP_NAME(_nc_scroll_oldhash) (CURRENT_SCREEN, n, top, bot);
+}
+#endif
+
 #ifdef HASHDEBUG
 static void
 usage(void)
index d5201325e94ccd507b94f82b6f74a88676c5aa86..3961f4571fa1d77c89211d8567b5a0fe08723bfd 100644 (file)
  * we'll consider nonlocal.
  */
 #define NOT_LOCAL(fy, fx, ty, tx)      ((tx > LONG_DIST) \
-                && (tx < screen_columns - 1 - LONG_DIST) \
+                && (tx < screen_columns(CURRENT_SCREEN) - 1 - LONG_DIST) \
                 && (abs(ty-fy) + abs(tx-fx) > LONG_DIST))
 
 /****************************************************************************
 #include <term.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_mvcur.c,v 1.114 2009/02/15 00:50:33 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.115 2009/04/18 19:03:05 tom Exp $")
 
 #define WANT_CHAR(y, x)        SP->_newscr->_line[y].text[x]   /* desired state */
 #define BAUDRATE       cur_term->_baudrate     /* bits per second */
@@ -258,7 +258,7 @@ reset_scroll_region(void)
 {
     if (change_scroll_region) {
        TPUTS_TRACE("change_scroll_region");
-       putp(TPARM_2(change_scroll_region, 0, screen_lines - 1));
+       putp(TPARM_2(change_scroll_region, 0, screen_lines(CURRENT_SCREEN) - 1));
     }
 }
 
@@ -424,7 +424,7 @@ _nc_mvcur_wrap(void)
 /* wrap up cursor-addressing mode */
 {
     /* leave cursor at screen bottom */
-    mvcur(-1, -1, screen_lines - 1, 0);
+    mvcur(-1, -1, screen_lines(CURRENT_SCREEN) - 1, 0);
 
     /* set cursor to normal mode */
     if (SP->_cursor != -1) {
@@ -781,7 +781,8 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
 
     /* tactic #4: use home-down + local movement */
     if (cursor_to_ll
-       && ((newcost = relative_move(NullResult, screen_lines - 1, 0, ynew,
+       && ((newcost = relative_move(NullResult,
+                                    screen_lines(CURRENT_SCREEN) - 1, 0, ynew,
                                     xnew, ovw)) != INFINITY)
        && SP->_ll_cost + newcost < usecost) {
        tactic = 4;
@@ -795,8 +796,12 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
     t5_cr_cost = (xold > 0 ? SP->_cr_cost : 0);
     if (auto_left_margin && !eat_newline_glitch
        && yold > 0 && cursor_left
-       && ((newcost = relative_move(NullResult, yold - 1, screen_columns -
-                                    1, ynew, xnew, ovw)) != INFINITY)
+       && ((newcost = relative_move(NullResult,
+                                    yold - 1,
+                                    screen_columns(CURRENT_SCREEN) - 1,
+                                    ynew,
+                                    xnew,
+                                    ovw)) != INFINITY)
        && t5_cr_cost + SP->_cub1_cost + newcost < usecost) {
        tactic = 5;
        usecost = t5_cr_cost + SP->_cub1_cost + newcost;
@@ -821,14 +826,23 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
        break;
     case 4:
        (void) _nc_safe_strcpy(&result, cursor_to_ll);
-       (void) relative_move(&result, screen_lines - 1, 0, ynew, xnew, ovw);
+       (void) relative_move(&result,
+                            screen_lines(CURRENT_SCREEN) - 1,
+                            0,
+                            ynew,
+                            xnew,
+                            ovw);
        break;
     case 5:
        if (xold > 0)
            (void) _nc_safe_strcat(&result, carriage_return);
        (void) _nc_safe_strcat(&result, cursor_left);
-       (void) relative_move(&result, yold - 1, screen_columns - 1, ynew,
-                            xnew, ovw);
+       (void) relative_move(&result,
+                            yold - 1,
+                            screen_columns(CURRENT_SCREEN) - 1,
+                            ynew,
+                            xnew,
+                            ovw);
        break;
     }
 #endif /* !NO_OPTIMIZE */
@@ -876,9 +890,9 @@ NCURSES_SP_NAME(mvcur) (NCURSES_SP_DCLx
         * column position implied by wraparound or the lack thereof and
         * rolling up the screen to get ynew on the screen.
         */
-       if (xnew >= screen_columns) {
-           ynew += xnew / screen_columns;
-           xnew %= screen_columns;
+       if (xnew >= screen_columns(CURRENT_SCREEN)) {
+           ynew += xnew / screen_columns(CURRENT_SCREEN);
+           xnew %= screen_columns(CURRENT_SCREEN);
        }
 
        /*
@@ -895,14 +909,14 @@ NCURSES_SP_NAME(mvcur) (NCURSES_SP_DCLx
            (void) VIDATTR(A_NORMAL, 0);
        }
 
-       if (xold >= screen_columns) {
+       if (xold >= screen_columns(CURRENT_SCREEN)) {
            int l;
 
            if (SP_PARM->_nl) {
-               l = (xold + 1) / screen_columns;
+               l = (xold + 1) / screen_columns(CURRENT_SCREEN);
                yold += l;
-               if (yold >= screen_lines)
-                   l -= (yold - screen_lines - 1);
+               if (yold >= screen_lines(CURRENT_SCREEN))
+                   l -= (yold - screen_lines(CURRENT_SCREEN) - 1);
 
                if (l > 0) {
                    if (carriage_return) {
@@ -931,10 +945,10 @@ NCURSES_SP_NAME(mvcur) (NCURSES_SP_DCLx
            }
        }
 
-       if (yold > screen_lines - 1)
-           yold = screen_lines - 1;
-       if (ynew > screen_lines - 1)
-           ynew = screen_lines - 1;
+       if (yold > screen_lines(CURRENT_SCREEN) - 1)
+           yold = screen_lines(CURRENT_SCREEN) - 1;
+       if (ynew > screen_lines(CURRENT_SCREEN) - 1)
+           ynew = screen_lines(CURRENT_SCREEN) - 1;
 
        /* destination location is on screen now */
        code = onscreen_mvcur(yold, xold, ynew, xnew, TRUE);
index 06c8411caa4d2a2891b63c3febc79b6d0d5e6ba9..4e7c53c18d2bf41855670da99b6eda3c6be1e757 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -46,7 +46,7 @@
 #define _POSIX_SOURCE
 #endif
 
-MODULE_ID("$Id: lib_tstp.c,v 1.37 2008/05/03 16:24:56 tom Exp $")
+MODULE_ID("$Id: lib_tstp.c,v 1.38 2009/04/18 19:36:11 tom Exp $")
 
 #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
 #define USE_SIGTSTP 1
@@ -59,16 +59,20 @@ static const char *
 signal_name(int sig)
 {
     switch (sig) {
+#ifdef SIGALRM
     case SIGALRM:
        return "SIGALRM";
+#endif
 #ifdef SIGCONT
     case SIGCONT:
        return "SIGCONT";
 #endif
     case SIGINT:
        return "SIGINT";
+#ifdef SIGQUIT
     case SIGQUIT:
        return "SIGQUIT";
+#endif
     case SIGTERM:
        return "SIGTERM";
 #ifdef SIGTSTP
@@ -136,6 +140,7 @@ signal_name(int sig)
 static void
 tstp(int dummy GCC_UNUSED)
 {
+    SCREEN *sp = CURRENT_SCREEN;
     sigset_t mask, omask;
     sigaction_t act, oact;
 
@@ -154,11 +159,11 @@ tstp(int dummy GCC_UNUSED)
      * parent was stopped before us, and we would likely pick up the
      * settings already modified by the shell.
      */
-    if (SP != 0 && !SP->_endwin)       /* don't do this if we're not in curses */
+    if (sp != 0 && !sp->_endwin)       /* don't do this if we're not in curses */
 #if HAVE_TCGETPGRP
        if (tcgetpgrp(STDIN_FILENO) == getpgrp())
 #endif
-           def_prog_mode();
+           NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG);
 
     /*
      * Block window change and timer signals.  The latter
@@ -166,7 +171,9 @@ tstp(int dummy GCC_UNUSED)
      * to repaint the screen.
      */
     (void) sigemptyset(&mask);
+#ifdef SIGALRM
     (void) sigaddset(&mask, SIGALRM);
+#endif
 #if USE_SIGWINCH
     (void) sigaddset(&mask, SIGWINCH);
 #endif
@@ -185,7 +192,7 @@ tstp(int dummy GCC_UNUSED)
      * End window mode, which also resets the terminal state to the
      * original (pre-curses) modes.
      */
-    endwin();
+    NCURSES_SP_NAME(endwin) (NCURSES_SP_ARG);
 
     /* Unblock SIGTSTP. */
     (void) sigemptyset(&mask);
@@ -212,19 +219,19 @@ tstp(int dummy GCC_UNUSED)
 
     T(("SIGCONT received"));
     sigaction(SIGTSTP, &oact, NULL);
-    flushinp();
+    NCURSES_SP_NAME(flushinp) (NCURSES_SP_ARG);
 
     /*
      * If the user modified the tty state while suspended, he wants
      * those changes to stick.  So save the new "default" terminal state.
      */
-    def_shell_mode();
+    NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG);
 
     /*
      * This relies on the fact that doupdate() will restore the
      * program-mode tty state, and issue enter_ca_mode if need be.
      */
-    doupdate();
+    NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG);
 
     /* Reset the signals. */
     (void) sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -234,6 +241,8 @@ tstp(int dummy GCC_UNUSED)
 static void
 cleanup(int sig)
 {
+    SCREEN *sp = CURRENT_SCREEN;
+
     /*
      * Actually, doing any sort of I/O from within an signal handler is
      * "unsafe".  But we'll _try_ to clean up the screen and terminal
@@ -241,7 +250,10 @@ cleanup(int sig)
      */
     if (!_nc_globals.cleanup_nested++
        && (sig == SIGINT
-           || sig == SIGQUIT)) {
+#ifdef SIGQUIT
+           || sig == SIGQUIT
+#endif
+       )) {
 #if HAVE_SIGACTION || HAVE_SIGVEC
        sigaction_t act;
        sigemptyset(&act.sa_mask);
@@ -260,9 +272,9 @@ cleanup(int sig)
                    scan->_outch = _nc_outch;
                }
                set_term(scan);
-               endwin();
-               if (SP)
-                   SP->_endwin = FALSE;        /* in case we have an atexit! */
+               NCURSES_SP_NAME(endwin) (NCURSES_SP_ARG);
+               if (sp)
+                   sp->_endwin = FALSE;        /* in case we have an atexit! */
            }
        }
     }
index 16d12edbbe3c297c12864b6718a4ce99a9e72501..3091719cd79ca126f1201b8decc000bab24a647a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 #  include <sys/select.h>
 # endif
 #endif
-
+#ifdef __MINGW32__
+#  include <sys/time.h>
+#endif
 #undef CUR
 
-MODULE_ID("$Id: lib_twait.c,v 1.59 2008/08/30 20:08:19 tom Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.60 2009/04/18 21:01:13 tom Exp $")
 
 static long
 _nc_gettime(TimeType * t0, bool first)
@@ -124,15 +126,27 @@ _nc_eventlist_timeout(_nc_eventlist * evl)
 }
 #endif /* NCURSES_WGETCH_EVENTS */
 
+#if (USE_FUNC_POLL || HAVE_SELECT)
+#  define MAYBE_UNUSED
+#else
+#  define MAYBE_UNUSED GCC_UNUSED
+#endif
+
+#if (USE_FUNC_POLL || HAVE_SELECT)
+#  define MAYBE_UNUSED
+#else
+#  define MAYBE_UNUSED GCC_UNUSED
+#endif
+
 /*
  * Wait a specified number of milliseconds, returning nonzero if the timer
  * didn't expire before there is activity on the specified file descriptors.
  * The file-descriptors are specified by the mode:
- *     0 - none (absolute time)
- *     1 - ncurses' normal input-descriptor
- *     2 - mouse descriptor, if any
- *     3 - either input or mouse.
- *
+ *     TW_NONE    0 - none (absolute time)
+ *     TW_INPUT   1 - ncurses' normal input-descriptor
+ *     TW_MOUSE   2 - mouse descriptor, if any
+ *     TW_ANY     3 - either input or mouse.
+ *      TW_EVENT   4 -
  * Experimental:  if NCURSES_WGETCH_EVENTS is defined, (mode & 4) determines
  * whether to pay attention to evl argument.  If set, the smallest of
  * millisecond and of timeout of evl is taken.
@@ -143,16 +157,18 @@ _nc_eventlist_timeout(_nc_eventlist * evl)
  * descriptors.
  */
 NCURSES_EXPORT(int)
-_nc_timed_wait(SCREEN *sp,
-              int mode,
+_nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
+              int mode MAYBE_UNUSED,
               int milliseconds,
               int *timeleft
               EVENTLIST_2nd(_nc_eventlist * evl))
 {
-    int fd;
     int count;
-    int result = 0;
+    int result = TW_NONE;
     TimeType t0;
+#if (USE_FUNC_POLL || HAVE_SELECT)
+    int fd;
+#endif
 
 #ifdef NCURSES_WGETCH_EVENTS
     int timeout_is_event = 0;
@@ -174,7 +190,7 @@ _nc_timed_wait(SCREEN *sp,
                      milliseconds, mode));
 
 #ifdef NCURSES_WGETCH_EVENTS
-    if (mode & 4) {
+    if (mode & TW_EVENT) {
        int event_delay = _nc_eventlist_timeout(evl);
 
        if (event_delay >= 0
@@ -193,7 +209,7 @@ _nc_timed_wait(SCREEN *sp,
     count = 0;
 
 #ifdef NCURSES_WGETCH_EVENTS
-    if ((mode & 4) && evl)
+    if ((mode & TW_EVENT) && evl)
        evl->result_flags = 0;
 #endif
 
@@ -201,23 +217,23 @@ _nc_timed_wait(SCREEN *sp,
     memset(fd_list, 0, sizeof(fd_list));
 
 #ifdef NCURSES_WGETCH_EVENTS
-    if ((mode & 4) && evl)
+    if ((mode & TW_EVENT) && evl)
        fds = typeMalloc(struct pollfd, MIN_FDS + evl->count);
 #endif
 
-    if (mode & 1) {
+    if (mode & TW_INPUT) {
        fds[count].fd = sp->_ifd;
        fds[count].events = POLLIN;
        count++;
     }
-    if ((mode & 2)
+    if ((mode & TW_MOUSE)
        && (fd = sp->_mouse_fd) >= 0) {
        fds[count].fd = fd;
        fds[count].events = POLLIN;
        count++;
     }
 #ifdef NCURSES_WGETCH_EVENTS
-    if ((mode & 4) && evl) {
+    if ((mode & TW_EVENT) && evl) {
        for (n = 0; n < evl->count; ++n) {
            _nc_event *ev = evl->events[n];
 
@@ -234,7 +250,7 @@ _nc_timed_wait(SCREEN *sp,
     result = poll(fds, (unsigned) count, milliseconds);
 
 #ifdef NCURSES_WGETCH_EVENTS
-    if ((mode & 4) && evl) {
+    if ((mode & TW_EVENT) && evl) {
        int c;
 
        if (!result)
@@ -276,8 +292,8 @@ _nc_timed_wait(SCREEN *sp,
      *
      * FIXME: this assumes mode&1 if milliseconds < 0 (see lib_getch.c).
      */
-    result = 0;
-    if (mode & 1) {
+    result = TW_NONE;
+    if (mode & TW_INPUT) {
        int step = (milliseconds < 0) ? 0 : 5000;
        bigtime_t d;
        bigtime_t useconds = milliseconds * 1000;
@@ -313,17 +329,17 @@ _nc_timed_wait(SCREEN *sp,
      */
     FD_ZERO(&set);
 
-    if (mode & 1) {
+    if (mode & TW_INPUT) {
        FD_SET(sp->_ifd, &set);
        count = sp->_ifd + 1;
     }
-    if ((mode & 2)
+    if ((mode & TW_MOUSE)
        && (fd = sp->_mouse_fd) >= 0) {
        FD_SET(fd, &set);
        count = max(fd, count) + 1;
     }
 #ifdef NCURSES_WGETCH_EVENTS
-    if ((mode & 4) && evl) {
+    if ((mode & TW_EVENT) && evl) {
        for (n = 0; n < evl->count; ++n) {
            _nc_event *ev = evl->events[n];
 
@@ -346,7 +362,7 @@ _nc_timed_wait(SCREEN *sp,
     }
 
 #ifdef NCURSES_WGETCH_EVENTS
-    if ((mode & 4) && evl) {
+    if ((mode & TW_EVENT) && evl) {
        evl->result_flags = 0;
        for (n = 0; n < evl->count; ++n) {
            _nc_event *ev = evl->events[n];
@@ -428,22 +444,22 @@ _nc_timed_wait(SCREEN *sp,
                }
            }
 #elif defined(__BEOS__)
-           result = 1;         /* redundant, but simple */
+           result = TW_INPUT;  /* redundant, but simple */
 #elif HAVE_SELECT
-           if ((mode & 2)
+           if ((mode & TW_MOUSE)
                && (fd = sp->_mouse_fd) >= 0
                && FD_ISSET(fd, &set))
-               result |= 2;
-           if ((mode & 1)
+               result |= TW_MOUSE;
+           if ((mode & TW_INPUT)
                && FD_ISSET(sp->_ifd, &set))
-               result |= 1;
+               result |= TW_INPUT;
 #endif
        } else
            result = 0;
     }
 #ifdef NCURSES_WGETCH_EVENTS
-    if ((mode & 4) && evl && evl->result_flags)
-       result |= 4;
+    if ((mode & TW_EVENT) && evl && evl->result_flags)
+       result |= TW_EVENT;
 #endif
 
     return (result);
index cdf173a3434d50fe2ea87cfa37df7877e8db6867..7a0636f2d9617628aacb8a3cd7adbab5885da797 100644 (file)
@@ -79,7 +79,7 @@
 #include <ctype.h>
 #include <term.h>
 
-MODULE_ID("$Id: tty_update.c,v 1.248 2009/02/15 00:51:22 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.250 2009/04/18 23:32:17 tom Exp $")
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
@@ -105,12 +105,20 @@ static NCURSES_CH_T normal = NewChar(BLANK_TEXT);
 /* #define POSITION_DEBUG */
 
 static NCURSES_INLINE NCURSES_CH_T ClrBlank(WINDOW *win);
-static int ClrBottom(int total);
-static void ClearScreen(NCURSES_CH_T blank);
-static void ClrUpdate(void);
 static void DelChar(int count);
 static void InsStr(NCURSES_CH_T * line, int count);
+
+#if NCURSES_SP_FUNCS
+static void ClearScreen(SCREEN *, NCURSES_CH_T blank);
+static int ClrBottom(SCREEN *, int total);
+static void ClrUpdate(SCREEN *);
+static void TransformLine(SCREEN *, int const lineno);
+#else
+static void ClearScreen(NCURSES_CH_T blank);
+static int ClrBottom(int total);
+static void ClrUpdate(void);
 static void TransformLine(int const lineno);
+#endif
 
 #ifdef POSITION_DEBUG
 /****************************************************************************
@@ -363,7 +371,7 @@ check_pending(void)
 
 /* put char at lower right corner */
 static void
-PutCharLR(const ARG_CH_T ch)
+PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch)
 {
     if (!auto_right_margin) {
        /* we can put the char directly */
@@ -374,17 +382,19 @@ PutCharLR(const ARG_CH_T ch)
        putp(exit_am_mode);
 
        PutAttrChar(ch);
-       SP->_curscol--;
-       position_check(SP->_cursrow, SP->_curscol, "exit_am_mode");
+       SP_PARM->_curscol--;
+       position_check(SP_PARM->_cursrow, SP_PARM->_curscol, "exit_am_mode");
 
        TPUTS_TRACE("enter_am_mode");
        putp(enter_am_mode);
     } else if ((enter_insert_mode && exit_insert_mode)
               || insert_character || parm_ich) {
-       GoTo(screen_lines - 1, screen_columns - 2);
+       GoTo(screen_lines(SP_PARM) - 1, screen_columns(SP_PARM) - 2);
        PutAttrChar(ch);
-       GoTo(screen_lines - 1, screen_columns - 2);
-       InsStr(newscr->_line[screen_lines - 1].text + screen_columns - 2, 1);
+       GoTo(screen_lines(SP_PARM) - 1, screen_columns(SP_PARM) - 2);
+       InsStr(newscr->_line[screen_lines(SP_PARM) - 1].text
+              + screen_columns(SP_PARM) - 2,
+              1);
     }
 }
 
@@ -430,18 +440,19 @@ wrap_cursor(void)
 }
 
 static NCURSES_INLINE void
-PutChar(const ARG_CH_T ch)
+PutChar(NCURSES_SP_DCLx const ARG_CH_T ch)
 /* insert character, handling automargin stuff */
 {
-    if (SP->_cursrow == screen_lines - 1 && SP->_curscol == screen_columns - 1)
-       PutCharLR(ch);
+    if (SP_PARM->_cursrow == screen_lines(SP_PARM) - 1
+       && SP_PARM->_curscol == screen_columns(SP_PARM) - 1)
+       PutCharLR(NCURSES_SP_ARGx ch);
     else
        PutAttrChar(ch);
 
-    if (SP->_curscol >= screen_columns)
+    if (SP_PARM->_curscol >= screen_columns(SP_PARM))
        wrap_cursor();
 
-    position_check(SP->_cursrow, SP->_curscol, "PutChar");
+    position_check(SP_PARM->_cursrow, SP_PARM->_curscol, "PutChar");
 }
 
 /*
@@ -489,7 +500,7 @@ can_clear_with(ARG_CH_T ch)
  * This code is optimized using ech and rep.
  */
 static int
-EmitRange(const NCURSES_CH_T * ntext, int num)
+EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T * ntext, int num)
 {
     int i;
 
@@ -501,13 +512,13 @@ EmitRange(const NCURSES_CH_T * ntext, int num)
            NCURSES_CH_T ntext0;
 
            while (num > 1 && !CharEq(ntext[0], ntext[1])) {
-               PutChar(CHREF(ntext[0]));
+               PutChar(NCURSES_SP_ARGx CHREF(ntext[0]));
                ntext++;
                num--;
            }
            ntext0 = ntext[0];
            if (num == 1) {
-               PutChar(CHREF(ntext0));
+               PutChar(NCURSES_SP_ARGx CHREF(ntext0));
                return 0;
            }
            runcount = 2;
@@ -524,7 +535,7 @@ EmitRange(const NCURSES_CH_T * ntext, int num)
             * which it would be marginally advantageous.
             */
            if (erase_chars
-               && runcount > SP->_ech_cost + SP->_cup_ch_cost
+               && runcount > SP_PARM->_ech_cost + SP_PARM->_cup_ch_cost
                && can_clear_with(CHREF(ntext0))) {
                UpdateAttrs(ntext0);
                putp(TPARM_1(erase_chars, runcount));
@@ -535,12 +546,13 @@ EmitRange(const NCURSES_CH_T * ntext, int num)
                 * last update on the line.
                 */
                if (runcount < num) {
-                   GoTo(SP->_cursrow, SP->_curscol + runcount);
+                   GoTo(SP_PARM->_cursrow, SP_PARM->_curscol + runcount);
                } else {
                    return 1;   /* cursor stays in the middle */
                }
-           } else if (repeat_char && runcount > SP->_rep_cost) {
-               bool wrap_possible = (SP->_curscol + runcount >= screen_columns);
+           } else if (repeat_char && runcount > SP_PARM->_rep_cost) {
+               bool wrap_possible = (SP_PARM->_curscol + runcount
+                                     >= screen_columns(SP_PARM));
                int rep_count = runcount;
 
                if (wrap_possible)
@@ -549,13 +561,13 @@ EmitRange(const NCURSES_CH_T * ntext, int num)
                UpdateAttrs(ntext0);
                tputs(TPARM_2(repeat_char, CharOf(ntext0), rep_count),
                      rep_count, _nc_outch);
-               SP->_curscol += rep_count;
+               SP_PARM->_curscol += rep_count;
 
                if (wrap_possible)
-                   PutChar(CHREF(ntext0));
+                   PutChar(NCURSES_SP_ARGx CHREF(ntext0));
            } else {
                for (i = 0; i < runcount; i++)
-                   PutChar(CHREF(ntext[i]));
+                   PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));
            }
            ntext += runcount;
            num -= runcount;
@@ -564,7 +576,7 @@ EmitRange(const NCURSES_CH_T * ntext, int num)
     }
 
     for (i = 0; i < num; i++)
-       PutChar(CHREF(ntext[i]));
+       PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));
     return 0;
 }
 
@@ -577,7 +589,8 @@ EmitRange(const NCURSES_CH_T * ntext, int num)
  * Returns: same as EmitRange
  */
 static int
-PutRange(const NCURSES_CH_T * otext,
+PutRange(NCURSES_SP_DCLx
+        const NCURSES_CH_T * otext,
         const NCURSES_CH_T * ntext,
         int row,
         int first, int last)
@@ -588,28 +601,28 @@ PutRange(const NCURSES_CH_T * otext,
                       otext, ntext, row, first, last));
 
     if (otext != ntext
-       && (last - first + 1) > SP->_inline_cost) {
+       && (last - first + 1) > SP_PARM->_inline_cost) {
        for (j = first, same = 0; j <= last; j++) {
            if (!same && isWidecExt(otext[j]))
                continue;
            if (CharEq(otext[j], ntext[j])) {
                same++;
            } else {
-               if (same > SP->_inline_cost) {
-                   EmitRange(ntext + first, j - same - first);
+               if (same > SP_PARM->_inline_cost) {
+                   EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first);
                    GoTo(row, first = j);
                }
                same = 0;
            }
        }
-       i = EmitRange(ntext + first, j - same - first);
+       i = EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first);
        /*
         * Always return 1 for the next GoTo() after a PutRange() if we found
         * identical characters at end of interval
         */
        return (same == 0 ? i : 1);
     }
-    return EmitRange(ntext + first, last - first + 1);
+    return EmitRange(NCURSES_SP_ARGx ntext + first, last - first + 1);
 }
 
 /* leave unbracketed here so 'indent' works */
@@ -696,8 +709,8 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
        int j, k;
        attr_t rattr = A_NORMAL;
 
-       for (i = 0; i < screen_lines; i++) {
-           for (j = 0; j < screen_columns; j++) {
+       for (i = 0; i < screen_lines(SP_PARM); i++) {
+           for (j = 0; j < screen_columns(SP_PARM); j++) {
                bool failed = FALSE;
                NCURSES_CH_T *thisline = newscr->_line[i].text;
                attr_t thisattr = AttrOf(thisline[j]) & SP_PARM->_xmc_triggers;
@@ -746,8 +759,8 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
                    int m, n = j;
 
                    /* find end of span, if it's onscreen */
-                   for (m = i; m < screen_lines; m++) {
-                       for (; n < screen_columns; n++) {
+                   for (m = i; m < screen_lines(SP_PARM); m++) {
+                       for (; n < screen_columns(SP_PARM); n++) {
                            attr_t testattr = AttrOf(newscr->_line[m].text[n]);
                            if ((testattr & SP_PARM->_xmc_triggers) == rattr) {
                                end_onscreen = TRUE;
@@ -780,7 +793,7 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
 
                        /* check that there's enough room at end of span */
                        for (k = 1; k <= magic_cookie_glitch; k++) {
-                           if (n + k >= screen_columns
+                           if (n + k >= screen_columns(SP_PARM)
                                || !ISBLANK(lastline[n + k])
                                || !SAFE(AttrOf(lastline[n + k]))) {
                                failed = TRUE;
@@ -807,8 +820,8 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
                        _traceattr(turnon), i, j));
 
                    /* turn off new attributes over span */
-                   for (p = i; p < screen_lines; p++) {
-                       for (; q < screen_columns; q++) {
+                   for (p = i; p < screen_lines(SP_PARM); p++) {
+                       for (; q < screen_columns(SP_PARM); q++) {
                            attr_t testattr = AttrOf(newscr->_line[p].text[q]);
                            if ((testattr & SP_PARM->_xmc_triggers) == rattr)
                                goto foundend;
@@ -847,7 +860,7 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
 
     nonempty = 0;
     if (curscr->_clear || newscr->_clear) {    /* force refresh ? */
-       ClrUpdate();
+       ClrUpdate(NCURSES_SP_ARG);
        curscr->_clear = FALSE; /* reset flag */
        newscr->_clear = FALSE; /* reset flag */
     } else {
@@ -856,13 +869,13 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
        if (check_pending())
            goto cleanup;
 
-       nonempty = min(screen_lines, newscr->_maxy + 1);
+       nonempty = min(screen_lines(SP_PARM), newscr->_maxy + 1);
 
        if (SP_PARM->_scrolling) {
            _nc_scroll_optimize();
        }
 
-       nonempty = ClrBottom(nonempty);
+       nonempty = ClrBottom(NCURSES_SP_ARGx nonempty);
 
        TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty));
        for (i = 0; i < nonempty; i++) {
@@ -883,7 +896,7 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
             */
            if (newscr->_line[i].firstchar != _NOCHANGE
                || curscr->_line[i].firstchar != _NOCHANGE) {
-               TransformLine(i);
+               TransformLine(NCURSES_SP_ARGx i);
                changedlines++;
            }
 
@@ -979,22 +992,22 @@ ClrBlank(WINDOW *win)
 */
 
 static void
-ClrUpdate(void)
+ClrUpdate(NCURSES_SP_DCL0)
 {
     int i;
     NCURSES_CH_T blank = ClrBlank(stdscr);
-    int nonempty = min(screen_lines, newscr->_maxy + 1);
+    int nonempty = min(screen_lines(SP_PARM), newscr->_maxy + 1);
 
     TR(TRACE_UPDATE, (T_CALLED("ClrUpdate")));
 
-    ClearScreen(blank);
+    ClearScreen(NCURSES_SP_ARGx blank);
 
     TR(TRACE_UPDATE, ("updating screen from scratch"));
 
-    nonempty = ClrBottom(nonempty);
+    nonempty = ClrBottom(NCURSES_SP_ARGx nonempty);
 
     for (i = 0; i < nonempty; i++)
-       TransformLine(i);
+       TransformLine(NCURSES_SP_ARGx i);
 
     TR(TRACE_UPDATE, (T_RETURN("")));
 }
@@ -1006,15 +1019,15 @@ ClrUpdate(void)
 */
 
 static void
-ClrToEOL(NCURSES_CH_T blank, bool needclear)
+ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, bool needclear)
 {
     int j;
 
     if (curscr != 0
-       && SP->_cursrow >= 0) {
-       for (j = SP->_curscol; j < screen_columns; j++) {
+       && SP_PARM->_cursrow >= 0) {
+       for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) {
            if (j >= 0) {
-               NCURSES_CH_T *cp = &(curscr->_line[SP->_cursrow].text[j]);
+               NCURSES_CH_T *cp = &(curscr->_line[SP_PARM->_cursrow].text[j]);
 
                if (!CharEq(*cp, blank)) {
                    *cp = blank;
@@ -1029,12 +1042,12 @@ ClrToEOL(NCURSES_CH_T blank, bool needclear)
     if (needclear) {
        UpdateAttrs(blank);
        TPUTS_TRACE("clr_eol");
-       if (clr_eol && SP->_el_cost <= (screen_columns - SP->_curscol)) {
+       if (clr_eol && SP_PARM->_el_cost <= (screen_columns(SP_PARM) - SP_PARM->_curscol)) {
            putp(clr_eol);
        } else {
-           int count = (screen_columns - SP->_curscol);
+           int count = (screen_columns(SP_PARM) - SP_PARM->_curscol);
            while (count-- > 0)
-               PutChar(CHREF(blank));
+               PutChar(NCURSES_SP_ARGx CHREF(blank));
        }
     }
 }
@@ -1046,22 +1059,22 @@ ClrToEOL(NCURSES_CH_T blank, bool needclear)
 */
 
 static void
-ClrToEOS(NCURSES_CH_T blank)
+ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank)
 {
     int row, col;
 
-    row = SP->_cursrow;
-    col = SP->_curscol;
+    row = SP_PARM->_cursrow;
+    col = SP_PARM->_curscol;
 
     UpdateAttrs(blank);
     TPUTS_TRACE("clr_eos");
-    tputs(clr_eos, screen_lines - row, _nc_outch);
+    tputs(clr_eos, screen_lines(SP_PARM) - row, _nc_outch);
 
-    while (col < screen_columns)
+    while (col < screen_columns(SP_PARM))
        curscr->_line[row].text[col++] = blank;
 
-    for (row++; row < screen_lines; row++) {
-       for (col = 0; col < screen_columns; col++)
+    for (row++; row < screen_lines(SP_PARM); row++) {
+       for (col = 0; col < screen_columns(SP_PARM); col++)
            curscr->_line[row].text[col] = blank;
     }
 }
@@ -1074,12 +1087,12 @@ ClrToEOS(NCURSES_CH_T blank)
  *     screen, checking if each is blank, and one or more are changed.
  */
 static int
-ClrBottom(int total)
+ClrBottom(NCURSES_SP_DCLx int total)
 {
     int row;
     int col;
     int top = total;
-    int last = min(screen_columns, newscr->_maxx + 1);
+    int last = min(screen_columns(SP_PARM), newscr->_maxx + 1);
     NCURSES_CH_T blank = newscr->_line[total - 1].text[last - 1];
     bool ok;
 
@@ -1102,10 +1115,10 @@ ClrBottom(int total)
        /* don't use clr_eos for just one line if clr_eol available */
        if (top < total) {
            GoTo(top, 0);
-           ClrToEOS(blank);
-           if (SP->oldhash && SP->newhash) {
-               for (row = top; row < screen_lines; row++)
-                   SP->oldhash[row] = SP->newhash[row];
+           ClrToEOS(NCURSES_SP_ARGx blank);
+           if (SP_PARM->oldhash && SP_PARM->newhash) {
+               for (row = top; row < screen_lines(SP_PARM); row++)
+                   SP_PARM->oldhash[row] = SP_PARM->newhash[row];
            }
        }
     }
@@ -1144,7 +1157,7 @@ ClrBottom(int total)
 */
 
 static void
-TransformLine(int const lineno)
+TransformLine(NCURSES_SP_DCLx int const lineno)
 {
     int firstChar, oLastChar, nLastChar;
     NCURSES_CH_T *newLine = newscr->_line[lineno].text;
@@ -1155,8 +1168,8 @@ TransformLine(int const lineno)
     TR(TRACE_UPDATE, (T_CALLED("TransformLine(%d)"), lineno));
 
     /* copy new hash value to old one */
-    if (SP->oldhash && SP->newhash)
-       SP->oldhash[lineno] = SP->newhash[lineno];
+    if (SP_PARM->oldhash && SP_PARM->newhash)
+       SP_PARM->oldhash[lineno] = SP_PARM->newhash[lineno];
 
     /*
      * If we have colors, there is the possibility of having two color pairs
@@ -1164,19 +1177,20 @@ TransformLine(int const lineno)
      * for this case, and update the old line with the new line's colors when
      * they are equivalent.
      */
-    if (SP->_coloron) {
+    if (SP_PARM->_coloron) {
        int oldPair;
        int newPair;
 
-       for (n = 0; n < screen_columns; n++) {
+       for (n = 0; n < screen_columns(SP_PARM); n++) {
            if (!CharEq(newLine[n], oldLine[n])) {
                oldPair = GetPair(oldLine[n]);
                newPair = GetPair(newLine[n]);
                if (oldPair != newPair
                    && unColor(oldLine[n]) == unColor(newLine[n])) {
-                   if (oldPair < SP->_pair_limit
-                       && newPair < SP->_pair_limit
-                       && SP->_color_pairs[oldPair] == SP->_color_pairs[newPair]) {
+                   if (oldPair < SP_PARM->_pair_limit
+                       && newPair < SP_PARM->_pair_limit
+                       && (SP_PARM->_color_pairs[oldPair] ==
+                           SP_PARM->_color_pairs[newPair])) {
                        SetPair(oldLine[n], GetPair(newLine[n]));
                    }
                }
@@ -1186,7 +1200,7 @@ TransformLine(int const lineno)
 
     if (ceol_standout_glitch && clr_eol) {
        firstChar = 0;
-       while (firstChar < screen_columns) {
+       while (firstChar < screen_columns(SP_PARM)) {
            if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) {
                attrchanged = TRUE;
                break;
@@ -1199,8 +1213,9 @@ TransformLine(int const lineno)
 
     if (attrchanged) {         /* we may have to disregard the whole line */
        GoTo(lineno, firstChar);
-       ClrToEOL(ClrBlank(curscr), FALSE);
-       PutRange(oldLine, newLine, lineno, 0, (screen_columns - 1));
+       ClrToEOL(NCURSES_SP_ARGx ClrBlank(curscr), FALSE);
+       PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
+                0, (screen_columns(SP_PARM) - 1));
 #if USE_XMC_SUPPORT
 
        /*
@@ -1216,7 +1231,7 @@ TransformLine(int const lineno)
         */
     } else if (magic_cookie_glitch > 0) {
        GoTo(lineno, firstChar);
-       for (n = 0; n < screen_columns; n++) {
+       for (n = 0; n < screen_columns(SP_PARM); n++) {
            int m = n + magic_cookie_glitch;
 
            /* check for turn-on:
@@ -1228,22 +1243,22 @@ TransformLine(int const lineno)
                     && xmc_turn_on(newLine[n - 1], newLine[n]))
                    || (n == 0
                        && lineno > 0
-                       && xmc_turn_on(xmc_new(lineno - 1, screen_columns - 1),
+                       && xmc_turn_on(xmc_new(lineno - 1, screen_columns(SP_PARM) - 1),
                                       newLine[n])))) {
                n = m;
            }
 
-           PutChar(CHREF(newLine[n]));
+           PutChar(NCURSES_SP_ARGx CHREF(newLine[n]));
 
            /* check for turn-off:
             * If we are writing an attributed non-blank, where the
             * next cell is blank, and not attributed.
             */
            if (!ISBLANK(newLine[n])
-               && ((n + 1 < screen_columns
+               && ((n + 1 < screen_columns(SP_PARM)
                     && xmc_turn_off(newLine[n], newLine[n + 1]))
-                   || (n + 1 >= screen_columns
-                       && lineno + 1 < screen_lines
+                   || (n + 1 >= screen_columns(SP_PARM)
+                       && lineno + 1 < screen_lines(SP_PARM)
                        && xmc_turn_off(newLine[n], xmc_new(lineno + 1, 0))))) {
                n = m;
            }
@@ -1258,26 +1273,30 @@ TransformLine(int const lineno)
        if (clr_bol && can_clear_with(CHREF(blank))) {
            int oFirstChar, nFirstChar;
 
-           for (oFirstChar = 0; oFirstChar < screen_columns; oFirstChar++)
+           for (oFirstChar = 0;
+                oFirstChar < screen_columns(SP_PARM);
+                oFirstChar++)
                if (!CharEq(oldLine[oFirstChar], blank))
                    break;
-           for (nFirstChar = 0; nFirstChar < screen_columns; nFirstChar++)
+           for (nFirstChar = 0;
+                nFirstChar < screen_columns(SP_PARM);
+                nFirstChar++)
                if (!CharEq(newLine[nFirstChar], blank))
                    break;
 
            if (nFirstChar == oFirstChar) {
                firstChar = nFirstChar;
                /* find the first differing character */
-               while (firstChar < screen_columns
+               while (firstChar < screen_columns(SP_PARM)
                       && CharEq(newLine[firstChar], oldLine[firstChar]))
                    firstChar++;
            } else if (oFirstChar > nFirstChar) {
                firstChar = nFirstChar;
            } else {            /* oFirstChar < nFirstChar */
                firstChar = oFirstChar;
-               if (SP->_el1_cost < nFirstChar - oFirstChar) {
-                   if (nFirstChar >= screen_columns
-                       && SP->_el_cost <= SP->_el1_cost) {
+               if (SP_PARM->_el1_cost < nFirstChar - oFirstChar) {
+                   if (nFirstChar >= screen_columns(SP_PARM)
+                       && SP_PARM->_el_cost <= SP_PARM->_el1_cost) {
                        GoTo(lineno, 0);
                        UpdateAttrs(blank);
                        TPUTS_TRACE("clr_eol");
@@ -1295,21 +1314,21 @@ TransformLine(int const lineno)
            }
        } else {
            /* find the first differing character */
-           while (firstChar < screen_columns
+           while (firstChar < screen_columns(SP_PARM)
                   && CharEq(newLine[firstChar], oldLine[firstChar]))
                firstChar++;
        }
        /* if there wasn't one, we're done */
-       if (firstChar >= screen_columns) {
+       if (firstChar >= screen_columns(SP_PARM)) {
            TR(TRACE_UPDATE, (T_RETURN("")));
            return;
        }
 
-       blank = newLine[screen_columns - 1];
+       blank = newLine[screen_columns(SP_PARM) - 1];
 
        if (!can_clear_with(CHREF(blank))) {
            /* find the last differing character */
-           nLastChar = screen_columns - 1;
+           nLastChar = screen_columns(SP_PARM) - 1;
 
            while (nLastChar > firstChar
                   && CharEq(newLine[nLastChar], oldLine[nLastChar]))
@@ -1317,7 +1336,8 @@ TransformLine(int const lineno)
 
            if (nLastChar >= firstChar) {
                GoTo(lineno, firstChar);
-               PutRange(oldLine, newLine, lineno, firstChar, nLastChar);
+               PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
+                        firstChar, nLastChar);
                memcpy(oldLine + firstChar,
                       newLine + firstChar,
                       (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
@@ -1327,32 +1347,35 @@ TransformLine(int const lineno)
        }
 
        /* find last non-blank character on old line */
-       oLastChar = screen_columns - 1;
+       oLastChar = screen_columns(SP_PARM) - 1;
        while (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank))
            oLastChar--;
 
        /* find last non-blank character on new line */
-       nLastChar = screen_columns - 1;
+       nLastChar = screen_columns(SP_PARM) - 1;
        while (nLastChar > firstChar && CharEq(newLine[nLastChar], blank))
            nLastChar--;
 
        if ((nLastChar == firstChar)
-           && (SP->_el_cost < (oLastChar - nLastChar))) {
+           && (SP_PARM->_el_cost < (oLastChar - nLastChar))) {
            GoTo(lineno, firstChar);
            if (!CharEq(newLine[firstChar], blank))
-               PutChar(CHREF(newLine[firstChar]));
-           ClrToEOL(blank, FALSE);
+               PutChar(NCURSES_SP_ARGx CHREF(newLine[firstChar]));
+           ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
        } else if ((nLastChar != oLastChar)
                   && (!CharEq(newLine[nLastChar], oldLine[oLastChar])
                       || !(_nc_idcok && has_ic()))) {
            GoTo(lineno, firstChar);
-           if ((oLastChar - nLastChar) > SP->_el_cost) {
-               if (PutRange(oldLine, newLine, lineno, firstChar, nLastChar))
+           if ((oLastChar - nLastChar) > SP_PARM->_el_cost) {
+               if (PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
+                            firstChar, nLastChar)) {
                    GoTo(lineno, nLastChar + 1);
-               ClrToEOL(blank, FALSE);
+               }
+               ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
            } else {
                n = max(nLastChar, oLastChar);
-               PutRange(oldLine, newLine, lineno, firstChar, n);
+               PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
+                        firstChar, n);
            }
        } else {
            int nLastNonblank = nLastChar;
@@ -1374,7 +1397,8 @@ TransformLine(int const lineno)
            n = min(oLastChar, nLastChar);
            if (n >= firstChar) {
                GoTo(lineno, firstChar);
-               PutRange(oldLine, newLine, lineno, firstChar, n);
+               PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
+                        firstChar, n);
            }
 
            if (oLastChar < nLastChar) {
@@ -1388,18 +1412,19 @@ TransformLine(int const lineno)
                GoTo(lineno, n + 1);
                if ((nLastChar < nLastNonblank)
                    || InsCharCost(nLastChar - oLastChar) > (m - n)) {
-                   PutRange(oldLine, newLine, lineno, n + 1, m);
+                   PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
+                            n + 1, m);
                } else {
                    InsStr(&newLine[n + 1], nLastChar - oLastChar);
                }
            } else if (oLastChar > nLastChar) {
                GoTo(lineno, n + 1);
                if (DelCharCost(oLastChar - nLastChar)
-                   > SP->_el_cost + nLastNonblank - (n + 1)) {
-                   if (PutRange(oldLine, newLine, lineno,
+                   > SP_PARM->_el_cost + nLastNonblank - (n + 1)) {
+                   if (PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
                                 n + 1, nLastNonblank))
-                       GoTo(lineno, nLastNonblank + 1);
-                   ClrToEOL(blank, FALSE);
+                         GoTo(lineno, nLastNonblank + 1);
+                   ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
                } else {
                    /*
                     * The delete-char sequence will
@@ -1417,10 +1442,10 @@ TransformLine(int const lineno)
     }
 
     /* update the code's internal representation */
-    if (screen_columns > firstChar)
+    if (screen_columns(SP_PARM) > firstChar)
        memcpy(oldLine + firstChar,
               newLine + firstChar,
-              (screen_columns - firstChar) * sizeof(NCURSES_CH_T));
+              (screen_columns(SP_PARM) - firstChar) * sizeof(NCURSES_CH_T));
     TR(TRACE_UPDATE, (T_RETURN("")));
     return;
 }
@@ -1433,7 +1458,7 @@ TransformLine(int const lineno)
 */
 
 static void
-ClearScreen(NCURSES_CH_T blank)
+ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank)
 {
     int i, j;
     bool fast_clear = (clear_screen || clr_eos || clr_eol);
@@ -1441,9 +1466,9 @@ ClearScreen(NCURSES_CH_T blank)
     TR(TRACE_UPDATE, ("ClearScreen() called"));
 
 #if NCURSES_EXT_FUNCS
-    if (SP->_coloron
-       && !SP->_default_color) {
-       _nc_do_color(GET_SCREEN_PAIR(SP), 0, FALSE, _nc_outch);
+    if (SP_PARM->_coloron
+       && !SP_PARM->_default_color) {
+       _nc_do_color(GET_SCREEN_PAIR(SP_PARM), 0, FALSE, _nc_outch);
        if (!back_color_erase) {
            fast_clear = FALSE;
        }
@@ -1455,20 +1480,21 @@ ClearScreen(NCURSES_CH_T blank)
            UpdateAttrs(blank);
            TPUTS_TRACE("clear_screen");
            putp(clear_screen);
-           SP->_cursrow = SP->_curscol = 0;
-           position_check(SP->_cursrow, SP->_curscol, "ClearScreen");
+           SP_PARM->_cursrow = SP_PARM->_curscol = 0;
+           position_check(SP_PARM->_cursrow, SP_PARM->_curscol,
+                          "ClearScreen");
        } else if (clr_eos) {
-           SP->_cursrow = SP->_curscol = -1;
+           SP_PARM->_cursrow = SP_PARM->_curscol = -1;
            GoTo(0, 0);
 
            UpdateAttrs(blank);
            TPUTS_TRACE("clr_eos");
-           tputs(clr_eos, screen_lines, _nc_outch);
+           tputs(clr_eos, screen_lines(SP_PARM), _nc_outch);
        } else if (clr_eol) {
-           SP->_cursrow = SP->_curscol = -1;
+           SP_PARM->_cursrow = SP_PARM->_curscol = -1;
 
            UpdateAttrs(blank);
-           for (i = 0; i < screen_lines; i++) {
+           for (i = 0; i < screen_lines(SP_PARM); i++) {
                GoTo(i, 0);
                TPUTS_TRACE("clr_eol");
                putp(clr_eol);
@@ -1477,16 +1503,16 @@ ClearScreen(NCURSES_CH_T blank)
        }
     } else {
        UpdateAttrs(blank);
-       for (i = 0; i < screen_lines; i++) {
+       for (i = 0; i < screen_lines(SP_PARM); i++) {
            GoTo(i, 0);
-           for (j = 0; j < screen_columns; j++)
-               PutChar(CHREF(blank));
+           for (j = 0; j < screen_columns(SP_PARM); j++)
+               PutChar(NCURSES_SP_ARGx CHREF(blank));
        }
        GoTo(0, 0);
     }
 
-    for (i = 0; i < screen_lines; i++) {
-       for (j = 0; j < screen_columns; j++)
+    for (i = 0; i < screen_lines(SP_PARM); i++) {
+       for (j = 0; j < screen_columns(SP_PARM); j++)
            curscr->_line[i].text[j] = blank;
     }
 
@@ -1543,7 +1569,7 @@ InsStr(NCURSES_CH_T * line, int count)
            count--;
        }
     }
-    position_check(SP->_cursrow, SP->_curscol, "InsStr");
+    position_check(SP_PARM->_cursrow, SP_PARM->_curscol, "InsStr");
 }
 
 /*
@@ -1608,7 +1634,13 @@ DelChar(int count)
 
 /* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */
 static int
-scroll_csr_forward(int n, int top, int bot, int miny, int maxy, NCURSES_CH_T blank)
+scroll_csr_forward(NCURSES_SP_DCLx
+                  int n,
+                  int top,
+                  int bot,
+                  int miny,
+                  int maxy,
+                  NCURSES_CH_T blank)
 {
     int i;
 
@@ -1654,8 +1686,8 @@ scroll_csr_forward(int n, int top, int bot, int miny, int maxy, NCURSES_CH_T bla
        int j;
        for (i = 0; i < n; i++) {
            GoTo(bot - i, 0);
-           for (j = 0; j < screen_columns; j++)
-               PutChar(CHREF(blank));
+           for (j = 0; j < screen_columns(SP_PARM); j++)
+               PutChar(NCURSES_SP_ARGx CHREF(blank));
        }
     }
 #endif
@@ -1665,7 +1697,12 @@ scroll_csr_forward(int n, int top, int bot, int miny, int maxy, NCURSES_CH_T bla
 /* Try to scroll down assuming given csr (miny, maxy). Returns ERR on failure */
 /* n > 0 */
 static int
-scroll_csr_backward(int n, int top, int bot, int miny, int maxy,
+scroll_csr_backward(NCURSES_SP_DCLx
+                   int n,
+                   int top,
+                   int bot,
+                   int miny,
+                   int maxy,
                    NCURSES_CH_T blank)
 {
     int i;
@@ -1712,8 +1749,8 @@ scroll_csr_backward(int n, int top, int bot, int miny, int maxy,
        int j;
        for (i = 0; i < n; i++) {
            GoTo(top + i, 0);
-           for (j = 0; j < screen_columns; j++)
-               PutChar(CHREF(blank));
+           for (j = 0; j < screen_columns(SP_PARM); j++)
+               PutChar(NCURSES_SP_ARGx CHREF(blank));
        }
     }
 #endif
@@ -1772,7 +1809,11 @@ scroll_idl(int n, int del, int ins, NCURSES_CH_T blank)
  * save/restore cursor capabilities if the terminal has them.
  */
 NCURSES_EXPORT(int)
-_nc_scrolln(int n, int top, int bot, int maxy)
+NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx
+                             int n,
+                             int top,
+                             int bot,
+                             int maxy)
 /* scroll region from top to bot by n lines */
 {
     NCURSES_CH_T blank = ClrBlank(stdscr);
@@ -1796,11 +1837,11 @@ _nc_scrolln(int n, int top, int bot, int maxy)
         * Explicitly clear if stuff pushed off top of region might
         * be saved by the terminal.
         */
-       res = scroll_csr_forward(n, top, bot, 0, maxy, blank);
+       res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, 0, maxy, blank);
 
        if (res == ERR && change_scroll_region) {
            if ((((n == 1 && scroll_forward) || parm_index)
-                && (SP->_cursrow == bot || SP->_cursrow == bot - 1))
+                && (SP_PARM->_cursrow == bot || SP_PARM->_cursrow == bot - 1))
                && save_cursor && restore_cursor) {
                cursor_saved = TRUE;
                TPUTS_TRACE("save_cursor");
@@ -1812,14 +1853,14 @@ _nc_scrolln(int n, int top, int bot, int maxy)
                TPUTS_TRACE("restore_cursor");
                putp(restore_cursor);
            } else {
-               SP->_cursrow = SP->_curscol = -1;
+               SP_PARM->_cursrow = SP_PARM->_curscol = -1;
            }
 
-           res = scroll_csr_forward(n, top, bot, top, bot, blank);
+           res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, top, bot, blank);
 
            TPUTS_TRACE("change_scroll_region");
            putp(TPARM_2(change_scroll_region, 0, maxy));
-           SP->_cursrow = SP->_curscol = -1;
+           SP_PARM->_cursrow = SP_PARM->_curscol = -1;
        }
 
        if (res == ERR && _nc_idlok)
@@ -1833,20 +1874,21 @@ _nc_scrolln(int n, int top, int bot, int maxy)
            static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
            if (bot == maxy && clr_eos) {
                GoTo(bot - n + 1, 0);
-               ClrToEOS(blank2);
+               ClrToEOS(NCURSES_SP_ARGx blank2);
            } else {
                for (i = 0; i < n; i++) {
                    GoTo(bot - i, 0);
-                   ClrToEOL(blank2, FALSE);
+                   ClrToEOL(NCURSES_SP_ARGx blank2, FALSE);
                }
            }
        }
 
     } else {                   /* (n < 0) - scroll down (backward) */
-       res = scroll_csr_backward(-n, top, bot, 0, maxy, blank);
+       res = scroll_csr_backward(NCURSES_SP_ARGx -n, top, bot, 0, maxy, blank);
 
        if (res == ERR && change_scroll_region) {
-           if (top != 0 && (SP->_cursrow == top || SP->_cursrow == top - 1)
+           if (top != 0
+               && (SP_PARM->_cursrow == top || SP_PARM->_cursrow == top - 1)
                && save_cursor && restore_cursor) {
                cursor_saved = TRUE;
                TPUTS_TRACE("save_cursor");
@@ -1858,14 +1900,15 @@ _nc_scrolln(int n, int top, int bot, int maxy)
                TPUTS_TRACE("restore_cursor");
                putp(restore_cursor);
            } else {
-               SP->_cursrow = SP->_curscol = -1;
+               SP_PARM->_cursrow = SP_PARM->_curscol = -1;
            }
 
-           res = scroll_csr_backward(-n, top, bot, top, bot, blank);
+           res = scroll_csr_backward(NCURSES_SP_ARGx
+                                     -n, top, bot, top, bot, blank);
 
            TPUTS_TRACE("change_scroll_region");
            putp(TPARM_2(change_scroll_region, 0, maxy));
-           SP->_cursrow = SP->_curscol = -1;
+           SP_PARM->_cursrow = SP_PARM->_curscol = -1;
        }
 
        if (res == ERR && _nc_idlok)
@@ -1879,7 +1922,7 @@ _nc_scrolln(int n, int top, int bot, int maxy)
            static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
            for (i = 0; i < -n; i++) {
                GoTo(i + top, 0);
-               ClrToEOL(blank2, FALSE);
+               ClrToEOL(NCURSES_SP_ARGx blank2, FALSE);
            }
        }
     }
@@ -1895,6 +1938,14 @@ _nc_scrolln(int n, int top, int bot, int maxy)
     return (OK);
 }
 
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+_nc_scrolln(int n, int top, int bot, int maxy)
+{
+    return NCURSES_SP_NAME(_nc_scrolln) (CURRENT_SCREEN, n, top, bot, maxy);
+}
+#endif
+
 NCURSES_EXPORT(void)
 _nc_screen_resume(void)
 {
@@ -1945,27 +1996,37 @@ _nc_screen_init(void)
 
 /* wrap up screen handling */
 NCURSES_EXPORT(void)
-_nc_screen_wrap(void)
+NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0)
 {
     UpdateAttrs(normal);
 #if NCURSES_EXT_FUNCS
-    if (SP->_coloron
-       && !SP->_default_color) {
+    if (SP_PARM->_coloron
+       && !SP_PARM->_default_color) {
        static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
-       SP->_default_color = TRUE;
+       SP_PARM->_default_color = TRUE;
        _nc_do_color(-1, 0, FALSE, _nc_outch);
-       SP->_default_color = FALSE;
+       SP_PARM->_default_color = FALSE;
 
-       mvcur(SP->_cursrow, SP->_curscol, screen_lines - 1, 0);
+       mvcur(SP_PARM->_cursrow,
+             SP_PARM->_curscol,
+             screen_lines(SP_PARM) - 1, 0);
 
-       ClrToEOL(blank, TRUE);
+       ClrToEOL(NCURSES_SP_ARGx blank, TRUE);
     }
 #endif
-    if (SP->_color_defs) {
+    if (SP_PARM->_color_defs) {
        _nc_reset_colors();
     }
 }
 
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+_nc_screen_wrap(void)
+{
+    NCURSES_SP_NAME(_nc_screen_wrap) (CURRENT_SCREEN);
+}
+#endif
+
 #if USE_XMC_SUPPORT
 NCURSES_EXPORT(void)
 _nc_do_xmc_glitch(attr_t previous)
index 6cf3129f2d18f962a0f4efaf14287056584db1d8..c6ab927748faffa9d83a5e41f9ab8ca93fcd46da 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 2002-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +40,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_get_wch.c,v 1.17 2008/08/16 19:22:55 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.18 2009/04/18 22:41:33 tom Exp $")
 
 #if HAVE_MBTOWC && HAVE_MBLEN
 #define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
@@ -95,12 +95,12 @@ wget_wch(WINDOW *win, wint_t *result)
                 * whether the improvement would be worth the effort.
                 */
                if (count != 0) {
-                   _nc_ungetch(sp, (int) value);
+                   safe_ungetch (SP_PARM, (int) value);
                    code = ERR;
                }
                break;
            } else if (count + 1 >= sizeof(buffer)) {
-               _nc_ungetch(sp, (int) value);
+               safe_ungetch (SP_PARM, (int) value);
                code = ERR;
                break;
            } else {
@@ -111,7 +111,7 @@ wget_wch(WINDOW *win, wint_t *result)
                    reset_mbytes(state);
                    if (check_mbytes(wch, buffer, count, state) != status) {
                        code = ERR;     /* the two calls should match */
-                       _nc_ungetch(sp, (int) value);
+                       safe_ungetch (SP_PARM, (int) value);
                    }
                    value = wch;
                    break;
index bb2c4a084b15f51d37d7540fb7dd6f6b4897c78f..1d2cf83ef8d2fcf0cdf7a0e1d11b18003a2a0f42 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 2002-2008,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_unget_wch.c,v 1.10 2008/06/07 14:50:37 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.11 2009/04/04 23:57:25 tom Exp $")
 
 /*
  * Wrapper for wcrtomb() which obtains the length needed for the given
@@ -65,14 +65,14 @@ _nc_wcrtomb(char *target, wchar_t source, mbstate_t * state)
 }
 
 NCURSES_EXPORT(int)
-unget_wch(const wchar_t wch)
+NCURSES_SP_NAME(unget_wch) (NCURSES_SP_DCLx const wchar_t wch)
 {
     int result = OK;
     mbstate_t state;
     size_t length;
     int n;
 
-    T((T_CALLED("unget_wch(%#lx)"), (unsigned long) wch));
+    T((T_CALLED("unget_wch(%p, %#lx)"), SP_PARM, (unsigned long) wch));
 
     init_mb(state);
     length = _nc_wcrtomb(0, wch, &state);
@@ -86,7 +86,7 @@ unget_wch(const wchar_t wch)
            wcrtomb(string, wch, &state);
 
            for (n = (int) (length - 1); n >= 0; --n) {
-               if (_nc_ungetch(SP, string[n]) != OK) {
+               if (NCURSES_SP_NAME(ungetch) (NCURSES_SP_ARGx string[n]) != OK) {
                    result = ERR;
                    break;
                }
@@ -101,3 +101,11 @@ unget_wch(const wchar_t wch)
 
     returnCode(result);
 }
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+unget_wch(const wchar_t wch)
+{
+    return NCURSES_SP_NAME(unget_wch) (CURRENT_SCREEN, wch);
+}
+#endif
index be2259acdcffda4cf49dca6f428673cfe173abd6..b9f8d6a5e0f180cfefca5bcbebee5ff228167253 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2001-2005,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 2001-2007,2009 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_wunctrl.c,v 1.12 2007/06/12 20:22:32 tom Exp $")
+MODULE_ID("$Id: lib_wunctrl.c,v 1.13 2009/04/18 19:06:55 tom Exp $")
 
 NCURSES_EXPORT(wchar_t *)
-wunctrl(cchar_t *wc)
+NCURSES_SP_NAME(wunctrl) (NCURSES_SP_DCLx cchar_t *wc)
 {
-    static wchar_t str[CCHARW_MAX + 1], *sp;
+    static wchar_t str[CCHARW_MAX + 1], *wsp;
 
     if (Charable(*wc)) {
-       const char *p = unctrl((unsigned) _nc_to_char((wint_t) CharOf(*wc)));
+       const char *p =
+       NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx
+                                (unsigned) _nc_to_char((wint_t)CharOf(*wc)));
 
-       for (sp = str; *p; ++p) {
-           *sp++ = _nc_to_widechar(*p);
+       for (wsp = str; *p; ++p) {
+           *wsp++ = _nc_to_widechar(*p);
        }
-       *sp = 0;
+       *wsp = 0;
        return str;
     } else
        return wc->chars;
 }
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(wchar_t *)
+wunctrl(cchar_t *wc)
+{
+    return NCURSES_SP_NAME(wunctrl) (CURRENT_SCREEN, wc);
+}
+#endif