pkginfo.cc 5.7 KB

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