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