aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/widechar
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/widechar')
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_box_set.c113
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_cchar.c114
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_erasewchar.c77
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_get_wch.c99
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_get_wstr.c205
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_hline_set.c79
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_in_wch.c60
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_in_wchnstr.c62
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_ins_nwstr.c84
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_ins_wch.c65
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_inwstr.c96
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_unget_wch.c76
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_vid_attr.c94
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_vline_set.c78
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_wacs.c120
-rw-r--r--contrib/ncurses/ncurses/widechar/lib_wunctrl.c56
16 files changed, 1478 insertions, 0 deletions
diff --git a/contrib/ncurses/ncurses/widechar/lib_box_set.c b/contrib/ncurses/ncurses/widechar/lib_box_set.c
new file mode 100644
index 000000000000..7f69e5aa5113
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_box_set.c
@@ -0,0 +1,113 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Authors: Sven Verdoolaege and Thomas Dickey 2001,2002 *
+ ****************************************************************************/
+
+/*
+** lib_box_set.c
+**
+** The routine wborder_set().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_box_set.c,v 1.2 2002/03/23 21:35:24 tom Exp $")
+
+NCURSES_EXPORT(int)
+wborder_set(WINDOW *win,
+ const ARG_CH_T ls, const ARG_CH_T rs,
+ const ARG_CH_T ts, const ARG_CH_T bs,
+ const ARG_CH_T tl, const ARG_CH_T tr,
+ const ARG_CH_T bl, const ARG_CH_T br)
+{
+ NCURSES_SIZE_T i;
+ NCURSES_SIZE_T endx, endy;
+ 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,
+ _tracech_t2(1, ls),
+ _tracech_t2(2, rs),
+ _tracech_t2(3, ts),
+ _tracech_t2(4, bs),
+ _tracech_t2(5, tl),
+ _tracech_t2(6, tr),
+ _tracech_t2(7, bl),
+ _tracech_t2(8, br)));
+
+ if (!win)
+ returnCode(ERR);
+
+#define RENDER_WITH_DEFAULT(ch,def) w ##ch = (ch == 0) ? *def : *ch
+
+ RENDER_WITH_DEFAULT(ls, WACS_VLINE);
+ RENDER_WITH_DEFAULT(rs, WACS_VLINE);
+ RENDER_WITH_DEFAULT(ts, WACS_HLINE);
+ RENDER_WITH_DEFAULT(bs, WACS_HLINE);
+ RENDER_WITH_DEFAULT(tl, WACS_ULCORNER);
+ RENDER_WITH_DEFAULT(tr, WACS_URCORNER);
+ RENDER_WITH_DEFAULT(bl, WACS_LLCORNER);
+ RENDER_WITH_DEFAULT(br, WACS_LRCORNER);
+
+ T(("using %s, %s, %s, %s, %s, %s, %s, %s",
+ _tracech_t2(1, CHREF(wls)),
+ _tracech_t2(2, CHREF(wrs)),
+ _tracech_t2(3, CHREF(wts)),
+ _tracech_t2(4, CHREF(wbs)),
+ _tracech_t2(5, CHREF(wtl)),
+ _tracech_t2(6, CHREF(wtr)),
+ _tracech_t2(7, CHREF(wbl)),
+ _tracech_t2(8, CHREF(wbr))));
+
+ endx = win->_maxx;
+ endy = win->_maxy;
+
+ for (i = 0; i <= endx; i++) {
+ win->_line[0].text[i] = wts;
+ win->_line[endy].text[i] = wbs;
+ }
+ win->_line[endy].firstchar = win->_line[0].firstchar = 0;
+ win->_line[endy].lastchar = win->_line[0].lastchar = endx;
+
+ for (i = 0; i <= endy; i++) {
+ win->_line[i].text[0] = wls;
+ win->_line[i].text[endx] = wrs;
+ win->_line[i].firstchar = 0;
+ win->_line[i].lastchar = endx;
+ }
+ win->_line[0].text[0] = wtl;
+ win->_line[0].text[endx] = wtr;
+ win->_line[endy].text[0] = wbl;
+ win->_line[endy].text[endx] = wbr;
+
+ _nc_synchook(win);
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_cchar.c b/contrib/ncurses/ncurses/widechar/lib_cchar.c
new file mode 100644
index 000000000000..efbfc69b1c0f
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_cchar.c
@@ -0,0 +1,114 @@
+/****************************************************************************
+ * Copyright (c) 2001,2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/*
+** lib_cchar.c
+**
+** The routines setcchar() and getcchar().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_cchar.c,v 1.5 2002/04/27 22:35:46 tom Exp $")
+
+/*
+ * The SuSv2 description leaves some room for interpretation. We'll assume wch
+ * is L'\0' terminated, contains at most one character with strictly positive
+ * width, which must be the first, and contains no characters of negative
+ * width.
+ */
+NCURSES_EXPORT(int)
+setcchar(cchar_t * wcval, const wchar_t * wch, const attr_t attrs,
+ short color_pair, const void *opts)
+{
+ int i;
+ int len;
+ int code = OK;
+
+ TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%ld,%d,%p)"),
+ wcval, _nc_viswbuf(wch), attrs, color_pair, opts));
+
+ if (opts != NULL || (len = wcslen(wch)) > CCHARW_MAX
+ || (len > 0 && wcwidth(wch[0]) < 0)) {
+ code = ERR;
+ } else {
+
+ for (i = 1; i < len; ++i) {
+ if (wcwidth(wch[i]) != 0) {
+ code = ERR;
+ break;
+ }
+ }
+
+ if (code != ERR) {
+ memset(wcval, 0, sizeof(*wcval));
+
+ if (len != 0) {
+ SetAttr(*wcval, attrs | color_pair);
+ memcpy(&wcval->chars, wch, len * sizeof(wchar_t));
+ TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len,
+ _tracecchar_t(wcval)));
+ }
+ }
+ }
+
+ TR(TRACE_CCALLS, (T_RETURN("%d"), code));
+ return (code);
+}
+
+NCURSES_EXPORT(int)
+getcchar(const cchar_t * wcval, wchar_t * wch, attr_t * attrs,
+ short *color_pair, void *opts)
+{
+ wchar_t *wp;
+ int len;
+ int code = ERR;
+
+ TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"),
+ wcval, wch, attrs, color_pair, opts));
+
+ if (opts == NULL) {
+ len = (wp = wmemchr(wcval->chars, L'\0', CCHARW_MAX))
+ ? wp - wcval->chars
+ : CCHARW_MAX;
+
+ if (wch == NULL) {
+ code = len;
+ } else if (len >= 0) {
+ *attrs = AttrOf(*wcval) & A_ATTRIBUTES;
+ *color_pair = AttrOf(*wcval) & A_COLOR;
+ wmemcpy(wch, wcval->chars, (unsigned) len);
+ wch[len] = L'\0';
+ code = OK;
+ }
+ }
+
+ TR(TRACE_CCALLS, (T_RETURN("%d"), code));
+ return (code);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_erasewchar.c b/contrib/ncurses/ncurses/widechar/lib_erasewchar.c
new file mode 100644
index 000000000000..7d6455370ff9
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_erasewchar.c
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2002 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_erasewchar.c,v 1.1 2002/05/11 20:38:06 tom Exp $")
+
+/*
+ * erasewchar()
+ *
+ * Return erase character as given in cur_term->Ottyb.
+ *
+ */
+
+NCURSES_EXPORT(int)
+erasewchar(wchar_t * wch)
+{
+ int value;
+ int result = ERR;
+
+ T((T_CALLED("erasewchar()")));
+ if ((value = erasechar()) != ERR) {
+ *wch = value;
+ result = OK;
+ }
+ returnCode(result);
+}
+
+/*
+ * killwchar()
+ *
+ * Return kill character as given in cur_term->Ottyb.
+ *
+ */
+
+NCURSES_EXPORT(int)
+killwchar(wchar_t * wch)
+{
+ int value;
+ int result = ERR;
+
+ T((T_CALLED("killwchar()")));
+ if ((value = killchar()) != ERR) {
+ *wch = value;
+ result = OK;
+ }
+ returnCode(result);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_get_wch.c b/contrib/ncurses/ncurses/widechar/lib_get_wch.c
new file mode 100644
index 000000000000..21c40a506ccc
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_get_wch.c
@@ -0,0 +1,99 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_get_wch.c
+**
+** The routine get_wch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_get_wch.c,v 1.3 2002/03/17 16:14:45 tom Exp $")
+
+NCURSES_EXPORT(int)
+wget_wch(WINDOW *win, wint_t * result)
+{
+ int code;
+ char buffer[(MB_CUR_MAX * 9) + 1]; /* allow some redundant shifts */
+ int status;
+ mbstate_t state;
+ size_t count = 0;
+ unsigned long value;
+ wchar_t wch;
+
+ T((T_CALLED("wget_wch(%p)"), win));
+ /*
+ * We can get a stream of single-byte characters and KEY_xxx codes from
+ * _nc_wgetch(), while we want to return a wide character or KEY_xxx code.
+ */
+ for (;;) {
+ T(("reading %d of %d", count + 1, sizeof(buffer)));
+ code = _nc_wgetch(win, &value, TRUE);
+ if (code == ERR) {
+ break;
+ } else if (code == KEY_CODE_YES) {
+ /*
+ * If we were processing an incomplete multibyte character, return
+ * an error since we have a KEY_xxx code which interrupts it. For
+ * some cases, we could improve this by writing a new version of
+ * lib_getch.c(!), but it is not clear whether the improvement
+ * would be worth the effort.
+ */
+ if (count != 0) {
+ ungetch(value);
+ code = ERR;
+ }
+ break;
+ } else if (count + 1 >= sizeof(buffer)) {
+ ungetch(value);
+ code = ERR;
+ break;
+ } else {
+ buffer[count++] = UChar(value);
+ memset(&state, 0, sizeof(state));
+ status = mbrlen(buffer, count, &state);
+ if (status >= 0) {
+ memset(&state, 0, sizeof(state));
+ if ((int) mbrtowc(&wch, buffer, count, &state) != status) {
+ code = ERR; /* the two calls should match */
+ }
+ value = wch;
+ break;
+ }
+ }
+ }
+ *result = value;
+ T(("result %#o", value));
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_get_wstr.c b/contrib/ncurses/ncurses/widechar/lib_get_wstr.c
new file mode 100644
index 000000000000..426381cce0a5
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_get_wstr.c
@@ -0,0 +1,205 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_get_wstr.c
+**
+** The routine wgetn_wstr().
+**
+*/
+
+#include <curses.priv.h>
+#include <term.h>
+
+MODULE_ID("$Id: lib_get_wstr.c,v 1.3 2002/05/11 22:29:43 tom Exp $")
+
+/*
+ * This wipes out the last character, no matter whether it was a tab, control
+ * or other character, and handles reverse wraparound.
+ */
+static wchar_t *
+WipeOut(WINDOW *win, int y, int x, wchar_t * first, wchar_t * last, bool echoed)
+{
+ if (last > first) {
+ *--last = '\0';
+ if (echoed) {
+ int y1 = win->_cury;
+ int x1 = win->_curx;
+
+ wmove(win, y, x);
+ waddwstr(win, first);
+ getyx(win, y, x);
+ while (win->_cury < y1
+ || (win->_cury == y1 && win->_curx < x1))
+ waddch(win, (chtype) ' ');
+
+ wmove(win, y, x);
+ }
+ }
+ return last;
+}
+
+NCURSES_EXPORT(int)
+wgetn_wstr(WINDOW *win, wint_t * str, int maxlen)
+{
+ TTY buf;
+ bool oldnl, oldecho, oldraw, oldcbreak;
+ wint_t erasec;
+ wint_t killc;
+ wchar_t *oldstr;
+ wchar_t *tmpstr;
+ wint_t ch;
+ int y, x, code;
+
+ T((T_CALLED("wgetn_wstr(%p,%p, %d)"), win, str, maxlen));
+
+ if (!win)
+ returnCode(ERR);
+
+ _nc_get_tty_mode(&buf);
+
+ oldnl = SP->_nl;
+ oldecho = SP->_echo;
+ oldraw = SP->_raw;
+ oldcbreak = SP->_cbreak;
+ nl();
+ noecho();
+ noraw();
+ cbreak();
+
+ erasec = erasechar();
+ killc = killchar();
+
+ assert(sizeof(wchar_t) == sizeof(wint_t));
+ oldstr = (wchar_t *) str;
+ tmpstr = (wchar_t *) str;
+
+ getyx(win, y, x);
+
+ if (is_wintouched(win) || (win->_flags & _HASMOVED))
+ wrefresh(win);
+
+ while ((code = wget_wch(win, &ch)) != ERR) {
+ if (code == KEY_CODE_YES) {
+ /*
+ * Some terminals (the Wyse-50 is the most common) generate a \n
+ * from the down-arrow key. With this logic, it's the user's
+ * choice whether to set kcud=\n for wget_wch(); terminating
+ * *getn_wstr() with \n should work either way.
+ */
+ if (ch == '\n'
+ || ch == '\r'
+ || ch == KEY_DOWN
+ || ch == KEY_ENTER) {
+ if (oldecho == TRUE
+ && win->_cury == win->_maxy
+ && win->_scroll)
+ wechochar(win, (chtype) '\n');
+ break;
+ }
+ if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
+ if (tmpstr > oldstr) {
+ tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+ }
+ } else if (ch == killc) {
+ while (tmpstr > oldstr) {
+ tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+ }
+ } else {
+ beep();
+ }
+ } else if (maxlen >= 0 && tmpstr - oldstr >= maxlen) {
+ beep();
+ } else {
+ *tmpstr++ = ch;
+ if (oldecho == TRUE) {
+ int oldy = win->_cury;
+ cchar_t tmp;
+
+ setcchar(&tmp, tmpstr - 1, A_NORMAL, 0, NULL);
+ if (wadd_wch(win, &tmp) == ERR) {
+ /*
+ * We can't really use the lower-right corner for input,
+ * since it'll mess up bookkeeping for erases.
+ */
+ win->_flags &= ~_WRAPPED;
+ waddch(win, (chtype) ' ');
+ tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+ continue;
+ } else if (win->_flags & _WRAPPED) {
+ /*
+ * If the last waddch forced a wrap & scroll, adjust our
+ * reference point for erasures.
+ */
+ if (win->_scroll
+ && oldy == win->_maxy
+ && win->_cury == win->_maxy) {
+ if (--y <= 0) {
+ y = 0;
+ }
+ }
+ win->_flags &= ~_WRAPPED;
+ }
+ wrefresh(win);
+ }
+ }
+ }
+
+ win->_curx = 0;
+ win->_flags &= ~_WRAPPED;
+ if (win->_cury < win->_maxy)
+ win->_cury++;
+ wrefresh(win);
+
+ /* Restore with a single I/O call, to fix minor asymmetry between
+ * raw/noraw, etc.
+ */
+ SP->_nl = oldnl;
+ SP->_echo = oldecho;
+ SP->_raw = oldraw;
+ SP->_cbreak = oldcbreak;
+
+ _nc_set_tty_mode(&buf);
+
+ *tmpstr = 0;
+ if (code == ERR) {
+ if (tmpstr == oldstr) {
+ *tmpstr++ = (wchar_t)WEOF;
+ *tmpstr = 0;
+ }
+ returnCode(ERR);
+ }
+
+ T(("wgetn_wstr returns %s", _nc_viswbuf(oldstr)));
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_hline_set.c b/contrib/ncurses/ncurses/widechar/lib_hline_set.c
new file mode 100644
index 000000000000..43175de83464
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_hline_set.c
@@ -0,0 +1,79 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_hline_set.c
+**
+** The routine whline_set().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_hline_set.c,v 1.2 2002/03/23 21:35:34 tom Exp $")
+
+NCURSES_EXPORT(int)
+whline_set(WINDOW *win, const cchar_t * ch, int n)
+{
+ int code = ERR;
+ NCURSES_SIZE_T start;
+ NCURSES_SIZE_T end;
+
+ T((T_CALLED("whline_set(%p,%s,%d)"), win, _tracecchar_t(ch), n));
+
+ if (win) {
+ struct ldat *line = &(win->_line[win->_cury]);
+ NCURSES_CH_T wch;
+
+ start = win->_curx;
+ end = start + n - 1;
+ if (end > win->_maxx)
+ end = win->_maxx;
+
+ CHANGED_RANGE(line, start, end);
+
+ if (ch == 0)
+ wch = *WACS_HLINE;
+ else
+ wch = *ch;
+ wch = _nc_render(win, wch);
+
+ while (end >= start) {
+ line->text[end] = wch;
+ end--;
+ }
+
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_in_wch.c b/contrib/ncurses/ncurses/widechar/lib_in_wch.c
new file mode 100644
index 000000000000..562fa82602fe
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_in_wch.c
@@ -0,0 +1,60 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_in_wch.c
+**
+** The routine win_wch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_in_wch.c,v 1.1 2002/03/10 20:22:00 tom Exp $")
+
+NCURSES_EXPORT(int)
+win_wch(WINDOW *win, NCURSES_CONST cchar_t * wcval)
+{
+ int row, col;
+ int code = OK;
+
+ TR(TRACE_CCALLS, (T_CALLED("win_wch(%p,%p)"), win, wcval));
+ if (win != 0
+ && wcval != 0) {
+ getyx(win, row, col);
+
+ *wcval = win->_line[row].text[col];
+ } else {
+ code = ERR;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_in_wchnstr.c b/contrib/ncurses/ncurses/widechar/lib_in_wchnstr.c
new file mode 100644
index 000000000000..42268ec3e025
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_in_wchnstr.c
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_in_wchnstr.c
+**
+** The routine win_wchnstr().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_in_wchnstr.c,v 1.1 2002/04/13 19:33:57 tom Exp $")
+
+NCURSES_EXPORT(int)
+win_wchnstr(WINDOW *win, NCURSES_CONST cchar_t * wchstr, int n)
+{
+ int code = OK;
+
+ TR(TRACE_CCALLS, (T_CALLED("win_wchnstr(%p,%p,%d)"), win, wchstr, n));
+ if (win != 0
+ && wchstr != 0) {
+
+ if (n < 0) {
+ n = getmaxx(win) + 1 - getcurx(win);
+ }
+ while (n-- > 0)
+ win_wch(win, wchstr++);
+ } else {
+ code = ERR;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_ins_nwstr.c b/contrib/ncurses/ncurses/widechar/lib_ins_nwstr.c
new file mode 100644
index 000000000000..8302b8b52276
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_ins_nwstr.c
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_ins_nwstr.c
+**
+** The routine wins_nwstr().
+**
+*/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_ins_nwstr.c,v 1.2 2002/03/10 22:43:12 tom Exp $")
+
+NCURSES_EXPORT(int)
+wins_nwstr(WINDOW *win, const wchar_t * wstr, int n)
+{
+ int code = ERR;
+ NCURSES_SIZE_T oy;
+ NCURSES_SIZE_T ox;
+ const wchar_t *cp;
+
+ T((T_CALLED("wins_nwstr(%p,%s,%d)"), win, _nc_viswbuf(wstr), n));
+
+ if (win != 0
+ && wstr != 0
+ && wcwidth(*wstr) > 0) {
+ code = OK;
+ if (n < 1)
+ n = wcslen(wstr);
+ oy = win->_cury;
+ ox = win->_curx;
+ for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
+ NCURSES_CH_T wch;
+ SetChar2(wch, *cp);
+ if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') {
+ _nc_waddch_nosync(win, wch);
+ } else if (is7bits(*cp) && iscntrl(*cp)) {
+ winsch(win, ' ' + (chtype) (*cp));
+ winsch(win, (chtype) '^');
+ win->_curx += 2;
+ } else if (wins_wch(win, &wch) == ERR
+ || win->_curx > win->_maxx) {
+ break;
+ }
+ }
+
+ win->_curx = ox;
+ win->_cury = oy;
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_ins_wch.c b/contrib/ncurses/ncurses/widechar/lib_ins_wch.c
new file mode 100644
index 000000000000..0821ee590bf8
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_ins_wch.c
@@ -0,0 +1,65 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_ins_wch.c
+**
+** The routine wins_wch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_ins_wch.c,v 1.1 2002/03/10 22:25:06 tom Exp $")
+
+NCURSES_EXPORT(int)
+wins_wch(WINDOW *win, const cchar_t * wch)
+{
+ int code = ERR;
+
+ T((T_CALLED("wins_wch(%p, %s)"), win, _tracecchar_t(wch)));
+
+ if (win) {
+ 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 - 1;
+
+ CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+ while (temp1 > end)
+ *temp1-- = *temp2--;
+
+ *temp1 = _nc_render(win, *wch);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_inwstr.c b/contrib/ncurses/ncurses/widechar/lib_inwstr.c
new file mode 100644
index 000000000000..c3c46fa9e554
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_inwstr.c
@@ -0,0 +1,96 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_inwstr.c
+**
+** The routines winnwstr() and winwstr().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_inwstr.c,v 1.1 2002/03/10 00:25:27 tom Exp $")
+
+NCURSES_EXPORT(int)
+winnwstr(WINDOW *win, wchar_t * wstr, int n)
+{
+ int row, col, inx;
+ int count = 0;
+ int last = 0;
+ cchar_t *text;
+ wchar_t wch;
+
+ TR(TRACE_CCALLS, (T_CALLED("winnwstr(%p,%p,%d)"), win, wstr, n));
+ if (wstr != 0) {
+ if (win) {
+ getyx(win, row, col);
+
+ text = win->_line[row].text;
+ while (count < n && count != ERR) {
+ for (inx = 0; (inx < CCHARW_MAX)
+ && ((wch = text[col].chars[inx]) != 0);
+ ++inx) {
+ if (count + 1 >= n) {
+ if ((count = last) == 0) {
+ count = ERR; /* error if we t store nothing */
+ }
+ break;
+ }
+ wstr[count++] = wch;
+ }
+ last = count;
+ if (++col > win->_maxx) {
+ break;
+ }
+ }
+ }
+ if (count > 0)
+ wstr[count] = '\0';
+ }
+ returnCode(count);
+}
+
+/*
+ * X/Open says winwstr() returns OK if not ERR. If that is not a blunder, it
+ * must have a null termination on the string (see above). Unlike winnstr(),
+ * it does not define what happens for a negative count with winnwstr().
+ */
+NCURSES_EXPORT(int)
+winwstr(WINDOW *win, wchar_t * wstr)
+{
+ int result = OK;
+ TR(TRACE_CCALLS, (T_CALLED("winwstr(%p,%p)"), win, wstr));
+ if (winnwstr(win, wstr, CCHARW_MAX * (win->_maxx - win->_curx + 1)) == ERR)
+ result = ERR;
+ returnCode(result);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_unget_wch.c b/contrib/ncurses/ncurses/widechar/lib_unget_wch.c
new file mode 100644
index 000000000000..b4b3433519c1
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_unget_wch.c
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_unget_wch.c
+**
+** The routine unget_wch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_unget_wch.c,v 1.2 2002/03/17 00:01:38 tom Exp $")
+
+NCURSES_EXPORT(int)
+unget_wch(const wchar_t wch)
+{
+ int result = OK;
+ mbstate_t state;
+ size_t length;
+ int n;
+
+ T((T_CALLED("unget_wch(%d)"), wch));
+
+ memset(&state, 0, sizeof(state));
+ length = wcrtomb(0, wch, &state);
+
+ if (length != (size_t) (-1)
+ && length != 0) {
+ char *string = malloc(length);
+
+ memset(&state, 0, sizeof(state));
+ wcrtomb(string, wch, &state);
+
+ for (n = (int) (length - 1); n >= 0; --n) {
+ if (ungetch(string[n]) != OK) {
+ result = ERR;
+ break;
+ }
+ }
+ free(string);
+ } else {
+ result = ERR;
+ }
+
+ returnCode(result);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_vid_attr.c b/contrib/ncurses/ncurses/widechar/lib_vid_attr.c
new file mode 100644
index 000000000000..06e7880dd4d0
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_vid_attr.c
@@ -0,0 +1,94 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2002 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+#include <term.h>
+
+MODULE_ID("$Id: lib_vid_attr.c,v 1.1 2002/05/11 20:55:26 tom Exp $")
+
+#define set_color(mode, pair) mode &= ~A_COLOR; mode |= COLOR_PAIR(pair)
+
+NCURSES_EXPORT(int)
+vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
+{
+ T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
+ set_color(newmode, pair);
+ returnCode(vidputs(newmode, outc));
+}
+
+#undef vid_attr
+NCURSES_EXPORT(int)
+vid_attr(attr_t newmode, short pair, void *opts GCC_UNUSED)
+{
+ T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), pair));
+ set_color(newmode, pair);
+ returnCode(vidputs(newmode, _nc_outch));
+}
+
+NCURSES_EXPORT(attr_t)
+term_attrs(void)
+{
+ attr_t attrs = WA_NORMAL;
+
+ T((T_CALLED("term_attrs()")));
+ if (enter_alt_charset_mode)
+ attrs |= WA_ALTCHARSET;
+
+ if (enter_blink_mode)
+ attrs |= WA_BLINK;
+
+ if (enter_bold_mode)
+ attrs |= WA_BOLD;
+
+ if (enter_dim_mode)
+ attrs |= WA_DIM;
+
+ if (enter_reverse_mode)
+ attrs |= WA_REVERSE;
+
+ if (enter_standout_mode)
+ attrs |= WA_STANDOUT;
+
+ if (enter_protected_mode)
+ attrs |= WA_PROTECT;
+
+ if (enter_secure_mode)
+ attrs |= WA_INVIS;
+
+ if (enter_underline_mode)
+ attrs |= WA_UNDERLINE;
+
+ if (SP->_coloron)
+ attrs |= A_COLOR;
+
+ returnAttr(attrs);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_vline_set.c b/contrib/ncurses/ncurses/widechar/lib_vline_set.c
new file mode 100644
index 000000000000..af42df1f24ab
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_vline_set.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey 2002 *
+ ****************************************************************************/
+
+/*
+** lib_vline_set.c
+**
+** The routine wvline_set().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_vline_set.c,v 1.2 2002/03/23 21:36:01 tom Exp $")
+
+NCURSES_EXPORT(int)
+wvline_set(WINDOW *win, const cchar_t * ch, int n)
+{
+ int code = ERR;
+ NCURSES_SIZE_T row, col;
+ NCURSES_SIZE_T end;
+
+ T((T_CALLED("wvline(%p,%s,%d)"), win, _tracecchar_t(ch), n));
+
+ if (win) {
+ NCURSES_CH_T wch;
+ row = win->_cury;
+ col = win->_curx;
+ end = row + n - 1;
+ if (end > win->_maxy)
+ end = win->_maxy;
+
+ if (ch == 0)
+ wch = *WACS_VLINE;
+ else
+ wch = *ch;
+ wch = _nc_render(win, wch);
+
+ while (end >= row) {
+ struct ldat *line = &(win->_line[end]);
+ line->text[col] = wch;
+ CHANGED_CELL(line, col);
+ end--;
+ }
+
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_wacs.c b/contrib/ncurses/ncurses/widechar/lib_wacs.c
new file mode 100644
index 000000000000..05fa329dd9fa
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_wacs.c
@@ -0,0 +1,120 @@
+/****************************************************************************
+ * Copyright (c) 2002 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey 2002 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+#include <term.h>
+
+MODULE_ID("$Id: lib_wacs.c,v 1.2 2002/02/17 00:02:15 tom Exp $")
+
+NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 0;
+
+static int
+_nc_unicode_locale(void)
+{
+ char *s;
+ if (((s = getenv("LC_ALL")) != 0 && *s != '\0')
+ || ((s = getenv("LC_ALL")) != 0 && *s != '\0')
+ || ((s = getenv("LC_ALL")) != 0 && *s != '\0')) {
+ if (strstr(s, ".UTF-8") != 0)
+ return 1;
+ }
+ return 0;
+}
+
+NCURSES_EXPORT(void)
+_nc_init_wacs(void)
+{
+ /* *INDENT-OFF* */
+ static const struct {
+ int map;
+ int value[2];
+ } table[] = {
+ /* VT100 symbols */
+ { 'l', { '+', 0x250c }}, /* upper left corner */
+ { 'm', { '+', 0x2514 }}, /* lower left corner */
+ { 'k', { '+', 0x2510 }}, /* upper right corner */
+ { 'j', { '+', 0x2518 }}, /* lower right corner */
+ { 't', { '+', 0x251c }}, /* tee pointing left */
+ { 'u', { '+', 0x2524 }}, /* tee pointing right */
+ { 'v', { '+', 0x2534 }}, /* tee pointing up */
+ { 'w', { '+', 0x252c }}, /* tee pointing down */
+ { 'q', { '-', 0x2500 }}, /* horizontal line */
+ { 'x', { '|', 0x2502 }}, /* vertical line */
+ { 'n', { '+', 0x253c }}, /* large plus or crossover */
+ { 'o', { '~', 0x23ba }}, /* scan line 1 */
+ { 's', { '_', 0x23bd }}, /* scan line 9 */
+ { '\'', { '+', 0x25c6 }}, /* diamond */
+ { 'a', { ':', 0x2592 }}, /* checker board (stipple) */
+ { 'f', { '\'', 0x00b0 }}, /* degree symbol */
+ { 'g', { '#', 0x00b1 }}, /* plus/minus */
+ { '~', { 'o', 0x00b7 }}, /* bullet */
+ /* Teletype 5410v1 symbols */
+ { ',', { '<', 0x2190 }}, /* arrow pointing left */
+ { '+', { '>', 0x2192 }}, /* arrow pointing right */
+ { '.', { 'v', 0x2193 }}, /* arrow pointing down */
+ { '-', { '^', 0x2191 }}, /* arrow pointing up */
+ { 'h', { '#', 0x2592 }}, /* board of squares */
+ { 'i', { '#', 0x2603 }}, /* lantern symbol */
+ { '0', { '#', 0x25ae }}, /* solid square block */
+ /* these defaults were invented for ncurses */
+ { 'p', { '-', 0x23bb }}, /* scan line 3 */
+ { 'r', { '-', 0x23bc }}, /* scan line 7 */
+ { 'y', { '<', 0x2264 }}, /* less-than-or-equal-to */
+ { 'z', { '>', 0x2265 }}, /* greater-than-or-equal-to */
+ { '{', { '*', 0x03c0 }}, /* greek pi */
+ { '|', { '!', 0x2260 }}, /* not-equal */
+ { '}', { 'f', 0x00a3 }}, /* pound-sterling symbol */
+ };
+ /* *INDENT-ON* */
+
+ unsigned n, m;
+ int active = _nc_unicode_locale();
+
+ T(("initializing WIDE-ACS map (Unicode is%s active)",
+ active ? "" : " not"));
+
+ if (active) {
+ enter_alt_charset_mode = "";
+ exit_alt_charset_mode = "";
+ acs_chars = "";
+ ena_acs = "";
+ }
+ _nc_wacs = typeCalloc(cchar_t, ACS_LEN);
+ for (n = 0; n < SIZEOF(table); ++n) {
+ m = table[n].map;
+ SetChar(_nc_wacs[m], table[n].value[active], A_NORMAL);
+ T(("#%d, SetChar(%c, %#04x) = %s",
+ n, m,
+ table[n].value[active],
+ _tracecchar_t(&_nc_wacs[m])));
+ }
+}
diff --git a/contrib/ncurses/ncurses/widechar/lib_wunctrl.c b/contrib/ncurses/ncurses/widechar/lib_wunctrl.c
new file mode 100644
index 000000000000..f4887d125fcf
--- /dev/null
+++ b/contrib/ncurses/ncurses/widechar/lib_wunctrl.c
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * Copyright (c) 2001 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"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/*
+** lib_wunctrl.c
+**
+** The routine wunctrl().
+**
+*/
+
+#include <curses.priv.h>
+
+#if USE_WIDEC_SUPPORT
+
+MODULE_ID("$Id: lib_wunctrl.c,v 1.6 2001/09/22 19:18:02 tom Exp $")
+
+NCURSES_EXPORT(wchar_t *)
+wunctrl(cchar_t * wc)
+{
+ static wchar_t str[5], *sp;
+
+ if (Charable(*wc)) {
+ const char *p;
+ for (p = unctrl(wctob(CharOf(*wc))), sp = str; *p;)
+ *sp++ = btowc(*p++);
+ return str;
+ } else
+ return wc->chars;
+}
+
+#endif