197049Speter/****************************************************************************
297049Speter * Copyright (c) 2002 Free Software Foundation, Inc.                        *
397049Speter *                                                                          *
497049Speter * Permission is hereby granted, free of charge, to any person obtaining a  *
597049Speter * copy of this software and associated documentation files (the            *
697049Speter * "Software"), to deal in the Software without restriction, including      *
797049Speter * without limitation the rights to use, copy, modify, merge, publish,      *
897049Speter * distribute, distribute with modifications, sublicense, and/or sell       *
997049Speter * copies of the Software, and to permit persons to whom the Software is    *
1097049Speter * furnished to do so, subject to the following conditions:                 *
1197049Speter *                                                                          *
1297049Speter * The above copyright notice and this permission notice shall be included  *
1397049Speter * in all copies or substantial portions of the Software.                   *
1497049Speter *                                                                          *
1597049Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
1697049Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
1797049Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
1897049Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
1997049Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
2097049Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
2197049Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
2297049Speter *                                                                          *
2397049Speter * Except as contained in this notice, the name(s) of the above copyright   *
2497049Speter * holders shall not be used in advertising or otherwise to promote the     *
2597049Speter * sale, use or other dealings in this Software without prior written       *
2697049Speter * authorization.                                                           *
2797049Speter ****************************************************************************/
2897049Speter
2997049Speter/****************************************************************************
3097049Speter *  Author: Thomas Dickey 2002                                              *
3197049Speter ****************************************************************************/
3297049Speter
3397049Speter/*
3497049Speter**	lib_hline_set.c
3597049Speter**
3697049Speter**	The routine whline_set().
3797049Speter**
3897049Speter*/
3997049Speter
4097049Speter#include <curses.priv.h>
4197049Speter
4297049SpeterMODULE_ID("$Id: lib_hline_set.c,v 1.2 2002/03/23 21:35:34 tom Exp $")
4397049Speter
4497049SpeterNCURSES_EXPORT(int)
4597049Speterwhline_set(WINDOW *win, const cchar_t * ch, int n)
4697049Speter{
4797049Speter    int code = ERR;
4897049Speter    NCURSES_SIZE_T start;
4997049Speter    NCURSES_SIZE_T end;
5097049Speter
5197049Speter    T((T_CALLED("whline_set(%p,%s,%d)"), win, _tracecchar_t(ch), n));
5297049Speter
5397049Speter    if (win) {
5497049Speter	struct ldat *line = &(win->_line[win->_cury]);
5597049Speter	NCURSES_CH_T wch;
5697049Speter
5797049Speter	start = win->_curx;
5897049Speter	end = start + n - 1;
5997049Speter	if (end > win->_maxx)
6097049Speter	    end = win->_maxx;
6197049Speter
6297049Speter	CHANGED_RANGE(line, start, end);
6397049Speter
6497049Speter	if (ch == 0)
6597049Speter	    wch = *WACS_HLINE;
6697049Speter	else
6797049Speter	    wch = *ch;
6897049Speter	wch = _nc_render(win, wch);
6997049Speter
7097049Speter	while (end >= start) {
7197049Speter	    line->text[end] = wch;
7297049Speter	    end--;
7397049Speter	}
7497049Speter
7597049Speter	_nc_synchook(win);
7697049Speter	code = OK;
7797049Speter    }
7897049Speter    returnCode(code);
7997049Speter}
80