bindings.h 2.5 KB

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