dselect.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. enum screenparts {
  38. background,
  39. list,
  40. listsel,
  41. title,
  42. thisstate,
  43. selstate,
  44. selstatesel,
  45. colheads,
  46. query,
  47. info,
  48. info_head,
  49. whatinfo,
  50. helpscreen,
  51. numscreenparts,
  52. };
  53. class baselist {
  54. protected:
  55. // Screen dimensions &c.
  56. int xmax, ymax;
  57. int title_height, colheads_height, list_height;
  58. int thisstate_height, info_height, whatinfo_height;
  59. int colheads_row, thisstate_row, info_row, whatinfo_row, list_row;
  60. int part_attr[numscreenparts];
  61. int gap_width;
  62. int total_width;
  63. // (n)curses stuff
  64. WINDOW *listpad, *infopad, *colheadspad, *thisstatepad;
  65. WINDOW *titlewin, *whatinfowin, *querywin;
  66. // If listpad is null, then we have not started to display yet, and
  67. // so none of the auto-displaying update routines need to display.
  68. // SIGWINCH handling
  69. struct sigaction *osigactp, nsigact;
  70. sigset_t *oblockedp, sigwinchset;
  71. void setupsigwinch();
  72. static baselist *signallist;
  73. static void sigwinchhandler(int);
  74. int nitems, ldrawnstart, ldrawnend, showinfo;
  75. int topofscreen, leftofscreen, cursorline;
  76. int infotopofscreen, infolines;
  77. varbuf whatinfovb;
  78. char searchstring[128];
  79. virtual void setheights();
  80. void unsizes();
  81. void dosearch();
  82. void displayhelp(const struct helpmenuentry *menu, int key);
  83. void displayerror(const char* str);
  84. void redrawall();
  85. void redrawitemsrange(int start /*inclusive*/, int end /*exclusive*/);
  86. void redraw1item(int index);
  87. void refreshlist();
  88. void refreshinfo();
  89. void refreshcolheads();
  90. void setcursor(int index);
  91. void itd_keys();
  92. virtual void redraw1itemsel(int index, int selected) =0;
  93. virtual void redrawcolheads() =0;
  94. virtual void redrawthisstate() =0;
  95. virtual void redrawinfo() =0;
  96. virtual void redrawtitle() =0;
  97. virtual void setwidths() =0;
  98. virtual const char *itemname(int index) =0;
  99. virtual const struct helpmenuentry *helpmenulist() =0;
  100. virtual bool checksearch(char *str);
  101. virtual bool matchsearch(int index);
  102. void wordwrapinfo(int offset, const char *string);
  103. public:
  104. keybindings *bindings;
  105. void kd_up();
  106. void kd_down();
  107. void kd_redraw();
  108. void kd_scrollon();
  109. void kd_scrollback();
  110. void kd_scrollon1();
  111. void kd_scrollback1();
  112. void kd_panon();
  113. void kd_panback();
  114. void kd_panon1();
  115. void kd_panback1();
  116. void kd_top();
  117. void kd_bottom();
  118. void kd_iscrollon();
  119. void kd_iscrollback();
  120. void kd_iscrollon1();
  121. void kd_iscrollback1();
  122. void kd_search();
  123. void kd_searchagain();
  124. void kd_help();
  125. void startdisplay();
  126. void enddisplay();
  127. baselist(keybindings*);
  128. virtual ~baselist();
  129. };
  130. void displayhelp(const struct helpmenuentry *menu, int key);
  131. void mywerase(WINDOW *win);
  132. void curseson();
  133. void cursesoff();
  134. extern int expertmode;
  135. struct colordata {
  136. int fore;
  137. int back;
  138. int attr;
  139. };
  140. extern colordata color[];
  141. /* Evil recommends flag variable. */
  142. extern int manual_install;
  143. enum urqresult { urqr_normal, urqr_fail, urqr_quitmenu };
  144. enum quitaction { qa_noquit, qa_quitchecksave, qa_quitnochecksave };
  145. typedef urqresult urqfunction(void);
  146. urqfunction urq_list, urq_quit, urq_menu;
  147. urqfunction urq_setup, urq_update, urq_install, urq_config, urq_remove;
  148. #endif /* DSELECT_H */