Home | History | Annotate | Line # | Download | only in libcurses
meta.c revision 1.10
      1  1.10    rin /*	$NetBSD: meta.c,v 1.10 2021/09/06 07:03:50 rin Exp $	*/
      2   1.1  blymn 
      3   1.1  blymn /*-
      4   1.1  blymn  * Copyright (c) 1998-2000 Brett Lymn
      5   1.1  blymn  *                         (blymn (at) baea.com.au, brett_lymn (at) yahoo.com.au)
      6   1.1  blymn  * All rights reserved.
      7   1.1  blymn  *
      8   1.1  blymn  * This code has been donated to The NetBSD Foundation by the Author.
      9   1.1  blymn  *
     10   1.1  blymn  * Redistribution and use in source and binary forms, with or without
     11   1.1  blymn  * modification, are permitted provided that the following conditions
     12   1.1  blymn  * are met:
     13   1.1  blymn  * 1. Redistributions of source code must retain the above copyright
     14   1.1  blymn  *    notice, this list of conditions and the following disclaimer.
     15   1.1  blymn  * 2. The name of the author may not be used to endorse or promote products
     16   1.4    wiz  *    derived from this software without specific prior written permission
     17   1.1  blymn  *
     18   1.1  blymn  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19   1.1  blymn  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20   1.1  blymn  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21   1.1  blymn  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22   1.1  blymn  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23   1.1  blymn  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24   1.1  blymn  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25   1.1  blymn  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26   1.1  blymn  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27   1.1  blymn  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28   1.1  blymn  *
     29   1.1  blymn  *
     30   1.1  blymn  */
     31   1.1  blymn 
     32   1.2  blymn #include <sys/cdefs.h>
     33   1.2  blymn #ifndef lint
     34  1.10    rin __RCSID("$NetBSD: meta.c,v 1.10 2021/09/06 07:03:50 rin Exp $");
     35   1.2  blymn #endif				/* not lint */
     36   1.2  blymn 
     37   1.1  blymn #include "curses.h"
     38   1.1  blymn #include "curses_private.h"
     39   1.1  blymn 
     40   1.1  blymn /*
     41   1.1  blymn  * meta --
     42   1.1  blymn  *    Turn on or off the terminal meta mode.
     43   1.1  blymn  */
     44   1.1  blymn int
     45   1.1  blymn meta(/*ARGSUSED*/ WINDOW *win, bool bf)
     46   1.1  blymn {
     47   1.9    roy 
     48   1.1  blymn 	if (bf == TRUE) {
     49   1.7    roy 		if (meta_on != NULL) {
     50   1.6    jdc 			__CTRACE(__CTRACE_MISC, "meta: TRUE\n");
     51   1.7    roy 			tputs(meta_on, 0, __cputchar);
     52   1.5  blymn 			_cursesi_screen->meta_state = TRUE;
     53   1.8  blymn 			fflush(_cursesi_screen->outfd);
     54   1.1  blymn 		}
     55   1.1  blymn 	} else {
     56   1.7    roy 		if (meta_off != NULL) {
     57   1.6    jdc 			__CTRACE(__CTRACE_MISC, "meta: FALSE\n");
     58   1.7    roy 			tputs(meta_off, 0, __cputchar);
     59   1.5  blymn 			_cursesi_screen->meta_state = FALSE;
     60   1.8  blymn 			fflush(_cursesi_screen->outfd);
     61   1.1  blymn 		}
     62   1.1  blymn 	}
     63   1.1  blymn 
     64   1.1  blymn 	return OK;
     65   1.1  blymn }
     66   1.1  blymn 
     67   1.2  blymn /*
     68   1.2  blymn  * __restore_meta_state --
     69   1.2  blymn  *    Restore old meta state.
     70   1.2  blymn  */
     71   1.2  blymn void
     72   1.2  blymn __restore_meta_state(void)
     73   1.2  blymn {
     74   1.9    roy 
     75   1.5  blymn 	meta(NULL, _cursesi_screen->meta_state);
     76   1.2  blymn }
     77   1.2  blymn 
     78