dselect.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* -*- c++ -*-
  2. * dselect - selection of Debian packages
  3. * dselect.h - external definitions for this program
  4. *
  5. * Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk>
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2,
  10. * or (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with dpkg; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #ifndef DSELECT_H
  22. #define DSELECT_H
  23. #define TOTAL_LIST_WIDTH 180
  24. #define MAX_DISPLAY_INFO 120
  25. #include <signal.h>
  26. #undef ERR
  27. #include <curses.h>
  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[50];
  62. virtual void setheights();
  63. void unsizes();
  64. void dosearch();
  65. void displayhelp(const struct helpmenuentry *menu, int key);
  66. void redrawall();
  67. void redrawitemsrange(int start /*inclusive*/, int end /*exclusive*/);
  68. void redraw1item(int index);
  69. void refreshlist();
  70. void refreshinfo();
  71. void refreshcolheads();
  72. void setcursor(int index);
  73. void itd_keys();
  74. virtual void redraw1itemsel(int index, int selected) =0;
  75. virtual void redrawcolheads() =0;
  76. virtual void redrawthisstate() =0;
  77. virtual void redrawinfo() =0;
  78. virtual void redrawtitle() =0;
  79. virtual void setwidths() =0;
  80. virtual const char *itemname(int index) =0;
  81. virtual const struct helpmenuentry *helpmenulist() =0;
  82. void wordwrapinfo(int offset, const char *string);
  83. public:
  84. keybindings *bindings;
  85. void kd_up();
  86. void kd_down();
  87. void kd_redraw();
  88. void kd_scrollon();
  89. void kd_scrollback();
  90. void kd_scrollon1();
  91. void kd_scrollback1();
  92. void kd_panon();
  93. void kd_panback();
  94. void kd_panon1();
  95. void kd_panback1();
  96. void kd_top();
  97. void kd_bottom();
  98. void kd_iscrollon();
  99. void kd_iscrollback();
  100. void kd_iscrollon1();
  101. void kd_iscrollback1();
  102. void kd_search();
  103. void kd_searchagain();
  104. void kd_help();
  105. void startdisplay();
  106. void enddisplay();
  107. baselist(keybindings*);
  108. virtual ~baselist();
  109. };
  110. static inline int lesserint(int a, int b) { return a<b ? a : b; }
  111. static inline int greaterint(int a, int b) { return a>b ? a : b; }
  112. void displayhelp(const struct helpmenuentry *menu, int key);
  113. void mywerase(WINDOW *win);
  114. void curseson();
  115. void cursesoff();
  116. extern const char *admindir;
  117. extern FILE *debug;
  118. extern int expertmode;
  119. enum screenparts {
  120. background,
  121. list,
  122. listsel,
  123. title,
  124. thisstate,
  125. selstate,
  126. selstatesel,
  127. colheads,
  128. query,
  129. info,
  130. info_head,
  131. whatinfo,
  132. helpscreen,
  133. numscreenparts,
  134. };
  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. urqresult falliblesubprocess(const char *exepath, const char *name,
  149. const char *const *args);
  150. #endif /* DSELECT_H */