1 |
|
|
/* $OpenBSD: ttykbd.c,v 1.18 2015/03/19 21:22:15 bcallah Exp $ */ |
2 |
|
|
|
3 |
|
|
/* This file is in the public domain. */ |
4 |
|
|
|
5 |
|
|
/* |
6 |
|
|
* Name: MG 2a |
7 |
|
|
* Terminfo keyboard driver using key files |
8 |
|
|
* Created: 22-Nov-1987 Mic Kaczmarczik (mic@emx.cc.utexas.edu) |
9 |
|
|
*/ |
10 |
|
|
|
11 |
|
|
#include <sys/queue.h> |
12 |
|
|
#include <signal.h> |
13 |
|
|
#include <stdio.h> |
14 |
|
|
#include <stdlib.h> |
15 |
|
|
#include <term.h> |
16 |
|
|
|
17 |
|
|
#include "def.h" |
18 |
|
|
#include "kbd.h" |
19 |
|
|
|
20 |
|
|
/* |
21 |
|
|
* Get keyboard character. Very simple if you use keymaps and keys files. |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
char *keystrings[] = {NULL}; |
25 |
|
|
|
26 |
|
|
/* |
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. |
30 |
|
|
*/ |
31 |
|
|
void |
32 |
|
|
ttykeymapinit(void) |
33 |
|
|
{ |
34 |
|
|
char *cp; |
35 |
|
|
|
36 |
|
|
/* Bind keypad function keys. */ |
37 |
|
|
if (key_left) |
38 |
|
|
dobindkey(fundamental_map, "backward-char", key_left); |
39 |
|
|
if (key_right) |
40 |
|
|
dobindkey(fundamental_map, "forward-char", key_right); |
41 |
|
|
if (key_up) |
42 |
|
|
dobindkey(fundamental_map, "previous-line", key_up); |
43 |
|
|
if (key_down) |
44 |
|
|
dobindkey(fundamental_map, "next-line", key_down); |
45 |
|
|
if (key_beg) |
46 |
|
|
dobindkey(fundamental_map, "beginning-of-line", key_beg); |
47 |
|
|
else if (key_home) |
48 |
|
|
dobindkey(fundamental_map, "beginning-of-line", key_home); |
49 |
|
|
if (key_end) |
50 |
|
|
dobindkey(fundamental_map, "end-of-line", key_end); |
51 |
|
|
if (key_npage) |
52 |
|
|
dobindkey(fundamental_map, "scroll-up", key_npage); |
53 |
|
|
if (key_ppage) |
54 |
|
|
dobindkey(fundamental_map, "scroll-down", key_ppage); |
55 |
|
|
if (key_dc) |
56 |
|
|
dobindkey(fundamental_map, "delete-char", key_dc); |
57 |
|
|
|
58 |
|
|
if ((cp = getenv("TERM"))) { |
59 |
|
|
if (((cp = startupfile(cp)) != NULL) && (load(cp) != TRUE)) |
60 |
|
|
ewprintf("Error reading key initialization file"); |
61 |
|
|
} |
62 |
|
|
if (keypad_xmit) |
63 |
|
|
/* turn on keypad */ |
64 |
|
|
putpad(keypad_xmit, 1); |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
/* |
68 |
|
|
* Clean up the keyboard -- called by tttidy() |
69 |
|
|
*/ |
70 |
|
|
void |
71 |
|
|
ttykeymaptidy(void) |
72 |
|
|
{ |
73 |
|
|
if (keypad_local) |
74 |
|
|
/* turn off keypad */ |
75 |
|
|
putpad(keypad_local, 1); |
76 |
|
|
} |
77 |
|
|
|