lib_chgat.c revision 166124
1121326Sharti/****************************************************************************
2121326Sharti * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
3121326Sharti *                                                                          *
4121326Sharti * Permission is hereby granted, free of charge, to any person obtaining a  *
5121326Sharti * copy of this software and associated documentation files (the            *
6121326Sharti * "Software"), to deal in the Software without restriction, including      *
7121326Sharti * without limitation the rights to use, copy, modify, merge, publish,      *
8121326Sharti * distribute, distribute with modifications, sublicense, and/or sell       *
9121326Sharti * copies of the Software, and to permit persons to whom the Software is    *
10121326Sharti * furnished to do so, subject to the following conditions:                 *
11121326Sharti *                                                                          *
12121326Sharti * The above copyright notice and this permission notice shall be included  *
13121326Sharti * in all copies or substantial portions of the Software.                   *
14121326Sharti *                                                                          *
15121326Sharti * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16121326Sharti * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17121326Sharti * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18121326Sharti * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19121326Sharti * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20121326Sharti * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21121326Sharti * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22121326Sharti *                                                                          *
23121326Sharti * Except as contained in this notice, the name(s) of the above copyright   *
24121326Sharti * holders shall not be used in advertising or otherwise to promote the     *
25121326Sharti * sale, use or other dealings in this Software without prior written       *
26121326Sharti * authorization.                                                           *
27121326Sharti ****************************************************************************/
28121326Sharti
29121326Sharti/****************************************************************************
30121326Sharti *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31121326Sharti *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32121326Sharti *     and: Sven Verdoolaege                        2001                    *
33121326Sharti *     and: Thomas E. Dickey                        2005                    *
34121326Sharti ****************************************************************************/
35121326Sharti
36121326Sharti/*
37121326Sharti**	lib_chgat.c
38121326Sharti**
39121326Sharti**	The routine wchgat().
40121326Sharti**
41121326Sharti*/
42121326Sharti
43121326Sharti#include <curses.priv.h>
44121326Sharti
45121326ShartiMODULE_ID("$Id: lib_chgat.c,v 1.7 2006/07/15 22:07:11 tom Exp $")
46121326Sharti
47121326ShartiNCURSES_EXPORT(int)
48121326Shartiwchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
49121326Sharti{
50121326Sharti    int i;
51121326Sharti
52121326Sharti    T((T_CALLED("wchgat(%p,%d,%s,%d)"), win, n, _traceattr(attr), color));
53121326Sharti
54121326Sharti    if (win) {
55121326Sharti	struct ldat *line = &(win->_line[win->_cury]);
56121326Sharti
57121326Sharti	toggle_attr_on(attr, COLOR_PAIR(color));
58121326Sharti
59121326Sharti	for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) {
60121326Sharti	    SetAttr(line->text[i], attr);
61121326Sharti	    SetPair(line->text[i], color);
62121326Sharti	    CHANGED_CELL(line, i);
63121326Sharti	}
64121326Sharti
65121326Sharti	returnCode(OK);
66121326Sharti    } else
67	returnCode(ERR);
68}
69