dselect.h 4.1 KB

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