2 * dselect - Debian package maintenance user interface
3 * pkgtop.cc - handles (re)draw of package list windows colheads, list, thisstate
5 * Copyright © 1994,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/>.
29 #include <dpkg/i18n.h>
30 #include <dpkg/dpkg.h>
31 #include <dpkg/dpkg-db.h>
37 pkgprioritystring(const struct pkginfo
*pkg
)
39 if (pkg
->priority
== pkginfo::pri_unset
) {
41 } else if (pkg
->priority
== pkginfo::pri_other
) {
42 return pkg
->otherpriority
;
44 assert(pkg
->priority
<= pkginfo::pri_unknown
);
45 return gettext(prioritystrings
[pkg
->priority
]);
49 int packagelist::describemany(char buf
[], const char *prioritystring
,
51 const struct perpackagestate
*pps
) {
52 const char *ssostring
, *ssoabbrev
;
58 switch (statsortorder
) {
60 if (pps
->ssavail
== -1) break;
61 ssostring
= ssastrings
[pps
->ssavail
];
62 ssoabbrev
= ssaabbrevs
[pps
->ssavail
];
66 if (pps
->ssstate
== -1) break;
67 ssostring
= sssstrings
[pps
->ssstate
];
68 ssoabbrev
= sssabbrevs
[pps
->ssstate
];
74 internerr("unknown statsortrder in describemany all");
77 if (!prioritystring
) {
79 strcpy(buf
, ssostring
? gettext(ssostring
) : _("All packages"));
83 sprintf(buf
,_("%s packages without a section"),gettext(ssoabbrev
));
85 sprintf(buf
,_("%s packages in section %s"),gettext(ssoabbrev
),section
);
91 sprintf(buf
,_("%s %s packages"),gettext(ssoabbrev
),prioritystring
);
95 sprintf(buf
,_("%s %s packages without a section"),gettext(ssoabbrev
),prioritystring
);
97 sprintf(buf
,_("%s %s packages in section %s"),gettext(ssoabbrev
),prioritystring
,section
);
104 void packagelist::redrawthisstate() {
105 if (!thisstate_height
) return;
106 mywerase(thisstatepad
);
108 const char *section
= table
[cursorline
]->pkg
->section
;
109 const char *priority
= pkgprioritystring(table
[cursorline
]->pkg
);
110 char *buf
= new char[500+
111 max((table
[cursorline
]->pkg
->name
?
112 strlen(table
[cursorline
]->pkg
->name
) : 0),
113 (section
? strlen(section
) : 0) +
114 (priority
? strlen(priority
) : 0))];
116 if (table
[cursorline
]->pkg
->name
) {
118 _("%-*s %s%s%s; %s (was: %s). %s"),
120 table
[cursorline
]->pkg
->name
,
121 gettext(statusstrings
[table
[cursorline
]->pkg
->status
]),
122 ((eflagstrings
[table
[cursorline
]->pkg
->eflag
][0]==' ') &&
123 (eflagstrings
[table
[cursorline
]->pkg
->eflag
][1]=='\0')) ? "" : " - ",
124 gettext(eflagstrings
[table
[cursorline
]->pkg
->eflag
]),
125 gettext(wantstrings
[table
[cursorline
]->selected
]),
126 gettext(wantstrings
[table
[cursorline
]->original
]),
129 describemany(buf
,priority
,section
,table
[cursorline
]->pkg
->clientdata
);
131 mvwaddnstr(thisstatepad
,0,0, buf
, total_width
);
132 pnoutrefresh(thisstatepad
, 0,leftofscreen
, thisstate_row
,0,
133 thisstate_row
, min(total_width
- 1, xmax
- 1));
138 void packagelist::redraw1itemsel(int index
, int selected
) {
141 const struct pkginfo
*pkg
= table
[index
]->pkg
;
142 const struct pkginfoperfile
*info
= &pkg
->available
;
143 int screenline
= index
- topofscreen
;
145 wattrset(listpad
, selected
? listsel_attr
: list_attr
);
151 mvwprintw(listpad
, screenline
, 0, "%-*.*s ",
152 status_hold_width
, status_hold_width
,
153 gettext(eflagstrings
[pkg
->eflag
]));
154 wprintw(listpad
, "%-*.*s ",
155 status_status_width
, status_status_width
,
156 gettext(statusstrings
[pkg
->status
]));
157 wprintw(listpad
, "%-*.*s ",
158 status_want_width
, status_want_width
,
159 /* FIXME: keep this? */
160 /*table[index]->original == table[index]->selected ? "(same)"
161 : */gettext(wantstrings
[table
[index
]->original
]));
162 wattrset(listpad
, selected
? selstatesel_attr
: selstate_attr
);
163 wprintw(listpad
, "%-*.*s",
164 status_want_width
, status_want_width
,
165 gettext(wantstrings
[table
[index
]->selected
]));
166 wattrset(listpad
, selected
? listsel_attr
: list_attr
);
167 waddch(listpad
, ' ');
169 mvwprintw(listpad
, screenline
, priority_column
- 1, " %-*.*s",
170 priority_width
, priority_width
,
171 pkg
->priority
== pkginfo::pri_other
? pkg
->otherpriority
:
172 gettext(prioritystrings
[pkg
->priority
]));
176 mvwaddch(listpad
, screenline
, 0, eflagchars
[pkg
->eflag
]);
177 waddch(listpad
, statuschars
[pkg
->status
]);
179 /* FIXME: keep this feature? */
180 /*table[index]->original == table[index]->selected ? ' '
181 : */wantchars
[table
[index
]->original
]);
183 wattrset(listpad
, selected
? selstatesel_attr
: selstate_attr
);
184 waddch(listpad
, wantchars
[table
[index
]->selected
]);
185 wattrset(listpad
, selected
? listsel_attr
: list_attr
);
187 wmove(listpad
, screenline
, priority_column
- 1);
188 waddch(listpad
, ' ');
189 if (pkg
->priority
== pkginfo::pri_other
) {
192 for (i
=priority_width
, p
=pkg
->otherpriority
;
195 waddch(listpad
, tolower(*p
));
196 while (i
-- > 0) waddch(listpad
,' ');
198 wprintw(listpad
, "%-*.*s", priority_width
, priority_width
,
199 gettext(priorityabbrevs
[pkg
->priority
]));
204 mvwprintw(listpad
, screenline
, section_column
- 1, " %-*.*s",
205 section_width
, section_width
,
206 pkg
->section
? pkg
->section
: "?");
208 mvwprintw(listpad
, screenline
, package_column
- 1, " %-*.*s ",
209 package_width
, package_width
, pkg
->name
);
211 if (versioninstalled_width
)
212 mvwprintw(listpad
, screenline
, versioninstalled_column
, "%-*.*s ",
213 versioninstalled_width
, versioninstalled_width
,
214 versiondescribe(&pkg
->installed
.version
, vdew_nonambig
));
215 if (versionavailable_width
) {
216 if (informativeversion(&pkg
->available
.version
) &&
217 versioncompare(&pkg
->available
.version
,&pkg
->installed
.version
) > 0)
218 wattrset(listpad
, selected
? selstatesel_attr
: selstate_attr
);
219 mvwprintw(listpad
, screenline
, versionavailable_column
, "%-*.*s",
220 versionavailable_width
, versionavailable_width
,
221 versiondescribe(&pkg
->available
.version
, vdew_nonambig
));
222 wattrset(listpad
, selected
? listsel_attr
: list_attr
);
226 i
= description_width
;
227 p
= info
->description
? info
->description
:
228 pkg
->installed
.description
? pkg
->installed
.description
: "";
229 while (i
>0 && *p
&& *p
!= '\n') { waddnstr(listpad
,p
,1); i
--; p
++; }
233 const char *section
= pkg
->section
;
234 const char *priority
= pkgprioritystring(pkg
);
236 char *buf
= new char[500+
237 (section
? strlen(section
) : 0) +
238 (priority
? strlen(priority
) : 0)];
240 indent
= describemany(buf
,priority
,section
,pkg
->clientdata
);
242 mvwaddstr(listpad
, screenline
, 0, " ");
245 while (j
-- >0) { waddch(listpad
,ACS_HLINE
); i
--; }
248 wattrset(listpad
, selected
? selstatesel_attr
: selstate_attr
);
250 while (i
>0 && *p
) { waddnstr(listpad
, p
,1); p
++; i
--; }
251 wattrset(listpad
, selected
? listsel_attr
: list_attr
);
255 while (j
-- >0) { waddch(listpad
,ACS_HLINE
); i
--; }
261 while (i
>0) { waddch(listpad
,' '); i
--; }
264 void packagelist::redrawcolheads() {
265 if (colheads_height
) {
266 wattrset(colheadspad
,colheads_attr
);
267 mywerase(colheadspad
);
269 wmove(colheadspad
,0,0);
270 for (int i
=0; i
<status_width
-status_want_width
; i
++) waddch(colheadspad
,'.');
271 mvwaddnstr(colheadspad
,0,
275 mvwaddnstr(colheadspad
,0,
278 status_status_width
);
279 mvwaddnstr(colheadspad
,0,
280 status_hold_width
+status_status_width
+2,
283 mvwaddnstr(colheadspad
,0,
284 status_hold_width
+status_status_width
+status_want_width
+3,
288 mvwaddstr(colheadspad
,0,0, _("EIOM"));
290 mvwaddnstr(colheadspad
,0,section_column
, _("Section"), section_width
);
291 mvwaddnstr(colheadspad
,0,priority_column
, _("Priority"), priority_width
);
292 mvwaddnstr(colheadspad
,0,package_column
, _("Package"), package_width
);
294 if (versioninstalled_width
)
295 mvwaddnstr(colheadspad
,0,versioninstalled_column
,
296 _("Inst.ver"),versioninstalled_width
);
297 if (versionavailable_width
)
298 mvwaddnstr(colheadspad
,0,versionavailable_column
,
299 _("Avail.ver"),versionavailable_width
);
301 mvwaddnstr(colheadspad
,0,description_column
, _("Description"), description_width
);