pkginfo.cc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * dselect - Debian GNU/Linux package maintenance user interface
  3. * pkginfo.cc - handles (re)draw of package list window infopad
  4. *
  5. * Copyright (C) 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 this; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include <curses.h>
  24. #include <assert.h>
  25. #include <ctype.h>
  26. extern "C" {
  27. #include <config.h>
  28. #include <dpkg.h>
  29. #include <dpkg-db.h>
  30. }
  31. #include "dselect.h"
  32. #include "bindings.h"
  33. #include "helpmsgs.h"
  34. const struct helpmenuentry *packagelist::helpmenulist() {
  35. static const struct helpmenuentry
  36. rw[]= {
  37. { 'i', &hlp_mainintro },
  38. { 'k', &hlp_listkeys },
  39. { 'l', &hlp_displayexplain1 },
  40. { 'd', &hlp_displayexplain2 },
  41. { 0 }
  42. },
  43. ro[]= {
  44. { 'i', &hlp_readonlyintro },
  45. { 'k', &hlp_listkeys },
  46. { 'l', &hlp_displayexplain1 },
  47. { 'd', &hlp_displayexplain2 },
  48. { 0 }
  49. },
  50. recur[]= {
  51. { 'i', &hlp_recurintro },
  52. { 'k', &hlp_listkeys },
  53. { 'l', &hlp_displayexplain1 },
  54. { 'd', &hlp_displayexplain2 },
  55. { 0 }
  56. };
  57. return
  58. !readwrite ? ro :
  59. !recursive ? rw :
  60. recur;
  61. }
  62. int packagelist::itr_recursive() { return recursive; }
  63. const packagelist::infotype packagelist::infoinfos[]= {
  64. { &packagelist::itr_recursive, &packagelist::itd_relations },
  65. { 0, &packagelist::itd_description },
  66. { 0, &packagelist::itd_statuscontrol },
  67. { 0, &packagelist::itd_availablecontrol },
  68. { 0, 0 }
  69. };
  70. const packagelist::infotype *const packagelist::baseinfo= infoinfos;
  71. void packagelist::severalinfoblurb(const char *whatinfoline) {
  72. whatinfovb(whatinfoline);
  73. varbuf vb;
  74. vb(_("The line you have highlighted represents many packages; "
  75. "if you ask to install, remove, hold, &c it you will affect all "
  76. "the packages which match the criterion shown.\n"
  77. "\n"
  78. "If you move the highlight to a line for a particular package "
  79. "you will see information about that package displayed here."
  80. "\n"
  81. "You can use `o' and `O' to change the sort order and give yourself "
  82. "the opportunity to mark packages in different kinds of groups."));
  83. wordwrapinfo(0,vb.string());
  84. }
  85. void packagelist::itd_relations() {
  86. if (table[cursorline]->pkg->name) {
  87. whatinfovb(_("interrelationships affecting "));
  88. whatinfovb(table[cursorline]->pkg->name);
  89. if (debug) fprintf(debug,"packagelist[%p]::idt_relations(); `%s'\n",
  90. this,table[cursorline]->relations.string());
  91. waddstr(infopad,table[cursorline]->relations.string());
  92. } else {
  93. severalinfoblurb(_("interrelationships"));
  94. }
  95. }
  96. void packagelist::itd_description() {
  97. if (table[cursorline]->pkg->name) {
  98. whatinfovb(_("description of "));
  99. whatinfovb(table[cursorline]->pkg->name);
  100. const char *m= table[cursorline]->pkg->available.description;
  101. if (!m || !*m) m= _("no description available.");
  102. const char *p= strchr(m,'\n');
  103. int l= p ? (int)(p-m) : strlen(m);
  104. wattrset(infopad,info_headattr);
  105. waddstr(infopad, table[cursorline]->pkg->name);
  106. waddstr(infopad," - ");
  107. waddnstr(infopad,m,l);
  108. wattrset(infopad,info_attr);
  109. if (p) {
  110. waddstr(infopad,"\n\n");
  111. wordwrapinfo(1,++p);
  112. }
  113. } else {
  114. severalinfoblurb(_("description"));
  115. }
  116. }
  117. void packagelist::itd_statuscontrol() {
  118. werase(infopad);
  119. if (!table[cursorline]->pkg->name) {
  120. severalinfoblurb(_("currently installed control info"));
  121. } else {
  122. whatinfovb(_("installed control info for "));
  123. whatinfovb(table[cursorline]->pkg->name);
  124. varbuf vb;
  125. varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->installed);
  126. vb.terminate();
  127. if (debug)
  128. fprintf(debug,"packagelist[%p]::idt_statuscontrol(); `%s'\n",this,vb.string());
  129. waddstr(infopad,vb.string());
  130. }
  131. }
  132. void packagelist::itd_availablecontrol() {
  133. werase(infopad);
  134. if (!table[cursorline]->pkg->name) {
  135. severalinfoblurb(_("available version of control file info"));
  136. } else {
  137. whatinfovb(_("available version of control info for "));
  138. whatinfovb(table[cursorline]->pkg->name);
  139. varbuf vb;
  140. varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->available);
  141. vb.terminate();
  142. if (debug)
  143. fprintf(debug,"packagelist[%p]::idt_availablecontrol(); `%s'\n",this,vb.string());
  144. waddstr(infopad,vb.string());
  145. }
  146. }
  147. void packagelist::redrawinfo() {
  148. for (;;) {
  149. if (!currentinfo || !currentinfo->display) currentinfo= baseinfo;
  150. if (!currentinfo->relevant) break;
  151. if ((this->*currentinfo->relevant)()) break;
  152. currentinfo++;
  153. }
  154. if (!info_height) return;
  155. whatinfovb.reset();
  156. werase(infopad); wmove(infopad,0,0);
  157. if (debug)
  158. fprintf(debug,"packagelist[%p]::redrawinfo(); #=%d\n", this,
  159. (int)(currentinfo - baseinfo));
  160. (this->*currentinfo->display)();
  161. whatinfovb.terminate();
  162. int y,x;
  163. getyx(infopad, y,x);
  164. if (x) y++;
  165. infolines= y;
  166. refreshinfo();
  167. }