bindings.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 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 <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef BINDINGS_H
  21. #define BINDINGS_H
  22. struct keybindings {
  23. struct interpretation;
  24. struct orgbinding {
  25. int key;
  26. const char *action;
  27. };
  28. struct keyname {
  29. int key;
  30. const char *kname;
  31. };
  32. struct description {
  33. const char *action, *desc;
  34. };
  35. struct binding {
  36. binding *next;
  37. int key;
  38. const struct interpretation *interp;
  39. const char *desc;
  40. };
  41. private:
  42. static const keyname keynames[];
  43. static const description descriptions[];
  44. binding *bindings;
  45. const description *iterate;
  46. const interpretation *interps;
  47. int bind(int key, const char *action);
  48. public:
  49. int name2key(const char *name);
  50. const char *key2name(int key);
  51. int bind(const char *name, const char *action) { return bind(name2key(name),action); }
  52. const interpretation *operator()(int key);
  53. const char *find(const char *action);
  54. void describestart() { iterate=descriptions; }
  55. const char **describenext();
  56. //... returns array, null-term, first element is description, rest are key strings
  57. // caller must delete[] the array. Null means end.
  58. keybindings(const interpretation *ints, const orgbinding *orgbindings);
  59. ~keybindings();
  60. };
  61. #include "pkglist.h"
  62. #include "method.h"
  63. struct keybindings::interpretation {
  64. const char *action;
  65. void (methodlist::*mfn)();
  66. void (packagelist::*pfn)();
  67. quitaction qa;
  68. };
  69. extern const keybindings::interpretation packagelist_kinterps[];
  70. extern const keybindings::orgbinding packagelist_korgbindings[];
  71. extern const keybindings::interpretation methodlist_kinterps[];
  72. extern const keybindings::orgbinding methodlist_korgbindings[];
  73. #endif /* BINDINGS_H */