dselect.h 4.3 KB

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