pkginfo.cc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 <assert.h>
  24. #include <ctype.h>
  25. extern "C" {
  26. #include <config.h>
  27. #include <dpkg.h>
  28. #include <dpkg-db.h>
  29. }
  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(const char *whatinfoline) {
  71. whatinfovb(whatinfoline);
  72. varbuf vb;
  73. vb(_("The line you have highlighted represents many packages; "
  74. "if you ask to install, remove, hold, &c 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. if (table[cursorline]->pkg->name) {
  86. whatinfovb(_("interrelationships affecting "));
  87. whatinfovb(table[cursorline]->pkg->name);
  88. if (debug) fprintf(debug,"packagelist[%p]::idt_relations(); `%s'\n",
  89. this,table[cursorline]->relations.string());
  90. waddstr(infopad,table[cursorline]->relations.string());
  91. } else {
  92. severalinfoblurb(_("interrelationships"));
  93. }
  94. }
  95. void packagelist::itd_description() {
  96. if (table[cursorline]->pkg->name) {
  97. whatinfovb(_("description of "));
  98. whatinfovb(table[cursorline]->pkg->name);
  99. const char *m= table[cursorline]->pkg->available.description;
  100. if (!m || !*m) m= _("no description available.");
  101. const char *p= strchr(m,'\n');
  102. int l= p ? (int)(p-m) : strlen(m);
  103. wattrset(infopad,info_headattr);
  104. waddstr(infopad, table[cursorline]->pkg->name);
  105. waddstr(infopad," - ");
  106. waddnstr(infopad,m,l);
  107. wattrset(infopad,info_attr);
  108. if (p) {
  109. waddstr(infopad,"\n\n");
  110. wordwrapinfo(1,++p);
  111. }
  112. } else {
  113. severalinfoblurb(_("description"));
  114. }
  115. }
  116. void packagelist::itd_statuscontrol() {
  117. werase(infopad);
  118. if (!table[cursorline]->pkg->name) {
  119. severalinfoblurb(_("currently installed control info"));
  120. } else {
  121. whatinfovb(_("installed control info for "));
  122. whatinfovb(table[cursorline]->pkg->name);
  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. werase(infopad);
  133. if (!table[cursorline]->pkg->name) {
  134. severalinfoblurb(_("available version of control file info"));
  135. } else {
  136. whatinfovb(_("available version of control info for "));
  137. whatinfovb(table[cursorline]->pkg->name);
  138. varbuf vb;
  139. varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->available);
  140. vb.terminate();
  141. if (debug)
  142. fprintf(debug,"packagelist[%p]::idt_availablecontrol(); `%s'\n",this,vb.string());
  143. waddstr(infopad,vb.string());
  144. }
  145. }
  146. void packagelist::redrawinfo() {
  147. for (;;) {
  148. if (!currentinfo || !currentinfo->display) currentinfo= baseinfo;
  149. if (!currentinfo->relevant) break;
  150. if ((this->*currentinfo->relevant)()) break;
  151. currentinfo++;
  152. }
  153. if (!info_height) return;
  154. whatinfovb.reset();
  155. werase(infopad); wmove(infopad,0,0);
  156. if (debug)
  157. fprintf(debug,"packagelist[%p]::redrawinfo(); #=%d\n", this,
  158. (int)(currentinfo - baseinfo));
  159. (this->*currentinfo->display)();
  160. whatinfovb.terminate();
  161. int y,x;
  162. getyx(infopad, y,x);
  163. if (x) y++;
  164. infolines= y;
  165. refreshinfo();
  166. }