dpkg (1.2.12); priority=LOW
[dpkg.git] / dselect / pkginfo.cc
blob718bc1fbb067eb9f017e949859008901aa95659c
1 /*
2 * dselect - Debian GNU/Linux package maintenance user interface
3 * pkginfo.cc - handles (re)draw of package list window infopad
5 * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.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
9 * published by the Free Software Foundation; either version 2,
10 * or (at your option) any later version.
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.
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.
22 #include <stdio.h>
23 #include <string.h>
24 #include <ncurses.h>
25 #include <assert.h>
26 #include <ctype.h>
28 extern "C" {
29 #include "config.h"
30 #include "dpkg.h"
31 #include "dpkg-db.h"
33 #include "dselect.h"
34 #include "bindings.h"
35 #include "helpmsgs.h"
37 const struct helpmenuentry *packagelist::helpmenulist() {
38 static const struct helpmenuentry
39 rw[]= {
40 { 'i', &hlp_mainintro },
41 { 'k', &hlp_listkeys },
42 { 'l', &hlp_displayexplain1 },
43 { 'd', &hlp_displayexplain2 },
44 { 0 }
46 ro[]= {
47 { 'i', &hlp_readonlyintro },
48 { 'k', &hlp_listkeys },
49 { 'l', &hlp_displayexplain1 },
50 { 'd', &hlp_displayexplain2 },
51 { 0 }
53 recur[]= {
54 { 'i', &hlp_recurintro },
55 { 'k', &hlp_listkeys },
56 { 'l', &hlp_displayexplain1 },
57 { 'd', &hlp_displayexplain2 },
58 { 0 }
60 return
61 !readwrite ? ro :
62 !recursive ? rw :
63 recur;
66 int packagelist::itr_recursive() { return recursive; }
68 const packagelist::infotype packagelist::infoinfos[]= {
69 { itr_recursive, itd_relations },
70 { 0, itd_description },
71 { 0, itd_statuscontrol },
72 { 0, itd_availablecontrol },
73 { 0, 0 }
76 const packagelist::infotype *const packagelist::baseinfo= infoinfos;
78 void packagelist::severalinfoblurb(const char *whatinfoline) {
79 whatinfovb(whatinfoline);
80 varbuf vb;
81 vb("The line you have highlighted represents many packages; "
82 "if you ask to install, remove, hold, &c it you will affect all "
83 "the packages which match the criterion shown.\n"
84 "\n"
85 "If you move the highlight to a line for a particular package "
86 "you will see information about that package displayed here."
87 "\n"
88 "You can use `o' and `O' to change the sort order and give yourself "
89 "the opportunity to mark packages in different kinds of groups.");
90 wordwrapinfo(0,vb.string());
93 void packagelist::itd_relations() {
94 if (table[cursorline]->pkg->name) {
95 whatinfovb("interrelationships affecting ");
96 whatinfovb(table[cursorline]->pkg->name);
97 if (debug) fprintf(debug,"packagelist[%p]::idt_relations(); `%s'\n",
98 this,table[cursorline]->relations.string());
99 waddstr(infopad,table[cursorline]->relations.string());
100 } else {
101 severalinfoblurb("interrelationships");
105 void packagelist::itd_description() {
106 if (table[cursorline]->pkg->name) {
107 whatinfovb("description of ");
108 whatinfovb(table[cursorline]->pkg->name);
110 const char *m= table[cursorline]->pkg->available.description;
111 if (!m || !*m) m= "no description available.";
112 const char *p= strchr(m,'\n');
113 int l= p ? (int)(p-m) : strlen(m);
114 wattrset(infopad,info_headattr);
115 waddstr(infopad, table[cursorline]->pkg->name);
116 waddstr(infopad," - ");
117 waddnstr(infopad,m,l);
118 wattrset(infopad,info_attr);
119 if (p) {
120 waddstr(infopad,"\n\n");
121 wordwrapinfo(1,++p);
123 } else {
124 severalinfoblurb("description");
128 void packagelist::itd_statuscontrol() {
129 werase(infopad);
130 if (!table[cursorline]->pkg->name) {
131 severalinfoblurb("currently installed control info");
132 } else {
133 whatinfovb("installed control info for ");
134 whatinfovb(table[cursorline]->pkg->name);
135 varbuf vb;
136 varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->installed);
137 vb.terminate();
138 if (debug)
139 fprintf(debug,"packagelist[%p]::idt_statuscontrol(); `%s'\n",this,vb.string());
140 waddstr(infopad,vb.string());
144 void packagelist::itd_availablecontrol() {
145 werase(infopad);
146 if (!table[cursorline]->pkg->name) {
147 severalinfoblurb("available version of control file info");
148 } else {
149 whatinfovb("available version of control info for ");
150 whatinfovb(table[cursorline]->pkg->name);
151 varbuf vb;
152 varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->available);
153 vb.terminate();
154 if (debug)
155 fprintf(debug,"packagelist[%p]::idt_availablecontrol(); `%s'\n",this,vb.string());
156 waddstr(infopad,vb.string());
160 void packagelist::redrawinfo() {
161 for (;;) {
162 if (!currentinfo || !currentinfo->display) currentinfo= baseinfo;
163 if (!currentinfo->relevant) break;
164 if ((this->*currentinfo->relevant)()) break;
165 currentinfo++;
167 if (!info_height) return;
168 whatinfovb.reset();
169 werase(infopad); wmove(infopad,0,0);
171 if (debug)
172 fprintf(debug,"packagelist[%p]::redrawinfo(); #=%d\n", this,
173 (int)(currentinfo - baseinfo));
175 (this->*currentinfo->display)();
176 whatinfovb.terminate();
177 int y,x;
178 getyx(infopad, y,x);
179 if (x) y++;
180 infolines= y;
182 refreshinfo();