Home | History | Annotate | Line # | Download | only in libcurses
keypad.c revision 1.12.28.1
      1  1.12.28.1  pgoyette /*	$NetBSD: keypad.c,v 1.12.28.1 2017/01/07 08:56:04 pgoyette Exp $  */
      2        1.1       mrg 
      3        1.1       mrg /*-
      4        1.1       mrg  * Copyright (c) 1998-1999 Brett Lymn (blymn (at) baea.com.au, brett_lymn (at) yahoo.com)
      5        1.1       mrg  * All rights reserved.
      6        1.1       mrg  *
      7        1.1       mrg  * Redistribution and use in source and binary forms, with or without
      8        1.1       mrg  * modification, are permitted provided that the following conditions
      9        1.1       mrg  * are met:
     10        1.1       mrg  * 1. Redistributions of source code must retain the above copyright
     11        1.1       mrg  *    notice, this list of conditions and the following disclaimer.
     12        1.1       mrg  * 2. The name of the author may not be used to endorse or promote products
     13        1.8       wiz  *    derived from this software without specific prior written permission
     14        1.1       mrg  *
     15        1.1       mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16        1.1       mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17        1.1       mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18        1.1       mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19        1.1       mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20        1.1       mrg  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21        1.1       mrg  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22        1.1       mrg  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23        1.1       mrg  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24        1.1       mrg  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25        1.1       mrg  *
     26        1.1       mrg  *
     27        1.1       mrg  */
     28        1.4     blymn 
     29        1.4     blymn #include <sys/cdefs.h>
     30        1.4     blymn #ifndef lint
     31  1.12.28.1  pgoyette __RCSID("$NetBSD: keypad.c,v 1.12.28.1 2017/01/07 08:56:04 pgoyette Exp $");
     32        1.4     blymn #endif				/* not lint */
     33        1.1       mrg 
     34        1.1       mrg #include "curses.h"
     35        1.2     blymn #include "curses_private.h"
     36        1.1       mrg 
     37        1.1       mrg /*
     38        1.1       mrg  * keypad --
     39        1.1       mrg  *	Turn on and off interpretation of function/keypad keys in the
     40        1.1       mrg  *	given window.
     41        1.1       mrg  */
     42       1.11      cube int
     43        1.3     blymn keypad(WINDOW *win, bool bf)
     44        1.1       mrg {
     45        1.5       jdc #ifdef DEBUG
     46       1.10       jdc 	__CTRACE(__CTRACE_MISC,
     47       1.10       jdc 	    "keypad: win %p, %s\n", win, bf ? "TRUE" : "FALSE");
     48        1.5       jdc #endif
     49        1.5       jdc 	if (bf) {
     50        1.1       mrg 		win->flags |= __KEYPAD;
     51        1.5       jdc 		if (!(curscr->flags & __KEYPAD)) {
     52  1.12.28.1  pgoyette 			tputs(keypad_xmit, 0, __cputchar);
     53        1.5       jdc 			curscr->flags |= __KEYPAD;
     54        1.5       jdc 		}
     55        1.6       jdc 	} else
     56        1.1       mrg 		win->flags &= ~__KEYPAD;
     57       1.11      cube 
     58       1.11      cube 	return OK;
     59        1.1       mrg }
     60  1.12.28.1  pgoyette 
     61  1.12.28.1  pgoyette /*
     62  1.12.28.1  pgoyette  * is_keypad --
     63  1.12.28.1  pgoyette  *	Return true if window is set for keypad.
     64  1.12.28.1  pgoyette  */
     65  1.12.28.1  pgoyette bool
     66  1.12.28.1  pgoyette is_keypad(const WINDOW *win)
     67  1.12.28.1  pgoyette {
     68  1.12.28.1  pgoyette 
     69  1.12.28.1  pgoyette 	return win->flags & __KEYPAD ? true : false;
     70  1.12.28.1  pgoyette }
     71