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