Module Name: src Committed By: joerg Date: Mon Jul 6 15:19:49 UTC 2009
Modified Files: src/distrib/sets/lists/comp: mi src/lib/libcurses: Makefile curses.3 curses.h Added Files: src/lib/libcurses: chgat.c curses_chgat.3 Log Message: Add support for the chgat(3) family. It is a useful extension from ncurses, supporting it dramatically reduces the need for ncurses in pkgsrc. To generate a diff of this commit: cvs rdiff -u -r1.1275 -r1.1276 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.62 -r1.63 src/lib/libcurses/Makefile cvs rdiff -u -r0 -r1.1 src/lib/libcurses/chgat.c \ src/lib/libcurses/curses_chgat.3 cvs rdiff -u -r1.58 -r1.59 src/lib/libcurses/curses.3 cvs rdiff -u -r1.94 -r1.95 src/lib/libcurses/curses.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.1275 src/distrib/sets/lists/comp/mi:1.1276 --- src/distrib/sets/lists/comp/mi:1.1275 Fri Jun 26 19:36:21 2009 +++ src/distrib/sets/lists/comp/mi Mon Jul 6 15:19:49 2009 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1275 2009/06/26 19:36:21 jakllsch Exp $ +# $NetBSD: mi,v 1.1276 2009/07/06 15:19:49 joerg Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5010,6 +5010,7 @@ ./usr/share/man/cat3/cgetset.0 comp-c-catman .cat ./usr/share/man/cat3/cgetstr.0 comp-c-catman .cat ./usr/share/man/cat3/cgetustr.0 comp-c-catman .cat +./usr/share/man/cat3/chgat.0 comp-c-catman .cat ./usr/share/man/cat3/cimag.0 comp-c-catman .cat ./usr/share/man/cat3/cimagf.0 comp-c-catman .cat ./usr/share/man/cat3/circleq_empty.0 comp-obsolete obsolete @@ -5113,6 +5114,7 @@ ./usr/share/man/cat3/curses_attributes.0 comp-c-catman .cat ./usr/share/man/cat3/curses_background.0 comp-c-catman .cat ./usr/share/man/cat3/curses_border.0 comp-c-catman .cat +./usr/share/man/cat3/curses_chgat.0 comp-c-catman .cat ./usr/share/man/cat3/curses_clear.0 comp-c-catman .cat ./usr/share/man/cat3/curses_color.0 comp-c-catman .cat ./usr/share/man/cat3/curses_cursor.0 comp-c-catman .cat @@ -6754,6 +6756,7 @@ ./usr/share/man/cat3/mvaddchstr.0 comp-c-catman .cat ./usr/share/man/cat3/mvaddnstr.0 comp-c-catman .cat ./usr/share/man/cat3/mvaddstr.0 comp-c-catman .cat +./usr/share/man/cat3/mvchgat.0 comp-c-catman .cat ./usr/share/man/cat3/mvcur.0 comp-c-catman .cat ./usr/share/man/cat3/mvderwin.0 comp-c-catman .cat ./usr/share/man/cat3/mvgetch.0 comp-c-catman .cat @@ -6771,6 +6774,7 @@ ./usr/share/man/cat3/mvwaddchstr.0 comp-c-catman .cat ./usr/share/man/cat3/mvwaddnstr.0 comp-c-catman .cat ./usr/share/man/cat3/mvwaddstr.0 comp-c-catman .cat +./usr/share/man/cat3/mvwchgat.0 comp-c-catman .cat ./usr/share/man/cat3/mvwgetch.0 comp-c-catman .cat ./usr/share/man/cat3/mvwgetnstr.0 comp-c-catman .cat ./usr/share/man/cat3/mvwgetstr.0 comp-c-catman .cat @@ -7877,6 +7881,7 @@ ./usr/share/man/cat3/wbkgd.0 comp-c-catman .cat ./usr/share/man/cat3/wbkgdset.0 comp-c-catman .cat ./usr/share/man/cat3/wborder.0 comp-c-catman .cat +./usr/share/man/cat3/wchgat.0 comp-c-catman .cat ./usr/share/man/cat3/wclear.0 comp-c-catman .cat ./usr/share/man/cat3/wclrtobot.0 comp-c-catman .cat ./usr/share/man/cat3/wclrtoeol.0 comp-c-catman .cat @@ -10517,6 +10522,7 @@ ./usr/share/man/html3/cgetset.html comp-c-htmlman html ./usr/share/man/html3/cgetstr.html comp-c-htmlman html ./usr/share/man/html3/cgetustr.html comp-c-htmlman html +./usr/share/man/html3/chgat.html comp-c-htmlman html ./usr/share/man/html3/cimag.html comp-c-htmlman html ./usr/share/man/html3/cimagf.html comp-c-htmlman html ./usr/share/man/html3/clear.html comp-c-htmlman html @@ -10606,6 +10612,7 @@ ./usr/share/man/html3/curses_attributes.html comp-c-htmlman html ./usr/share/man/html3/curses_background.html comp-c-htmlman html ./usr/share/man/html3/curses_border.html comp-c-htmlman html +./usr/share/man/html3/curses_chgat.html comp-c-htmlman html ./usr/share/man/html3/curses_clear.html comp-c-htmlman html ./usr/share/man/html3/curses_color.html comp-c-htmlman html ./usr/share/man/html3/curses_cursor.html comp-c-htmlman html @@ -12206,6 +12213,7 @@ ./usr/share/man/html3/mvaddchstr.html comp-c-htmlman html ./usr/share/man/html3/mvaddnstr.html comp-c-htmlman html ./usr/share/man/html3/mvaddstr.html comp-c-htmlman html +./usr/share/man/html3/mvchgat.html comp-c-htmlman html ./usr/share/man/html3/mvcur.html comp-c-htmlman html ./usr/share/man/html3/mvderwin.html comp-c-htmlman html ./usr/share/man/html3/mvgetch.html comp-c-htmlman html @@ -12223,6 +12231,7 @@ ./usr/share/man/html3/mvwaddchstr.html comp-c-htmlman html ./usr/share/man/html3/mvwaddnstr.html comp-c-htmlman html ./usr/share/man/html3/mvwaddstr.html comp-c-htmlman html +./usr/share/man/html3/mvwchgat.html comp-c-htmlman html ./usr/share/man/html3/mvwgetch.html comp-c-htmlman html ./usr/share/man/html3/mvwgetnstr.html comp-c-htmlman html ./usr/share/man/html3/mvwgetstr.html comp-c-htmlman html @@ -13282,6 +13291,7 @@ ./usr/share/man/html3/wbkgd.html comp-c-htmlman html ./usr/share/man/html3/wbkgdset.html comp-c-htmlman html ./usr/share/man/html3/wborder.html comp-c-htmlman html +./usr/share/man/html3/wchgat.html comp-c-htmlman html ./usr/share/man/html3/wclear.html comp-c-htmlman html ./usr/share/man/html3/wclrtobot.html comp-c-htmlman html ./usr/share/man/html3/wclrtoeol.html comp-c-htmlman html @@ -15902,6 +15912,7 @@ ./usr/share/man/man3/cgetset.3 comp-c-man .man ./usr/share/man/man3/cgetstr.3 comp-c-man .man ./usr/share/man/man3/cgetustr.3 comp-c-man .man +./usr/share/man/man3/chgat.3 comp-c-man .man ./usr/share/man/man3/cimag.3 comp-c-man .man ./usr/share/man/man3/cimagf.3 comp-c-man .man ./usr/share/man/man3/circleq_empty.3 comp-obsolete obsolete @@ -16005,6 +16016,7 @@ ./usr/share/man/man3/curses_attributes.3 comp-c-man .man ./usr/share/man/man3/curses_background.3 comp-c-man .man ./usr/share/man/man3/curses_border.3 comp-c-man .man +./usr/share/man/man3/curses_chgat.3 comp-c-man .man ./usr/share/man/man3/curses_clear.3 comp-c-man .man ./usr/share/man/man3/curses_color.3 comp-c-man .man ./usr/share/man/man3/curses_cursor.3 comp-c-man .man @@ -17646,6 +17658,7 @@ ./usr/share/man/man3/mvaddchstr.3 comp-c-man .man ./usr/share/man/man3/mvaddnstr.3 comp-c-man .man ./usr/share/man/man3/mvaddstr.3 comp-c-man .man +./usr/share/man/man3/mvchgat.3 comp-c-man .man ./usr/share/man/man3/mvcur.3 comp-c-man .man ./usr/share/man/man3/mvderwin.3 comp-c-man .man ./usr/share/man/man3/mvgetch.3 comp-c-man .man @@ -17663,6 +17676,7 @@ ./usr/share/man/man3/mvwaddchstr.3 comp-c-man .man ./usr/share/man/man3/mvwaddnstr.3 comp-c-man .man ./usr/share/man/man3/mvwaddstr.3 comp-c-man .man +./usr/share/man/man3/mvwchgat.3 comp-c-man .man ./usr/share/man/man3/mvwgetch.3 comp-c-man .man ./usr/share/man/man3/mvwgetnstr.3 comp-c-man .man ./usr/share/man/man3/mvwgetstr.3 comp-c-man .man @@ -18765,6 +18779,7 @@ ./usr/share/man/man3/wbkgd.3 comp-c-man .man ./usr/share/man/man3/wbkgdset.3 comp-c-man .man ./usr/share/man/man3/wborder.3 comp-c-man .man +./usr/share/man/man3/wchgat.3 comp-c-man .man ./usr/share/man/man3/wclear.3 comp-c-man .man ./usr/share/man/man3/wclrtobot.3 comp-c-man .man ./usr/share/man/man3/wclrtoeol.3 comp-c-man .man Index: src/lib/libcurses/Makefile diff -u src/lib/libcurses/Makefile:1.62 src/lib/libcurses/Makefile:1.63 --- src/lib/libcurses/Makefile:1.62 Mon Apr 6 00:48:19 2009 +++ src/lib/libcurses/Makefile Mon Jul 6 15:19:49 2009 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.62 2009/04/06 00:48:19 christos Exp $ +# $NetBSD: Makefile,v 1.63 2009/07/06 15:19:49 joerg Exp $ # @(#)Makefile 8.2 (Berkeley) 1/2/94 .include <bsd.own.mk> @@ -14,8 +14,9 @@ .endif LIB= curses SRCS= acs.c addbytes.c addch.c addchnstr.c addnstr.c attributes.c \ - background.c bell.c border.c box.c clear.c clearok.c clrtobot.c \ - clrtoeol.c color.c copywin.c cr_put.c ctrace.c cur_hash.c curs_set.c \ + background.c bell.c border.c box.c chgat.c clear.c clearok.c \ + clrtobot.c clrtoeol.c color.c copywin.c cr_put.c \ + ctrace.c cur_hash.c curs_set.c \ curses.c delch.c deleteln.c delwin.c echochar.c erase.c fileio.c \ flushok.c fullname.c getch.c getstr.c getyx.c id_subwins.c idlok.c \ idcok.c inch.c inchstr.c initscr.c insch.c insdelln.c insertln.c \ @@ -27,7 +28,8 @@ MAN= curses.3 curses_addch.3 curses_addchstr.3 curses_addstr.3 \ curses_attributes.3 curses_background.3 curses_border.3 \ - curses_clear.3 curses_color.3 curses_cursor.3 curses_default_colors.3 \ + curses_chgat.3 curses_clear.3 curses_color.3 \ + curses_cursor.3 curses_default_colors.3 \ curses_delch.3 curses_deleteln.3 curses_echochar.3 curses_fileio.3 \ curses_inch.3 curses_input.3 curses_insertch.3 curses_insertln.3 \ curses_insdelln.3 curses_keyname.3 curses_line.3 curses_pad.3 \ @@ -60,6 +62,8 @@ curses_attributes.3 attrset.3 curses_tty.3 beep.3 \ curses_background.3 bkgd.3 curses_background.3 bkgdset.3 \ curses_border.3 border.3 curses_border.3 box.3 \ + curses_chgat.3 chgat.3 curses_chgat.3 mvchgat.3 \ + curses_chgat.3 mvwchgat.3 curses_chgat.3 wchgat.3 \ curses_color.3 can_change_color.3 curses_tty.3 cbreak.3 \ curses_clear.3 clear.3 curses_clear.3 clearok.3 \ curses_clear.3 clrtobot.3 curses_clear.3 clrtoeol.3 \ Index: src/lib/libcurses/curses.3 diff -u src/lib/libcurses/curses.3:1.58 src/lib/libcurses/curses.3:1.59 --- src/lib/libcurses/curses.3:1.58 Mon Feb 23 08:27:13 2009 +++ src/lib/libcurses/curses.3 Mon Jul 6 15:19:49 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses.3,v 1.58 2009/02/23 08:27:13 wiz Exp $ +.\" $NetBSD: curses.3,v 1.59 2009/07/06 15:19:49 joerg Exp $ .\" .\" Copyright (c) 1985, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -86,6 +86,7 @@ .It box Ta Xr curses_border 3 .It can_change_color Ta Xr curses_color 3 .It cbreak Ta Xr curses_tty 3 +.It chgat Ta Xr curses_chgat 3 .It clear Ta Xr curses_clear 3 .It clearok Ta Xr curses_clear 3 .It clrtobot Ta Xr curses_clear 3 @@ -165,6 +166,7 @@ .It mvaddchstr Ta Xr curses_addchstr 3 .It mvaddnstr Ta Xr curses_addstr 3 .It mvaddstr Ta Xr curses_addstr 3 +.It mvchgat Ta Xr curses_chgat 3 .It mvcur Ta Xr curses_cursor 3 .It mvderwin Ta Xr curses_window 3 .It mvgetnstr Ta Xr curses_input 3 @@ -180,6 +182,7 @@ .It mvwaddchstr Ta Xr curses_addchstr 3 .It mvwaddnstr Ta Xr curses_addstr 3 .It mvwaddstr Ta Xr curses_addstr 3 +.It mvwchgat Ta Xr curses_chgat 3 .It mvwgetnstr Ta Xr curses_input 3 .It mvwgetstr Ta Xr curses_input 3 .It mvwhline Ta Xr curses_line 3 @@ -255,6 +258,7 @@ .It wbkgd Ta Xr curses_background 3 .It wbkgdset Ta Xr curses_background 3 .It wborder Ta Xr curses_border 3 +.It wchgat Ta Xr curses_chgat 3 .It wclear Ta Xr curses_clear 3 .It wclrtobot Ta Xr curses_clear 3 .It wclrtoeol Ta Xr curses_clear 3 Index: src/lib/libcurses/curses.h diff -u src/lib/libcurses/curses.h:1.94 src/lib/libcurses/curses.h:1.95 --- src/lib/libcurses/curses.h:1.94 Wed Apr 1 20:59:15 2009 +++ src/lib/libcurses/curses.h Mon Jul 6 15:19:49 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: curses.h,v 1.94 2009/04/01 20:59:15 cube Exp $ */ +/* $NetBSD: curses.h,v 1.95 2009/07/06 15:19:49 joerg Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -805,6 +805,11 @@ int winsnstr(WINDOW *, const char *, int); int winsstr(WINDOW *, const char *); +int chgat(int, attr_t, short, const void *); +int wchgat(WINDOW *, int, attr_t, short, const void *); +int mvchgat(int, int, int, attr_t, short, const void *); +int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); + /* wide character support routines */ /* return ERR when HAVE_WCHAR is not defined */ /* add */ Added files: Index: src/lib/libcurses/chgat.c diff -u /dev/null src/lib/libcurses/chgat.c:1.1 --- /dev/null Mon Jul 6 15:19:50 2009 +++ src/lib/libcurses/chgat.c Mon Jul 6 15:19:49 2009 @@ -0,0 +1,98 @@ +/* $NetBSD: chgat.c,v 1.1 2009/07/06 15:19:49 joerg Exp $ */ + +/* + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__RCSID("$NetBSD: chgat.c,v 1.1 2009/07/06 15:19:49 joerg Exp $"); + +#include "curses.h" +#include "curses_private.h" + +int +chgat(int n, attr_t attr, short color, const void *opts) +{ + return wchgat(stdscr, n, attr, color, opts); +} + +int +mvchgat(int y, int x, int n, attr_t attr, short color, + const void *opts) +{ + return mvwchgat(stdscr, y, x, n, attr, color, opts); +} + +int +mvwchgat(WINDOW *win , int y, int x, int n, attr_t attr, short color, + const void *opts) +{ + if (wmove(win, y, x) == ERR) + return ERR; + + return wchgat(win, n, attr, color, opts); +} + +int +wchgat(WINDOW *win, int count, attr_t attr, short color, const void *opts) +{ + __LINE *lp; + __LDATA *lc; + int newx; + + attr = (attr & ~__COLOR) | COLOR_PAIR(color); + + if (count < 0 || count > win->maxx - win->curx) + count = win->maxx - win->curx; + + lp = win->lines[win->cury]; + lc = &lp->line[win->curx]; + newx = win->curx + win->ch_off; + win->curx += count; + if (win->curx == win->maxx) { + lp->flags |= __ISPASTEOL; + --win->curx; + } + + while (count-- > 0) { + lp->flags |= __ISDIRTY; + if (newx < *lp->firstchp) + *lp->firstchp = newx; + if (newx > *lp->lastchp) + *lp->lastchp = newx; +#ifdef HAVE_WCHAR + lc->attr = (lc->attr & ~WA_ATTRIBUTES) | attr; +#else + lc->attr = attr; +#endif + ++lc; + ++newx; + } + + return OK; +} Index: src/lib/libcurses/curses_chgat.3 diff -u /dev/null src/lib/libcurses/curses_chgat.3:1.1 --- /dev/null Mon Jul 6 15:19:50 2009 +++ src/lib/libcurses/curses_chgat.3 Mon Jul 6 15:19:49 2009 @@ -0,0 +1,116 @@ +.\" +.\" Copyright (c) 2009 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd July 6, 2009 +.Dt CURSES_CHGAT 3 +.Os +.Sh NAME +.Nm chgat , +.Nm wchgat , +.Nm mvchgat , +.Nm mvwchgat +.Nd curses on-screen attribute manipulation routines +.Sh LIBRARY +.Lb libcurses +.Sh SYNOPSIS +.In curses.h +.Ft int +.Fn chgat "int n" "attr_t attr" "short color" "const void *opts" +.Ft int +.Fn wchgat "WINDOW *win" "int n" "attr_t attr" "short color" \ +"const void *opts" +.Ft int +.Fn mvchgat "int y" "int x" "int n" "attr_t attr" "short color" \ +"const void *opts" +.Ft int +.Fn mvwchgat "WINDOW *win" "int y" "int x" "int n" "attr_t attr" \ +"short color" "const void *opts" +.Sh DESCRIPTION +These functions modify the attributes of the drawn content on stdscr or +on the specified window. +.Pp +The +.Fn chgat +function sets the attributes of the next +.Fa n +characters to +.Fa attr +and the color pair to +.Fa color . +If +.Fa n +is negative or larger than the reminder of the line, it gets truncated. +.Pp +The +.Fn wchgat +is the same as the +.Fn chgat +function, excepting that the attributes are changed in the window specified by +.Fa win . +.Pp +The +.Fn mvchgat +and +.Fn mvwchgat +functions are the same as the +.Fn chgat +and +.Fn wchgat +functions, respectively, excepting that +.Fn wmove +is called to mvoe the cursor to the position specified by +.Fa y , +.Fa x +before the attributes are changed. +.Sh RETURN VALUES +The functions that return an int will return one of the following +values: +.Pp +.Bl -tag -width ERR -compact +.It Er OK +The function completed successfully. +.It Er ERR +An error occurred in the function. +.El +.Sh SEE ALSO +.Xr curses_attributes 3 +.Sh STANDARDS +The +.Nx +Curses library complies with the X/Open Curses specification, part of +the Single Unix Specification. +The +.Fn chgat +family is an extension and compatible with GNU ncurses. +.Sh HISTORY +The Curses package appeared in +.Bx 4.0 . +Support for the +.Fn chgat +family was added in +.Nx 6.0 .