xref: /netbsd-src/lib/libcurses/clearok.c (revision 6348e3f32a4431b45d07e1da16fd7b12725a45e7)
1*6348e3f3Sblymn /*	$NetBSD: clearok.c,v 1.6 2024/12/23 02:58:03 blymn Exp $	*/
223464ee5Sblymn 
323464ee5Sblymn /*-
423464ee5Sblymn  * Copyright (c) 1999 The NetBSD Foundation, Inc.
523464ee5Sblymn  * All rights reserved.
623464ee5Sblymn  *
723464ee5Sblymn  * This code is derived from software contributed to The NetBSD Foundation
823464ee5Sblymn  * by Julian Coleman.
923464ee5Sblymn  *
1023464ee5Sblymn  * Redistribution and use in source and binary forms, with or without
1123464ee5Sblymn  * modification, are permitted provided that the following conditions
1223464ee5Sblymn  * are met:
1323464ee5Sblymn  * 1. Redistributions of source code must retain the above copyright
1423464ee5Sblymn  *    notice, this list of conditions and the following disclaimer.
1523464ee5Sblymn  * 2. Redistributions in binary form must reproduce the above copyright
1623464ee5Sblymn  *    notice, this list of conditions and the following disclaimer in the
1723464ee5Sblymn  *    documentation and/or other materials provided with the distribution.
1823464ee5Sblymn  *
1923464ee5Sblymn  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2023464ee5Sblymn  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2123464ee5Sblymn  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2223464ee5Sblymn  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2323464ee5Sblymn  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2423464ee5Sblymn  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2523464ee5Sblymn  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2623464ee5Sblymn  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2723464ee5Sblymn  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2823464ee5Sblymn  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2923464ee5Sblymn  * POSSIBILITY OF SUCH DAMAGE.
3023464ee5Sblymn  */
3123464ee5Sblymn 
3266cab71cSblymn #include <sys/cdefs.h>
3366cab71cSblymn #ifndef lint
34*6348e3f3Sblymn __RCSID("$NetBSD: clearok.c,v 1.6 2024/12/23 02:58:03 blymn Exp $");
3566cab71cSblymn #endif				/* not lint */
3666cab71cSblymn 
3723464ee5Sblymn #include "curses.h"
3823464ee5Sblymn #include "curses_private.h"
3923464ee5Sblymn 
4023464ee5Sblymn /*
4123464ee5Sblymn  * clearok --
4223464ee5Sblymn  *	Turn on and off clear before refresh for the given window.
4323464ee5Sblymn  */
4423464ee5Sblymn int
45aaf74682Sblymn clearok(WINDOW *win, bool bf)
4623464ee5Sblymn {
47*6348e3f3Sblymn 	if (__predict_false(win == NULL))
48*6348e3f3Sblymn 		return ERR;
49*6348e3f3Sblymn 
5023464ee5Sblymn 	if (bf)
5123464ee5Sblymn 		win->flags |= __CLEAROK;
5223464ee5Sblymn 	else
5323464ee5Sblymn 		win->flags &= ~__CLEAROK;
5423464ee5Sblymn 	return (OK);
5523464ee5Sblymn }
56