summaryrefslogtreecommitdiff
path: root/usr.bin/mg/ttykbd.c
blob: b10712f5c467bbfbcc58fb93fe803542116c3497 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Name:	MG 2a
 *		Terminfo keyboard driver using key files
 * Created:	22-Nov-1987 Mic Kaczmarczik (mic@emx.cc.utexas.edu)
 */

#include	"def.h"
#include	"kbd.h"
#ifdef	XKEYS
#include	<term.h>

#ifdef  FKEYS
/*
 * Get keyboard character.  Very simple if you use keymaps and keys files.
 * Bob was right -- the old XKEYS code is not the right solution.
 * FKEYS code is not usefull other than to help debug FKEYS code in
 * extend.c.
 */

char           *keystrings[] = {NULL};
#endif

/*
 * Turn on function keys using keypad_xmit, then load a keys file, if
 * available.  The keys file is located in the same manner as the startup
 * file is, depending on what startupfile() does on your system.
 */
extern int      ttputc();

ttykeymapinit()
{
	extern int      dobindkey();	/* XXX */
	char           *cp;
#ifdef FKEYS
	/* Bind keypad function keys. */
	if (key_left)
		dobindkey(map_table[0].p_map, "backward-char", key_left);
	if (key_right)
		dobindkey(map_table[0].p_map, "forward-char", key_right);
	if (key_up)
		dobindkey(map_table[0].p_map, "previous-line", key_up);
	if (key_down)
		dobindkey(map_table[0].p_map, "next-line", key_down);
	if (key_beg)
		dobindkey(map_table[0].p_map, "beginning-of-line", key_beg);
	else if (key_home)
		dobindkey(map_table[0].p_map, "beginning-of-line", key_home);
	if (key_end)
		dobindkey(map_table[0].p_map, "end-of-line", key_end);
	if (key_npage)
		dobindkey(map_table[0].p_map, "scroll-up", key_npage);
	if (key_ppage)
		dobindkey(map_table[0].p_map, "scroll-down", key_ppage);
#endif
#ifndef	NO_STARTUP
	if (cp = gettermtype()) {
		extern char    *startupfile();
		if (((cp = startupfile(cp)) != NULL)
		    && (load(cp) != TRUE))
			ewprintf("Error reading key initialization file");
	}
#endif
	if (keypad_xmit)	/* turn on keypad	 */
		putpad(keypad_xmit, 1);
}

/*
 * Clean up the keyboard -- called by tttidy()
 */
ttykeymaptidy()
{

	if (keypad_local)
		putpad(keypad_local, 1);	/* turn off keypad	 */
}

#endif