[BACK]Return to ttykbd.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Annotation of src/usr.bin/mg/ttykbd.c, Revision 1.16

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