pkginfo.cc 5.4 KB

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