awful debugging hacking
[dpkg] / dselect / bindings.h
1 /*
2 * dselect - Debian package maintenance user interface
3 * bindings.h - keybindings class header file
4 *
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 *
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21 #ifndef BINDINGS_H
22 #define BINDINGS_H
23
24 struct keybindings {
25 struct interpretation;
26
27 struct orgbinding {
28 int key;
29 const char *action;
30 };
31
32 struct keyname {
33 int key;
34 const char *kname;
35 };
36
37 struct description {
38 const char *action, *desc;
39 };
40
41 struct binding {
42 binding *next;
43 int key;
44 const struct interpretation *interp;
45 const char *desc;
46 };
47
48 private:
49 static const keyname keynames[];
50 static const description descriptions[];
51
52 binding *bindings;
53 const description *iterate;
54 const interpretation *interps;
55
56 bool bind(int key, const char *action);
57
58 public:
59 int name2key(const char *name);
60 const char *key2name(int key);
61
62 bool bind(const char *name, const char *action)
63 { return bind(name2key(name), action); }
64 const interpretation *operator()(int key);
65 const char *find(const char *action);
66
67 void describestart() { iterate=descriptions; }
68 const char **describenext();
69 //... returns array, null-term, first element is description, rest are key strings
70 // caller must delete[] the array. Null means end.
71
72 keybindings(const interpretation *ints, const orgbinding *orgbindings);
73 ~keybindings();
74 };
75
76 #include "pkglist.h"
77 #include "method.h"
78
79 struct keybindings::interpretation {
80 const char *action;
81 void (methodlist::*mfn)();
82 void (packagelist::*pfn)();
83 quitaction qa;
84 };
85
86 extern const keybindings::interpretation packagelist_kinterps[];
87 extern const keybindings::orgbinding packagelist_korgbindings[];
88
89 extern const keybindings::interpretation methodlist_kinterps[];
90 extern const keybindings::orgbinding methodlist_korgbindings[];
91
92 #ifndef CTRL
93 #define CTRL(x) ((x) - 'a' + 1)
94 #endif
95
96 #endif /* BINDINGS_H */