2 * dselect - Debian package maintenance user interface
3 * pkgdisplay.cc - package list display
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2006, 2008-2015 Guillem Jover <guillem@debian.org>
8 * This is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 #include <dpkg/i18n.h>
29 #include <dpkg/dpkg.h>
30 #include <dpkg/dpkg-db.h>
35 /* These MUST be in the same order as the corresponding enums in dpkg-db.h */
37 *const wantstrings
[]= { N_("new package"),
44 /* TRANSLATORS: The space is a trick to work around gettext which uses
45 * the empty string to store information about the translation. DO NOT
46 * CHANGE THAT IN A TRANSLATION! The code really relies on that being
48 *const eflagstrings
[]= { N_(" "),
52 *const statusstrings
[]= { N_("not installed"),
53 N_("removed (configs remain)"),
55 N_("unpacked (not set up)"),
56 N_("half configured (config failed)"),
57 N_("awaiting trigger processing"),
62 *const prioritystrings
[]= { N_("Required"),
70 *const relatestrings
[]= { N_("suggests"),
81 *const priorityabbrevs
[]= { N_("Req"),
89 const char statuschars
[] = " -IUCWt*";
90 const char eflagchars
[] = " R";
91 const char wantchars
[]= "n*=-_";
93 /* These MUST be in the same order as the corresponding enums in pkglist.h */
95 *const ssaabbrevs
[]= { N_("Broken"),
102 *const ssastrings
[]= { N_("Brokenly installed packages"),
103 N_("Newly available packages"),
104 N_("Upgradable packages"),
105 N_("Obsolete and locally created packages"),
106 N_("Installed packages"),
107 N_("Available not installed packages"),
108 N_("Removed and no longer available packages") };
111 *const sssstrings
[]= { N_("Brokenly installed packages"),
112 N_("Installed packages"),
113 N_("Removed packages (configuration still present)"),
114 N_("Purged packages and those never installed") },
115 *const sssabbrevs
[]= { N_("Broken"),
120 static int maximumstring(const char *const *array
) {
123 int l
= strlen(gettext(*array
));
124 const char *p
= strchr(*array
, '(');
125 if (p
&& p
> *array
&& *--p
== ' ') l
= p
- *array
;
126 if (l
> maxlen
) maxlen
= l
;
132 void packagelist::setwidths() {
133 debug(dbg_general
, "packagelist[%p]::setwidths()", this);
138 add_column(col_status_hold
, _("Error"), 9);
139 add_column(col_status_status
, _("Installed?"), maximumstring(statusstrings
));
140 add_column(col_status_old_want
, _("Old mark"), maximumstring(wantstrings
));
141 add_column(col_status_new_want
, _("Marked for"), maximumstring(wantstrings
));
143 add_column(col_status
, _("EIOM"), 4);
146 if (sortorder
== so_section
)
147 add_column(col_section
, _("Section"), 8);
148 add_column(col_priority
, _("Priority"), verbose
? 8 : 3);
149 if (sortorder
!= so_section
)
150 add_column(col_section
, _("Section"), 8);
152 add_column(col_package
, _("Package"), verbose
? 16 : 12);
154 switch (archdisplayopt
) {
156 col_archinstalled
.blank();
157 col_archavailable
.blank();
160 col_archinstalled
.blank();
161 add_column(col_archavailable
, _("Avail.arch"), verbose
? 14 : 10);
164 add_column(col_archinstalled
, _("Inst.arch"), verbose
? 14 : 10);
165 add_column(col_archavailable
, _("Avail.arch"), verbose
? 14 : 10);
168 internerr("unknown archdisplayopt %d", archdisplayopt
);
171 switch (versiondisplayopt
) {
173 col_versioninstalled
.blank();
174 col_versionavailable
.blank();
177 col_versioninstalled
.blank();
178 add_column(col_versionavailable
, _("Avail.ver"), 11);
181 add_column(col_versioninstalled
, _("Inst.ver"), 11);
182 add_column(col_versionavailable
, _("Avail.ver"), 11);
185 internerr("unknown versiondisplayopt %d", versiondisplayopt
);
188 end_column(col_description
, _("Description"));
191 void packagelist::redrawtitle() {
192 int x
, y DPKG_ATTR_UNUSED
;
196 mvwaddnstr(titlewin
,0,0,
197 recursive
? _("dselect - recursive package listing") :
198 modstatdb_get_status() == msdbrw_readonly
?
199 _("dselect - inspection of package states") :
200 _("dselect - main package listing"),
206 switch (statsortorder
) {
208 waddnstr(titlewin
, _(" (by section)"), xmax
-x
);
211 waddnstr(titlewin
, _(" (avail., section)"), xmax
-x
);
214 waddnstr(titlewin
, _(" (status, section)"), xmax
-x
);
217 internerr("bad statsort %d on so_section", statsortorder
);
221 switch (statsortorder
) {
223 waddnstr(titlewin
, _(" (by priority)"), xmax
-x
);
226 waddnstr(titlewin
, _(" (avail., priority)"), xmax
-x
);
229 waddnstr(titlewin
, _(" (status, priority)"), xmax
-x
);
232 internerr("bad statsort %d on so_priority", statsortorder
);
236 switch (statsortorder
) {
238 waddnstr(titlewin
, _(" (alphabetically)"), xmax
-x
);
241 waddnstr(titlewin
, _(" (by availability)"), xmax
-x
);
244 waddnstr(titlewin
, _(" (by status)"), xmax
-x
);
247 internerr("bad statsort %d on so_priority", statsortorder
);
253 internerr("bad sort %d", sortorder
);
256 const char *helpstring
;
258 if (modstatdb_get_status() == msdbrw_write
)
259 helpstring
= (verbose
? _(" mark:+/=/- terse:v help:?")
260 : _(" mark:+/=/- verbose:v help:?"));
262 helpstring
= (verbose
? _(" terse:v help:?")
263 : _(" verbose:v help:?"));
265 int l
= strlen(helpstring
);
268 mvwaddstr(titlewin
,0,xmax
-l
, helpstring
);
270 wnoutrefresh(titlewin
);