pkginfo.cc 5.4 KB

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