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 published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful,
  13. * but 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 <dpkg/string.h>
  29. #include "dselect.h"
  30. #include "bindings.h"
  31. #include "helpmsgs.h"
  32. const struct helpmenuentry *packagelist::helpmenulist() {
  33. static const struct helpmenuentry
  34. rw[]= {
  35. { 'i', &hlp_mainintro },
  36. { 'k', &hlp_listkeys },
  37. { 'l', &hlp_displayexplain1 },
  38. { 'd', &hlp_displayexplain2 },
  39. { 0 }
  40. },
  41. ro[]= {
  42. { 'i', &hlp_readonlyintro },
  43. { 'k', &hlp_listkeys },
  44. { 'l', &hlp_displayexplain1 },
  45. { 'd', &hlp_displayexplain2 },
  46. { 0 }
  47. },
  48. recur[]= {
  49. { 'i', &hlp_recurintro },
  50. { 'k', &hlp_listkeys },
  51. { 'l', &hlp_displayexplain1 },
  52. { 'd', &hlp_displayexplain2 },
  53. { 0 }
  54. };
  55. return
  56. modstatdb_get_status() == msdbrw_readonly ? ro :
  57. !recursive ? rw :
  58. recur;
  59. }
  60. int packagelist::itr_recursive() { return recursive; }
  61. const packagelist::infotype packagelist::infoinfos[]= {
  62. { &packagelist::itr_recursive, &packagelist::itd_relations },
  63. { 0, &packagelist::itd_description },
  64. { 0, &packagelist::itd_statuscontrol },
  65. { 0, &packagelist::itd_availablecontrol },
  66. { 0, 0 }
  67. };
  68. const packagelist::infotype *const packagelist::baseinfo= infoinfos;
  69. void packagelist::severalinfoblurb()
  70. {
  71. varbuf vb;
  72. vb(_("The line you have highlighted represents many packages; "
  73. "if you ask to install, remove, hold, etc. it you will affect all "
  74. "the packages which match the criterion shown.\n"
  75. "\n"
  76. "If you move the highlight to a line for a particular package "
  77. "you will see information about that package displayed here."
  78. "\n"
  79. "You can use `o' and `O' to change the sort order and give yourself "
  80. "the opportunity to mark packages in different kinds of groups."));
  81. wordwrapinfo(0,vb.string());
  82. }
  83. void packagelist::itd_relations() {
  84. whatinfovb(_("Interrelationships"));
  85. if (table[cursorline]->pkg->set->name) {
  86. debug(dbg_general, "packagelist[%p]::idt_relations(); '%s'",
  87. this, table[cursorline]->relations.string());
  88. waddstr(infopad,table[cursorline]->relations.string());
  89. } else {
  90. severalinfoblurb();
  91. }
  92. }
  93. void packagelist::itd_description() {
  94. whatinfovb(_("Description"));
  95. if (table[cursorline]->pkg->set->name) {
  96. const char *m= table[cursorline]->pkg->available.description;
  97. if (str_is_unset(m))
  98. m = table[cursorline]->pkg->installed.description;
  99. if (str_is_unset(m))
  100. m = _("No description available.");
  101. const char *p= strchr(m,'\n');
  102. int l= p ? (int)(p-m) : strlen(m);
  103. wattrset(infopad, part_attr[info_head]);
  104. waddstr(infopad, table[cursorline]->pkg->set->name);
  105. waddstr(infopad," - ");
  106. waddnstr(infopad,m,l);
  107. wattrset(infopad, part_attr[info]);
  108. if (p) {
  109. waddstr(infopad,"\n\n");
  110. wordwrapinfo(1,++p);
  111. }
  112. } else {
  113. severalinfoblurb();
  114. }
  115. }
  116. void packagelist::itd_statuscontrol() {
  117. whatinfovb(_("Installed control file information"));
  118. werase(infopad);
  119. if (!table[cursorline]->pkg->set->name) {
  120. severalinfoblurb();
  121. } else {
  122. varbuf vb;
  123. varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->installed);
  124. vb.terminate();
  125. debug(dbg_general, "packagelist[%p]::idt_statuscontrol(); '%s'",
  126. this, vb.string());
  127. waddstr(infopad,vb.string());
  128. }
  129. }
  130. void packagelist::itd_availablecontrol() {
  131. whatinfovb(_("Available control file information"));
  132. werase(infopad);
  133. if (!table[cursorline]->pkg->set->name) {
  134. severalinfoblurb();
  135. } else {
  136. varbuf vb;
  137. varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->available);
  138. vb.terminate();
  139. debug(dbg_general, "packagelist[%p]::idt_availablecontrol(); '%s'",
  140. this, vb.string());
  141. waddstr(infopad,vb.string());
  142. }
  143. }
  144. void packagelist::redrawinfo() {
  145. for (;;) {
  146. if (!currentinfo || !currentinfo->display) currentinfo= baseinfo;
  147. if (!currentinfo->relevant) break;
  148. if ((this->*currentinfo->relevant)()) break;
  149. currentinfo++;
  150. }
  151. if (!info_height) return;
  152. whatinfovb.reset();
  153. werase(infopad); wmove(infopad,0,0);
  154. debug(dbg_general, "packagelist[%p]::redrawinfo(); #=%d",
  155. this, (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. }