dselect.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* -*- c++ -*-
  2. * dselect - selection of Debian packages
  3. * dselect.h - external definitions for this program
  4. *
  5. * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright © 2001 Wichert Akkerman <wakkerma@debian.org>
  7. *
  8. * This is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2,
  11. * or (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef DSELECT_H
  22. #define DSELECT_H
  23. #include <signal.h>
  24. #include "dselect-curses.h"
  25. #define DSELECT "dselect"
  26. #define TOTAL_LIST_WIDTH 180
  27. #define MAX_DISPLAY_INFO 120
  28. struct helpmenuentry {
  29. char key;
  30. const struct helpmessage *msg;
  31. };
  32. class keybindings;
  33. class baselist {
  34. protected:
  35. // Screen dimensions &c.
  36. int xmax, ymax;
  37. int title_height, colheads_height, list_height;
  38. int thisstate_height, info_height, whatinfo_height;
  39. int colheads_row, thisstate_row, info_row, whatinfo_row, list_row;
  40. int list_attr, listsel_attr, title_attr, colheads_attr, info_attr;
  41. int info_headattr, whatinfo_attr;
  42. int thisstate_attr, query_attr;
  43. int selstate_attr, selstatesel_attr;
  44. int helpscreen_attr;
  45. int total_width;
  46. // (n)curses stuff
  47. WINDOW *listpad, *infopad, *colheadspad, *thisstatepad;
  48. WINDOW *titlewin, *whatinfowin, *querywin;
  49. // If listpad is null, then we have not started to display yet, and
  50. // so none of the auto-displaying update routines need to display.
  51. // SIGWINCH handling
  52. struct sigaction *osigactp, nsigact;
  53. sigset_t *oblockedp, sigwinchset;
  54. void setupsigwinch();
  55. static baselist *signallist;
  56. static void sigwinchhandler(int);
  57. int nitems, ldrawnstart, ldrawnend, showinfo;
  58. int topofscreen, leftofscreen, cursorline;
  59. int infotopofscreen, infolines;
  60. varbuf whatinfovb;
  61. char searchstring[128];
  62. virtual void setheights();
  63. void unsizes();
  64. void dosearch();
  65. void displayhelp(const struct helpmenuentry *menu, int key);
  66. void displayerror(const char* str);
  67. void redrawall();
  68. void redrawitemsrange(int start /*inclusive*/, int end /*exclusive*/);
  69. void redraw1item(int index);
  70. void refreshlist();
  71. void refreshinfo();
  72. void refreshcolheads();
  73. void setcursor(int index);
  74. void itd_keys();
  75. virtual void redraw1itemsel(int index, int selected) =0;
  76. virtual void redrawcolheads() =0;
  77. virtual void redrawthisstate() =0;
  78. virtual void redrawinfo() =0;
  79. virtual void redrawtitle() =0;
  80. virtual void setwidths() =0;
  81. virtual const char *itemname(int index) =0;
  82. virtual const struct helpmenuentry *helpmenulist() =0;
  83. virtual int checksearch(char* str);
  84. virtual int matchsearch(int index);
  85. void wordwrapinfo(int offset, const char *string);
  86. public:
  87. keybindings *bindings;
  88. void kd_up();
  89. void kd_down();
  90. void kd_redraw();
  91. void kd_scrollon();
  92. void kd_scrollback();
  93. void kd_scrollon1();
  94. void kd_scrollback1();
  95. void kd_panon();
  96. void kd_panback();
  97. void kd_panon1();
  98. void kd_panback1();
  99. void kd_top();
  100. void kd_bottom();
  101. void kd_iscrollon();
  102. void kd_iscrollback();
  103. void kd_iscrollon1();
  104. void kd_iscrollback1();
  105. void kd_search();
  106. void kd_searchagain();
  107. void kd_help();
  108. void startdisplay();
  109. void enddisplay();
  110. baselist(keybindings*);
  111. virtual ~baselist();
  112. };
  113. static inline int lesserint(int a, int b) { return a<b ? a : b; }
  114. static inline int greaterint(int a, int b) { return a>b ? a : b; }
  115. void displayhelp(const struct helpmenuentry *menu, int key);
  116. void mywerase(WINDOW *win);
  117. void curseson();
  118. void cursesoff();
  119. extern const char *admindir;
  120. extern FILE *debug;
  121. extern int expertmode;
  122. enum screenparts {
  123. background,
  124. list,
  125. listsel,
  126. title,
  127. thisstate,
  128. selstate,
  129. selstatesel,
  130. colheads,
  131. query,
  132. info,
  133. info_head,
  134. whatinfo,
  135. helpscreen,
  136. numscreenparts,
  137. };
  138. struct colordata {
  139. int fore;
  140. int back;
  141. int attr;
  142. };
  143. extern colordata color[];
  144. /* Evil recommends flag variable. */
  145. extern int manual_install;
  146. enum urqresult { urqr_normal, urqr_fail, urqr_quitmenu };
  147. enum quitaction { qa_noquit, qa_quitchecksave, qa_quitnochecksave };
  148. typedef urqresult urqfunction(void);
  149. urqfunction urq_list, urq_quit, urq_menu;
  150. urqfunction urq_setup, urq_update, urq_install, urq_config, urq_remove;
  151. urqresult falliblesubprocess(const char *exepath, const char *name,
  152. const char *const *args);
  153. #endif /* DSELECT_H */