+ continue integrating "sp-funcs" by Juergen Pfeifer (incomplete).
-- 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
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
# 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
# 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)
/****************************************************************************
- * 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 *
#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
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
+ }
}
/*---------------------------------------------------------------------------
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 */
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"
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"
* 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
#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 */
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 */
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 */
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 */
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*);
-/* $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
}
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)
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);
#define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */
#endif
+#include <unctrl.h>
+
#ifdef __cplusplus
#ifndef NCURSES_NOMACROS
-/* $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
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
/*
/****************************************************************************
- * 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 *
/****************************************************************************
* 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
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
* 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
#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
/****************************************************************************
- * 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 *
* 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
#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
-# $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"), #
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) {
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 "}"
}
#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);
* 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));
/* 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') {
{
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
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
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.
/****************************************************************************
- * 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) {
if (!deleted)
break;
}
- delscreen(SP);
+ delscreen(SP_PARM);
_nc_unlock_global(curses);
}
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 */
{
}
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
#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>
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
#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 */
|| !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
#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;
}
}
/****************************************************************************
- * 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 *
#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
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;
}
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)
} 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)
/****************************************************************************
- * 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 *
#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)
}
#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);
#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
#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;
#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)
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);
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
}
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;
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))
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;
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));
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
/****************************************************************************
- * 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 *
#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)
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);
/****************************************************************************
- * 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 *
#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,...)
{
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);
/****************************************************************************
- * 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 *
#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)
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);
#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>
#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;
#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
/****************************************************************************
- * 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 <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)
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) {
/****************************************************************************
- * 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 <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)
_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),
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)));
}
/*
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);
_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)) {
_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;
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;
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;
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
#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
* 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;
#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);
}
}
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
/*
- * $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
*
#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, \
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
#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
#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);
/* 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);
#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);
#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
*/
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**);
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
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
#!/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"), #
# 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
#
*/
#include <curses.priv.h>
-#include <term.h>
EOF
/****************************************************************************
- * 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 <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
/*
/*
* 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:
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;
/*
* 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:
for (j = first; j < last; j++) {
if (!strcmp(name, tp->ext_Names[j])) {
- return j;
+ return (int) j;
}
}
return -1;
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];
}
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;
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];
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) {
/****************************************************************************
- * 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()
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);
#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.
}
NCURSES_EXPORT(int)
-del_curterm(TERMINAL * termp)
+NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL * termp)
{
int rc = ERR;
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
#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
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
#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 $")
/****************************************************************************
*
NCURSES_EXPORT(int *)
_nc_ptr_Lines(void)
{
- return ptrLines();
+ return ptrLines(CURRENT_SCREEN);
}
NCURSES_EXPORT(int)
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)
/*
* 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;
/****************************************************************************
- * 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 <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[] =
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:
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;
}
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;
case NUMBER:
entryp->tterm.Numbers[entry_ptr->nte_index] =
- _nc_curr_token.tk_valnumber;
+ (short) _nc_curr_token.tk_valnumber;
break;
case STRING:
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)
/****************************************************************************
- * 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 *
#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;
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))) {
while (*other_names != '\0') {
ptr = other_names++;
+ assert(ptr < buffer + sizeof(buffer) - 1);
while (*other_names != '|' && *other_names != '\0')
other_names++;
}
while (*other_names != '\0') {
ptr = other_names++;
- assert(ptr < buffer + sizeof(buffer) - 1);
while (*other_names != '|' && *other_names != '\0')
other_names++;
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)
#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++) {
} 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));
}
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)
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)
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;
#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);
*/
#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))
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 */
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, " | ");
/****************************************************************************
- * 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 <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
: _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);
*/
(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);
NCURSES_EXPORT(char *)
_tracechar(int ch)
{
- return _nc_tracechar(SP, ch);
+ return _nc_tracechar(CURRENT_SCREEN, ch);
}
#else
EMPTY_MODULE(_nc_lib_tracechr)
/****************************************************************************
- * 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 <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
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);
}
* 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)
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 {
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)
/****************************************************************************
- * 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 <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;
}
}
/* 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;
}
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
/****************************************************************************
- * 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 *
*****************************************************************************/
#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
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])
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);
}
/* 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++;
}
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;
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++;
* 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;
* 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 */
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));
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));
}
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
/*
* 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 */
}
/*
* 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
* 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)
* 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 */
{
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));
}
}
/* 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) {
/* 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;
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;
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 */
* 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);
}
/*
(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) {
}
}
- 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);
/****************************************************************************
- * 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 *
#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
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
static void
tstp(int dummy GCC_UNUSED)
{
+ SCREEN *sp = CURRENT_SCREEN;
sigset_t mask, omask;
sigaction_t act, oact;
* 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
* to repaint the screen.
*/
(void) sigemptyset(&mask);
+#ifdef SIGALRM
(void) sigaddset(&mask, SIGALRM);
+#endif
#if USE_SIGWINCH
(void) sigaddset(&mask, SIGWINCH);
#endif
* 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);
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);
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
*/
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);
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! */
}
}
}
/****************************************************************************
- * 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)
}
#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.
* 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;
milliseconds, mode));
#ifdef NCURSES_WGETCH_EVENTS
- if (mode & 4) {
+ if (mode & TW_EVENT) {
int event_delay = _nc_eventlist_timeout(evl);
if (event_delay >= 0
count = 0;
#ifdef NCURSES_WGETCH_EVENTS
- if ((mode & 4) && evl)
+ if ((mode & TW_EVENT) && evl)
evl->result_flags = 0;
#endif
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];
result = poll(fds, (unsigned) count, milliseconds);
#ifdef NCURSES_WGETCH_EVENTS
- if ((mode & 4) && evl) {
+ if ((mode & TW_EVENT) && evl) {
int c;
if (!result)
*
* 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;
*/
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];
}
#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];
}
}
#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);
#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
/* #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
/****************************************************************************
/* 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 */
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);
}
}
}
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");
}
/*
* 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;
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;
* 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));
* 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)
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;
}
for (i = 0; i < num; i++)
- PutChar(CHREF(ntext[i]));
+ PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));
return 0;
}
* 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)
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 */
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;
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;
/* 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;
_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;
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 {
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++) {
*/
if (newscr->_line[i].firstchar != _NOCHANGE
|| curscr->_line[i].firstchar != _NOCHANGE) {
- TransformLine(i);
+ TransformLine(NCURSES_SP_ARGx i);
changedlines++;
}
*/
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("")));
}
*/
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;
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));
}
}
}
*/
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;
}
}
* 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;
/* 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];
}
}
}
*/
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;
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
* 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]));
}
}
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;
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
/*
*/
} 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:
&& 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;
}
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");
}
} 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]))
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));
}
/* 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;
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) {
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
}
/* 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;
}
*/
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);
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;
}
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);
}
} 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;
}
count--;
}
}
- position_check(SP->_cursrow, SP->_curscol, "InsStr");
+ position_check(SP_PARM->_cursrow, SP_PARM->_curscol, "InsStr");
}
/*
/* 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;
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
/* 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;
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
* 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);
* 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");
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)
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");
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)
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);
}
}
}
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)
{
/* 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)
/****************************************************************************
- * 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 *
#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)
* 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 {
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;
/****************************************************************************
- * 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 *
#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
}
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);
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;
}
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
/****************************************************************************
- * 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