dselect.h 4.1 KB

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