2 * dselect - Debian GNU/Linux package maintenance user interface
3 * pkgdisplay.cc - package list display
5 * Copyright (C) 1994,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.
36 /* These MUST be in the same order as the corresponding enums in dpkg-db.h */
38 *const wantstrings
[]= { "new package", "install", "hold", "remove", "purge", 0 },
39 *const eflagstrings
[]= { "", "REINSTALL", 0 },
40 *const statusstrings
[]= { "not installed", "unpacked (not set up)",
41 "failed config", "installed", "half installed",
42 "removed (configs remain)", 0 },
43 *const prioritystrings
[]= { "Required", "Important", "Standard", "Recommended",
44 "Optional", "Extra", "Contrib",
45 "!Bug!", "Unclassified", 0 },
46 *const relatestrings
[]= { "suggests", "recommends", "depends on", "pre-depends on",
47 "conflicts with", "provides", "replaces", 0 },
48 *const priorityabbrevs
[]= { "Req", "Imp", "Std", "Rec",
51 const char statuschars
[]= " UC*I-";
52 const char eflagchars
[]= " R?#";
53 const char wantchars
[]= "n*=-_";
55 /* These MUST be in the same order as the corresponding enums in pkglist.h */
57 *const ssaabbrevs
[]= { "Broken",
64 *const ssastrings
[]= { "Brokenly installed packages",
65 "Newly available packages",
66 "Updated packages (newer version is available)",
67 "Obsolete and local packages present on system",
68 "Up to date installed packages",
69 "Available packages (not currently installed)",
70 "Removed and no longer available packages" };
73 *const sssstrings
[]= { "Brokenly installed packages",
75 "Removed packages (configuration still present)",
76 "Purged packages and those never installed" },
77 *const sssabbrevs
[]= { "Broken",
82 static int maximumstring(const char *const *array
) {
85 int l
= strlen(*array
);
86 const char *p
= strchr(*array
, '(');
87 if (p
&& p
> *array
&& *--p
== ' ') l
= p
- *array
;
88 if (l
> maxlen
) maxlen
= l
;
94 void packagelist::setwidths() {
95 if (debug
) fprintf(debug
,"packagelist[%p]::setwidths()\n",this);
99 status_status_width
= maximumstring(statusstrings
);
100 status_want_width
= maximumstring(wantstrings
);
101 status_width
= status_hold_width
+status_status_width
+status_want_width
*2+3;
113 if (sortorder
== so_section
) {
114 section_column
= status_width
+ gap_width
;
115 priority_column
= section_column
+ section_width
+ gap_width
;
116 package_column
= priority_column
+ priority_width
+ gap_width
;
118 priority_column
= status_width
+ gap_width
;
119 section_column
= priority_column
+ priority_width
+ gap_width
;
120 package_column
= section_column
+ section_width
+ gap_width
;
123 int versiondescriptioncolumn
= package_column
+ package_width
+ gap_width
;
125 switch (versiondisplayopt
) {
127 versioninstalled_column
= versioninstalled_width
= 0;
128 versionavailable_column
= versionavailable_width
= 0;
129 description_column
= versiondescriptioncolumn
;
132 versioninstalled_column
= versioninstalled_width
= 0;
133 versionavailable_column
= versiondescriptioncolumn
;
134 versionavailable_width
= 11;
135 description_column
= versionavailable_column
+ versionavailable_width
+ gap_width
;
138 versioninstalled_column
= versiondescriptioncolumn
;
139 versioninstalled_width
= 11;
140 versionavailable_column
= versioninstalled_column
+ versioninstalled_width
+gap_width
;
141 versionavailable_width
= versioninstalled_width
;
142 description_column
= versionavailable_column
+ versionavailable_width
+ gap_width
;
145 internerr("unknown versiondisplayopt in setwidths");
148 total_width
= TOTAL_LIST_WIDTH
;
149 description_width
= total_width
- description_column
;
152 void packagelist::redrawtitle() {
157 mvwaddnstr(titlewin
,0,0,
158 recursive
? "dselect - recursive package listing" :
159 !readwrite
? "dselect - inspection of package states" :
160 "dselect - main package listing",
166 switch (statsortorder
) {
168 waddnstr(titlewin
, " (by section)", xmax
-x
);
171 waddnstr(titlewin
, " (avail., section)", xmax
-x
);
174 waddnstr(titlewin
, " (status, section)", xmax
-x
);
177 internerr("bad statsort in redrawtitle/so_section");
181 switch (statsortorder
) {
183 waddnstr(titlewin
, " (by priority)", xmax
-x
);
186 waddnstr(titlewin
, " (avail., priority)", xmax
-x
);
189 waddnstr(titlewin
, " (status, priority)", xmax
-x
);
192 internerr("bad statsort in redrawtitle/so_priority");
196 switch (statsortorder
) {
198 waddnstr(titlewin
, " (alphabetically)", xmax
-x
);
201 waddnstr(titlewin
, " (by availability)", xmax
-x
);
204 waddnstr(titlewin
, " (by status)", xmax
-x
);
207 internerr("bad statsort in redrawtitle/so_priority");
210 waddnstr(titlewin
, " (alphabetically)", xmax
-x
);
215 internerr("bad sort in redrawtitle");
218 const char *helpstring
= readwrite
? (verbose
? " mark:+/=/- terse:v help:?"
219 : " mark:+/=/- verbose:v help:?")
220 : (verbose
? " terse:v help:?"
221 : " verbose:v help:?");
222 int l
= strlen(helpstring
);
225 mvwaddstr(titlewin
,0,xmax
-l
, helpstring
);
227 wnoutrefresh(titlewin
);