2 * dselect - Debian package maintenance user interface
3 * pkgdisplay.cc - package list display
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/>.
27 #include <dpkg/i18n.h>
28 #include <dpkg/dpkg.h>
29 #include <dpkg/dpkg-db.h>
34 /* These MUST be in the same order as the corresponding enums in dpkg-db.h */
36 *const wantstrings
[]= { N_("new package"),
42 /* WTA: the space is a trick to work around gettext which uses the empty
43 * string to store information about the translation. DO NOT CHANGE
44 * THAT IN A TRANSLATION! The code really relies on that being a single space.
46 *const eflagstrings
[]= { N_(" "),
50 *const statusstrings
[]= { N_("not installed"),
51 N_("removed (configs remain)"),
53 N_("unpacked (not set up)"),
54 N_("half configured (config failed)"),
55 N_("awaiting trigger processing"),
60 *const prioritystrings
[]= { N_("Required"),
69 *const relatestrings
[]= { N_("suggests"),
80 *const priorityabbrevs
[]= { N_("Req"),
88 const char statuschars
[] = " -IUCWt*";
89 const char eflagchars
[] = " R";
90 const char wantchars
[]= "n*=-_";
92 /* These MUST be in the same order as the corresponding enums in pkglist.h */
94 *const ssaabbrevs
[]= { N_("Broken"),
101 *const ssastrings
[]= { N_("Brokenly installed packages"),
102 N_("Newly available packages"),
103 N_("Updated packages (newer version is available)"),
104 N_("Obsolete and local packages present on system"),
105 N_("Up to date installed packages"),
106 N_("Available packages (not currently installed)"),
107 N_("Removed and no longer available packages") };
110 *const sssstrings
[]= { N_("Brokenly installed packages"),
111 N_("Installed packages"),
112 N_("Removed packages (configuration still present)"),
113 N_("Purged packages and those never installed") },
114 *const sssabbrevs
[]= { N_("Broken"),
119 static int maximumstring(const char *const *array
) {
122 int l
= strlen(gettext(*array
));
123 const char *p
= strchr(*array
, '(');
124 if (p
&& p
> *array
&& *--p
== ' ') l
= p
- *array
;
125 if (l
> maxlen
) maxlen
= l
;
131 void packagelist::setwidths() {
132 if (debug
) fprintf(debug
,"packagelist[%p]::setwidths()\n",this);
135 status_hold_width
= 9;
136 status_status_width
= maximumstring(statusstrings
);
137 status_want_width
= maximumstring(wantstrings
);
138 status_width
= status_hold_width
+status_status_width
+status_want_width
*2+3;
150 if (sortorder
== so_section
) {
151 section_column
= status_width
+ gap_width
;
152 priority_column
= section_column
+ section_width
+ gap_width
;
153 package_column
= priority_column
+ priority_width
+ gap_width
;
155 priority_column
= status_width
+ gap_width
;
156 section_column
= priority_column
+ priority_width
+ gap_width
;
157 package_column
= section_column
+ section_width
+ gap_width
;
160 int versiondescriptioncolumn
= package_column
+ package_width
+ gap_width
;
162 switch (versiondisplayopt
) {
164 versioninstalled_column
= versioninstalled_width
= 0;
165 versionavailable_column
= versionavailable_width
= 0;
166 description_column
= versiondescriptioncolumn
;
169 versioninstalled_column
= versioninstalled_width
= 0;
170 versionavailable_column
= versiondescriptioncolumn
;
171 versionavailable_width
= 11;
172 description_column
= versionavailable_column
+ versionavailable_width
+ gap_width
;
175 versioninstalled_column
= versiondescriptioncolumn
;
176 versioninstalled_width
= 11;
177 versionavailable_column
= versioninstalled_column
+ versioninstalled_width
+gap_width
;
178 versionavailable_width
= versioninstalled_width
;
179 description_column
= versionavailable_column
+ versionavailable_width
+ gap_width
;
182 internerr("unknown versiondisplayopt in setwidths");
185 total_width
= TOTAL_LIST_WIDTH
;
186 if (total_width
< COLS
)
188 description_width
= total_width
- description_column
;
191 void packagelist::redrawtitle() {
196 mvwaddnstr(titlewin
,0,0,
197 recursive
? _("dselect - recursive package listing") :
198 !readwrite
? _("dselect - inspection of package states") :
199 _("dselect - main package listing"),
205 switch (statsortorder
) {
207 waddnstr(titlewin
, _(" (by section)"), xmax
-x
);
210 waddnstr(titlewin
, _(" (avail., section)"), xmax
-x
);
213 waddnstr(titlewin
, _(" (status, section)"), xmax
-x
);
216 internerr("bad statsort in redrawtitle/so_section");
220 switch (statsortorder
) {
222 waddnstr(titlewin
, _(" (by priority)"), xmax
-x
);
225 waddnstr(titlewin
, _(" (avail., priority)"), xmax
-x
);
228 waddnstr(titlewin
, _(" (status, priority)"), xmax
-x
);
231 internerr("bad statsort in redrawtitle/so_priority");
235 switch (statsortorder
) {
237 waddnstr(titlewin
, _(" (alphabetically)"), xmax
-x
);
240 waddnstr(titlewin
, _(" (by availability)"), xmax
-x
);
243 waddnstr(titlewin
, _(" (by status)"), xmax
-x
);
246 internerr("bad statsort in redrawtitle/so_priority");
249 waddnstr(titlewin
, _(" (alphabetically)"), xmax
-x
);
254 internerr("bad sort in redrawtitle");
257 const char *helpstring
= readwrite
? (verbose
? _(" mark:+/=/- terse:v help:?")
258 : _(" mark:+/=/- verbose:v help:?"))
259 : (verbose
? _(" terse:v help:?")
260 : _(" verbose:v help:?"));
261 int l
= strlen(helpstring
);
264 mvwaddstr(titlewin
,0,xmax
-l
, helpstring
);
266 wnoutrefresh(titlewin
);