pkginfo.cc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. bool
  61. packagelist::itr_recursive()
  62. {
  63. return recursive;
  64. }
  65. const packagelist::infotype packagelist::infoinfos[]= {
  66. { &packagelist::itr_recursive, &packagelist::itd_relations },
  67. { 0, &packagelist::itd_description },
  68. { 0, &packagelist::itd_statuscontrol },
  69. { 0, &packagelist::itd_availablecontrol },
  70. { 0, 0 }
  71. };
  72. const packagelist::infotype *const packagelist::baseinfo= infoinfos;
  73. void packagelist::severalinfoblurb()
  74. {
  75. varbuf vb;
  76. vb(_("The line you have highlighted represents many packages; "
  77. "if you ask to install, remove, hold, etc. it you will affect all "
  78. "the packages which match the criterion shown.\n"
  79. "\n"
  80. "If you move the highlight to a line for a particular package "
  81. "you will see information about that package displayed here."
  82. "\n"
  83. "You can use `o' and `O' to change the sort order and give yourself "
  84. "the opportunity to mark packages in different kinds of groups."));
  85. wordwrapinfo(0,vb.string());
  86. }
  87. void packagelist::itd_relations() {
  88. whatinfovb(_("Interrelationships"));
  89. if (table[cursorline]->pkg->set->name) {
  90. debug(dbg_general, "packagelist[%p]::idt_relations(); '%s'",
  91. this, table[cursorline]->relations.string());
  92. waddstr(infopad,table[cursorline]->relations.string());
  93. } else {
  94. severalinfoblurb();
  95. }
  96. }
  97. void packagelist::itd_description() {
  98. whatinfovb(_("Description"));
  99. if (table[cursorline]->pkg->set->name) {
  100. const char *m= table[cursorline]->pkg->available.description;
  101. if (str_is_unset(m))
  102. m = table[cursorline]->pkg->installed.description;
  103. if (str_is_unset(m))
  104. m = _("No description available.");
  105. const char *p= strchr(m,'\n');
  106. int l= p ? (int)(p-m) : strlen(m);
  107. wattrset(infopad, part_attr[info_head]);
  108. waddstr(infopad, table[cursorline]->pkg->set->name);
  109. waddstr(infopad," - ");
  110. waddnstr(infopad,m,l);
  111. wattrset(infopad, part_attr[info]);
  112. if (p) {
  113. waddstr(infopad,"\n\n");
  114. wordwrapinfo(1,++p);
  115. }
  116. } else {
  117. severalinfoblurb();
  118. }
  119. }
  120. void packagelist::itd_statuscontrol() {
  121. whatinfovb(_("Installed control file information"));
  122. werase(infopad);
  123. if (!table[cursorline]->pkg->set->name) {
  124. severalinfoblurb();
  125. } else {
  126. varbuf vb;
  127. varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->installed);
  128. vb.terminate();
  129. debug(dbg_general, "packagelist[%p]::idt_statuscontrol(); '%s'",
  130. this, vb.string());
  131. waddstr(infopad,vb.string());
  132. }
  133. }
  134. void packagelist::itd_availablecontrol() {
  135. whatinfovb(_("Available control file information"));
  136. werase(infopad);
  137. if (!table[cursorline]->pkg->set->name) {
  138. severalinfoblurb();
  139. } else {
  140. varbuf vb;
  141. varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->available);
  142. vb.terminate();
  143. debug(dbg_general, "packagelist[%p]::idt_availablecontrol(); '%s'",
  144. this, vb.string());
  145. waddstr(infopad,vb.string());
  146. }
  147. }
  148. void packagelist::redrawinfo() {
  149. for (;;) {
  150. if (!currentinfo || !currentinfo->display) currentinfo= baseinfo;
  151. if (!currentinfo->relevant) break;
  152. if ((this->*currentinfo->relevant)()) break;
  153. currentinfo++;
  154. }
  155. if (!info_height) return;
  156. whatinfovb.reset();
  157. werase(infopad); wmove(infopad,0,0);
  158. debug(dbg_general, "packagelist[%p]::redrawinfo(); #=%d",
  159. this, (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. }