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