dselect.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* -*- c++ -*-
  2. * dselect - Debian package maintenance user interface
  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 published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful,
  14. * but 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 <algorithm>
  25. using std::min;
  26. using std::max;
  27. #include <dpkg/debug.h>
  28. #include "dselect-curses.h"
  29. #define DSELECT "dselect"
  30. #define TOTAL_LIST_WIDTH 180
  31. #define MAX_DISPLAY_INFO 120
  32. struct helpmenuentry {
  33. char key;
  34. const struct helpmessage *msg;
  35. };
  36. struct keybindings;
  37. class baselist {
  38. protected:
  39. // Screen dimensions &c.
  40. int xmax, ymax;
  41. int title_height, colheads_height, list_height;
  42. int thisstate_height, info_height, whatinfo_height;
  43. int colheads_row, thisstate_row, info_row, whatinfo_row, list_row;
  44. int list_attr, listsel_attr, title_attr, colheads_attr, info_attr;
  45. int info_headattr, whatinfo_attr;
  46. int thisstate_attr, query_attr;
  47. int selstate_attr, selstatesel_attr;
  48. int helpscreen_attr;
  49. int total_width;
  50. // (n)curses stuff
  51. WINDOW *listpad, *infopad, *colheadspad, *thisstatepad;
  52. WINDOW *titlewin, *whatinfowin, *querywin;
  53. // If listpad is null, then we have not started to display yet, and
  54. // so none of the auto-displaying update routines need to display.
  55. // SIGWINCH handling
  56. struct sigaction *osigactp, nsigact;
  57. sigset_t *oblockedp, sigwinchset;
  58. void setupsigwinch();
  59. static baselist *signallist;
  60. static void sigwinchhandler(int);
  61. int nitems, ldrawnstart, ldrawnend, showinfo;
  62. int topofscreen, leftofscreen, cursorline;
  63. int infotopofscreen, infolines;
  64. varbuf whatinfovb;
  65. char searchstring[128];
  66. virtual void setheights();
  67. void unsizes();
  68. void dosearch();
  69. void displayhelp(const struct helpmenuentry *menu, int key);
  70. void displayerror(const char* str);
  71. void redrawall();
  72. void redrawitemsrange(int start /*inclusive*/, int end /*exclusive*/);
  73. void redraw1item(int index);
  74. void refreshlist();
  75. void refreshinfo();
  76. void refreshcolheads();
  77. void setcursor(int index);
  78. void itd_keys();
  79. virtual void redraw1itemsel(int index, int selected) =0;
  80. virtual void redrawcolheads() =0;
  81. virtual void redrawthisstate() =0;
  82. virtual void redrawinfo() =0;
  83. virtual void redrawtitle() =0;
  84. virtual void setwidths() =0;
  85. virtual const char *itemname(int index) =0;
  86. virtual const struct helpmenuentry *helpmenulist() =0;
  87. virtual bool checksearch(char *str);
  88. virtual bool matchsearch(int index);
  89. void wordwrapinfo(int offset, const char *string);
  90. public:
  91. keybindings *bindings;
  92. void kd_up();
  93. void kd_down();
  94. void kd_redraw();
  95. void kd_scrollon();
  96. void kd_scrollback();
  97. void kd_scrollon1();
  98. void kd_scrollback1();
  99. void kd_panon();
  100. void kd_panback();
  101. void kd_panon1();
  102. void kd_panback1();
  103. void kd_top();
  104. void kd_bottom();
  105. void kd_iscrollon();
  106. void kd_iscrollback();
  107. void kd_iscrollon1();
  108. void kd_iscrollback1();
  109. void kd_search();
  110. void kd_searchagain();
  111. void kd_help();
  112. void startdisplay();
  113. void enddisplay();
  114. baselist(keybindings*);
  115. virtual ~baselist();
  116. };
  117. void displayhelp(const struct helpmenuentry *menu, int key);
  118. void mywerase(WINDOW *win);
  119. void curseson();
  120. void cursesoff();
  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. #endif /* DSELECT_H */