Annotation of src/usr.bin/mg/ttykbd.c, Revision 1.7
1.7 ! niklas 1: /* $OpenBSD$ */
! 2:
1.1 deraadt 3: /*
4: * Name: MG 2a
1.2 millert 5: * Terminfo keyboard driver using key files
1.1 deraadt 6: * Created: 22-Nov-1987 Mic Kaczmarczik (mic@emx.cc.utexas.edu)
7: */
8:
1.6 millert 9: #include "def.h"
10: #include "kbd.h"
11:
1.1 deraadt 12: #ifdef XKEYS
1.6 millert 13: #include <term.h>
1.1 deraadt 14:
1.2 millert 15: #ifdef FKEYS
1.1 deraadt 16: /*
17: * Get keyboard character. Very simple if you use keymaps and keys files.
18: * Bob was right -- the old XKEYS code is not the right solution.
19: * FKEYS code is not usefull other than to help debug FKEYS code in
20: * extend.c.
21: */
22:
1.5 millert 23: char *keystrings[] = {NULL};
1.6 millert 24: #endif /* FKEYS */
1.1 deraadt 25:
26: /*
1.2 millert 27: * Turn on function keys using keypad_xmit, then load a keys file, if
28: * available. The keys file is located in the same manner as the startup
29: * file is, depending on what startupfile() does on your system.
1.1 deraadt 30: */
1.6 millert 31: void
1.1 deraadt 32: ttykeymapinit()
33: {
1.6 millert 34: char *cp;
35:
1.2 millert 36: #ifdef FKEYS
37: /* Bind keypad function keys. */
38: if (key_left)
1.3 millert 39: dobindkey(map_table[0].p_map, "backward-char", key_left);
1.2 millert 40: if (key_right)
1.3 millert 41: dobindkey(map_table[0].p_map, "forward-char", key_right);
1.2 millert 42: if (key_up)
1.3 millert 43: dobindkey(map_table[0].p_map, "previous-line", key_up);
1.2 millert 44: if (key_down)
1.3 millert 45: dobindkey(map_table[0].p_map, "next-line", key_down);
1.2 millert 46: if (key_beg)
1.3 millert 47: dobindkey(map_table[0].p_map, "beginning-of-line", key_beg);
1.4 millert 48: else if (key_home)
49: dobindkey(map_table[0].p_map, "beginning-of-line", key_home);
1.2 millert 50: if (key_end)
1.3 millert 51: dobindkey(map_table[0].p_map, "end-of-line", key_end);
1.2 millert 52: if (key_npage)
1.3 millert 53: dobindkey(map_table[0].p_map, "scroll-up", key_npage);
1.2 millert 54: if (key_ppage)
1.3 millert 55: dobindkey(map_table[0].p_map, "scroll-down", key_ppage);
1.6 millert 56: #endif /* FKEYS */
57:
1.1 deraadt 58: #ifndef NO_STARTUP
1.6 millert 59: if ((cp = gettermtype())) {
60: if (((cp = startupfile(cp)) != NULL) && (load(cp) != TRUE))
1.1 deraadt 61: ewprintf("Error reading key initialization file");
62: }
1.6 millert 63: #endif /* !NO_STARTUP */
64: if (keypad_xmit)
65: /* turn on keypad */
1.2 millert 66: putpad(keypad_xmit, 1);
1.1 deraadt 67: }
68:
69: /*
70: * Clean up the keyboard -- called by tttidy()
71: */
1.6 millert 72: void
1.1 deraadt 73: ttykeymaptidy()
74: {
1.2 millert 75: if (keypad_local)
1.6 millert 76: /* turn off keypad */
77: putpad(keypad_local, 1);
1.1 deraadt 78: }
79:
1.6 millert 80: #endif /* XKEYS */