1*0c3ae37fSLionel Sambuc /* $NetBSD: meta.c,v 1.8 2011/08/07 10:52:18 blymn Exp $ */
251ffecc1SBen Gras
351ffecc1SBen Gras /*-
451ffecc1SBen Gras * Copyright (c) 1998-2000 Brett Lymn
551ffecc1SBen Gras * (blymn@baea.com.au, brett_lymn@yahoo.com.au)
651ffecc1SBen Gras * All rights reserved.
751ffecc1SBen Gras *
851ffecc1SBen Gras * This code has been donated to The NetBSD Foundation by the Author.
951ffecc1SBen Gras *
1051ffecc1SBen Gras * Redistribution and use in source and binary forms, with or without
1151ffecc1SBen Gras * modification, are permitted provided that the following conditions
1251ffecc1SBen Gras * are met:
1351ffecc1SBen Gras * 1. Redistributions of source code must retain the above copyright
1451ffecc1SBen Gras * notice, this list of conditions and the following disclaimer.
1551ffecc1SBen Gras * 2. The name of the author may not be used to endorse or promote products
1651ffecc1SBen Gras * derived from this software without specific prior written permission
1751ffecc1SBen Gras *
1851ffecc1SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1951ffecc1SBen Gras * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2051ffecc1SBen Gras * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2151ffecc1SBen Gras * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2251ffecc1SBen Gras * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2351ffecc1SBen Gras * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2451ffecc1SBen Gras * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2551ffecc1SBen Gras * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2651ffecc1SBen Gras * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2751ffecc1SBen Gras * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2851ffecc1SBen Gras *
2951ffecc1SBen Gras *
3051ffecc1SBen Gras */
3151ffecc1SBen Gras
3251ffecc1SBen Gras #include <sys/cdefs.h>
3351ffecc1SBen Gras #ifndef lint
34*0c3ae37fSLionel Sambuc __RCSID("$NetBSD: meta.c,v 1.8 2011/08/07 10:52:18 blymn Exp $");
3551ffecc1SBen Gras #endif /* not lint */
3651ffecc1SBen Gras
3751ffecc1SBen Gras #include "curses.h"
3851ffecc1SBen Gras #include "curses_private.h"
3951ffecc1SBen Gras
4051ffecc1SBen Gras /*
4151ffecc1SBen Gras * meta --
4251ffecc1SBen Gras * Turn on or off the terminal meta mode.
4351ffecc1SBen Gras */
4451ffecc1SBen Gras int
meta(WINDOW * win,bool bf)4551ffecc1SBen Gras meta(/*ARGSUSED*/ WINDOW *win, bool bf)
4651ffecc1SBen Gras {
4751ffecc1SBen Gras if (bf == TRUE) {
4851ffecc1SBen Gras if (meta_on != NULL) {
4951ffecc1SBen Gras #ifdef DEBUG
5051ffecc1SBen Gras __CTRACE(__CTRACE_MISC, "meta: TRUE\n");
5151ffecc1SBen Gras #endif
5251ffecc1SBen Gras tputs(meta_on, 0, __cputchar);
5351ffecc1SBen Gras _cursesi_screen->meta_state = TRUE;
54*0c3ae37fSLionel Sambuc fflush(_cursesi_screen->outfd);
5551ffecc1SBen Gras }
5651ffecc1SBen Gras } else {
5751ffecc1SBen Gras if (meta_off != NULL) {
5851ffecc1SBen Gras #ifdef DEBUG
5951ffecc1SBen Gras __CTRACE(__CTRACE_MISC, "meta: FALSE\n");
6051ffecc1SBen Gras #endif
6151ffecc1SBen Gras tputs(meta_off, 0, __cputchar);
6251ffecc1SBen Gras _cursesi_screen->meta_state = FALSE;
63*0c3ae37fSLionel Sambuc fflush(_cursesi_screen->outfd);
6451ffecc1SBen Gras }
6551ffecc1SBen Gras }
6651ffecc1SBen Gras
6751ffecc1SBen Gras return OK;
6851ffecc1SBen Gras }
6951ffecc1SBen Gras
7051ffecc1SBen Gras /*
7151ffecc1SBen Gras * __restore_meta_state --
7251ffecc1SBen Gras * Restore old meta state.
7351ffecc1SBen Gras */
7451ffecc1SBen Gras void
__restore_meta_state(void)7551ffecc1SBen Gras __restore_meta_state(void)
7651ffecc1SBen Gras {
7751ffecc1SBen Gras meta(NULL, _cursesi_screen->meta_state);
7851ffecc1SBen Gras }
7951ffecc1SBen Gras
80