aboutsummaryrefslogtreecommitdiff
path: root/ncurses/widechar
diff options
context:
space:
mode:
Diffstat (limited to 'ncurses/widechar')
-rw-r--r--ncurses/widechar/lib_add_wch.c438
-rw-r--r--ncurses/widechar/lib_box_set.c6
-rw-r--r--ncurses/widechar/lib_cchar.c34
-rw-r--r--ncurses/widechar/lib_erasewchar.c8
-rw-r--r--ncurses/widechar/lib_get_wch.c33
-rw-r--r--ncurses/widechar/lib_get_wstr.c7
-rw-r--r--ncurses/widechar/lib_hline_set.c12
-rw-r--r--ncurses/widechar/lib_in_wch.c6
-rw-r--r--ncurses/widechar/lib_in_wchnstr.c6
-rw-r--r--ncurses/widechar/lib_ins_wch.c62
-rw-r--r--ncurses/widechar/lib_inwstr.c8
-rw-r--r--ncurses/widechar/lib_pecho_wchar.c8
-rw-r--r--ncurses/widechar/lib_unget_wch.c28
-rw-r--r--ncurses/widechar/lib_vid_attr.c124
-rw-r--r--ncurses/widechar/lib_vline_set.c12
-rw-r--r--ncurses/widechar/lib_wacs.c31
-rw-r--r--ncurses/widechar/lib_wunctrl.c26
17 files changed, 637 insertions, 212 deletions
diff --git a/ncurses/widechar/lib_add_wch.c b/ncurses/widechar/lib_add_wch.c
index 93b41bb4930c..38d3130a54c4 100644
--- a/ncurses/widechar/lib_add_wch.c
+++ b/ncurses/widechar/lib_add_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2004,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 2004-2010,2011 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 *
@@ -35,79 +35,409 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_add_wch.c,v 1.6 2006/12/02 21:19:17 tom Exp $")
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
-NCURSES_EXPORT(int)
-wadd_wch(WINDOW *win, const cchar_t *wch)
+MODULE_ID("$Id: lib_add_wch.c,v 1.12 2011/03/22 09:31:15 Petr.Pavlu Exp $")
+
+/* clone/adapt lib_addch.c */
+static const cchar_t blankchar = NewChar(BLANK_TEXT);
+
+/*
+ * Ugly microtweaking alert. Everything from here to end of module is
+ * likely to be speed-critical -- profiling data sure says it is!
+ * Most of the important screen-painting functions are shells around
+ * wadd_wch(). So we make every effort to reduce function-call overhead
+ * by inlining stuff, even at the cost of making wrapped copies for
+ * export. Also we supply some internal versions that don't call the
+ * window sync hook, for use by string-put functions.
+ */
+
+/* Return bit mask for clearing color pair number if given ch has color */
+#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0))
+
+static NCURSES_INLINE cchar_t
+render_char(WINDOW *win, cchar_t ch)
+/* compute a rendition of the given char correct for the current context */
{
- PUTC_DATA;
- int n;
- int code = ERR;
+ attr_t a = WINDOW_ATTRS(win);
+ int pair = GetPair(ch);
+
+ if (ISBLANK(ch)
+ && AttrOf(ch) == A_NORMAL
+ && pair == 0) {
+ /* color/pair in attrs has precedence over bkgrnd */
+ ch = win->_nc_bkgd;
+ SetAttr(ch, a | AttrOf(win->_nc_bkgd));
+ if ((pair = GET_WINDOW_PAIR(win)) == 0)
+ pair = GetPair(win->_nc_bkgd);
+ SetPair(ch, pair);
+ } else {
+ /* color in attrs has precedence over bkgrnd */
+ a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a);
+ /* color in ch has precedence */
+ if (pair == 0) {
+ if ((pair = GET_WINDOW_PAIR(win)) == 0)
+ pair = GetPair(win->_nc_bkgd);
+ }
+ AddAttr(ch, (a & COLOR_MASK(AttrOf(ch))));
+ SetPair(ch, pair);
+ }
+
+ TR(TRACE_VIRTPUT,
+ ("render_char bkg %s (%d), attrs %s (%d) -> ch %s (%d)",
+ _tracech_t2(1, CHREF(win->_nc_bkgd)),
+ GetPair(win->_nc_bkgd),
+ _traceattr(WINDOW_ATTRS(win)),
+ GET_WINDOW_PAIR(win),
+ _tracech_t2(3, CHREF(ch)),
+ GetPair(ch)));
+
+ return (ch);
+}
+
+/* check if position is legal; if not, return error */
+#ifndef NDEBUG /* treat this like an assertion */
+#define CHECK_POSITION(win, x, y) \
+ if (y > win->_maxy \
+ || x > win->_maxx \
+ || y < 0 \
+ || x < 0) { \
+ TR(TRACE_VIRTPUT, ("Alert! Win=%p _curx = %d, _cury = %d " \
+ "(_maxx = %d, _maxy = %d)", win, x, y, \
+ win->_maxx, win->_maxy)); \
+ return(ERR); \
+ }
+#else
+#define CHECK_POSITION(win, x, y) /* nothing */
+#endif
+
+static bool
+newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T * ypos)
+{
+ bool result = FALSE;
+
+ if (*ypos >= win->_regtop && *ypos == win->_regbottom) {
+ *ypos = win->_regbottom;
+ result = TRUE;
+ } else {
+ *ypos = (NCURSES_SIZE_T) (*ypos + 1);
+ }
+ return result;
+}
- TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), win,
- _tracech_t(wch)));
-
- if (win != 0) {
- PUTC_INIT;
- for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
- attr_t attrs = (wch->attr & A_ATTRIBUTES);
-
- if ((PUTC_ch = wch->chars[PUTC_i]) == L'\0')
- break;
- if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) {
- code = ERR;
- if (is8bits(PUTC_ch))
- code = waddch(win, UChar(PUTC_ch) | attrs);
- break;
+/*
+ * The _WRAPPED flag is useful only for telling an application that we've just
+ * wrapped the cursor. We don't do anything with this flag except set it when
+ * wrapping, and clear it whenever we move the cursor. If we try to wrap at
+ * the lower-right corner of a window, we cannot move the cursor (since that
+ * wouldn't be legal). So we return an error (which is what SVr4 does).
+ * Unlike SVr4, we can successfully add a character to the lower-right corner
+ * (Solaris 2.6 does this also, however).
+ */
+static int
+wrap_to_next_line(WINDOW *win)
+{
+ win->_flags |= _WRAPPED;
+ if (newline_forces_scroll(win, &(win->_cury))) {
+ win->_curx = win->_maxx;
+ if (!win->_scroll)
+ return (ERR);
+ scroll(win);
+ }
+ win->_curx = 0;
+ return (OK);
+}
+
+static int wadd_wch_literal(WINDOW *, cchar_t);
+/*
+ * Fill the given number of cells with blanks using the current background
+ * rendition. This saves/restores the current x-position.
+ */
+static void
+fill_cells(WINDOW *win, int count)
+{
+ cchar_t blank = blankchar;
+ int save_x = win->_curx;
+ int save_y = win->_cury;
+
+ while (count-- > 0) {
+ if (wadd_wch_literal(win, blank) == ERR)
+ break;
+ }
+ win->_curx = (NCURSES_SIZE_T) save_x;
+ win->_cury = (NCURSES_SIZE_T) save_y;
+}
+
+static int
+wadd_wch_literal(WINDOW *win, cchar_t ch)
+{
+ int x;
+ int y;
+ struct ldat *line;
+
+ x = win->_curx;
+ y = win->_cury;
+
+ CHECK_POSITION(win, x, y);
+
+ ch = render_char(win, ch);
+
+ line = win->_line + y;
+
+ CHANGED_CELL(line, x);
+
+ /*
+ * Non-spacing characters are added to the current cell.
+ *
+ * Spacing characters that are wider than one column require some display
+ * adjustments.
+ */
+ {
+ int len = wcwidth(CharOf(ch));
+ int i;
+ int j;
+ wchar_t *chars;
+
+ if (len == 0) { /* non-spacing */
+ if ((x > 0 && y >= 0)
+ || (win->_maxx >= 0 && win->_cury >= 1)) {
+ if (x > 0 && y >= 0)
+ chars = (win->_line[y].text[x - 1].chars);
+ else
+ chars = (win->_line[y - 1].text[win->_maxx].chars);
+ for (i = 0; i < CCHARW_MAX; ++i) {
+ if (chars[i] == 0) {
+ TR(TRACE_VIRTPUT,
+ ("added non-spacing %d: %x",
+ x, (int) CharOf(ch)));
+ chars[i] = CharOf(ch);
+ break;
+ }
+ }
+ }
+ goto testwrapping;
+ } else if (len > 1) { /* multi-column characters */
+ /*
+ * Check if the character will fit on the current line. If it does
+ * not fit, fill in the remainder of the line with blanks. and
+ * move to the next line.
+ */
+ if (len > win->_maxx + 1) {
+ TR(TRACE_VIRTPUT, ("character will not fit"));
+ return ERR;
+ } else if (x + len > win->_maxx + 1) {
+ int count = win->_maxx + 1 - x;
+ TR(TRACE_VIRTPUT, ("fill %d remaining cells", count));
+ fill_cells(win, count);
+ if (wrap_to_next_line(win) == ERR)
+ return ERR;
+ x = win->_curx;
+ y = win->_cury;
+ line = win->_line + y;
}
- for (n = 0; n < PUTC_n; n++) {
- if ((code = waddch(win, UChar(PUTC_buf[n]) | attrs)) == ERR) {
+ /*
+ * Check for cells which are orphaned by adding this character, set
+ * those to blanks.
+ *
+ * FIXME: this actually could fill j-i cells, more complicated to
+ * setup though.
+ */
+ for (i = 0; i < len; ++i) {
+ if (isWidecBase(win->_line[y].text[x + i])) {
+ break;
+ } else if (isWidecExt(win->_line[y].text[x + i])) {
+ for (j = i; x + j <= win->_maxx; ++j) {
+ if (!isWidecExt(win->_line[y].text[x + j])) {
+ TR(TRACE_VIRTPUT, ("fill %d orphan cells", j));
+ fill_cells(win, j);
+ break;
+ }
+ }
break;
}
}
- if (code == ERR)
- break;
+ /*
+ * Finally, add the cells for this character.
+ */
+ for (i = 0; i < len; ++i) {
+ cchar_t value = ch;
+ SetWidecExt(value, i);
+ TR(TRACE_VIRTPUT, ("multicolumn %d:%d (%d,%d)",
+ i + 1, len,
+ win->_begy + y, win->_begx + x));
+ line->text[x] = value;
+ CHANGED_CELL(line, x);
+ ++x;
+ }
+ goto testwrapping;
}
}
- TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));
- return (code);
+ /*
+ * Single-column characters.
+ */
+ line->text[x++] = ch;
+ /*
+ * This label is used only for wide-characters.
+ */
+ testwrapping:
+
+ TR(TRACE_VIRTPUT, ("cell (%ld, %ld..%d) = %s",
+ (long) win->_cury, (long) win->_curx, x - 1,
+ _tracech_t(CHREF(ch))));
+
+ if (x > win->_maxx) {
+ return wrap_to_next_line(win);
+ }
+ win->_curx = (NCURSES_SIZE_T) x;
+ return OK;
}
-NCURSES_EXPORT(int)
-wecho_wchar(WINDOW *win, const cchar_t *wch)
+static NCURSES_INLINE int
+wadd_wch_nosync(WINDOW *win, cchar_t ch)
+/* the workhorse function -- add a character to the given window */
{
- PUTC_DATA;
- int n;
- int code = ERR;
+ NCURSES_SIZE_T x, y;
+ wchar_t *s;
+ int tabsize = 8;
+#if USE_REENTRANT
+ SCREEN *sp = _nc_screen_of(win);
+#endif
+
+ /*
+ * If we are using the alternate character set, forget about locale.
+ * Otherwise, if the locale claims the code is printable, treat it that
+ * way.
+ */
+ if ((AttrOf(ch) & A_ALTCHARSET)
+ || iswprint((wint_t) CharOf(ch)))
+ return wadd_wch_literal(win, ch);
- TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wecho_wchar(%p, %s)"), win,
- _tracech_t(wch)));
-
- if (win != 0) {
- PUTC_INIT;
- for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
- attr_t attrs = (wch->attr & A_ATTRIBUTES);
-
- if ((PUTC_ch = wch->chars[PUTC_i]) == L'\0')
- break;
- if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) {
- code = ERR;
- if (is8bits(PUTC_ch))
- code = waddch(win, UChar(PUTC_ch) | attrs);
- break;
+ /*
+ * Handle carriage control and other codes that are not printable, or are
+ * known to expand to more than one character according to unctrl().
+ */
+ x = win->_curx;
+ y = win->_cury;
+
+ switch (CharOf(ch)) {
+ case '\t':
+#if USE_REENTRANT
+ tabsize = *ptrTabsize(sp);
+#else
+ tabsize = TABSIZE;
+#endif
+ x = (NCURSES_SIZE_T) (x + (tabsize - (x % tabsize)));
+ /*
+ * Space-fill the tab on the bottom line so that we'll get the
+ * "correct" cursor position.
+ */
+ if ((!win->_scroll && (y == win->_regbottom))
+ || (x <= win->_maxx)) {
+ cchar_t blank = blankchar;
+ AddAttr(blank, AttrOf(ch));
+ while (win->_curx < x) {
+ if (wadd_wch_literal(win, blank) == ERR)
+ return (ERR);
}
- for (n = 0; n < PUTC_n; n++) {
- if ((code = waddch(win, UChar(PUTC_buf[n]) | attrs)) == ERR) {
- break;
+ break;
+ } else {
+ wclrtoeol(win);
+ win->_flags |= _WRAPPED;
+ if (newline_forces_scroll(win, &y)) {
+ x = win->_maxx;
+ if (win->_scroll) {
+ scroll(win);
+ x = 0;
}
+ } else {
+ x = 0;
+ }
+ }
+ break;
+ case '\n':
+ wclrtoeol(win);
+ if (newline_forces_scroll(win, &y)) {
+ if (win->_scroll)
+ scroll(win);
+ else
+ return (ERR);
+ }
+ /* FALLTHRU */
+ case '\r':
+ x = 0;
+ win->_flags &= ~_WRAPPED;
+ break;
+ case '\b':
+ if (x == 0)
+ return (OK);
+ x--;
+ win->_flags &= ~_WRAPPED;
+ break;
+ default:
+ if ((s = wunctrl(&ch)) != 0) {
+ while (*s) {
+ cchar_t sch;
+ SetChar(sch, *s++, AttrOf(ch));
+ if_EXT_COLORS(SetPair(sch, GetPair(ch)));
+ if (wadd_wch_literal(win, sch) == ERR)
+ return ERR;
}
- if (code == ERR)
- break;
+ return OK;
}
- wrefresh(win);
+ return ERR;
}
+ win->_curx = x;
+ win->_cury = y;
+
+ return OK;
+}
+
+/*
+ * The versions below call _nc_synchook(). We wanted to avoid this in the
+ * version exported for string puts; they'll call _nc_synchook once at end
+ * of run.
+ */
+
+/* These are actual entry points */
+
+NCURSES_EXPORT(int)
+wadd_wch(WINDOW *win, const cchar_t *wch)
+{
+ int code = ERR;
+
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"),
+ (void *) win,
+ _tracecchar_t(wch)));
+
+ if (win && (wadd_wch_nosync(win, *wch) != ERR)) {
+ _nc_synchook(win);
+ code = OK;
+ }
+
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));
+ return (code);
+}
+
+NCURSES_EXPORT(int)
+wecho_wchar(WINDOW *win, const cchar_t *wch)
+{
+ int code = ERR;
+
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"),
+ (void *) win,
+ _tracecchar_t(wch)));
+
+ if (win && (wadd_wch_nosync(win, *wch) != ERR)) {
+ bool save_immed = win->_immed;
+ win->_immed = TRUE;
+ _nc_synchook(win);
+ win->_immed = save_immed;
+ code = OK;
+ }
TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));
return (code);
}
diff --git a/ncurses/widechar/lib_box_set.c b/ncurses/widechar/lib_box_set.c
index 35fce46d8d40..585c94963b0f 100644
--- a/ncurses/widechar/lib_box_set.c
+++ b/ncurses/widechar/lib_box_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2003,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_box_set.c,v 1.4 2003/12/06 18:02:13 tom Exp $")
+MODULE_ID("$Id: lib_box_set.c,v 1.5 2009/10/24 22:36:56 tom Exp $")
NCURSES_EXPORT(int)
wborder_set(WINDOW *win,
@@ -53,7 +53,7 @@ wborder_set(WINDOW *win,
NCURSES_CH_T wls, wrs, wts, wbs, wtl, wtr, wbl, wbr;
T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
- win,
+ (void *) win,
_tracech_t2(1, ls),
_tracech_t2(2, rs),
_tracech_t2(3, ts),
diff --git a/ncurses/widechar/lib_cchar.c b/ncurses/widechar/lib_cchar.c
index b4a0c37a285f..c61c79529db7 100644
--- a/ncurses/widechar/lib_cchar.c
+++ b/ncurses/widechar/lib_cchar.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001-2005,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-2009,2010 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 *
@@ -35,7 +35,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_cchar.c,v 1.12 2007/05/12 19:03:06 tom Exp $")
+MODULE_ID("$Id: lib_cchar.c,v 1.20 2010/12/25 23:46:26 tom Exp $")
/*
* The SuSv2 description leaves some room for interpretation. We'll assume wch
@@ -50,15 +50,15 @@ setcchar(cchar_t *wcval,
short color_pair,
const void *opts)
{
- int i;
- int len;
+ unsigned i;
+ unsigned len;
int code = OK;
TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%lu,%d,%p)"),
- wcval, _nc_viswbuf(wch),
+ (void *) wcval, _nc_viswbuf(wch),
(unsigned long) attrs, color_pair, opts));
- len = wcslen(wch);
+ len = (unsigned) wcslen(wch);
if (opts != NULL
|| (len > 1 && wcwidth(wch[0]) < 0)) {
code = ERR;
@@ -80,7 +80,7 @@ setcchar(cchar_t *wcval,
memset(wcval, 0, sizeof(*wcval));
if (len != 0) {
- SetAttr(*wcval, attrs | COLOR_PAIR(color_pair));
+ SetAttr(*wcval, attrs | (attr_t) ColorPair(color_pair));
SetPair(CHDEREF(wcval), color_pair);
memcpy(&wcval->chars, wch, len * sizeof(wchar_t));
TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len,
@@ -104,20 +104,28 @@ getcchar(const cchar_t *wcval,
int code = ERR;
TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"),
- wcval, wch, attrs, color_pair, opts));
+ (const void *) wcval,
+ (void *) wch,
+ (void *) attrs,
+ (void *) color_pair,
+ opts));
if (opts == NULL) {
- len = (wp = wmemchr(wcval->chars, L'\0', CCHARW_MAX))
- ? wp - wcval->chars
- : CCHARW_MAX;
+ len = ((wp = wmemchr(wcval->chars, L'\0', CCHARW_MAX))
+ ? (int) (wp - wcval->chars)
+ : CCHARW_MAX);
if (wch == NULL) {
- code = len;
+ /*
+ * If the value is a null, set the length to 1.
+ * If the value is not a null, return the length plus 1 for null.
+ */
+ code = (len < CCHARW_MAX) ? (len + 1) : CCHARW_MAX;
} else if (attrs == 0 || color_pair == 0) {
code = ERR;
} else if (len >= 0) {
*attrs = AttrOf(*wcval) & A_ATTRIBUTES;
- *color_pair = GetPair(*wcval);
+ *color_pair = (short) GetPair(*wcval);
wmemcpy(wch, wcval->chars, (unsigned) len);
wch[len] = L'\0';
code = OK;
diff --git a/ncurses/widechar/lib_erasewchar.c b/ncurses/widechar/lib_erasewchar.c
index 7d6455370ff9..a4ee93ffa428 100644
--- a/ncurses/widechar/lib_erasewchar.c
+++ b/ncurses/widechar/lib_erasewchar.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc. *
+ * Copyright (c) 2002,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_erasewchar.c,v 1.1 2002/05/11 20:38:06 tom Exp $")
+MODULE_ID("$Id: lib_erasewchar.c,v 1.2 2010/07/24 11:35:12 tom Exp $")
/*
* erasewchar()
@@ -42,7 +42,7 @@ MODULE_ID("$Id: lib_erasewchar.c,v 1.1 2002/05/11 20:38:06 tom Exp $")
*/
NCURSES_EXPORT(int)
-erasewchar(wchar_t * wch)
+erasewchar(wchar_t *wch)
{
int value;
int result = ERR;
@@ -63,7 +63,7 @@ erasewchar(wchar_t * wch)
*/
NCURSES_EXPORT(int)
-killwchar(wchar_t * wch)
+killwchar(wchar_t *wch)
{
int value;
int result = ERR;
diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c
index 6cf3129f2d18..32033df2ff9b 100644
--- a/ncurses/widechar/lib_get_wch.c
+++ b/ncurses/widechar/lib_get_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,22 +40,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_get_wch.c,v 1.17 2008/08/16 19:22:55 tom Exp $")
-
-#if HAVE_MBTOWC && HAVE_MBLEN
-#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
-#define count_mbytes(buffer,length,state) mblen(buffer,length)
-#define check_mbytes(wch,buffer,length,state) \
- (int) mbtowc(&wch, buffer, length)
-#define state_unused
-#elif HAVE_MBRTOWC && HAVE_MBRLEN
-#define reset_mbytes(state) init_mb(state)
-#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
-#define check_mbytes(wch,buffer,length,state) \
- (int) mbrtowc(&wch, buffer, length, &state)
-#else
-make an error
-#endif
+MODULE_ID("$Id: lib_get_wch.c,v 1.22 2010/08/28 21:00:35 tom Exp $")
NCURSES_EXPORT(int)
wget_wch(WINDOW *win, wint_t *result)
@@ -65,13 +50,13 @@ wget_wch(WINDOW *win, wint_t *result)
char buffer[(MB_LEN_MAX * 9) + 1]; /* allow some redundant shifts */
int status;
size_t count = 0;
- unsigned long value;
+ int value = 0;
wchar_t wch;
#ifndef state_unused
mbstate_t state;
#endif
- T((T_CALLED("wget_wch(%p)"), win));
+ T((T_CALLED("wget_wch(%p)"), (void *) win));
/*
* We can get a stream of single-byte characters and KEY_xxx codes from
@@ -95,12 +80,12 @@ wget_wch(WINDOW *win, wint_t *result)
* whether the improvement would be worth the effort.
*/
if (count != 0) {
- _nc_ungetch(sp, (int) value);
+ safe_ungetch(SP_PARM, value);
code = ERR;
}
break;
} else if (count + 1 >= sizeof(buffer)) {
- _nc_ungetch(sp, (int) value);
+ safe_ungetch(SP_PARM, value);
code = ERR;
break;
} else {
@@ -111,7 +96,7 @@ wget_wch(WINDOW *win, wint_t *result)
reset_mbytes(state);
if (check_mbytes(wch, buffer, count, state) != status) {
code = ERR; /* the two calls should match */
- _nc_ungetch(sp, (int) value);
+ safe_ungetch(SP_PARM, value);
}
value = wch;
break;
@@ -121,8 +106,8 @@ wget_wch(WINDOW *win, wint_t *result)
} else {
code = ERR;
}
- *result = value;
+ *result = (wint_t) value;
_nc_unlock_global(curses);
- T(("result %#lo", value));
+ T(("result %#o", value));
returnCode(code);
}
diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c
index baa70a5a53f9..0b450211b2c3 100644
--- a/ncurses/widechar/lib_get_wstr.c
+++ b/ncurses/widechar/lib_get_wstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2004,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 *
@@ -38,9 +38,8 @@
*/
#include <curses.priv.h>
-#include <term.h>
-MODULE_ID("$Id: lib_get_wstr.c,v 1.10 2008/08/16 19:25:33 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.12 2009/10/24 22:38:11 tom Exp $")
static int
wadd_wint(WINDOW *win, wint_t *src)
@@ -96,7 +95,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
wint_t ch;
int y, x, code;
- T((T_CALLED("wgetn_wstr(%p,%p, %d)"), win, str, maxlen));
+ T((T_CALLED("wgetn_wstr(%p,%p, %d)"), (void *) win, (void *) str, maxlen));
if (!win)
returnCode(ERR);
diff --git a/ncurses/widechar/lib_hline_set.c b/ncurses/widechar/lib_hline_set.c
index 43175de83464..da92b834f1c3 100644
--- a/ncurses/widechar/lib_hline_set.c
+++ b/ncurses/widechar/lib_hline_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,16 +39,16 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_hline_set.c,v 1.2 2002/03/23 21:35:34 tom Exp $")
+MODULE_ID("$Id: lib_hline_set.c,v 1.4 2010/12/19 01:45:03 tom Exp $")
NCURSES_EXPORT(int)
-whline_set(WINDOW *win, const cchar_t * ch, int n)
+whline_set(WINDOW *win, const cchar_t *ch, int n)
{
int code = ERR;
- NCURSES_SIZE_T start;
- NCURSES_SIZE_T end;
+ int start;
+ int end;
- T((T_CALLED("whline_set(%p,%s,%d)"), win, _tracecchar_t(ch), n));
+ T((T_CALLED("whline_set(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n));
if (win) {
struct ldat *line = &(win->_line[win->_cury]);
diff --git a/ncurses/widechar/lib_in_wch.c b/ncurses/widechar/lib_in_wch.c
index 5cd92e382de4..b2396508ba25 100644
--- a/ncurses/widechar/lib_in_wch.c
+++ b/ncurses/widechar/lib_in_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2004,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-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 *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_in_wch.c,v 1.4 2006/09/03 15:41:22 tom Exp $")
+MODULE_ID("$Id: lib_in_wch.c,v 1.5 2009/10/24 22:37:55 tom Exp $")
NCURSES_EXPORT(int)
win_wch(WINDOW *win, cchar_t *wcval)
@@ -47,7 +47,7 @@ win_wch(WINDOW *win, cchar_t *wcval)
int row, col;
int code = OK;
- TR(TRACE_CCALLS, (T_CALLED("win_wch(%p,%p)"), win, wcval));
+ TR(TRACE_CCALLS, (T_CALLED("win_wch(%p,%p)"), (void *) win, (void *) wcval));
if (win != 0
&& wcval != 0) {
getyx(win, row, col);
diff --git a/ncurses/widechar/lib_in_wchnstr.c b/ncurses/widechar/lib_in_wchnstr.c
index e9f0646ea66a..57cc2ca6e73f 100644
--- a/ncurses/widechar/lib_in_wchnstr.c
+++ b/ncurses/widechar/lib_in_wchnstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2004-2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2007,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,14 +39,14 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_in_wchnstr.c,v 1.7 2007/02/11 01:00:00 tom Exp $")
+MODULE_ID("$Id: lib_in_wchnstr.c,v 1.8 2009/10/24 22:37:48 tom Exp $")
NCURSES_EXPORT(int)
win_wchnstr(WINDOW *win, cchar_t *wchstr, int n)
{
int code = OK;
- T((T_CALLED("win_wchnstr(%p,%p,%d)"), win, wchstr, n));
+ T((T_CALLED("win_wchnstr(%p,%p,%d)"), (void *) win, (void *) wchstr, n));
if (win != 0
&& wchstr != 0) {
NCURSES_CH_T *src;
diff --git a/ncurses/widechar/lib_ins_wch.c b/ncurses/widechar/lib_ins_wch.c
index c3d0420e53b8..1eee8a3ec016 100644
--- a/ncurses/widechar/lib_ins_wch.c
+++ b/ncurses/widechar/lib_ins_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2003,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,39 +39,44 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_ins_wch.c,v 1.8 2005/12/03 20:24:19 tom Exp $")
+MODULE_ID("$Id: lib_ins_wch.c,v 1.16 2010/12/19 01:34:04 tom Exp $")
/*
* Insert the given character, updating the current location to simplify
* inserting a string.
*/
-static int
+NCURSES_EXPORT(int)
_nc_insert_wch(WINDOW *win, const cchar_t *wch)
{
int cells = wcwidth(CharOf(CHDEREF(wch)));
int cell;
+ int code = OK;
+
+ if (cells < 0) {
+ code = winsch(win, (chtype) CharOf(CHDEREF(wch)));
+ } else {
+ if (cells == 0)
+ cells = 1;
+
+ if (win->_curx <= win->_maxx) {
+ struct ldat *line = &(win->_line[win->_cury]);
+ NCURSES_CH_T *end = &(line->text[win->_curx]);
+ NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
+ NCURSES_CH_T *temp2 = temp1 - cells;
+
+ CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+ while (temp1 > end)
+ *temp1-- = *temp2--;
+
+ *temp1 = _nc_render(win, *wch);
+ for (cell = 1; cell < cells; ++cell) {
+ SetWidecExt(temp1[cell], cell);
+ }
- if (cells <= 0)
- cells = 1;
-
- if (win->_curx <= win->_maxx) {
- struct ldat *line = &(win->_line[win->_cury]);
- NCURSES_CH_T *end = &(line->text[win->_curx]);
- NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
- NCURSES_CH_T *temp2 = temp1 - cells;
-
- CHANGED_TO_EOL(line, win->_curx, win->_maxx);
- while (temp1 > end)
- *temp1-- = *temp2--;
-
- *temp1 = _nc_render(win, *wch);
- for (cell = 1; cell < cells; ++cell) {
- SetWidecExt(temp1[cell], cell);
+ win->_curx++;
}
-
- win->_curx++;
}
- return OK;
+ return code;
}
NCURSES_EXPORT(int)
@@ -81,7 +86,7 @@ wins_wch(WINDOW *win, const cchar_t *wch)
NCURSES_SIZE_T ox;
int code = ERR;
- T((T_CALLED("wins_wch(%p, %s)"), win, _tracecchar_t(wch)));
+ T((T_CALLED("wins_wch(%p, %s)"), (void *) win, _tracecchar_t(wch)));
if (win != 0) {
oy = win->_cury;
@@ -104,20 +109,23 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
NCURSES_SIZE_T ox;
const wchar_t *cp;
- T((T_CALLED("wins_nwstr(%p,%s,%d)"), win, _nc_viswbufn(wstr, n), n));
+ T((T_CALLED("wins_nwstr(%p,%s,%d)"),
+ (void *) win, _nc_viswbufn(wstr, n), n));
if (win != 0
&& wstr != 0) {
if (n < 1)
- n = wcslen(wstr);
+ n = (int) wcslen(wstr);
code = OK;
if (n > 0) {
+ SCREEN *sp = _nc_screen_of(win);
+
oy = win->_cury;
ox = win->_curx;
for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
int len = wcwidth(*cp);
- if (len != 1 || !is8bits(*cp)) {
+ if ((len >= 0 && len != 1) || !is7bits(*cp)) {
cchar_t tmp_cchar;
wchar_t tmp_wchar = *cp;
memset(&tmp_cchar, 0, sizeof(tmp_cchar));
@@ -129,7 +137,7 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
code = _nc_insert_wch(win, &tmp_cchar);
} else {
/* tabs, other ASCII stuff */
- code = _nc_insert_ch(win, (chtype) (*cp));
+ code = _nc_insert_ch(sp, win, (chtype) (*cp));
}
if (code != OK)
break;
diff --git a/ncurses/widechar/lib_inwstr.c b/ncurses/widechar/lib_inwstr.c
index 2207a5f5d19f..4cf7182ae061 100644
--- a/ncurses/widechar/lib_inwstr.c
+++ b/ncurses/widechar/lib_inwstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002,2004 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-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 *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_inwstr.c,v 1.4 2004/10/23 20:41:28 tom Exp $")
+MODULE_ID("$Id: lib_inwstr.c,v 1.5 2009/10/24 22:37:29 tom Exp $")
NCURSES_EXPORT(int)
winnwstr(WINDOW *win, wchar_t *wstr, int n)
@@ -50,7 +50,7 @@ winnwstr(WINDOW *win, wchar_t *wstr, int n)
cchar_t *text;
wchar_t wch;
- T((T_CALLED("winnwstr(%p,%p,%d)"), win, wstr, n));
+ T((T_CALLED("winnwstr(%p,%p,%d)"), (void *) win, (void *) wstr, n));
if (wstr != 0) {
if (win) {
getyx(win, row, col);
@@ -93,7 +93,7 @@ NCURSES_EXPORT(int)
winwstr(WINDOW *win, wchar_t *wstr)
{
int result = OK;
- T((T_CALLED("winwstr(%p,%p)"), win, wstr));
+ T((T_CALLED("winwstr(%p,%p)"), (void *) win, (void *) wstr));
if (winnwstr(win, wstr, CCHARW_MAX * (win->_maxx - win->_curx + 1)) == ERR)
result = ERR;
returnCode(result);
diff --git a/ncurses/widechar/lib_pecho_wchar.c b/ncurses/widechar/lib_pecho_wchar.c
index e61277574311..b6da7a865698 100644
--- a/ncurses/widechar/lib_pecho_wchar.c
+++ b/ncurses/widechar/lib_pecho_wchar.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2004 Free Software Foundation, Inc. *
+ * Copyright (c) 2004,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -32,12 +32,12 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_pecho_wchar.c,v 1.1 2004/01/03 21:42:01 tom Exp $")
+MODULE_ID("$Id: lib_pecho_wchar.c,v 1.2 2009/10/24 22:43:32 tom Exp $")
NCURSES_EXPORT(int)
-pecho_wchar(WINDOW *pad, const cchar_t * wch)
+pecho_wchar(WINDOW *pad, const cchar_t *wch)
{
- T((T_CALLED("pecho_wchar(%p, %s)"), pad, _tracech_t(wch)));
+ T((T_CALLED("pecho_wchar(%p, %s)"), (void *) pad, _tracech_t(wch)));
if (pad == 0)
returnCode(ERR);
diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c
index bb2c4a084b15..7a626a9eee84 100644
--- a/ncurses/widechar/lib_unget_wch.c
+++ b/ncurses/widechar/lib_unget_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_unget_wch.c,v 1.10 2008/06/07 14:50:37 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.14 2010/07/24 11:35:21 tom Exp $")
/*
* Wrapper for wcrtomb() which obtains the length needed for the given
@@ -55,24 +55,24 @@ _nc_wcrtomb(char *target, wchar_t source, mbstate_t * state)
const wchar_t *tempp = temp;
temp[0] = source;
temp[1] = 0;
- result = wcsrtombs(NULL, &tempp, 0, state);
+ result = (int) wcsrtombs(NULL, &tempp, 0, state);
} else {
- result = wcrtomb(target, source, state);
+ result = (int) wcrtomb(target, source, state);
}
if (!isEILSEQ(result) && (result == 0))
result = 1;
- return result;
+ return (size_t) result;
}
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)"), (void *) SP_PARM, (unsigned long) wch));
init_mb(state);
length = _nc_wcrtomb(0, wch, &state);
@@ -83,10 +83,12 @@ unget_wch(const wchar_t wch)
if ((string = (char *) malloc(length)) != 0) {
init_mb(state);
- wcrtomb(string, wch, &state);
+ /* ignore the result, since we already validated the character */
+ IGNORE_RC((int) 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
+ UChar(string[n])) !=OK) {
result = ERR;
break;
}
@@ -101,3 +103,11 @@ unget_wch(const wchar_t wch)
returnCode(result);
}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+unget_wch(const wchar_t wch)
+{
+ return NCURSES_SP_NAME(unget_wch) (CURRENT_SCREEN, wch);
+}
+#endif
diff --git a/ncurses/widechar/lib_vid_attr.c b/ncurses/widechar/lib_vid_attr.c
index 1dc679e6d907..e4cf093a1f6b 100644
--- a/ncurses/widechar/lib_vid_attr.c
+++ b/ncurses/widechar/lib_vid_attr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2006,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2009,2010 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 *
@@ -31,11 +31,14 @@
****************************************************************************/
#include <curses.priv.h>
-#include <term.h>
-MODULE_ID("$Id: lib_vid_attr.c,v 1.5 2007/06/30 22:03:02 tom Exp $")
+#ifndef CUR
+#define CUR SP_TERMTYPE
+#endif
+
+MODULE_ID("$Id: lib_vid_attr.c,v 1.14 2010/12/19 01:44:24 tom Exp $")
-#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
+#define doPut(mode) TPUTS_TRACE(#mode); NCURSES_SP_NAME(tputs)(NCURSES_SP_ARGx mode, 1, outc)
#define TurnOn(mask,mode) \
if ((turn_on & mask) && mode) { doPut(mode); }
@@ -50,14 +53,22 @@ MODULE_ID("$Id: lib_vid_attr.c,v 1.5 2007/06/30 22:03:02 tom Exp $")
if ((pair != old_pair) \
|| (fix_pair0 && (pair == 0)) \
|| (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
- _nc_do_color(old_pair, pair, reverse, outc); \
+ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx \
+ old_pair, pair, \
+ reverse, outc); \
} \
}
-#define set_color(mode, pair) mode &= ALL_BUT_COLOR; mode |= COLOR_PAIR(pair)
+#define set_color(mode, pair) \
+ mode &= ALL_BUT_COLOR; \
+ mode |= (attr_t) ColorPair(pair)
NCURSES_EXPORT(int)
-vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
+NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
+ attr_t newmode,
+ short pair,
+ void *opts GCC_UNUSED,
+ NCURSES_SP_OUTC outc)
{
#if NCURSES_EXT_COLORS
static attr_t previous_attr = A_NORMAL;
@@ -65,9 +76,9 @@ vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
attr_t turn_on, turn_off;
bool reverse = FALSE;
- bool can_color = (SP == 0 || SP->_coloron);
+ bool can_color = (SP_PARM == 0 || SP_PARM->_coloron);
#if NCURSES_EXT_FUNCS
- bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
+ bool fix_pair0 = (SP_PARM != 0 && SP_PARM->_coloron && !SP_PARM->_default_color);
#else
#define fix_pair0 FALSE
#endif
@@ -76,18 +87,18 @@ vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
/* this allows us to go on whether or not newterm() has been called */
- if (SP) {
- previous_attr = AttrOf(SCREEN_ATTRS(SP));
- previous_pair = GetPair(SCREEN_ATTRS(SP));
+ if (SP_PARM) {
+ previous_attr = AttrOf(SCREEN_ATTRS(SP_PARM));
+ previous_pair = GetPair(SCREEN_ATTRS(SP_PARM));
}
TR(TRACE_ATTRS, ("previous attribute was %s, %d",
_traceattr(previous_attr), previous_pair));
#if !USE_XMC_SUPPORT
- if ((SP != 0)
+ if ((SP_PARM != 0)
&& (magic_cookie_glitch > 0))
- newmode &= ~(SP->_xmc_suppress);
+ newmode &= ~(SP_PARM->_xmc_suppress);
#endif
/*
@@ -144,10 +155,10 @@ vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
if (exit_attribute_mode) {
doPut(exit_attribute_mode);
} else {
- if (!SP || SP->_use_rmul) {
+ if (!SP_PARM || SP_PARM->_use_rmul) {
TurnOff(A_UNDERLINE, exit_underline_mode);
}
- if (!SP || SP->_use_rmso) {
+ if (!SP_PARM || SP_PARM->_use_rmso) {
TurnOff(A_STANDOUT, exit_standout_mode);
}
}
@@ -159,16 +170,18 @@ vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
} else if (set_attributes) {
if (turn_on || turn_off) {
TPUTS_TRACE("set_attributes");
- tputs(TPARM_9(set_attributes,
- (newmode & A_STANDOUT) != 0,
- (newmode & A_UNDERLINE) != 0,
- (newmode & A_REVERSE) != 0,
- (newmode & A_BLINK) != 0,
- (newmode & A_DIM) != 0,
- (newmode & A_BOLD) != 0,
- (newmode & A_INVIS) != 0,
- (newmode & A_PROTECT) != 0,
- (newmode & A_ALTCHARSET) != 0), 1, outc);
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
+ TPARM_9(set_attributes,
+ (newmode & A_STANDOUT) != 0,
+ (newmode & A_UNDERLINE) != 0,
+ (newmode & A_REVERSE) != 0,
+ (newmode & A_BLINK) != 0,
+ (newmode & A_DIM) != 0,
+ (newmode & A_BOLD) != 0,
+ (newmode & A_INVIS) != 0,
+ (newmode & A_PROTECT) != 0,
+ (newmode & A_ALTCHARSET) != 0),
+ 1, outc);
previous_attr &= ALL_BUT_COLOR;
previous_pair = 0;
}
@@ -179,11 +192,11 @@ vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
TurnOff(A_ALTCHARSET, exit_alt_charset_mode);
- if (!SP || SP->_use_rmul) {
+ if (!SP_PARM || SP_PARM->_use_rmul) {
TurnOff(A_UNDERLINE, exit_underline_mode);
}
- if (!SP || SP->_use_rmso) {
+ if (!SP_PARM || SP_PARM->_use_rmso) {
TurnOff(A_STANDOUT, exit_standout_mode);
}
@@ -221,9 +234,9 @@ vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
if (reverse)
newmode |= A_REVERSE;
- if (SP) {
- SetAttr(SCREEN_ATTRS(SP), newmode);
- SetPair(SCREEN_ATTRS(SP), pair);
+ if (SP_PARM) {
+ SetAttr(SCREEN_ATTRS(SP_PARM), newmode);
+ SetPair(SCREEN_ATTRS(SP_PARM), pair);
} else {
previous_attr = newmode;
previous_pair = pair;
@@ -233,29 +246,60 @@ vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
#else
T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
set_color(newmode, pair);
- returnCode(vidputs(newmode, outc));
+ returnCode(NCURSES_SP_NAME(vidputs) (NCURSES_SP_ARGx newmode, outc));
#endif
}
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+vid_puts(attr_t newmode,
+ short pair,
+ void *opts GCC_UNUSED,
+ NCURSES_OUTC outc)
+{
+ SetSafeOutcWrapper(outc);
+ return NCURSES_SP_NAME(vid_puts) (CURRENT_SCREEN,
+ newmode,
+ pair,
+ opts,
+ _nc_outc_wrapper);
+}
+#endif
+
#undef vid_attr
NCURSES_EXPORT(int)
-vid_attr(attr_t newmode, short pair, void *opts)
+NCURSES_SP_NAME(vid_attr) (NCURSES_SP_DCLx
+ attr_t newmode,
+ short pair,
+ void *opts)
{
T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), pair));
- returnCode(vid_puts(newmode, pair, opts, _nc_outch));
+ returnCode(NCURSES_SP_NAME(vid_puts) (NCURSES_SP_ARGx
+ newmode,
+ pair,
+ opts,
+ NCURSES_SP_NAME(_nc_outch)));
}
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+vid_attr(attr_t newmode, short pair, void *opts)
+{
+ return NCURSES_SP_NAME(vid_attr) (CURRENT_SCREEN, newmode, pair, opts);
+}
+#endif
+
/*
* This implementation uses the same mask values for A_xxx and WA_xxx, so
* we can use termattrs() for part of the logic.
*/
NCURSES_EXPORT(attr_t)
-term_attrs(void)
+NCURSES_SP_NAME(term_attrs) (NCURSES_SP_DCL0)
{
attr_t attrs;
T((T_CALLED("term_attrs()")));
- attrs = termattrs();
+ attrs = SP_PARM ? NCURSES_SP_NAME(termattrs) (NCURSES_SP_ARG) : 0;
/* these are only supported for wide-character mode */
if (enter_horizontal_hl_mode)
@@ -273,3 +317,11 @@ term_attrs(void)
returnAttr(attrs);
}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(attr_t)
+term_attrs(void)
+{
+ return NCURSES_SP_NAME(term_attrs) (CURRENT_SCREEN);
+}
+#endif
diff --git a/ncurses/widechar/lib_vline_set.c b/ncurses/widechar/lib_vline_set.c
index af42df1f24ab..917caac44b44 100644
--- a/ncurses/widechar/lib_vline_set.c
+++ b/ncurses/widechar/lib_vline_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,16 +39,16 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_vline_set.c,v 1.2 2002/03/23 21:36:01 tom Exp $")
+MODULE_ID("$Id: lib_vline_set.c,v 1.4 2010/12/19 01:50:50 tom Exp $")
NCURSES_EXPORT(int)
-wvline_set(WINDOW *win, const cchar_t * ch, int n)
+wvline_set(WINDOW *win, const cchar_t *ch, int n)
{
int code = ERR;
- NCURSES_SIZE_T row, col;
- NCURSES_SIZE_T end;
+ int row, col;
+ int end;
- T((T_CALLED("wvline(%p,%s,%d)"), win, _tracecchar_t(ch), n));
+ T((T_CALLED("wvline(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n));
if (win) {
NCURSES_CH_T wch;
diff --git a/ncurses/widechar/lib_wacs.c b/ncurses/widechar/lib_wacs.c
index fe893b4d2f8b..5a16e457e091 100644
--- a/ncurses/widechar/lib_wacs.c
+++ b/ncurses/widechar/lib_wacs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2009,2010 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 *
@@ -31,9 +31,8 @@
****************************************************************************/
#include <curses.priv.h>
-#include <term.h>
-MODULE_ID("$Id: lib_wacs.c,v 1.7 2006/12/17 15:16:17 tom Exp $")
+MODULE_ID("$Id: lib_wacs.c,v 1.10 2010/12/19 01:43:19 tom Exp $")
NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 0;
@@ -42,7 +41,7 @@ _nc_init_wacs(void)
{
/* *INDENT-OFF* */
static const struct {
- int map;
+ unsigned map;
int value[2];
} table[] = {
/* VT100 symbols */
@@ -80,6 +79,30 @@ _nc_init_wacs(void)
{ '{', { '*', 0x03c0 }}, /* greek pi */
{ '|', { '!', 0x2260 }}, /* not-equal */
{ '}', { 'f', 0x00a3 }}, /* pound-sterling symbol */
+ /* thick-line-drawing */
+ { 'L', { '+', 0x250f }}, /* upper left corner */
+ { 'M', { '+', 0x2517 }}, /* lower left corner */
+ { 'K', { '+', 0x2513 }}, /* upper right corner */
+ { 'J', { '+', 0x251b }}, /* lower right corner */
+ { 'T', { '+', 0x2523 }}, /* tee pointing left */
+ { 'U', { '+', 0x252b }}, /* tee pointing right */
+ { 'V', { '+', 0x253b }}, /* tee pointing up */
+ { 'W', { '+', 0x2533 }}, /* tee pointing down */
+ { 'Q', { '-', 0x2501 }}, /* horizontal line */
+ { 'X', { '|', 0x2503 }}, /* vertical line */
+ { 'N', { '+', 0x254b }}, /* large plus or crossover */
+ /* double-line-drawing */
+ { 'C', { '+', 0x2554 }}, /* upper left corner */
+ { 'D', { '+', 0x255a }}, /* lower left corner */
+ { 'B', { '+', 0x2557 }}, /* upper right corner */
+ { 'A', { '+', 0x255d }}, /* lower right corner */
+ { 'G', { '+', 0x2563 }}, /* tee pointing left */
+ { 'F', { '+', 0x2560 }}, /* tee pointing right */
+ { 'H', { '+', 0x2569 }}, /* tee pointing up */
+ { 'I', { '+', 0x2566 }}, /* tee pointing down */
+ { 'R', { '-', 0x2550 }}, /* horizontal line */
+ { 'Y', { '|', 0x2551 }}, /* vertical line */
+ { 'E', { '+', 0x256c }}, /* large plus or crossover */
};
/* *INDENT-ON* */
diff --git a/ncurses/widechar/lib_wunctrl.c b/ncurses/widechar/lib_wunctrl.c
index be2259acdcff..50958e44c7bb 100644
--- a/ncurses/widechar/lib_wunctrl.c
+++ b/ncurses/widechar/lib_wunctrl.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001-2005,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-2009,2010 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 *
@@ -35,21 +35,31 @@
#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.14 2010/12/19 01:42:15 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++ = (wchar_t) _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