diff options
author | 2010-09-06 17:26:17 +0000 | |
---|---|---|
committer | 2010-09-06 17:26:17 +0000 | |
commit | 6bc6570d7fd20fe27f87e204c2ecf395c194fff8 (patch) | |
tree | f71d3f7957c33df4e938c0bb81284e3e9a4e738d /lib | |
parent | add ssh_host_ecdsa_key to /etc; from Mattieu Baptiste <mattieu.b@gmail.com> (diff) | |
download | wireguard-openbsd-6bc6570d7fd20fe27f87e204c2ecf395c194fff8.tar.xz wireguard-openbsd-6bc6570d7fd20fe27f87e204c2ecf395c194fff8.zip |
Enable wide character support in ncurses. It is built into libcurses,
libform, libmenu, libpanel and each library is also linked to a
corresponding "w" version.
This is a major bump for all four libraries.
Thanks to landry, stsp, sthen, naddy, oga, Martin Pieuchot, and anyone
else I've forgotten for testing.
ok naddy krw deraadt
Diffstat (limited to 'lib')
42 files changed, 3700 insertions, 26 deletions
diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile index 9414ea4e646..ebdb3744cd3 100644 --- a/lib/libcurses/Makefile +++ b/lib/libcurses/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.59 2010/01/12 23:21:58 nicm Exp $ +# $OpenBSD: Makefile,v 1.60 2010/09/06 17:26:17 nicm Exp $ # Uncomment this to enable tracing in libcurses #CURSESTRACE=-DTRACE @@ -10,7 +10,8 @@ FALLBACK_LIST= AWK?= /usr/bin/awk # Search in subdirs -.PATH: ${.CURDIR}/base ${.CURDIR}/tinfo ${.CURDIR}/trace ${.CURDIR}/tty +.PATH: ${.CURDIR}/base ${.CURDIR}/tinfo ${.CURDIR}/trace ${.CURDIR}/tty \ + ${.CURDIR}/widechar LIB= curses WANTLINT= @@ -53,6 +54,12 @@ SRCS+= lib_trace.c lib_traceatr.c lib_tracebits.c lib_tracechr.c \ # tty SRCS+= hardscroll.c hashmap.c lib_mvcur.c lib_tstp.c lib_twait.c \ lib_vidattr.c tty_update.c +# widechar +SRCS+= charable.c lib_add_wch.c lib_box_set.c lib_cchar.c lib_erasewchar.c \ + lib_get_wch.c lib_get_wstr.c lib_hline_set.c lib_in_wch.c \ + lib_in_wchnstr.c lib_ins_wch.c lib_inwstr.c lib_key_name.c \ + lib_pecho_wchar.c lib_slk_wset.c lib_unget_wch.c lib_vid_attr.c \ + lib_vline_set.c lib_wacs.c lib_wunctrl.c HOSTCFLAGS?= ${CFLAGS} HOSTLDFLAGS?= ${LDFLAGS} @@ -65,7 +72,8 @@ MAN= curs_addch.3tbl curs_addchstr.3 curs_addstr.3 curs_attr.3tbl \ curs_delch.3 curs_deleteln.3 \ curs_extend.3 \ curs_getch.3tbl curs_getstr.3 curs_getyx.3 \ - curs_inch.3tbl curs_inchstr.3 curs_initscr.3 curs_inopts.3 curs_insch.3 curs_insstr.3 curs_instr.3 \ + curs_inch.3tbl curs_inchstr.3 curs_initscr.3 curs_inopts.3 \ + curs_insch.3 curs_insstr.3 curs_instr.3 \ curs_kernel.3 \ curs_legacy.3 \ curs_mouse.3tbl curs_move.3 \ @@ -76,6 +84,9 @@ MAN= curs_addch.3tbl curs_addchstr.3 curs_addstr.3 curs_attr.3tbl \ curs_termattrs.3 curs_touch.3 \ curs_util.3 \ curs_window.3 \ + curs_add_wch.3 curs_add_wchstr.3 curs_addwstr.3 curs_get_wch.3 \ + curs_get_wstr.3 curs_in_wch.3 curs_in_wchstr.3 curs_ins_wch.3 \ + curs_ins_wstr.3 curs_inwstr.3 \ default_colors.3 define_key.3 \ key_defined.3 keybound.3 keyok.3 \ curses.3tbl \ @@ -83,8 +94,8 @@ MAN= curs_addch.3tbl curs_addchstr.3 curs_addstr.3 curs_attr.3tbl \ term.5tbl term.7 termcap.3 terminfo.3 terminfo.5tbl \ wresize.3 -MLINKS+=curses.3 ncurses.3 -MLINKS+=curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 mvaddch.3 \ +MLINKS+= curses.3 ncurses.3 +MLINKS+= curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 mvaddch.3 \ curs_addch.3 mvwaddch.3 curs_addch.3 echochar.3 curs_addch.3 \ wechochar.3 curs_addchstr.3 addchstr.3 curs_addchstr.3 addchnstr.3 \ curs_addchstr.3 waddchstr.3 curs_addchstr.3 waddchnstr.3 \ @@ -192,7 +203,7 @@ MLINKS+=curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 mvaddch.3 \ mvderwin.3 curs_window.3 dupwin.3 curs_window.3 wsyncup.3 \ curs_window.3 syncok.3 curs_window.3 wcursyncup.3 \ curs_window.3 wsyncdown.3 -MLINKS+=curs_extend.3 curses_version.3 curs_extend.3 use_extended_names.3 \ +MLINKS+= curs_extend.3 curses_version.3 curs_extend.3 use_extended_names.3 \ default_colors.3 assume_default_colors.3 \ default_colors.3 use_default_colors.3 MLINKS+= terminfo.3 setupterm.3 terminfo.3 setterm.3 terminfo.3 set_curterm.3 \ @@ -221,6 +232,41 @@ MLINKS+= curs_opaque.3 is_cleared.3 curs_opaque.3 is_idcok.3 \ curs_opaque.3 is_nodelay.3 curs_opaque.3 is_notimeout.3 \ curs_opaque.3 is_scrollok.3 curs_opaque.3 is_syncok.3 \ curs_opaque.3 wgetparent.3 curs_opaque.3 wgetscrreg.3 +MLINKS+= resizeterm.3 is_term_resized.3 resizeterm.3 resize_term.3 +MLINKS+= curs_add_wch.3 add_wch.3 curs_add_wch.3 wadd_wch.3 \ + curs_add_wch.3 mvadd_wch.3 curs_add_wch.3 mvwadd_wch.3 \ + curs_add_wch.3 echo_wchar.3 curs_add_wch.3 wecho_wchar.3 +MLINKS+= curs_add_wchstr.3 add_wchstr.3 curs_add_wchstr.3 add_wchnstr.3 \ + curs_add_wchstr.3 wadd_wchstr.3 curs_add_wchstr.3 wadd_wchnstr.3 \ + curs_add_wchstr.3 mvadd_wchstr.3 curs_add_wchstr.3 mvadd_wchnstr.3 \ + curs_add_wchstr.3 mvwadd_wchstr.3 curs_add_wchstr.3 mvwadd_wchnstr.3 +MLINKS+= curs_addwstr.3 addwstr.3 curs_addwstr.3 addnwstr.3 \ + curs_addwstr.3 waddwstr.3 curs_addwstr.3 waddnwstr.3 \ + curs_addwstr.3 mvaddwstr.3 curs_addwstr.3 mvaddnwstr.3 \ + curs_addwstr.3 mvwaddwstr.3 curs_addwstr.3 mvwaddnwstr.3 +MLINKS+= curs_get_wch.3 get_wch.3 curs_get_wch.3 wget_wch.3 \ + curs_get_wch.3 mvget_wch.3 curs_get_wch.3 mvwget_wch.3 \ + curs_get_wch.3 unget_wch.3 +MLINKS+= curs_get_wstr.3 get_wstr.3 curs_get_wstr.3 getn_wstr.3 \ + curs_get_wstr.3 wget_wstr.3 curs_get_wstr.3 wgetn_wstr.3 \ + curs_get_wstr.3 mvget_wstr.3 curs_get_wstr.3 mvgetn_wstr.3 \ + curs_get_wstr.3 mvwget_wstr.3 curs_get_wstr.3 mvwgetn_wstr.3 +MLINKS+= curs_in_wch.3 in_wch.3 curs_in_wch.3 mvin_wch.3 \ + curs_in_wch.3 mvwin_wch.3 curs_in_wch.3 win_wch.3 +MLINKS+= curs_in_wchstr.3 in_wchstr.3 curs_in_wchstr.3 in_wchnstr.3 \ + curs_in_wchstr.3 win_wchstr.3 curs_in_wchstr.3 win_wchnstr.3 \ + curs_in_wchstr.3 mvin_wchstr.3 curs_in_wchstr.3 mvin_wchnstr.3 \ + curs_in_wchstr.3 mvwin_wchstr.3 curs_in_wchstr.3 mvwin_wchnstr.3 +MLINKS+= curs_ins_wch.3 ins_wch.3 curs_ins_wch.3 mvins_wch.3 \ + curs_ins_wch.3 mvwins_wch.3 curs_ins_wch.3 wins_wch.3 +MLINKS+= curs_ins_wstr.3 ins_wstr.3 curs_ins_wstr.3 ins_nwstr.3 \ + curs_ins_wstr.3 wins_wstr.3 curs_ins_wstr.3 wins_nwstr.3 \ + curs_ins_wstr.3 mvins_wstr.3 curs_ins_wstr.3 mvins_nwstr.3 \ + curs_ins_wstr.3 mvwins_wstr.3 curs_ins_wstr.3 mvwins_nwstr.3 +MLINKS+= curs_inwstr.3 inwstr.3 curs_inwstr.3 innwstr.3 \ + curs_inwstr.3 winwstr.3 curs_inwstr.3 winnwstr.3 \ + curs_inwstr.3 mvinwstr.3 curs_inwstr.3 mvinnwstr.3 \ + curs_inwstr.3 mvwinwstr.3 curs_inwstr.3 mvwinnwstr.3 GENERATED= init_keytry.h codes.c comp_captab.c expanded.c fallback.c \ keys.list lib_gen.c lib_keyname.c names.c unctrl.c make_hash make_keys @@ -298,12 +344,14 @@ afterinstall: ln -f $$i `echo $$i | sed 's/curses/termlib/'`; \ ln -f $$i `echo $$i | sed 's/curses/termcap/'`; \ ln -f $$i `echo $$i | sed 's/curses/ncurses/'`; \ + ln -f $$i `echo $$i | sed 's/curses/ncursesw/'`; \ done .if (${DEBUGLIBS:L} == "yes") -cd ${DESTDIR}${LIBDIR}/debug; \ ln -f lib${LIB}.a lib`echo ${LIB} | sed 's/curses/termlib/'`.a; \ ln -f lib${LIB}.a lib`echo ${LIB} | sed 's/curses/termcap/'`.a; \ - ln -f lib${LIB}.a lib`echo ${LIB} | sed 's/curses/ncurses/'`.a + ln -f lib${LIB}.a lib`echo ${LIB} | sed 's/curses/ncurses/'`.a; \ + ln -f lib${LIB}.a lib`echo ${LIB} | sed 's/curses/ncursesw/'`.a .endif .include <bsd.lib.mk> diff --git a/lib/libcurses/curs_add_wch.3 b/lib/libcurses/curs_add_wch.3 new file mode 100644 index 00000000000..61fee35067f --- /dev/null +++ b/lib/libcurses/curs_add_wch.3 @@ -0,0 +1,136 @@ +.\" $OpenBSD: curs_add_wch.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2001-2002,2006 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_add_wch.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_add_wch 3 "" +.SH NAME +\fBadd_wch\fP, +\fBwadd_wch\fP, +\fBmvadd_wch\fP, +\fBmvwadd_wch\fP, +\fBecho_wchar\fP, +\fBwecho_wchar\fP - add a complex character and rendition to a \fBcurses\fR window, then advance the cursor +.SH SYNOPSIS +.PP +\fB#include <curses.h>\fP +.sp +.B "int add_wch( const cchar_t *\fIwch\fB );" +.br +.B "int wadd_wch( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );" +.br +.B "int mvadd_wch( int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );" +.br +.B "int mvwadd_wch( WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );" +.br +.B "int echo_wchar( const cchar_t *\fIwch\fB );" +.br +.B "int wecho_wchar( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );" +.br +.SH DESCRIPTION +.PP +The +\fBadd_wch\fP, +\fBwadd_wch\fP, +\fBmvadd_wch\fP, and +\fBmvwadd_wch\fP +functions put the complex character \fIwch\fP into the given +window at its current position, +which is then advanced. +These functions perform +wrapping and special-character processing as follows: +.TP 5 +- +If \fIwch\fP refers to a spacing character, +then any previous character at that location is removed. +A new character specified by \fIwch\fP is +placed at that location with rendition specified by \fIwch\fP. +The cursor then advances to +the next spacing character on the screen. +.TP 5 +- +If \fIwch\fP refers to a non-spacing character, +all previous characters at that location are preserved. +The non-spacing characters of \fIwch\fP +are added to the spacing complex character, +and the rendition specified by \fIwch\fP is ignored. +.TP 5 +- +If the character part of \fIwch\fP is +a tab, newline, backspace or other control character, +the window is updated and the cursor moves as if \fBaddch\fR were called. +.PP +The \fBecho_wchar\fP +function is functionally equivalent to a call to +\fBadd_wch\fP +followed by a call to +\fBrefresh\fP. +Similarly, the +\fBwecho_wchar\fP +is functionally equivalent to a call to +\fBwadd_wch\fP +followed by a call to +\fBwrefresh\fP. +The knowledge +that only a single character is being output is taken into consideration and, +for non-control characters, a considerable performance gain might be seen +by using the *\fBecho\fP* functions instead of their equivalents. +.SH RETURN VALUES +.PP +All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success. +.SH NOTES +.PP +Note that +\fBadd_wch\fP, +\fBmvadd_wch\fP, +\fBmvwadd_wch\fP, and +\fBecho_wchar\fP +may be macros. +.SH PORTABILITY +.PP +All these functions are described in the XSI Curses standard, Issue 4. +The defaults specified for forms-drawing characters apply in the POSIX locale. +.PP +XSI documents constants beginning with \fBWACS_\fP which are used for +line-drawing. +Those are not currently implemented in \fBncurses\fP. +.SH SEE ALSO +.PP +\fBcurses\fR(3), +\fBcurs_addch\fR(3), +\fBcurs_attr\fR(3), +\fBcurs_clear\fR(3), +\fBcurs_outopts\fR(3), +\fBcurs_refresh\fR(3), +\fBputwc\fR(3) +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curs_add_wchstr.3 b/lib/libcurses/curs_add_wchstr.3 new file mode 100644 index 00000000000..ab7eb5af3ec --- /dev/null +++ b/lib/libcurses/curs_add_wchstr.3 @@ -0,0 +1,98 @@ +.\" $OpenBSD: curs_add_wchstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002-2004,2005 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_add_wchstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_add_wchstr 3 "" +.SH NAME +\fBadd_wchstr\fR, +\fBadd_wchnstr\fR, +\fBwadd_wchstr\fR, +\fBwadd_wchnstr\fR, +\fBmvadd_wchstr\fR, +\fBmvadd_wchnstr\fR, +\fBmvwadd_wchstr\fR, +\fBmvwadd_wchnstr\fR \- add an array of complex characters (and attributes) to a curses window +.SH SYNOPSIS +.B #include <curses.h> +.PP +.nf +\fBint add_wchstr(const cchar_t *\fR\fIwchstr\fR\fB);\fR +.br +\fBint add_wchnstr(const cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint wadd_wchstr(WINDOW *\fR \fIwin\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB);\fR +.br +\fBint wadd_wchnstr(WINDOW *\fR \fIwin\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvadd_wchstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB);\fR +.br +\fBint mvadd_wchnstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvwadd_wchstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB);\fR +.br +\fBint mvwadd_wchnstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR +.fi +.SH DESCRIPTION +These routines copy the array of complex characters \fIwchstr\fR +into the window image structure at and after the current cursor position. +The four routines with \fIn\fR as the last +argument copy at most \fIn\fR elements, but no more than will fit on the line. +If \fBn\fR=\fB-1\fR then the whole array is copied, +to the maximum number of characters that will fit on the line. +.PP +The window cursor is \fInot\fR advanced. +These routines work faster than \fBwaddnstr\fR. +On the other hand, they do not perform checking +(such as for the newline, backspace, or carriage return characters), +they do not advance the current cursor position, +they do not expand other control characters to ^-escapes, +and they truncate the string if it crosses the right margin, +rather than wrapping it around to the new line. +.PP +These routines end successfully +on encountering a null \fIcchar_t\fR, or +when they have filled the current line. +If a complex character cannot completely fit at the end of the current line, +the remaining columns are filled with the background character and rendition. +.SH NOTES +All functions except \fBwadd_wchnstr\fR may be macros. +.SH RETURN VALUES +All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success. +.SH PORTABILITY +All these entry points are described in the XSI Curses standard, Issue 4. +.SH SEE ALSO +\fBcurses\fR(3), +\fBcurs_addchstr\fR(3), +\fBcurs_addwstr\fR(3) +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curs_addwstr.3 b/lib/libcurses/curs_addwstr.3 new file mode 100644 index 00000000000..474fc51a24b --- /dev/null +++ b/lib/libcurses/curs_addwstr.3 @@ -0,0 +1,95 @@ +.\" $OpenBSD: curs_addwstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002-2005,2006 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_addwstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_addwstr 3 "" +.na +.hy 0 +.SH NAME +\fBaddwstr\fR, +\fBaddnwstr\fR, +\fBwaddwstr\fR, +\fBwaddnwstr\fR, +\fBmvaddwstr\fR, +\fBmvaddnwstr\fR, +\fBmvwaddwstr\fR, +\fBmvwaddnwstr\fR \- add a string of wide characters to a \fBcurses\fR window and advance cursor +.ad +.hy +.SH SYNOPSIS +.nf +\fB#include <curses.h>\fR +.PP +\fBint addwstr(const wchar_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint addnwstr(const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint waddwstr(WINDOW *\fR\fIwin\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint waddnwstr(WINDOW *\fR\fIwin\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvaddwstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint mvaddnwstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvwaddwstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint mvwaddnwstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.fi +.SH DESCRIPTION +These routines write the characters of the +(null-terminated) \fBwchar_t\fR character string +\fIwstr\fR on the given window. +It is similar to constructing a \fBcchar_t\fR for each wchar_t in the string, +then calling \fBwadd_wch\fR for the resulting \fBcchar_t\fR. +.PP +The \fImv\fR routines perform cursor movement once, before writing any +characters. +Thereafter, the cursor is advanced as a side-effect of writing to the window. +.PP +The four routines with \fIn\fR as the last argument +write at most \fIn\fR \fBwchar_t\fR characters. +If \fIn\fR is -1, then the entire string will be added, +up to the maximum number of characters that will fit on the line, +or until a terminating null is reached. +.SH RETURN VALUES +All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success. +.SH NOTES +Note that all of these routines except \fBwaddnwstr\fR may be macros. +.SH PORTABILITY +All these entry points are described in the XSI Curses standard, Issue 4. +.SH SEE ALSO +\fBcurses\fR(3), +\fBcurs_add_wch\fR(3) +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curs_get_wch.3 b/lib/libcurses/curs_get_wch.3 new file mode 100644 index 00000000000..f3b9f0d29be --- /dev/null +++ b/lib/libcurses/curs_get_wch.3 @@ -0,0 +1,162 @@ +.\" $OpenBSD: curs_get_wch.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002-2003,2006 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_get_wch.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_get_wch 3 "" +.SH NAME +\fBget_wch\fR, +\fBwget_wch\fR, +\fBmvget_wch\fR, +\fBmvwget_wch\fR, +\fBunget_wch\fR \- get (or push back) a wide character from curses terminal keyboard +.SH SYNOPSIS +\fB#include <curses.h>\fR +.sp +\fBint get_wch(wint_t *\fR\fIwch\fR\fB);\fR +.br +\fBint wget_wch(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR +.br +\fBint mvget_wch(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR +.br +\fBint mvwget_wch(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR +.br +\fBint unget_wch(const wchar_t \fR\fIwch\fR\fB);\fR +.SH DESCRIPTION +The +\fBget_wch\fR, +\fBwget_wch\fR, +\fBmvget_wch\fR, and +\fBmvwget_wch\fR +functions read a character +from the terminal associated with the current or specified window. +In no-delay mode, +if no input is waiting, the value \fBERR\fR is returned. +In delay mode, +the program waits until the system passes text through to the program. +Depending on the setting of \fBcbreak\fR, +this is after one character (cbreak mode), +or after the first newline (nocbreak mode). +In half-delay mode, +the program waits until the user types a character or the specified +timeout interval has elapsed. +.PP +Unless \fBnoecho\fR has been set, +these routines echo the character into the designated window. +.PP +If the window is not a pad and has been moved or modified since the +last call to \fBwrefresh\fR, +\fBwrefresh\fR will be called before another character is read. +.PP +If \fBkeypad\fR is enabled, +these functions respond to +the pressing of a function key by setting the object pointed to by +\fIwch\fR +to the corresponding +\fBKEY_\fR +value defined +in +\fB<curses.h>\fR +and returning +\fBKEY_CODE_YES\fR. +If a character (such as escape) that could be the +beginning of a function key is received, curses sets a timer. +If the remainder +of the sequence does arrive within the designated time, curses passes through +the character; otherwise, curses returns the function key value. +For this +reason, many terminals experience a delay between the time a user presses +the escape key and the time the escape is returned to the program. +.PP +The +\fBunget_wch\fR +function pushes the wide character +\fIwch\fR +back onto the head of the input queue, so the wide character +is returned by the next call to +\fBget_wch\fR. +The pushback of +one character is guaranteed. +If the program calls +\fBunget_wch\fR +too many times without an intervening call to +\fBget_wch\fR, +the operation may fail. +.SH NOTES +The header file +\fB<curses.h>\fR +automatically +includes the header file +\fB<stdio.h>\fR. +.PP +Applications should not define the escape key by itself as a single-character +function. +.PP +When using +\fBget_wch\fR, +\fBwget_wch\fR, +\fBmvget_wch\fR, or +\fBmvwget_wch\fR, applications should +not use +\fBnocbreak\fR +mode and +\fBecho\fR +mode +at the same time. +Depending on the state of the tty driver when each character +is typed, the program may produce undesirable results. +.PP +All functions except \fBwget_wch\fR and \fBunget_wch\fR +may be macros. +.SH RETURN VALUES +When +\fBget_wch\fR, +\fBwget_wch\fR, +\fBmvget_wch\fR, and +\fBmvwget_wch\fR +functions successfully +report the pressing of a function key, they return +\fBKEY_CODE_YES\fR. +When they successfully report a wide character, they return +\fBOK\fR. +Otherwise, they return +\fBERR\fR. +.PP +Upon successful completion, +\fBunget_wch\fR +returns +\fBOK\fR. +Otherwise, the function returns +\fBERR\fR. +.SH SEE ALSO +\fBcurses\fR(3), +\fBcurs_getch\fR(3), +\fBcurs_ins_wch\fR(3), +\fBcurs_inopts\fR(3), +\fBcurs_move\fR(3), +\fBcurs_refresh\fR(3) diff --git a/lib/libcurses/curs_get_wstr.3 b/lib/libcurses/curs_get_wstr.3 new file mode 100644 index 00000000000..ce5770faf23 --- /dev/null +++ b/lib/libcurses/curs_get_wstr.3 @@ -0,0 +1,179 @@ +.\" $OpenBSD: curs_get_wstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002-2005,2006 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_get_wstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_get_wstr 3 "" +.na +.hy 0 +.SH NAME +\fBget_wstr\fR, +\fBgetn_wstr\fR, +\fBwget_wstr\fR, +\fBwgetn_wstr\fR, +\fBmvget_wstr\fR, +\fBmvgetn_wstr\fR, +\fBmvwget_wstr\fR, +\fBmvwgetn_wstr\fR \- get an array of wide characters from a curses terminal keyboard +.ad +.hy +.SH SYNOPSIS +.nf +\fB#include <curses.h>\fR +.sp +\fBint get_wstr(wint_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint getn_wstr(wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint wget_wstr(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint wgetn_wstr(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvget_wstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint mvgetn_wstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvwget_wstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint mvwgetn_wstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.fi +.SH DESCRIPTION +The effect of +\fBget_wstr\fR +is as though a series of calls +to +\fBget_wch\fR +were made, until a newline, other end-of-line, or end-of-file condition is processed. +An end-of-file condition is represented by \fBWEOF\fR, as defined in \fB<wchar.h>\fR. +The newline and end-of-line conditions are represented by the \fB\\n\fR \fBwchar_t\fR value. +In all instances, the end of the string is terminated by a null \fBwchar_t\fR. +The routine places resulting values in the area pointed to by \fIwstr\fR. +.PP +The user's erase and kill characters are interpreted. If keypad +mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR +are both considered equivalent to the user's kill character. +.PP +Characters input are echoed only if \fBecho\fR is currently on. In that case, +backspace is echoed as deletion of the previous character (typically a left +motion). +.PP +The effect of +\fBwget_wstr\fR +is as though a series of +calls to +\fBwget_wch\fR +were made. +.PP +The effect of +\fBmvget_wstr\fR +is as though a call to +\fBmove\fR +and then a series of calls to +\fBget_wch\fR +were +made. +.PP +The effect of +\fBmvwget_wstr\fR +is as though a call to +\fBwmove\fR +and then a series of calls to +\fBwget_wch\fR +were made. +.PP +The +\fBgetn_wstr\fR, +\fBmvgetn_wstr\fR, +\fBmvwgetn_wstr\fR, and +\fBwgetn_wstr\fR +functions are identical +to the +\fBget_wstr\fR, +\fBmvget_wstr\fR, +\fBmvwget_wstr\fR, and +\fBwget_wstr\fR +functions, respectively, +except that the +\fB*n_*\fR +versions read at most +\fIn\fR +characters, letting the application prevent overflow of the +input buffer. +.SH NOTES +Using +\fBget_wstr\fR, +\fBmvget_wstr\fR, +\fBmvwget_wstr\fR, or +\fBwget_wstr\fR +to read a line that +overflows the array pointed to by +\fBwstr\fR +causes undefined +results. +The use of +\fBgetn_wstr\fR, +\fBmvgetn_wstr\fR, +\fBmvwgetn_wstr\fR, or +\fBwgetn_wstr\fR, respectively, is recommended. +.PP +These functions cannot return \fBKEY_\fR values because there +is no way to distinguish a \fBKEY_\fR value from a valid \fBwchar_t\fR value. +.PP +All of these routines except \fBwgetn_wstr\fR may be macros. +.SH RETURN VALUES +All of these functions return \fBOK\fR upon successful completion. +Otherwise, they return \fBERR\fR. +.PP +Functions using a window parameter return an error if it is null. +.RS +.TP 5 +\fBwgetn_wstr\fP +returns an error if the associated call to \fBwget_wch\fP failed. +.RE +.SH PORTABILITY +These functions are described in The Single Unix Specification, Version 2. +No error conditions are defined. +This implementation returns ERR if the window pointer is null, +or if the lower-level \fBwget_wch\fR call returns an ERR. +In the latter case, +an ERR return without other data is treated as an end-of-file condition, +and the returned array contains a \fBWEOF\fR followed by a null \fBwchar_t\fR. +.PP +X/Open curses documents these functions to pass an array of \fBwchar_t\fR, +but all of the vendors implement this using \fBwint_t\fR. +.SH SEE ALSO +Functions: +\fBcurses\fR(3), +\fBcurs_get_wch\fR(3), +\fBcurs_getstr\fR(3). +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curs_in_wch.3 b/lib/libcurses/curs_in_wch.3 new file mode 100644 index 00000000000..97eea48692f --- /dev/null +++ b/lib/libcurses/curs_in_wch.3 @@ -0,0 +1,69 @@ +.\" $OpenBSD: curs_in_wch.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002,2006 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_in_wch.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_in_wch 3 "" +.SH NAME +\fBin_wch\fR, +\fBmvin_wch\fR, +\fBmvwin_wch\fR, +\fBwin_wch\fR - extract a complex character and rendition from a window +.SH SYNOPSIS +\fB#include <curses.h>\fR +.sp +\fBint in_wch(cchar_t *\fR\fIwcval\fR\fB);\fR +.br +\fBint mvin_wch(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwcval\fR\fB);\fR +.br +\fBint mvwin_wch(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwcval\fR\fB);\fR +.br +\fBint win_wch(WINDOW *\fR\fIwin\fR\fB, cchar_t *\fR\fIwcval\fR\fB);\fR +.SH DESCRIPTION +These functions extract the complex character and rendition from +the current position in the named window into the \fBcchar_t\fR object +referenced by wcval. +.SH RETURN VALUE +No errors are defined in the XSI Curses standard. +This implementation checks for null pointers, returns ERR in that case. +Also, the \fImv\fR routines check for error moving the cursor, returning ERR +in that case. +Otherwise they return OK +.SH NOTES +Note that all of these routines may be macros. +.SH PORTABILITY +These functions are described in the XSI Curses standard, Issue 4. +.SH SEE ALSO +\fBcurses\fR(3), +\fBcurs_inch\fR(3). +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curs_in_wchstr.3 b/lib/libcurses/curs_in_wchstr.3 new file mode 100644 index 00000000000..5ba964b6f78 --- /dev/null +++ b/lib/libcurses/curs_in_wchstr.3 @@ -0,0 +1,123 @@ +.\" $OpenBSD: curs_in_wchstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002-2005,2006 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_in_wchstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_in_wchstr 3 "" +.na +.hy 0 +.SH NAME +\fBin_wchstr\fR, +\fBin_wchnstr\fR, +\fBwin_wchstr\fR, +\fBwin_wchnstr\fR, +\fBmvin_wchstr\fR, +\fBmvin_wchnstr\fR, +\fBmvwin_wchstr\fR, +\fBmvwin_wchnstr\fR \- get an array of complex characters and renditions from a curses window +.ad +.hy +.SH SYNOPSIS +.nf +\fB#include <curses.h>\fR +.sp +\fBint in_wchstr(cchar_t *\fR\fIwchstr\fR\fB);\fR +.br +\fBint in_wchnstr(cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint win_wchstr(WINDOW *\fR\fIwin\fR\fB, cchar_t *\fR\fIwchstr\fR\fB);\fR +.br +\fBint win_wchnstr(WINDOW *\fR\fIwin\fR\fB, cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvin_wchstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwchstr\fR\fB);\fR +.br +\fBint mvin_wchnstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvwin_wchstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwchstr\fR\fB);\fR +.br +\fBint mvwin_wchnstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwchstr\fR, int \fIn\fR\fB);\fR +.fi +.SH DESCRIPTION +These functions return an array of complex characters in \fIwchstr\fR, +starting at the current cursor position in the named window. +Attributes (rendition) are stored with the characters. +.PP +The +\fBin_wchnstr\fR, +\fBmvin_wchnstr\fR, +\fBmvwin_wchnstr\fR +and +\fBwin_wchnstr\fR +fill the array +with at most +\fIn\fR +\fBcchar_t\fR +elements. +.br +.SH NOTES +Note that all routines except +\fBwin_wchnstr\fR +may be +macros. +.PP +Reading a line that overflows the array pointed to by +\fIwchstr\fR +with +\fBin_wchstr\fR, +\fBmvin_wchstr\fR, +\fBmvwin_wchstr\fR +or +\fBwin_wchstr\fR +causes undefined results. Therefore, the use of +\fBin_wchnstr\fR, +\fBmvin_wchnstr\fR, +\fBmvwin_wchnstr\fR, or +\fBwin_wchnstr\fR +is recommended. +.SH RETURN VALUES +Upon successful completion, these functions return +\fBOK\fR. +Otherwise, they return +\fBERR\fR. +.SH PORTABILITY +The XSI Curses defines no error conditions. +This implementation checks for null pointers, +returning ERR in that case. +.SH SEE ALSO +Functions: +\fBcurses\fR(3), +\fBcurs_in_wch\fR(3), +\fBcurs_instr\fR(3), +\fBcurs_inwstr\fR(3) +\fBcurs_inchstr\fR(3) +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curs_ins_wch.3 b/lib/libcurses/curs_ins_wch.3 new file mode 100644 index 00000000000..5e8e3eec5b6 --- /dev/null +++ b/lib/libcurses/curs_ins_wch.3 @@ -0,0 +1,66 @@ +.\" $OpenBSD: curs_ins_wch.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002,2006 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_ins_wch.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_ins_wch 3 "" +.SH NAME +\fBins_wch\fR, +\fBmvins_wch\fR, +\fBmvwins_wch\fR, +\fBwins_wch\fR \- insert a complex character and rendition into a window +.SH SYNOPSIS +#include <curses.h> +.sp +\fBint ins_wch(const cchar_t *\fR\fIwch\fR\fB);\fR +.br +\fBint wins_wch(WINDOW *\fR\fIwin, const cchar_t *\fR\fIwch\fR\fB);\fR +.br +\fBint mvins_wch(int \fR\fIy, int \fR\fIx, const cchar_t *\fR\fIwch\fR\fB);\fR +.br +\fBint mvwins_wch(WINDOW *\fR\fIwin, int \fR\fIy, int \fR\fIx, const cchar_t *\fR\fIwch\fR\fB);\fR +.SH DESCRIPTION +These routines, insert the complex character \fIwch\fR with rendition +before the character under the cursor. +All characters to the right of the cursor are moved one space to the right, +with the possibility of the rightmost character on the line being lost. +The insertion operation does not change the cursor position. +.SH RETURN VALUE +If successful, these functions return OK. +If not, they return ERR. +.SH ERRORS +No errors are defined. +.SH SEE ALSO +\fBcurses\fR(3), +\fBcurs_insch\fR(3). +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curs_ins_wstr.3 b/lib/libcurses/curs_ins_wstr.3 new file mode 100644 index 00000000000..d488fc6b8be --- /dev/null +++ b/lib/libcurses/curs_ins_wstr.3 @@ -0,0 +1,109 @@ +.\" $OpenBSD: curs_ins_wstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002,2005 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_ins_wstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_ins_wstr 3 "" +.na +.hy 0 +.SH NAME +\fBins_wstr\fR, +\fBins_nwstr\fR, +\fBwins_wstr\fR, +\fBwins_nwstr\fR, +\fBmvins_wstr\fR, +\fBmvins_nwstr\fR, +\fBmvwins_wstr\fR, +\fBmvwins_nwstr\fR \- insert a wide-character string into a curses window +.ad +.hy +.SH SYNOPSIS +.nf +\fB#include <curses.h>\fR +.sp +\fBint ins_wstr(const wchar_t *\fR\fIwstr);\fR +.br +\fBint ins_nwstr(const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint wins_wstr(WINDOW *\fR\fIwin\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint wins_nwstr(WINDOW *\fR\fIwin\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvins_wstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint mvins_nwstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvwins_wstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR +.br +\fBint mvwins_nwstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR +.fi +.SH DESCRIPTION +These routines insert a \fBwchar_t\fR character string +(as many characters as will fit on the line) +before the character under the cursor. +All characters to the right of the cursor are shifted right, +with the possibility of the rightmost characters on the line being lost. +No wrapping is performed. +The cursor position does not change +(after moving to \fIy\fR, \fIx\fR, if specified). +The four routines with \fIn\fR as the last argument +insert a leading substring of at most \fIn\fR \fBwchar_t\fR characters. +If \fIn\fR is less than 1, the entire string is inserted. +.PP +If a character in \fIwstr\fR is a tab, newline, carriage return or +backspace, the cursor is moved appropriately within the window. +A newline also does a \fBclrtoeol\fR before moving. +Tabs are considered to be at every eighth column. +If a character in \fIwstr\fR is another control character, +it is drawn in the \fB^\fR\fIX\fR notation. +Calling \fBwin_wch\fR after adding a control character +(and moving to it, if necessary) +does not return the control character, +but instead returns a character in the ^-representation +of the control character. +.SH NOTES +Note that all but wins_nwstr may be macros. +.PP +If the first character in the string is a nonspacing character, these +functions will fail. +XSI does not define what will happen if a nonspacing character follows +a control character. +.SH RETURN VALUES +Upon successful completion, these functions return OK. +Otherwise, they return ERR. +.SH SEE ALSO +\fBcurses\fR(3), +\fBcurs_insstr\fR(3), +\fBcurs_in_wch\fR(3), +\fBcurs_ins_wch\fR(3). +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curs_inwstr.3 b/lib/libcurses/curs_inwstr.3 new file mode 100644 index 00000000000..8cd418c7dfd --- /dev/null +++ b/lib/libcurses/curs_inwstr.3 @@ -0,0 +1,94 @@ +.\" $OpenBSD: curs_inwstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.\"*************************************************************************** +.\" Copyright (c) 2002-2005,2006 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. * +.\"*************************************************************************** +.\" +.\" $Id: curs_inwstr.3,v 1.1 2010/09/06 17:26:17 nicm Exp $ +.TH curs_inwstr 3 "" +.SH NAME +\fBinwstr\fR, +\fBinnwstr\fR, +\fBwinwstr\fR, +\fBwinnwstr\fR, +\fBmvinwstr\fR, +\fBmvinnwstr\fR, +\fBmvwinwstr\fR, +\fBmvwinnwstr\fR \- get a string of \fBwchar_t\fR characters from a curses window +.SH SYNOPSIS +.nf +\fB#include <curses.h> \fR +.sp +\fBint inwstr(\fR\fBwchar_t *\fR\fIstr\fR\fB);\fR +.br +\fBint innwstr(\fR\fBwchar_t *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint winwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, wchar_t *\fR\fIstr\fR\fB);\fR +.br +\fBint winnwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, wchar_t *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvinwstr(\fR\fBint \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIstr\fR\fB);\fR +.br +\fBint mvinnwstr(\fR\fBint \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR +.br +\fBint mvwinwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIstr\fR\fB);\fR +.br +\fBint mvwinnwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR +.fi +.SH DESCRIPTION +These routines return a string of \fBwchar_t\fR characters in \fIwstr\fR, +extracted starting at the current cursor position in the named window. +Attributes are stripped from the characters. +The four functions with \fIn\fR as the last argument return a leading substring at most +\fIn\fR bytes long (exclusive of the trailing NUL). +Transfer stops at the end of the current line, or when \fIn\fR bytes have +been stored at the location referenced by \fIwstr\fR. +.PP +If the size \fIn\fR is not large enough to store a complete character, +an error is generated. +.SH NOTES +Note that all routines except +\fBwinnwstr\fR +may be macros. +.SH RETURN VALUES +All routines return +\fBERR\fR +upon failure. Upon +successful completion, the *\fBinwstr\fR +routines return +\fBOK\fR, and the *\fBinnwstr\fR +routines return the +number of characters read into the string. +.SH SEE ALSO +\fBcurses\fR(3), +\fBcurs_instr\fR(3), +\fBcurs_in_wchstr\fR(3) +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/lib/libcurses/curses.3tbl b/lib/libcurses/curses.3tbl index 13bf0c7adfa..9b9cb455ac6 100644 --- a/lib/libcurses/curses.3tbl +++ b/lib/libcurses/curses.3tbl @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: curses.3tbl,v 1.20 2010/01/12 23:21:59 nicm Exp $ +.\" $OpenBSD: curses.3tbl,v 1.21 2010/09/06 17:26:17 nicm Exp $ .\" .\"*************************************************************************** .\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * @@ -29,7 +29,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: curses.3tbl,v 1.20 2010/01/12 23:21:59 nicm Exp $ +.\" $Id: curses.3tbl,v 1.21 2010/09/06 17:26:17 nicm Exp $ .hy 0 .TH ncurses 3 "" .ds n 5 @@ -272,8 +272,6 @@ functions in the "normal" library. There is a naming convention which relates many of the normal/wide variants: a "_w" is inserted into the name. For example, \fBwaddch\fP becomes \fBwadd_wch\fP. -.IP -ncursesw is not currently supported on OpenBSD. .RE .PP .\" diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index 574b6906abb..d0566e47040 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.h,v 1.60 2010/01/12 23:21:59 nicm Exp $ */ +/* $OpenBSD: curses.h,v 1.61 2010/09/06 17:26:17 nicm Exp $ */ /**************************************************************************** * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * @@ -34,7 +34,7 @@ * and: Thomas E. Dickey 1996-on * ****************************************************************************/ -/* $Id: curses.h,v 1.60 2010/01/12 23:21:59 nicm Exp $ */ +/* $Id: curses.h,v 1.61 2010/09/06 17:26:17 nicm Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H @@ -137,7 +137,7 @@ * of the header incompatible. */ #undef NCURSES_CH_T -#define NCURSES_CH_T chtype +#define NCURSES_CH_T cchar_t #if 0 && defined(_LP64) typedef unsigned chtype; @@ -342,7 +342,7 @@ typedef chtype attr_t; /* ...must be at least as wide as chtype */ #include <libutf8.h> #endif -#if 0 +#if 1 #include <wchar.h> /* ...to get mbstate_t, etc. */ #endif @@ -1334,7 +1334,259 @@ extern NCURSES_EXPORT_VAR(int) TABSIZE; #define KEY_EVENT 0633 /* We were interrupted by an event */ #define KEY_MAX 0777 /* Maximum key value is 0633 */ -/* $Id: curses.h,v 1.60 2010/01/12 23:21:59 nicm Exp $ */ +/* $Id: curses.h,v 1.61 2010/09/06 17:26:17 nicm Exp $ */ +/* + * vile:cmode: + * This file is part of ncurses, designed to be appended after curses.h.in + * (see that file for the relevant copyright). + */ +#ifdef _XOPEN_SOURCE_EXTENDED + +extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs; + +#define NCURSES_WACS(c) (&_nc_wacs[(unsigned char)c]) + +#define WACS_BSSB NCURSES_WACS('l') +#define WACS_SSBB NCURSES_WACS('m') +#define WACS_BBSS NCURSES_WACS('k') +#define WACS_SBBS NCURSES_WACS('j') +#define WACS_SBSS NCURSES_WACS('u') +#define WACS_SSSB NCURSES_WACS('t') +#define WACS_SSBS NCURSES_WACS('v') +#define WACS_BSSS NCURSES_WACS('w') +#define WACS_BSBS NCURSES_WACS('q') +#define WACS_SBSB NCURSES_WACS('x') +#define WACS_SSSS NCURSES_WACS('n') + +#define WACS_ULCORNER WACS_BSSB +#define WACS_LLCORNER WACS_SSBB +#define WACS_URCORNER WACS_BBSS +#define WACS_LRCORNER WACS_SBBS +#define WACS_RTEE WACS_SBSS +#define WACS_LTEE WACS_SSSB +#define WACS_BTEE WACS_SSBS +#define WACS_TTEE WACS_BSSS +#define WACS_HLINE WACS_BSBS +#define WACS_VLINE WACS_SBSB +#define WACS_PLUS WACS_SSSS + +#define WACS_S1 NCURSES_WACS('o') /* scan line 1 */ +#define WACS_S9 NCURSES_WACS('s') /* scan line 9 */ +#define WACS_DIAMOND NCURSES_WACS('`') /* diamond */ +#define WACS_CKBOARD NCURSES_WACS('a') /* checker board */ +#define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */ +#define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */ +#define WACS_BULLET NCURSES_WACS('~') /* bullet */ + + /* Teletype 5410v1 symbols */ +#define WACS_LARROW NCURSES_WACS(',') /* arrow left */ +#define WACS_RARROW NCURSES_WACS('+') /* arrow right */ +#define WACS_DARROW NCURSES_WACS('.') /* arrow down */ +#define WACS_UARROW NCURSES_WACS('-') /* arrow up */ +#define WACS_BOARD NCURSES_WACS('h') /* board of squares */ +#define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */ +#define WACS_BLOCK NCURSES_WACS('0') /* solid square block */ + + /* ncurses extensions */ +#define WACS_S3 NCURSES_WACS('p') /* scan line 3 */ +#define WACS_S7 NCURSES_WACS('r') /* scan line 7 */ +#define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */ +#define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */ +#define WACS_PI NCURSES_WACS('{') /* Pi */ +#define WACS_NEQUAL NCURSES_WACS('|') /* not equal */ +#define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */ + +/* + * Function prototypes for wide-character operations. + * + * "generated" comments should include ":WIDEC" to make the corresponding + * functions ifdef'd in lib_gen.c + * + * "implemented" comments do not need this marker. + */ + +extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */ +extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, short*, void*); /* implemented */ +extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */ +extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, short, const void *); /* implemented */ +extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ +extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ +extern NCURSES_EXPORT(int) vid_attr (attr_t, short, void *); /* implemented */ +extern NCURSES_EXPORT(int) vid_puts (attr_t, short, void *, int (*)(int)); /* implemented */ +extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ +extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */ +extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* implemented */ +extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */ +extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *,wint_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* implemented */ +extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */ + +#ifndef NCURSES_NOMACROS + +/* + * XSI curses macros for XPG4 conformance. + */ +#define add_wch(c) wadd_wch(stdscr,c) +#define add_wchnstr(str,n) wadd_wchnstr(stdscr,str,n) +#define add_wchstr(str) wadd_wchstr(stdscr,str) +#define addnwstr(wstr,n) waddnwstr(stdscr,wstr,n) +#define addwstr(wstr) waddwstr(stdscr,wstr) +#define bkgrnd(c) wbkgrnd(stdscr,c) +#define bkgrndset(c) wbkgrndset(stdscr,c) +#define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,l,r,t,b,tl,tr,bl,br) +#define box_set(w,v,h) wborder_set(w,v,v,h,h,0,0,0,0) +#define echo_wchar(c) wecho_wchar(stdscr,c) +#define get_wch(c) wget_wch(stdscr,c) +#define get_wstr(t) wget_wstr(stdscr,t) +#define getbkgrnd(wch) wgetbkgrnd(stdscr,wch) +#define getn_wstr(t,n) wgetn_wstr(stdscr,t,n) +#define hline_set(c,n) whline_set(stdscr,c,n) +#define in_wch(c) win_wch(stdscr,c) +#define in_wchnstr(c,n) win_wchnstr(stdscr,c,n) +#define in_wchstr(c) win_wchstr(stdscr,c) +#define innwstr(c,n) winnwstr(stdscr,c,n) +#define ins_nwstr(t,n) wins_nwstr(stdscr,t,n) +#define ins_wch(c) wins_wch(stdscr,c) +#define ins_wstr(t) wins_wstr(stdscr,t) +#define inwstr(c) winwstr(stdscr,c) +#define vline_set(c,n) wvline_set(stdscr,c,n) +#define wadd_wchstr(win,str) wadd_wchnstr(win,str,-1) +#define waddwstr(win,wstr) waddnwstr(win,wstr,-1) +#define wget_wstr(w,t) wgetn_wstr(w,t,-1) +#define win_wchstr(w,c) win_wchnstr(w,c,-1) +#define wins_wstr(w,t) wins_nwstr(w,t,-1) + +#if !NCURSES_OPAQUE +#define wgetbkgrnd(win,wch) (*wch = win->_bkgrnd, OK) +#endif + +#define mvadd_wch(y,x,c) mvwadd_wch(stdscr,y,x,c) +#define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,y,x,s,n) +#define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,y,x,s) +#define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,y,x,wstr,n) +#define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,y,x,wstr) +#define mvget_wch(y,x,c) mvwget_wch(stdscr,y,x,c) +#define mvget_wstr(y,x,t) mvwget_wstr(stdscr,y,x,t) +#define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,y,x,t,n) +#define mvhline_set(y,x,c,n) mvwhline_set(stdscr,y,x,c,n) +#define mvin_wch(y,x,c) mvwin_wch(stdscr,y,x,c) +#define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,y,x,c,n) +#define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,y,x,c) +#define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,y,x,c,n) +#define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,y,x,t,n) +#define mvins_wch(y,x,c) mvwins_wch(stdscr,y,x,c) +#define mvins_wstr(y,x,t) mvwins_wstr(stdscr,y,x,t) +#define mvinwstr(y,x,c) mvwinwstr(stdscr,y,x,c) +#define mvvline_set(y,x,c,n) mvwvline_set(stdscr,y,x,c,n) + +#define mvwadd_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wadd_wch(win,c)) +#define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,y,x) == ERR ? ERR : wadd_wchnstr(win,s,n)) +#define mvwadd_wchstr(win,y,x,s) (wmove(win,y,x) == ERR ? ERR : wadd_wchstr(win,s)) +#define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,y,x) == ERR ? ERR : waddnwstr(win,wstr,n)) +#define mvwaddwstr(win,y,x,wstr) (wmove(win,y,x) == ERR ? ERR : waddwstr(win,wstr)) +#define mvwget_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wget_wch(win,c)) +#define mvwget_wstr(win,y,x,t) (wmove(win,y,x) == ERR ? ERR : wget_wstr(win,t)) +#define mvwgetn_wstr(win,y,x,t,n) (wmove(win,y,x) == ERR ? ERR : wgetn_wstr(win,t,n)) +#define mvwhline_set(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : whline_set(win,c,n)) +#define mvwin_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : win_wch(win,c)) +#define mvwin_wchnstr(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : win_wchnstr(win,c,n)) +#define mvwin_wchstr(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : win_wchstr(win,c)) +#define mvwinnwstr(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : winnwstr(win,c,n)) +#define mvwins_nwstr(win,y,x,t,n) (wmove(win,y,x) == ERR ? ERR : wins_nwstr(win,t,n)) +#define mvwins_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wins_wch(win,c)) +#define mvwins_wstr(win,y,x,t) (wmove(win,y,x) == ERR ? ERR : wins_wstr(win,t)) +#define mvwinwstr(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winwstr(win,c)) +#define mvwvline_set(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline_set(win,c,n)) + +#endif /* NCURSES_NOMACROS */ + +#if defined(TRACE) || defined(NCURSES_TEST) +extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *); +extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *); +#endif + +#endif /* _XOPEN_SOURCE_EXTENDED */ +/* $Id: curses.h,v 1.61 2010/09/06 17:26:17 nicm Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in diff --git a/lib/libcurses/curses.priv.h b/lib/libcurses/curses.priv.h index 1b63370a674..334bbe0cf37 100644 --- a/lib/libcurses/curses.priv.h +++ b/lib/libcurses/curses.priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.priv.h,v 1.33 2010/01/12 23:21:59 nicm Exp $ */ +/* $OpenBSD: curses.priv.h,v 1.34 2010/09/06 17:26:17 nicm Exp $ */ /**************************************************************************** * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * @@ -36,7 +36,7 @@ /* - * $Id: curses.priv.h,v 1.33 2010/01/12 23:21:59 nicm Exp $ + * $Id: curses.priv.h,v 1.34 2010/09/06 17:26:17 nicm Exp $ * * curses.priv.h * @@ -262,6 +262,7 @@ color_t; #if USE_WIDEC_SUPPORT #define _nc_bkgd _bkgrnd +#define _XOPEN_SOURCE_EXTENDED 1 #else #undef _XOPEN_SOURCE_EXTENDED #define _nc_bkgd _bkgd diff --git a/lib/libcurses/ncurses_cfg.h b/lib/libcurses/ncurses_cfg.h index 24a1212830b..9677aaf1ce1 100644 --- a/lib/libcurses/ncurses_cfg.h +++ b/lib/libcurses/ncurses_cfg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ncurses_cfg.h,v 1.24 2010/01/12 23:21:59 nicm Exp $ */ +/* $OpenBSD: ncurses_cfg.h,v 1.25 2010/09/06 17:26:17 nicm Exp $ */ /* include/ncurses_cfg.h. Generated automatically by configure. */ /**************************************************************************** @@ -33,7 +33,7 @@ * Author: Thomas E. Dickey <dickey@clark.net> 1997 * ****************************************************************************/ /* - * $Id: ncurses_cfg.h,v 1.24 2010/01/12 23:21:59 nicm Exp $ + * $Id: ncurses_cfg.h,v 1.25 2010/09/06 17:26:17 nicm Exp $ * * This is a template-file used to generate the "ncurses_cfg.h" file. * @@ -58,6 +58,7 @@ #define GCC_UNUSED __attribute__((__unused__)) #define HAVE_BIG_CORE 1 #define HAVE_BSD_CGETENT 1 +#define HAVE_BTOWC 1 #define HAVE_CURSES_VERSION 1 #define HAVE_DIRENT_H 1 #define HAVE_ERRNO 1 @@ -80,6 +81,12 @@ #define HAVE_LINK 1 #define HAVE_LOCALE_H 1 #define HAVE_LONG_FILE_NAMES 1 +#define HAVE_MBLEN 1 +#define HAVE_MBRLEN 1 +#define HAVE_MBRTOWC 1 +#define HAVE_MBSRTOWCS 1 +#define HAVE_MBSTOWCS 1 +#define HAVE_MBTOWC 1 #define HAVE_MEMORY_H 1 #define HAVE_MENU_H 1 #define HAVE_MKSTEMP 1 @@ -88,6 +95,7 @@ #define HAVE_PANEL_H 1 #define HAVE_POLL 1 #define HAVE_POLL_H 1 +#define HAVE_PUTWC 1 #define HAVE_REGEX_H_FUNCS 1 #define HAVE_REMOVE 1 #define HAVE_REMOVE 1 @@ -130,6 +138,10 @@ #define HAVE_USE_DEFAULT_COLORS 1 #define HAVE_VSNPRINTF 1 #define HAVE_VSSCANF 1 +#define HAVE_WCSRTOMBS 1 +#define HAVE_WCSTOMBS 1 +#define HAVE_WCTOB 1 +#define HAVE_WCTOMB 1 #define HAVE_WCTYPE_H 1 #define HAVE_WORKING_POLL 1 #define HAVE_WRESIZE 1 @@ -140,6 +152,7 @@ #define NCURSES_PATHSEP ':' #define NCURSES_VERSION_STRING "5.7.20081102" #define NDEBUG 1 +#define NEED_WCHAR_H 1 #define PURE_TERMINFO 0 #define RETSIGTYPE void #define SIG_ATOMIC_T volatile sig_atomic_t @@ -152,12 +165,13 @@ #define TYPEOF_CHTYPE long #define USE_ASSUMED_COLOR 1 #define USE_DATABASE 1 -#define USE_GETCAP 1 +#define USE_GETCAP 1 #define USE_HASHMAP 1 #define USE_HOME_TERMINFO 1 #define USE_LINKS 1 #define USE_OPENPTY_HEADER <util.h> #define USE_ROOT_ENVIRON 1 +#define USE_WIDEC_SUPPORT 1 #define USE_XTERM_PTY 1 /* #define HAVE_LIBFORM 1 */ /* #define HAVE_LIBMENU 1 */ diff --git a/lib/libcurses/shlib_version b/lib/libcurses/shlib_version index f461c533903..56246d02b24 100644 --- a/lib/libcurses/shlib_version +++ b/lib/libcurses/shlib_version @@ -1,2 +1,2 @@ -major=11 +major=12 minor=0 diff --git a/lib/libcurses/widechar/charable.c b/lib/libcurses/widechar/charable.c new file mode 100644 index 00000000000..1654c7ef1e4 --- /dev/null +++ b/lib/libcurses/widechar/charable.c @@ -0,0 +1,82 @@ +/* $OpenBSD: charable.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2003-2005,2008 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "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. * + ****************************************************************************/ + +/* +** Support functions for wide/narrow conversion. +*/ + +#include <curses.priv.h> + +MODULE_ID("$Id: charable.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch) +{ + bool result; +#if HAVE_WCTOB + result = (wctob((wint_t) ch) == (int) ch); +#else + result = (_nc_to_char(ch) >= 0); +#endif + return result; +} + +NCURSES_EXPORT(int) _nc_to_char(wint_t ch) +{ + int result; +#if HAVE_WCTOB + result = wctob(ch); +#elif HAVE_WCTOMB + char temp[MB_LEN_MAX]; + result = wctomb(temp, ch); + if (strlen(temp) == 1) + result = UChar(temp[0]); + else + result = -1; +#endif + return result; +} + +NCURSES_EXPORT(wint_t) _nc_to_widechar(int ch) +{ + wint_t result; +#if HAVE_BTOWC + result = btowc(ch); +#elif HAVE_MBTOWC + wchar_t convert; + char temp[2]; + temp[0] = ch; + temp[1] = '\0'; + if (mbtowc(&convert, temp, 1) >= 0) + result = convert; + else + result = WEOF; +#endif + return result; +} diff --git a/lib/libcurses/widechar/lib_add_wch.c b/lib/libcurses/widechar/lib_add_wch.c new file mode 100644 index 00000000000..1d75bf62eb6 --- /dev/null +++ b/lib/libcurses/widechar/lib_add_wch.c @@ -0,0 +1,115 @@ +/* $OpenBSD: lib_add_wch.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2004,2006 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_add_wch.c +** +** The routine wadd_wch(). +** +*/ + +#include <curses.priv.h> + +MODULE_ID("$Id: lib_add_wch.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +NCURSES_EXPORT(int) +wadd_wch(WINDOW *win, const cchar_t *wch) +{ + PUTC_DATA; + int n; + int code = ERR; + + 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; + } + for (n = 0; n < PUTC_n; n++) { + if ((code = waddch(win, UChar(PUTC_buf[n]) | attrs)) == ERR) { + break; + } + } + if (code == ERR) + break; + } + } + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} + +NCURSES_EXPORT(int) +wecho_wchar(WINDOW *win, const cchar_t *wch) +{ + PUTC_DATA; + int n; + int code = ERR; + + 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; + } + for (n = 0; n < PUTC_n; n++) { + if ((code = waddch(win, UChar(PUTC_buf[n]) | attrs)) == ERR) { + break; + } + } + if (code == ERR) + break; + } + wrefresh(win); + } + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} diff --git a/lib/libcurses/widechar/lib_box_set.c b/lib/libcurses/widechar/lib_box_set.c new file mode 100644 index 00000000000..869ac22a3e3 --- /dev/null +++ b/lib/libcurses/widechar/lib_box_set.c @@ -0,0 +1,115 @@ +/* $OpenBSD: lib_box_set.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * 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.1 2010/09/06 17:26:17 nicm 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 = _nc_render(win, (ch == 0) ? *(const ARG_CH_T)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/lib/libcurses/widechar/lib_cchar.c b/lib/libcurses/widechar/lib_cchar.c new file mode 100644 index 00000000000..778c7b53b15 --- /dev/null +++ b/lib/libcurses/widechar/lib_cchar.c @@ -0,0 +1,131 @@ +/* $OpenBSD: lib_cchar.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2001-2005,2007 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.1 2010/09/06 17:26:17 nicm Exp $") + +/* + * The SuSv2 description leaves some room for interpretation. We'll assume wch + * points to a string which is L'\0' terminated, contains at least 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,%lu,%d,%p)"), + wcval, _nc_viswbuf(wch), + (unsigned long) attrs, color_pair, opts)); + + len = wcslen(wch); + if (opts != NULL + || (len > 1 && wcwidth(wch[0]) < 0)) { + code = ERR; + } else { + if (len > CCHARW_MAX) + len = CCHARW_MAX; + + /* + * If we have a following spacing-character, stop at that point. We + * are only interested in adding non-spacing characters. + */ + for (i = 1; i < len; ++i) { + if (wcwidth(wch[i]) != 0) { + len = i; + break; + } + } + + memset(wcval, 0, sizeof(*wcval)); + + if (len != 0) { + SetAttr(*wcval, attrs | COLOR_PAIR(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, + _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 (attrs == 0 || color_pair == 0) { + code = ERR; + } else if (len >= 0) { + *attrs = AttrOf(*wcval) & A_ATTRIBUTES; + *color_pair = GetPair(*wcval); + wmemcpy(wch, wcval->chars, (unsigned) len); + wch[len] = L'\0'; + code = OK; + } + } + + TR(TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} diff --git a/lib/libcurses/widechar/lib_erasewchar.c b/lib/libcurses/widechar/lib_erasewchar.c new file mode 100644 index 00000000000..c6bcb8e16f0 --- /dev/null +++ b/lib/libcurses/widechar/lib_erasewchar.c @@ -0,0 +1,79 @@ +/* $OpenBSD: lib_erasewchar.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * 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 2010/09/06 17:26:17 nicm 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/lib/libcurses/widechar/lib_get_wch.c b/lib/libcurses/widechar/lib_get_wch.c new file mode 100644 index 00000000000..c9c0fb4238d --- /dev/null +++ b/lib/libcurses/widechar/lib_get_wch.c @@ -0,0 +1,130 @@ +/* $OpenBSD: lib_get_wch.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), 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-on * + ****************************************************************************/ + +/* +** lib_get_wch.c +** +** The routine get_wch(). +** +*/ + +#include <curses.priv.h> +#include <ctype.h> + +MODULE_ID("$Id: lib_get_wch.c,v 1.1 2010/09/06 17:26:17 nicm 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 + +NCURSES_EXPORT(int) +wget_wch(WINDOW *win, wint_t *result) +{ + SCREEN *sp; + int code; + char buffer[(MB_LEN_MAX * 9) + 1]; /* allow some redundant shifts */ + int status; + size_t count = 0; + unsigned long value; + wchar_t wch; +#ifndef state_unused + mbstate_t state; +#endif + + 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. + */ + _nc_lock_global(curses); + sp = _nc_screen_of(win); + if (sp != 0) { + for (;;) { + T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer))); + code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist + *) 0)); + 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) { + _nc_ungetch(sp, (int) value); + code = ERR; + } + break; + } else if (count + 1 >= sizeof(buffer)) { + _nc_ungetch(sp, (int) value); + code = ERR; + break; + } else { + buffer[count++] = (char) UChar(value); + reset_mbytes(state); + status = count_mbytes(buffer, count, state); + if (status >= 0) { + reset_mbytes(state); + if (check_mbytes(wch, buffer, count, state) != status) { + code = ERR; /* the two calls should match */ + _nc_ungetch(sp, (int) value); + } + value = wch; + break; + } + } + } + } else { + code = ERR; + } + *result = value; + _nc_unlock_global(curses); + T(("result %#lo", value)); + returnCode(code); +} diff --git a/lib/libcurses/widechar/lib_get_wstr.c b/lib/libcurses/widechar/lib_get_wstr.c new file mode 100644 index 00000000000..0ad01d318d7 --- /dev/null +++ b/lib/libcurses/widechar/lib_get_wstr.c @@ -0,0 +1,234 @@ +/* $OpenBSD: lib_get_wstr.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002-2004,2008 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), 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 * + ****************************************************************************/ + +/* +** lib_get_wstr.c +** +** The routine wgetn_wstr(). +** +*/ + +#include <curses.priv.h> +#include <term.h> + +MODULE_ID("$Id: lib_get_wstr.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +static int +wadd_wint(WINDOW *win, wint_t *src) +{ + cchar_t tmp; + wchar_t wch[2]; + + wch[0] = (wchar_t) (*src); + wch[1] = 0; + setcchar(&tmp, wch, A_NORMAL, 0, NULL); + return wadd_wch(win, &tmp); +} + +/* + * This wipes out the last character, no matter whether it was a tab, control + * or other character, and handles reverse wraparound. + */ +static wint_t * +WipeOut(WINDOW *win, int y, int x, wint_t *first, wint_t *last, bool echoed) +{ + if (last > first) { + *--last = '\0'; + if (echoed) { + int y1 = win->_cury; + int x1 = win->_curx; + int n; + + wmove(win, y, x); + for (n = 0; first[n] != 0; ++n) { + wadd_wint(win, first + n); + } + 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) +{ + SCREEN *sp = _nc_screen_of(win); + TTY buf; + bool oldnl, oldecho, oldraw, oldcbreak; + wint_t erasec; + wint_t killc; + wint_t *oldstr = str; + wint_t *tmpstr = str; + 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 = (wint_t) erasechar(); + killc = (wint_t) killchar(); + + getyx(win, y, x); + + if (is_wintouched(win) || (win->_flags & _HASMOVED)) + wrefresh(win); + + while ((code = wget_wch(win, &ch)) != ERR) { + /* + * Map special characters into key-codes. + */ + if (ch == '\r') + ch = '\n'; + if (ch == '\n') { + code = KEY_CODE_YES; + ch = KEY_ENTER; + } + if (ch < KEY_MIN) { + if (ch == erasec) { + ch = KEY_BACKSPACE; + code = KEY_CODE_YES; + } + if (ch == killc) { + ch = KEY_EOL; + code = KEY_CODE_YES; + } + } + 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 == KEY_DOWN || ch == KEY_ENTER) { + if (oldecho == TRUE + && win->_cury == win->_maxy + && win->_scroll) + wechochar(win, (chtype) '\n'); + break; + } + if (ch == KEY_LEFT || ch == KEY_BACKSPACE) { + if (tmpstr > oldstr) { + tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho); + } + } else if (ch == KEY_EOL) { + while (tmpstr > oldstr) { + tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho); + } + } else { + beep(); + } + } else if (maxlen >= 0 && tmpstr - oldstr >= maxlen) { + beep(); + } else { + *tmpstr++ = ch; + *tmpstr = 0; + if (oldecho == TRUE) { + int oldy = win->_cury; + + if (wadd_wint(win, tmpstr - 1) == 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; + + (void) _nc_set_tty_mode(&buf); + + *tmpstr = 0; + if (code == ERR) { + if (tmpstr == oldstr) { + *tmpstr++ = WEOF; + *tmpstr = 0; + } + returnCode(ERR); + } + + T(("wgetn_wstr returns %s", _nc_viswibuf(oldstr))); + + returnCode(OK); +} diff --git a/lib/libcurses/widechar/lib_hline_set.c b/lib/libcurses/widechar/lib_hline_set.c new file mode 100644 index 00000000000..4f5b90fb1ca --- /dev/null +++ b/lib/libcurses/widechar/lib_hline_set.c @@ -0,0 +1,81 @@ +/* $OpenBSD: lib_hline_set.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * 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.1 2010/09/06 17:26:17 nicm 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/lib/libcurses/widechar/lib_in_wch.c b/lib/libcurses/widechar/lib_in_wch.c new file mode 100644 index 00000000000..811dfe4b209 --- /dev/null +++ b/lib/libcurses/widechar/lib_in_wch.c @@ -0,0 +1,64 @@ +/* $OpenBSD: lib_in_wch.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002-2004,2006 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 * + ****************************************************************************/ + +/* +** lib_in_wch.c +** +** The routine win_wch(). +** +*/ + +#include <curses.priv.h> + +MODULE_ID("$Id: lib_in_wch.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +NCURSES_EXPORT(int) +win_wch(WINDOW *win, 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]; + TR(TRACE_CCALLS, ("data %s", _tracecchar_t(wcval))); + } else { + code = ERR; + } + TR(TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} diff --git a/lib/libcurses/widechar/lib_in_wchnstr.c b/lib/libcurses/widechar/lib_in_wchnstr.c new file mode 100644 index 00000000000..d70ea5ffe52 --- /dev/null +++ b/lib/libcurses/widechar/lib_in_wchnstr.c @@ -0,0 +1,78 @@ +/* $OpenBSD: lib_in_wchnstr.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002-2004-2007 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 * + ****************************************************************************/ + +/* +** lib_in_wchnstr.c +** +** The routine win_wchnstr(). +** +*/ + +#include <curses.priv.h> + +MODULE_ID("$Id: lib_in_wchnstr.c,v 1.1 2010/09/06 17:26:17 nicm 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)); + if (win != 0 + && wchstr != 0) { + NCURSES_CH_T *src; + int row, col; + int j, k, limit; + + getyx(win, row, col); + limit = getmaxx(win) - col; + src = &(win->_line[row].text[col]); + + if (n < 0) { + n = limit; + } else if (n > limit) { + n = limit; + } + for (j = k = 0; j < n; ++j) { + if (j == 0 || !WidecExt(src[j]) || isWidecBase(src[j])) { + wchstr[k++] = src[j]; + } + } + memset(&(wchstr[k]), 0, sizeof(*wchstr)); + T(("result = %s", _nc_viscbuf(wchstr, n))); + } else { + code = ERR; + } + returnCode(code); +} diff --git a/lib/libcurses/widechar/lib_ins_wch.c b/lib/libcurses/widechar/lib_ins_wch.c new file mode 100644 index 00000000000..28b39d82fcf --- /dev/null +++ b/lib/libcurses/widechar/lib_ins_wch.c @@ -0,0 +1,146 @@ +/* $OpenBSD: lib_ins_wch.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002-2003,2005 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 2010/09/06 17:26:17 nicm Exp $") + +/* + * Insert the given character, updating the current location to simplify + * inserting a string. + */ +static int +_nc_insert_wch(WINDOW *win, const cchar_t *wch) +{ + int cells = wcwidth(CharOf(CHDEREF(wch))); + int 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++; + } + return OK; +} + +NCURSES_EXPORT(int) +wins_wch(WINDOW *win, const cchar_t *wch) +{ + NCURSES_SIZE_T oy; + NCURSES_SIZE_T ox; + int code = ERR; + + T((T_CALLED("wins_wch(%p, %s)"), win, _tracecchar_t(wch))); + + if (win != 0) { + oy = win->_cury; + ox = win->_curx; + + code = _nc_insert_wch(win, wch); + + win->_curx = ox; + win->_cury = oy; + _nc_synchook(win); + } + returnCode(code); +} + +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_viswbufn(wstr, n), n)); + + if (win != 0 + && wstr != 0) { + if (n < 1) + n = wcslen(wstr); + code = OK; + if (n > 0) { + oy = win->_cury; + ox = win->_curx; + for (cp = wstr; *cp && ((cp - wstr) < n); cp++) { + int len = wcwidth(*cp); + + if (len != 1 || !is8bits(*cp)) { + cchar_t tmp_cchar; + wchar_t tmp_wchar = *cp; + memset(&tmp_cchar, 0, sizeof(tmp_cchar)); + (void) setcchar(&tmp_cchar, + &tmp_wchar, + WA_NORMAL, + 0, + (void *) 0); + code = _nc_insert_wch(win, &tmp_cchar); + } else { + /* tabs, other ASCII stuff */ + code = _nc_insert_ch(win, (chtype) (*cp)); + } + if (code != OK) + break; + } + + win->_curx = ox; + win->_cury = oy; + _nc_synchook(win); + } + } + returnCode(code); +} diff --git a/lib/libcurses/widechar/lib_inwstr.c b/lib/libcurses/widechar/lib_inwstr.c new file mode 100644 index 00000000000..0dd27d77cf8 --- /dev/null +++ b/lib/libcurses/widechar/lib_inwstr.c @@ -0,0 +1,102 @@ +/* $OpenBSD: lib_inwstr.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002,2004 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 * + ****************************************************************************/ + +/* +** lib_inwstr.c +** +** The routines winnwstr() and winwstr(). +** +*/ + +#include <curses.priv.h> + +MODULE_ID("$Id: lib_inwstr.c,v 1.1 2010/09/06 17:26:17 nicm 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; + + T((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) { + if (!isWidecExt(text[col])) { + 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 store nothing */ + } + break; + } + wstr[count++] = wch; + } + } + last = count; + if (++col > win->_maxx) { + break; + } + } + } + if (count > 0) { + wstr[count] = '\0'; + T(("winnwstr returns %s", _nc_viswbuf(wstr))); + } + } + 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; + T((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/lib/libcurses/widechar/lib_key_name.c b/lib/libcurses/widechar/lib_key_name.c new file mode 100644 index 00000000000..8c511f2c1d7 --- /dev/null +++ b/lib/libcurses/widechar/lib_key_name.c @@ -0,0 +1,64 @@ +/* $OpenBSD: lib_key_name.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2007 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_key_name.c +** +** The routine key_name(). +** +*/ + +#include <curses.priv.h> + +MODULE_ID("$Id: lib_key_name.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +NCURSES_EXPORT(NCURSES_CONST char *) +key_name(wchar_t c) +{ + cchar_t my_cchar; + wchar_t *my_wchars; + size_t len; + + /* FIXME: move to _nc_globals */ + static char result[MB_LEN_MAX + 1]; + + memset(&my_cchar, 0, sizeof(my_cchar)); + my_cchar.chars[0] = c; + my_cchar.chars[1] = L'\0'; + + my_wchars = wunctrl(&my_cchar); + len = wcstombs(result, my_wchars, sizeof(result) - 1); + if (isEILSEQ(len) || (len == 0)) { + return 0; + } + + result[len] = '\0'; + return result; +} diff --git a/lib/libcurses/widechar/lib_pecho_wchar.c b/lib/libcurses/widechar/lib_pecho_wchar.c new file mode 100644 index 00000000000..867fd5065cc --- /dev/null +++ b/lib/libcurses/widechar/lib_pecho_wchar.c @@ -0,0 +1,59 @@ +/* $OpenBSD: lib_pecho_wchar.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2004 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 * + ****************************************************************************/ + +#include <curses.priv.h> + +MODULE_ID("$Id: lib_pecho_wchar.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +NCURSES_EXPORT(int) +pecho_wchar(WINDOW *pad, const cchar_t * wch) +{ + T((T_CALLED("pecho_wchar(%p, %s)"), pad, _tracech_t(wch))); + + if (pad == 0) + returnCode(ERR); + + if (!(pad->_flags & _ISPAD)) + returnCode(wecho_wchar(pad, wch)); + + wadd_wch(pad, wch); + prefresh(pad, pad->_pad._pad_y, + pad->_pad._pad_x, + pad->_pad._pad_top, + pad->_pad._pad_left, + pad->_pad._pad_bottom, + pad->_pad._pad_right); + + returnCode(OK); +} diff --git a/lib/libcurses/widechar/lib_slk_wset.c b/lib/libcurses/widechar/lib_slk_wset.c new file mode 100644 index 00000000000..84cb0ff4a60 --- /dev/null +++ b/lib/libcurses/widechar/lib_slk_wset.c @@ -0,0 +1,74 @@ +/* $OpenBSD: lib_slk_wset.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2003-2004,2005 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 * + ****************************************************************************/ + +/* + * lib_slk_wset.c + * Set soft label text. + */ +#include <curses.priv.h> + +#if HAVE_WCTYPE_H +#include <wctype.h> +#endif + +MODULE_ID("$Id: lib_slk_wset.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +NCURSES_EXPORT(int) +slk_wset(int i, const wchar_t *astr, int format) +{ + int result = ERR; + size_t arglen; + const wchar_t *str; + char *mystr; + mbstate_t state; + + T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format)); + + init_mb(state); + str = astr; + if ((arglen = wcsrtombs(NULL, &str, 0, &state)) != (size_t) -1) { + if ((mystr = (char *) _nc_doalloc(0, arglen + 1)) != 0) { + str = astr; + if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) { + /* glibc documentation claims that the terminating L'\0' + * is written, but it is not... + */ + mystr[arglen] = 0; + result = slk_set(i, mystr, format); + } + free(mystr); + } + } + returnCode(result); +} diff --git a/lib/libcurses/widechar/lib_unget_wch.c b/lib/libcurses/widechar/lib_unget_wch.c new file mode 100644 index 00000000000..c1db3e91a62 --- /dev/null +++ b/lib/libcurses/widechar/lib_unget_wch.c @@ -0,0 +1,105 @@ +/* $OpenBSD: lib_unget_wch.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), 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.1 2010/09/06 17:26:17 nicm Exp $") + +/* + * Wrapper for wcrtomb() which obtains the length needed for the given + * wide-character 'source'. + */ +NCURSES_EXPORT(size_t) +_nc_wcrtomb(char *target, wchar_t source, mbstate_t * state) +{ + int result; + + if (target == 0) { + wchar_t temp[2]; + const wchar_t *tempp = temp; + temp[0] = source; + temp[1] = 0; + result = wcsrtombs(NULL, &tempp, 0, state); + } else { + result = wcrtomb(target, source, state); + } + if (!isEILSEQ(result) && (result == 0)) + result = 1; + return result; +} + +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(%#lx)"), (unsigned long) wch)); + + init_mb(state); + length = _nc_wcrtomb(0, wch, &state); + + if (length != (size_t) (-1) + && length != 0) { + char *string; + + if ((string = (char *) malloc(length)) != 0) { + init_mb(state); + wcrtomb(string, wch, &state); + + for (n = (int) (length - 1); n >= 0; --n) { + if (_nc_ungetch(SP, string[n]) != OK) { + result = ERR; + break; + } + } + free(string); + } else { + result = ERR; + } + } else { + result = ERR; + } + + returnCode(result); +} diff --git a/lib/libcurses/widechar/lib_vid_attr.c b/lib/libcurses/widechar/lib_vid_attr.c new file mode 100644 index 00000000000..b5f3131cfad --- /dev/null +++ b/lib/libcurses/widechar/lib_vid_attr.c @@ -0,0 +1,277 @@ +/* $OpenBSD: lib_vid_attr.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002-2006,2007 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 * + ****************************************************************************/ + +#include <curses.priv.h> +#include <term.h> + +MODULE_ID("$Id: lib_vid_attr.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc) + +#define TurnOn(mask,mode) \ + if ((turn_on & mask) && mode) { doPut(mode); } + +#define TurnOff(mask,mode) \ + if ((turn_off & mask) && mode) { doPut(mode); turn_off &= ~mask; } + + /* if there is no current screen, assume we *can* do color */ +#define SetColorsIf(why, old_attr, old_pair) \ + if (can_color && (why)) { \ + TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \ + if ((pair != old_pair) \ + || (fix_pair0 && (pair == 0)) \ + || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \ + _nc_do_color(old_pair, pair, reverse, outc); \ + } \ + } + +#define set_color(mode, pair) mode &= ALL_BUT_COLOR; mode |= COLOR_PAIR(pair) + +NCURSES_EXPORT(int) +vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int)) +{ +#if NCURSES_EXT_COLORS + static attr_t previous_attr = A_NORMAL; + static int previous_pair = 0; + + attr_t turn_on, turn_off; + bool reverse = FALSE; + bool can_color = (SP == 0 || SP->_coloron); +#if NCURSES_EXT_FUNCS + bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color); +#else +#define fix_pair0 FALSE +#endif + + newmode &= A_ATTRIBUTES; + 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)); + } + + TR(TRACE_ATTRS, ("previous attribute was %s, %d", + _traceattr(previous_attr), previous_pair)); + +#if !USE_XMC_SUPPORT + if ((SP != 0) + && (magic_cookie_glitch > 0)) + newmode &= ~(SP->_xmc_suppress); +#endif + + /* + * If we have a terminal that cannot combine color with video + * attributes, use the colors in preference. + */ + if ((pair != 0 + || fix_pair0) + && (no_color_video > 0)) { + /* + * If we had chosen the A_xxx definitions to correspond to the + * no_color_video mask, we could simply shift it up and mask off the + * attributes. But we did not (actually copied Solaris' definitions). + * However, this is still simpler/faster than a lookup table. + * + * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK, + * A_DIM, A_BOLD which are 1:1 with no_color_video. The bits that + * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and + * A_ALTCHARSET (256) down 2 to line up. We use the NCURSES_BITS + * macro so this will work properly for the wide-character layout. + */ + unsigned value = no_color_video; + attr_t mask = NCURSES_BITS((value & 63) + | ((value & 192) << 1) + | ((value & 256) >> 2), 8); + + if ((mask & A_REVERSE) != 0 + && (newmode & A_REVERSE) != 0) { + reverse = TRUE; + mask &= ~A_REVERSE; + } + newmode &= ~mask; + } + + if (newmode == previous_attr + && pair == previous_pair) + returnCode(OK); + + if (reverse) { + newmode &= ~A_REVERSE; + } + + turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR; + turn_on = (newmode & ~previous_attr) & ALL_BUT_COLOR; + + SetColorsIf(((pair == 0) && !fix_pair0), previous_attr, previous_pair); + + if (newmode == A_NORMAL) { + if ((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) { + doPut(exit_alt_charset_mode); + previous_attr &= ~A_ALTCHARSET; + } + if (previous_attr) { + if (exit_attribute_mode) { + doPut(exit_attribute_mode); + } else { + if (!SP || SP->_use_rmul) { + TurnOff(A_UNDERLINE, exit_underline_mode); + } + if (!SP || SP->_use_rmso) { + TurnOff(A_STANDOUT, exit_standout_mode); + } + } + previous_attr &= ALL_BUT_COLOR; + previous_pair = 0; + } + + SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair); + } 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); + previous_attr &= ALL_BUT_COLOR; + previous_pair = 0; + } + SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair); + } else { + + TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off))); + + TurnOff(A_ALTCHARSET, exit_alt_charset_mode); + + if (!SP || SP->_use_rmul) { + TurnOff(A_UNDERLINE, exit_underline_mode); + } + + if (!SP || SP->_use_rmso) { + TurnOff(A_STANDOUT, exit_standout_mode); + } + + if (turn_off && exit_attribute_mode) { + doPut(exit_attribute_mode); + turn_on |= (newmode & ALL_BUT_COLOR); + previous_attr &= ALL_BUT_COLOR; + previous_pair = 0; + } + SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair); + + TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on))); + /* *INDENT-OFF* */ + TurnOn(A_ALTCHARSET, enter_alt_charset_mode); + TurnOn(A_BLINK, enter_blink_mode); + TurnOn(A_BOLD, enter_bold_mode); + TurnOn(A_DIM, enter_dim_mode); + TurnOn(A_REVERSE, enter_reverse_mode); + TurnOn(A_STANDOUT, enter_standout_mode); + TurnOn(A_PROTECT, enter_protected_mode); + TurnOn(A_INVIS, enter_secure_mode); + TurnOn(A_UNDERLINE, enter_underline_mode); +#if USE_WIDEC_SUPPORT + TurnOn(A_HORIZONTAL, enter_horizontal_hl_mode); + TurnOn(A_LEFT, enter_left_hl_mode); + TurnOn(A_LOW, enter_low_hl_mode); + TurnOn(A_RIGHT, enter_right_hl_mode); + TurnOn(A_TOP, enter_top_hl_mode); + TurnOn(A_VERTICAL, enter_vertical_hl_mode); +#endif + /* *INDENT-ON* */ + + } + + if (reverse) + newmode |= A_REVERSE; + + if (SP) { + SetAttr(SCREEN_ATTRS(SP), newmode); + SetPair(SCREEN_ATTRS(SP), pair); + } else { + previous_attr = newmode; + previous_pair = pair; + } + + returnCode(OK); +#else + T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair)); + set_color(newmode, pair); + returnCode(vidputs(newmode, outc)); +#endif +} + +#undef vid_attr +NCURSES_EXPORT(int) +vid_attr(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)); +} + +/* + * 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) +{ + attr_t attrs; + + T((T_CALLED("term_attrs()"))); + attrs = termattrs(); + + /* these are only supported for wide-character mode */ + if (enter_horizontal_hl_mode) + attrs |= WA_HORIZONTAL; + if (enter_left_hl_mode) + attrs |= WA_LEFT; + if (enter_low_hl_mode) + attrs |= WA_LOW; + if (enter_right_hl_mode) + attrs |= WA_RIGHT; + if (enter_top_hl_mode) + attrs |= WA_TOP; + if (enter_vertical_hl_mode) + attrs |= WA_VERTICAL; + + returnAttr(attrs); +} diff --git a/lib/libcurses/widechar/lib_vline_set.c b/lib/libcurses/widechar/lib_vline_set.c new file mode 100644 index 00000000000..22e0974d303 --- /dev/null +++ b/lib/libcurses/widechar/lib_vline_set.c @@ -0,0 +1,80 @@ +/* $OpenBSD: lib_vline_set.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * 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.1 2010/09/06 17:26:17 nicm 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/lib/libcurses/widechar/lib_wacs.c b/lib/libcurses/widechar/lib_wacs.c new file mode 100644 index 00000000000..65653dac7e7 --- /dev/null +++ b/lib/libcurses/widechar/lib_wacs.c @@ -0,0 +1,119 @@ +/* $OpenBSD: lib_wacs.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2002,2006 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.1 2010/09/06 17:26:17 nicm Exp $") + +NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 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(); + + /* + * If we're running in a UTF-8 locale, will use the Unicode equivalents + * rather than the terminfo information. Actually the terminfo should + * be the rule, but there are people who are offended by the notion that + * a Unicode-capable terminal would have something resembling a mode. + * So the smacs/rmacs may be disabled -- sometime. + */ + T(("initializing WIDE-ACS map (Unicode is%s active)", + active ? "" : " not")); + + _nc_wacs = typeCalloc(cchar_t, ACS_LEN); + for (n = 0; n < SIZEOF(table); ++n) { + int wide = wcwidth(table[n].value[active]); + + m = table[n].map; + if (active && (wide == 1)) { + SetChar(_nc_wacs[m], table[n].value[active], A_NORMAL); + } else if (acs_map[m] & A_ALTCHARSET) { + SetChar(_nc_wacs[m], m, A_ALTCHARSET); + } else { + SetChar(_nc_wacs[m], table[n].value[0], A_NORMAL); + } + + T(("#%d, SetChar(%c, %#04x) = %s", + n, m, + table[n].value[active], + _tracecchar_t(&_nc_wacs[m]))); + } +} diff --git a/lib/libcurses/widechar/lib_wunctrl.c b/lib/libcurses/widechar/lib_wunctrl.c new file mode 100644 index 00000000000..0ea8dada860 --- /dev/null +++ b/lib/libcurses/widechar/lib_wunctrl.c @@ -0,0 +1,57 @@ +/* $OpenBSD: lib_wunctrl.c,v 1.1 2010/09/06 17:26:17 nicm Exp $ */ + +/**************************************************************************** + * Copyright (c) 2001-2005,2007 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> + +MODULE_ID("$Id: lib_wunctrl.c,v 1.1 2010/09/06 17:26:17 nicm Exp $") + +NCURSES_EXPORT(wchar_t *) +wunctrl(cchar_t *wc) +{ + static wchar_t str[CCHARW_MAX + 1], *sp; + + if (Charable(*wc)) { + const char *p = unctrl((unsigned) _nc_to_char((wint_t) CharOf(*wc))); + + for (sp = str; *p; ++p) { + *sp++ = _nc_to_widechar(*p); + } + *sp = 0; + return str; + } else + return wc->chars; +} diff --git a/lib/libform/Makefile b/lib/libform/Makefile index 8ce3ad75cfa..aff6219ef33 100644 --- a/lib/libform/Makefile +++ b/lib/libform/Makefile @@ -57,4 +57,16 @@ includes: ${INSTALL} ${INSTALL_COPY} -m 444 -o $(BINOWN) -g $(BINGRP) $$i \ ${DESTDIR}/usr/include; done +.include <bsd.own.mk> + +afterinstall: + -cd ${DESTDIR}${LIBDIR}; \ + for i in ${_LIBS}; do \ + ln -f $$i `echo $$i | sed 's/form/formw/'`; \ + done +.if (${DEBUGLIBS:L} == "yes") + -cd ${DESTDIR}${LIBDIR}/debug; \ + ln -f lib${LIB}.a lib`echo ${LIB} | sed 's/form/formw/'`.a +.endif + .include <bsd.lib.mk> diff --git a/lib/libform/shlib_version b/lib/libform/shlib_version index d9961ea9fef..3066b9771e7 100644 --- a/lib/libform/shlib_version +++ b/lib/libform/shlib_version @@ -1,2 +1,2 @@ -major=4 +major=5 minor=0 diff --git a/lib/libmenu/Makefile b/lib/libmenu/Makefile index fbf5facbe93..38b53d5463d 100644 --- a/lib/libmenu/Makefile +++ b/lib/libmenu/Makefile @@ -1,3 +1,5 @@ +# $OpenBSD: Makefile,v 1.13 2010/09/06 17:26:17 nicm Exp $ + LIB= menu WANTLINT= SRCS= m_attribs.c m_cursor.c m_driver.c m_format.c \ @@ -46,4 +48,16 @@ includes: ${INSTALL} ${INSTALL_COPY} -m 444 -o $(BINOWN) -g $(BINGRP) $$i \ ${DESTDIR}/usr/include; done +.include <bsd.own.mk> + +afterinstall: + -cd ${DESTDIR}${LIBDIR}; \ + for i in ${_LIBS}; do \ + ln -f $$i `echo $$i | sed 's/menu/menuw/'`; \ + done +.if (${DEBUGLIBS:L} == "yes") + -cd ${DESTDIR}${LIBDIR}/debug; \ + ln -f lib${LIB}.a lib`echo ${LIB} | sed 's/menu/menuw/'`.a +.endif + .include <bsd.lib.mk> diff --git a/lib/libmenu/shlib_version b/lib/libmenu/shlib_version index d9961ea9fef..3066b9771e7 100644 --- a/lib/libmenu/shlib_version +++ b/lib/libmenu/shlib_version @@ -1,2 +1,2 @@ -major=4 +major=5 minor=0 diff --git a/lib/libpanel/Makefile b/lib/libpanel/Makefile index 9e68ab42b9f..964c15002c3 100644 --- a/lib/libpanel/Makefile +++ b/lib/libpanel/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.8 2010/01/12 23:22:08 nicm Exp $ +# $OpenBSD: Makefile,v 1.9 2010/09/06 17:26:17 nicm Exp $ LIB= panel WANTLINT= @@ -20,4 +20,16 @@ includes: ${INSTALL} ${INSTALL_COPY} -m 444 -o $(BINOWN) -g $(BINGRP) $$i \ ${DESTDIR}/usr/include; done +.include <bsd.own.mk> + +afterinstall: + -cd ${DESTDIR}${LIBDIR}; \ + for i in ${_LIBS}; do \ + ln -f $$i `echo $$i | sed 's/panel/panelw/'`; \ + done +.if (${DEBUGLIBS:L} == "yes") + -cd ${DESTDIR}${LIBDIR}/debug; \ + ln -f lib${LIB}.a lib`echo ${LIB} | sed 's/panel/panelw/'`.a +.endif + .include <bsd.lib.mk> diff --git a/lib/libpanel/shlib_version b/lib/libpanel/shlib_version index d9961ea9fef..3066b9771e7 100644 --- a/lib/libpanel/shlib_version +++ b/lib/libpanel/shlib_version @@ -1,2 +1,2 @@ -major=4 +major=5 minor=0 |