dselect.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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
  19. * License along with dpkg; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #ifndef DSELECT_H
  23. #define DSELECT_H
  24. #define DSELECT "dselect"
  25. #define TOTAL_LIST_WIDTH 180
  26. #define MAX_DISPLAY_INFO 120
  27. #include <signal.h>
  28. #include "dselect-curses.h"
  29. struct helpmenuentry {
  30. char key;
  31. const struct helpmessage *msg;
  32. };
  33. class keybindings;
  34. class baselist {
  35. protected:
  36. // Screen dimensions &c.
  37. int xmax, ymax;
  38. int title_height, colheads_height, list_height;
  39. int thisstate_height, info_height, whatinfo_height;
  40. int colheads_row, thisstate_row, info_row, whatinfo_row, list_row;
  41. int list_attr, listsel_attr, title_attr, colheads_attr, info_attr;
  42. int info_headattr, whatinfo_attr;
  43. int thisstate_attr, query_attr;
  44. int selstate_attr, selstatesel_attr;
  45. int helpscreen_attr;
  46. int total_width;
  47. // (n)curses stuff
  48. WINDOW *listpad, *infopad, *colheadspad, *thisstatepad;
  49. WINDOW *titlewin, *whatinfowin, *querywin;
  50. // If listpad is null, then we have not started to display yet, and
  51. // so none of the auto-displaying update routines need to display.
  52. // SIGWINCH handling
  53. struct sigaction *osigactp, nsigact;
  54. sigset_t *oblockedp, sigwinchset;
  55. void setupsigwinch();
  56. static baselist *signallist;
  57. static void sigwinchhandler(int);
  58. int nitems, ldrawnstart, ldrawnend, showinfo;
  59. int topofscreen, leftofscreen, cursorline;
  60. int infotopofscreen, infolines;
  61. varbuf whatinfovb;
  62. char searchstring[128];
  63. virtual void setheights();
  64. void unsizes();
  65. void dosearch();
  66. void displayhelp(const struct helpmenuentry *menu, int key);
  67. void displayerror(const char* str);
  68. void redrawall();
  69. void redrawitemsrange(int start /*inclusive*/, int end /*exclusive*/);
  70. void redraw1item(int index);
  71. void refreshlist();
  72. void refreshinfo();
  73. void refreshcolheads();
  74. void setcursor(int index);
  75. void itd_keys();
  76. virtual void redraw1itemsel(int index, int selected) =0;
  77. virtual void redrawcolheads() =0;
  78. virtual void redrawthisstate() =0;
  79. virtual void redrawinfo() =0;
  80. virtual void redrawtitle() =0;
  81. virtual void setwidths() =0;
  82. virtual const char *itemname(int index) =0;
  83. virtual const struct helpmenuentry *helpmenulist() =0;
  84. virtual int checksearch(char* str);
  85. virtual int matchsearch(int index);
  86. void wordwrapinfo(int offset, const char *string);
  87. public:
  88. keybindings *bindings;
  89. void kd_up();
  90. void kd_down();
  91. void kd_redraw();
  92. void kd_scrollon();
  93. void kd_scrollback();
  94. void kd_scrollon1();
  95. void kd_scrollback1();
  96. void kd_panon();
  97. void kd_panback();
  98. void kd_panon1();
  99. void kd_panback1();
  100. void kd_top();
  101. void kd_bottom();
  102. void kd_iscrollon();
  103. void kd_iscrollback();
  104. void kd_iscrollon1();
  105. void kd_iscrollback1();
  106. void kd_search();
  107. void kd_searchagain();
  108. void kd_help();
  109. void startdisplay();
  110. void enddisplay();
  111. baselist(keybindings*);
  112. virtual ~baselist();
  113. };
  114. static inline int lesserint(int a, int b) { return a<b ? a : b; }
  115. static inline int greaterint(int a, int b) { return a>b ? a : b; }
  116. void displayhelp(const struct helpmenuentry *menu, int key);
  117. void mywerase(WINDOW *win);
  118. void curseson();
  119. void cursesoff();
  120. extern const char *admindir;
  121. extern FILE *debug;
  122. extern int expertmode;
  123. enum screenparts {
  124. background,
  125. list,
  126. listsel,
  127. title,
  128. thisstate,
  129. selstate,
  130. selstatesel,
  131. colheads,
  132. query,
  133. info,
  134. info_head,
  135. whatinfo,
  136. helpscreen,
  137. numscreenparts,
  138. };
  139. struct colordata {
  140. int fore;
  141. int back;
  142. int attr;
  143. };
  144. extern colordata color[];
  145. /* Evil recommends flag variable. */
  146. extern int manual_install;
  147. enum urqresult { urqr_normal, urqr_fail, urqr_quitmenu };
  148. enum quitaction { qa_noquit, qa_quitchecksave, qa_quitnochecksave };
  149. typedef urqresult urqfunction(void);
  150. urqfunction urq_list, urq_quit, urq_menu;
  151. urqfunction urq_setup, urq_update, urq_install, urq_config, urq_remove;
  152. urqresult falliblesubprocess(const char *exepath, const char *name,
  153. const char *const *args);
  154. #endif /* DSELECT_H */