-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
--- $Id: NEWS,v 1.1199 2008/01/19 21:10:02 tom Exp $
+-- $Id: NEWS,v 1.1204 2008/02/03 20:34:02 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.
+20080203
+ + modify _nc_setupscreen() to set the legacy-coding value the same
+ for both narrow/wide models. It had been set only for wide model,
+ but is needed to make unctrl() work with locale in the narrow model.
+ + improve waddch() and winsch() handling of EILSEQ from mbrtowc() by
+ using unctrl() to display illegal bytes rather than trying to append
+ further bytes to make up a valid sequence (reported by Andrey A
+ Chernov).
+ + modify unctrl() to check codes in 128-255 range versus isprint().
+ If they are not printable, and locale was set, use a "M-" or "~"
+ sequence.
+
+20080126
+ + improve threading in test/worm.c (wrap refresh calls, and KEY_RESIZE
+ handling). Now it hangs in napms(), no matter whether nanosleep()
+ or poll() or select() are used on Linux.
+
20080119
+ fixes to build with --disable-ext-funcs
+ add manpage for use_window and use_screen.
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: dist.mk,v 1.625 2008/01/19 18:22:11 tom Exp $
+# $Id: dist.mk,v 1.628 2008/02/03 14:36:09 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 = 6
-NCURSES_PATCH = 20080119
+NCURSES_PATCH = 20080203
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
-# $Id: MKunctrl.awk,v 1.14 2007/07/28 21:13:21 tom Exp $
+# $Id: MKunctrl.awk,v 1.21 2008/02/03 20:24:30 tom Exp $
##############################################################################
-# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
# authorization. #
##############################################################################
#
-# Author: Thomas E. Dickey <dickey@clark.net> 1997
+# Author: Thomas E. Dickey (1997-on)
#
BEGIN {
print "/* generated by MKunctrl.awk */"
print ""
print "#include <curses.priv.h>"
+ print "#include <ctype.h>"
+ print ""
+ print "#if USE_WIDEC_SUPPORT"
+ print "#if HAVE_WCTYPE_H"
+ print "#include <wctype.h>"
+ print "#endif"
+ print "#endif"
print ""
print "#undef unctrl"
print ""
} else if (ch >= 128 && ch < 160) {
part = sprintf("~\\%03o", ch - 64);
offset = offset + 3;
+ } else if (ch == 255) {
+ part = "~?";
+ offset = offset + 3;
+ } else if (ch >= 160) {
+ part = sprintf("M-\\%03o", ch - 128);
+ offset = offset + 4;
} else {
gap = gap " "
part = sprintf("\\%03o", ch);
blob = blob "\"";
print ""
- print "#if NCURSES_EXT_FUNCS"
if (bigstrings) {
- blob = blob "\n#if NCURSES_EXT_FUNCS"
+ blob = blob "\n/* printable values in 128-255 range */"
printf "static const short unctrl_c1[] = {"
} else {
printf "static const char* const unctrl_c1[] = {"
}
- for ( ch = 128; ch < 160; ch++ ) {
+ for ( ch = 128; ch < 256; ch++ ) {
gap = ","
if ((ch % 8) == 0) {
if (ch != 128)
if (((ch + 1) % 8) != 0)
gap = gap " "
} else {
- if (ch >= 128 && ch < 160) {
+ if (ch >= 128) {
printf "\"\\%03o\"", ch
gap = gap " "
}
}
}
print "};"
- print "#endif /* NCURSES_EXT_FUNCS */"
- blob = blob "\"\n#endif /* NCURSES_EXT_FUNCS */\n"
+ blob = blob "\"\n"
print ""
if (bigstrings) {
} else {
stringname = "unctrl"
}
- print "\tint check = ChCharOf(ch);"
- print "\tconst char *result;"
- print ""
- print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
- print "#if NCURSES_EXT_FUNCS"
- print "\t\tif ((SP != 0)"
- print "\t\t && (SP->_legacy_coding > 1)"
- print "\t\t && (check >= 128)"
- print "\t\t && (check < 160))"
+ print "\tint check = ChCharOf(ch);"
+ print "\tconst char *result;"
+ print ""
+ print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
+ print "#if NCURSES_EXT_FUNCS"
+ print "\t\tif ((SP != 0)"
+ print "\t\t && (SP->_legacy_coding > 1)"
+ print "\t\t && (check >= 128)"
+ print "\t\t && (check < 160))"
+ printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
+ print "\t\telse"
+ print "#if USE_WIDEC_SUPPORT"
+ print "\t\tif ((check >= 160)"
+ print "\t\t && (check < 256)"
+ print "\t\t && ((SP != 0)"
+ print "\t\t && ((SP->_legacy_coding > 0)"
+ print "\t\t || (SP->_legacy_coding == 0"
+ print "\t\t && (isprint(check) || iswprint(check))))))"
+ printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
+ print "\t\telse"
+ print "#else"
+ print "\t\tif ((check >= 160)"
+ print "\t\t && (check < 256)"
+ print "\t\t && ((SP != 0)"
+ print "\t\t && ((SP->_legacy_coding > 0)"
+ print "\t\t || (SP->_legacy_coding == 0"
+ print "\t\t && isprint(check)))))"
printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
- print "\t\telse"
- print "#endif /* NCURSES_EXT_FUNCS */"
+ print "\t\telse"
+ print "#endif /* USE_WIDEC_SUPPORT */"
+ print "#endif /* NCURSES_EXT_FUNCS */"
printf "\t\t\tresult = %s_table[check];\n", stringname;
- print "\t} else {"
- print "\t\tresult = 0;"
- print "\t}"
- print "\treturn (NCURSES_CONST char *)result;"
- print "}"
+ print "\t} else {"
+ print "\t\tresult = 0;"
+ print "\t}"
+ print "\treturn (NCURSES_CONST char *)result;"
+ print "}"
}
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_addch.c,v 1.104 2006/10/14 20:31:19 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.108 2008/02/03 18:50:27 tom Exp $")
static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
attr_t attrs = AttrOf(CHDEREF(ch));
SetChar(CHDEREF(ch), result, attrs);
WINDOW_EXT(win, addch_used) = 0;
- } else {
- if (len == -1) {
- /*
- * An error occurred. We could either discard everything,
- * or assume that the error was in the previous input.
- * Try the latter.
- */
- TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error"));
- buffer[0] = CharOf(CHDEREF(ch));
- WINDOW_EXT(win, addch_used) = 1;
- }
+ } else if (len == -1) {
+ /*
+ * An error occurred. We could either discard everything,
+ * or assume that the error was in the previous input.
+ * Try the latter.
+ */
+ TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error"));
+ /* handle this with unctrl() */
+ WINDOW_EXT(win, addch_used) = 0;
}
return len;
}
if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) {
int len = _nc_build_wch(win, CHREF(ch));
- if (len > 0) {
+ if (len >= -1) {
+ /* handle EILSEQ */
if (is8bits(CharOf(ch))) {
const char *s = unctrl((chtype) CharOf(ch));
if (s[1] != 0) {
return waddstr(win, s);
}
}
+ if (len == -1)
+ return waddch(win, ' ');
} else {
return OK;
}
/****************************************************************************
- * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_insch.c,v 1.24 2005/02/26 19:27:28 tom Exp $")
+MODULE_ID("$Id: lib_insch.c,v 1.25 2008/02/03 00:14:37 tom Exp $")
/*
* Insert the given character, updating the current location to simplify
} else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) {
s = unctrl(ChCharOf(ch));
while (*s != '\0') {
- if ((code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s))) != OK)
+ code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s));
+ if (code != OK)
break;
++s;
}
*/
SetChar2(wch, ch);
wch = _nc_render(win, wch);
- if (_nc_build_wch(win, &wch) >= 0)
+ count = _nc_build_wch(win, &wch);
+ if (count > 0) {
code = wins_wch(win, &wch);
+ } else if (count == -1) {
+ /* handle EILSEQ */
+ if (is8bits(ch)) {
+ s = unctrl(ChCharOf(ch));
+ while (*s != '\0') {
+ code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s));
+ if (code != OK)
+ break;
+ ++s;
+ }
+ } else {
+ code = ERR;
+ }
+ }
}
#endif
break;
/****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_set_term.c,v 1.102 2007/12/29 20:36:32 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.103 2008/02/03 20:31:08 tom Exp $")
NCURSES_EXPORT(SCREEN *)
set_term(SCREEN *screenp)
bool filtered,
int slk_format)
{
+ char *env;
int bottom_stolen = 0;
bool support_cookies = USE_XMC_SUPPORT;
ripoff_t *rop;
_nc_init_wacs();
SP->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs());
- {
- char *env = _nc_get_locale();
- SP->_legacy_coding = ((env == 0)
- || !strcmp(env, "C")
- || !strcmp(env, "POSIX"));
- }
#endif
+ env = _nc_get_locale();
+ SP->_legacy_coding = ((env == 0)
+ || !strcmp(env, "C")
+ || !strcmp(env, "POSIX"));
+ T(("legacy-coding %d", SP->_legacy_coding));
_nc_idcok = TRUE;
_nc_idlok = FALSE;
/****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
/****************************************************************************
* Author: Thomas E. Dickey 1996-on *
****************************************************************************/
-/* $Id: test.priv.h,v 1.68 2007/06/30 17:53:09 tom Exp $ */
+/* $Id: test.priv.h,v 1.69 2008/01/26 22:05:48 tom Exp $ */
#ifndef __TEST_PRIV_H
#define __TEST_PRIV_H 1
signal(nsig, handler); \
}
+/*
+ * Simplify setting up demo of threading with these macros.
+ */
+#if !defined(NCURSES_VERSION_PATCH) || (NCURSES_VERSION_PATCH < 20070915) || !NCURSES_EXT_FUNCS
+#define WANT_USE_WINDOW() \
+static int \
+use_window(WINDOW *win, int (*func) (WINDOW *, void *), void *data) \
+{ \
+ return func(win, data); \
+}
+#define USING_WINDOW(w,func) use_window(w, (NCURSES_CALLBACK) func, w)
+#else
+#define WANT_USE_WINDOW() /* nothing */
+#define USING_WINDOW(w,func) func(w)
+#endif
+
+
#endif /* __TEST_PRIV_H */
traces will be dumped. The program stops and waits for one character of
input at the beginning and end of the interval.
- $Id: worm.c,v 1.53 2008/01/19 20:56:38 tom Exp $
+ $Id: worm.c,v 1.55 2008/01/26 22:07:57 tom Exp $
*/
#include <test.priv.h>
#include <pthread.h>
#endif
+WANT_USE_WINDOW();
+
+#define MAX_WORMS 40
+#define MAX_LENGTH 1024
+
static chtype flavor[] =
{
'O', '*', '#', '$', '%', '0', '@',
static unsigned long sequence = 0;
static bool quitting = FALSE;
-static WORM worm[40];
+static WORM worm[MAX_WORMS];
static short **refs;
+static int last_x, last_y;
static const char *field;
static int length = 16, number = 3;
static void
cleanup(void)
{
- standend();
- refresh();
+ USING_WINDOW(stdscr, wrefresh);
curs_set(1);
endwin();
}
int y;
int h;
- int bottom = LINES - 1;
- int last = COLS - 1;
-
bool done = FALSE;
if ((x = w->xpos[h = w->head]) < 0) {
- wmove(win, y = w->ypos[h] = bottom, x = w->xpos[h] = 0);
+ wmove(win, y = w->ypos[h] = last_y, x = w->xpos[h] = 0);
waddch(win, w->attrs);
refs[y][x]++;
} else {
y = w->ypos[h];
}
- if (x > last)
- x = last;
- if (y > bottom)
- y = bottom;
+ if (x > last_x)
+ x = last_x;
+ if (y > last_y)
+ y = last_y;
if (++h == length)
h = 0;
op = &(x == 0
? (y == 0
? upleft
- : (y == bottom
+ : (y == last_y
? lowleft
: left))
- : (x == last
+ : (x == last_x
? (y == 0
? upright
- : (y == bottom
+ : (y == last_y
? lowright
: right))
: (y == 0
? upper
- : (y == bottom
+ : (y == last_y
? lower
: normal))))[w->orientation];
return done;
}
-#if !defined(NCURSES_VERSION_PATCH) || (NCURSES_VERSION_PATCH < 20070915) || !NCURSES_EXT_FUNCS
-static int
-use_window(WINDOW *win, int (*func) (WINDOW *, void *), void *data)
-{
- return func(win, data);
-}
-#endif
-
#ifdef USE_PTHREADS
static bool
quit_worm(void)
get_input(void)
{
int ch;
-#ifdef USE_PTHREADS
- ch = use_window(stdscr, (NCURSES_CALLBACK) wgetch, stdscr);
-#else
- ch = getch();
-#endif
+ ch = USING_WINDOW(stdscr, wgetch);
return ch;
}
+#ifdef KEY_RESIZE
+static int
+update_refs(WINDOW *win)
+{
+ int x, y;
+
+ (void) win;
+ if (last_x != COLS - 1) {
+ for (y = 0; y <= last_y; y++) {
+ refs[y] = typeRealloc(short, COLS, refs[y]);
+ for (x = last_x + 1; x < COLS; x++)
+ refs[y][x] = 0;
+ }
+ last_x = COLS - 1;
+ }
+ if (last_y != LINES - 1) {
+ for (y = LINES; y <= last_y; y++)
+ free(refs[y]);
+ refs = typeRealloc(short *, LINES, refs);
+ for (y = last_y + 1; y < LINES; y++) {
+ refs[y] = typeMalloc(short, COLS);
+ for (x = 0; x < COLS; x++)
+ refs[y][x] = 0;
+ }
+ last_y = LINES - 1;
+ }
+ return OK;
+}
+#endif
+
int
main(int argc, char *argv[])
{
int n;
struct worm *w;
short *ip;
- int last, bottom;
bool done = FALSE;
setlocale(LC_ALL, "");
case 'l':
if (++x == argc)
goto usage;
- if ((length = atoi(argv[x])) < 2 || length > 1024) {
+ if ((length = atoi(argv[x])) < 2 || length > MAX_LENGTH) {
fprintf(stderr, "%s: Invalid length\n", *argv);
ExitProgram(EXIT_FAILURE);
}
case 'n':
if (++x == argc)
goto usage;
- if ((number = atoi(argv[x])) < 1 || number > 40) {
+ if ((number = atoi(argv[x])) < 1 || number > MAX_WORMS) {
fprintf(stderr, "%s: Invalid number of worms\n", *argv);
ExitProgram(EXIT_FAILURE);
}
curs_set(0);
- bottom = LINES - 1;
- last = COLS - 1;
+ last_y = LINES - 1;
+ last_x = COLS - 1;
#ifdef A_COLOR
if (has_colors()) {
#ifdef BADCORNER
/* if addressing the lower right corner doesn't work in your curses */
- refs[bottom][last] = 1;
+ refs[last_y][last_x] = 1;
#endif /* BADCORNER */
for (n = number, w = &worm[0]; --n >= 0; w++) {
if (field) {
const char *p;
p = field;
- for (y = bottom; --y >= 0;) {
+ for (y = last_y; --y >= 0;) {
for (x = COLS; --x >= 0;) {
addch((chtype) (*p++));
if (!*p)
}
}
}
- refresh();
+ USING_WINDOW(stdscr, wrefresh);
nodelay(stdscr, TRUE);
while (!done) {
generation++;
}
#endif
+
#ifdef KEY_RESIZE
if (ch == KEY_RESIZE) {
- if (last != COLS - 1) {
- for (y = 0; y <= bottom; y++) {
- refs[y] = typeRealloc(short, COLS, refs[y]);
- for (x = last + 1; x < COLS; x++)
- refs[y][x] = 0;
- }
- last = COLS - 1;
- }
- if (bottom != LINES - 1) {
- for (y = LINES; y <= bottom; y++)
- free(refs[y]);
- refs = typeRealloc(short *, LINES, refs);
- for (y = bottom + 1; y < LINES; y++) {
- refs[y] = typeMalloc(short, COLS);
- for (x = 0; x < COLS; x++)
- refs[y][x] = 0;
- }
- bottom = LINES - 1;
- }
+ USING_WINDOW(stdscr, update_refs);
}
#endif
+
/*
* Make it simple to put this into single-step mode, or resume
* normal operation -T.Dickey
done = draw_all_worms();
napms(10);
- refresh();
+ USING_WINDOW(stdscr, wrefresh);
}
cleanup();