bindings.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* -*- c++ -*-
  2. * dselect - selection of Debian packages
  3. * bindings.h - keybindings class header file
  4. *
  5. * Copyright © 1994,1995 Ian Jackson <ian@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
  9. * published by the Free Software Foundation; either version 2,
  10. * or (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful, but
  13. * 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 <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef BINDINGS_H
  21. #define BINDINGS_H
  22. enum quitaction;
  23. struct keybindings {
  24. struct interpretation;
  25. struct orgbinding {
  26. int key;
  27. const char *action;
  28. };
  29. struct keyname {
  30. int key;
  31. const char *kname;
  32. };
  33. struct description {
  34. const char *action, *desc;
  35. };
  36. struct binding {
  37. binding *next;
  38. int key;
  39. const struct interpretation *interp;
  40. const char *desc;
  41. };
  42. private:
  43. static const keyname keynames[];
  44. static const description descriptions[];
  45. binding *bindings;
  46. const description *iterate;
  47. const interpretation *interps;
  48. int bind(int key, const char *action);
  49. public:
  50. int name2key(const char *name);
  51. const char *key2name(int key);
  52. int bind(const char *name, const char *action) { return bind(name2key(name),action); }
  53. const interpretation *operator()(int key);
  54. const char *find(const char *action);
  55. void describestart() { iterate=descriptions; }
  56. const char **describenext();
  57. //... returns array, null-term, first element is description, rest are key strings
  58. // caller must delete[] the array. Null means end.
  59. keybindings(const interpretation *ints, const orgbinding *orgbindings);
  60. ~keybindings();
  61. };
  62. #include "pkglist.h"
  63. #include "method.h"
  64. struct keybindings::interpretation {
  65. const char *action;
  66. void (methodlist::*mfn)();
  67. void (packagelist::*pfn)();
  68. quitaction qa;
  69. };
  70. extern const keybindings::interpretation packagelist_kinterps[];
  71. extern const keybindings::orgbinding packagelist_korgbindings[];
  72. extern const keybindings::interpretation methodlist_kinterps[];
  73. extern const keybindings::orgbinding methodlist_korgbindings[];
  74. #endif /* BINDINGS_H */