Release 1.15.8
[dpkg.git] / dselect / pkginfo.cc
blob8ce15d9c00ec6ebfc91b90a1b790e1d3a48dde44
1 /*
2 * dselect - Debian package maintenance user interface
3 * pkginfo.cc - handles (re)draw of package list window infopad
5 * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
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.
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.
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/>.
21 #include <config.h>
22 #include <compat.h>
24 #include <ctype.h>
25 #include <string.h>
26 #include <stdio.h>
28 #include <dpkg/i18n.h>
29 #include <dpkg/dpkg.h>
30 #include <dpkg/dpkg-db.h>
32 #include "dselect.h"
33 #include "bindings.h"
34 #include "helpmsgs.h"
36 const struct helpmenuentry *packagelist::helpmenulist() {
37 static const struct helpmenuentry
38 rw[]= {
39 { 'i', &hlp_mainintro },
40 { 'k', &hlp_listkeys },
41 { 'l', &hlp_displayexplain1 },
42 { 'd', &hlp_displayexplain2 },
43 { 0 }
45 ro[]= {
46 { 'i', &hlp_readonlyintro },
47 { 'k', &hlp_listkeys },
48 { 'l', &hlp_displayexplain1 },
49 { 'd', &hlp_displayexplain2 },
50 { 0 }
52 recur[]= {
53 { 'i', &hlp_recurintro },
54 { 'k', &hlp_listkeys },
55 { 'l', &hlp_displayexplain1 },
56 { 'd', &hlp_displayexplain2 },
57 { 0 }
59 return
60 !readwrite ? ro :
61 !recursive ? rw :
62 recur;
65 int packagelist::itr_recursive() { return recursive; }
67 const packagelist::infotype packagelist::infoinfos[]= {
68 { &packagelist::itr_recursive, &packagelist::itd_relations },
69 { 0, &packagelist::itd_description },
70 { 0, &packagelist::itd_statuscontrol },
71 { 0, &packagelist::itd_availablecontrol },
72 { 0, 0 }
75 const packagelist::infotype *const packagelist::baseinfo= infoinfos;
77 void packagelist::severalinfoblurb()
79 varbuf vb;
80 vb(_("The line you have highlighted represents many packages; "
81 "if you ask to install, remove, hold, etc. it you will affect all "
82 "the packages which match the criterion shown.\n"
83 "\n"
84 "If you move the highlight to a line for a particular package "
85 "you will see information about that package displayed here."
86 "\n"
87 "You can use `o' and `O' to change the sort order and give yourself "
88 "the opportunity to mark packages in different kinds of groups."));
89 wordwrapinfo(0,vb.string());
92 void packagelist::itd_relations() {
93 whatinfovb(_("Interrelationships"));
95 if (table[cursorline]->pkg->name) {
96 if (debug) fprintf(debug,"packagelist[%p]::idt_relations(); `%s'\n",
97 this,table[cursorline]->relations.string());
98 waddstr(infopad,table[cursorline]->relations.string());
99 } else {
100 severalinfoblurb();
104 void packagelist::itd_description() {
105 whatinfovb(_("Description"));
107 if (table[cursorline]->pkg->name) {
108 const char *m= table[cursorline]->pkg->available.description;
109 if (!m || !*m)
110 m = table[cursorline]->pkg->installed.description;
111 if (!m || !*m)
112 m = _("No description available.");
113 const char *p= strchr(m,'\n');
114 int l= p ? (int)(p-m) : strlen(m);
115 wattrset(infopad,info_headattr);
116 waddstr(infopad, table[cursorline]->pkg->name);
117 waddstr(infopad," - ");
118 waddnstr(infopad,m,l);
119 wattrset(infopad,info_attr);
120 if (p) {
121 waddstr(infopad,"\n\n");
122 wordwrapinfo(1,++p);
124 } else {
125 severalinfoblurb();
129 void packagelist::itd_statuscontrol() {
130 whatinfovb(_("Installed control file information"));
132 werase(infopad);
133 if (!table[cursorline]->pkg->name) {
134 severalinfoblurb();
135 } else {
136 varbuf vb;
137 varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->installed);
138 vb.terminate();
139 if (debug)
140 fprintf(debug,"packagelist[%p]::idt_statuscontrol(); `%s'\n",this,vb.string());
141 waddstr(infopad,vb.string());
145 void packagelist::itd_availablecontrol() {
146 whatinfovb(_("Available control file information"));
148 werase(infopad);
149 if (!table[cursorline]->pkg->name) {
150 severalinfoblurb();
151 } else {
152 varbuf vb;
153 varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->available);
154 vb.terminate();
155 if (debug)
156 fprintf(debug,"packagelist[%p]::idt_availablecontrol(); `%s'\n",this,vb.string());
157 waddstr(infopad,vb.string());
161 void packagelist::redrawinfo() {
162 for (;;) {
163 if (!currentinfo || !currentinfo->display) currentinfo= baseinfo;
164 if (!currentinfo->relevant) break;
165 if ((this->*currentinfo->relevant)()) break;
166 currentinfo++;
168 if (!info_height) return;
169 whatinfovb.reset();
170 werase(infopad); wmove(infopad,0,0);
172 if (debug)
173 fprintf(debug,"packagelist[%p]::redrawinfo(); #=%d\n", this,
174 (int)(currentinfo - baseinfo));
176 (this->*currentinfo->display)();
177 whatinfovb.terminate();
178 int y,x;
179 getyx(infopad, y,x);
180 if (x) y++;
181 infolines= y;
183 refreshinfo();