2 * dselect - Debian package maintenance user interface
3 * methlist.cc - list of access methods and options
5 * Copyright © 1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2001 Wichert Akkerman <wakkerma@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/>.
29 #include <dpkg/i18n.h>
30 #include <dpkg/dpkg.h>
31 #include <dpkg/dpkg-db.h>
32 #include <dpkg/string.h>
39 static keybindings
methodlistbindings(methodlist_kinterps
,methodlist_korgbindings
);
41 const char *methodlist::itemname(int index
) {
42 return table
[index
]->name
;
45 void methodlist::kd_abort() { }
47 void methodlist::kd_quit() {
48 debug(dbg_general
, "methodlist[%p]::kd_quit() setting coption=%p",
49 this, table
[cursorline
]);
50 coption
= table
[cursorline
];
53 void methodlist::setheights() {
54 debug(dbg_general
, "methodlist[%p]::setheights()", this);
55 baselist::setheights();
59 void methodlist::setwidths() {
60 debug(dbg_general
, "methodlist[%p]::setwidths()", this);
64 add_column(col_status
, " ", 1);
65 add_column(col_name
, _("Abbrev."), 14);
66 end_column(col_desc
, _("Description"));
69 void methodlist::redrawtitle() {
72 mvwaddnstr(titlewin
,0,0,_("dselect - list of access methods"),xmax
);
73 wnoutrefresh(titlewin
);
77 void methodlist::redrawthisstate() {
78 if (!thisstate_height
) return;
79 mywerase(thisstatepad
);
81 _("Access method '%s'."),
82 table
[cursorline
]->name
);
83 pnoutrefresh(thisstatepad
, 0,0, thisstate_row
,0,
84 thisstate_row
, min(total_width
- 1, xmax
- 1));
87 void methodlist::redraw1itemsel(int index
, int selected
) {
91 wattrset(listpad
, part_attr
[selected
? listsel
: list
]);
92 mvwaddch(listpad
,index
,0,
93 table
[index
] == coption
? '*' : ' ');
94 wattrset(listpad
, part_attr
[selected
? listsel
: list
]);
95 draw_column_sep(col_name
, index
);
96 draw_column_item(col_name
, index
, table
[index
]->name
);
98 draw_column_sep(col_desc
, index
);
100 p
= table
[index
]->summary
? table
[index
]->summary
: "";
101 while (i
>0 && *p
&& *p
!= '\n') {
111 void methodlist::redrawcolheads() {
112 if (colheads_height
) {
113 wattrset(colheadspad
, part_attr
[colheads
]);
114 mywerase(colheadspad
);
115 draw_column_head(col_status
);
116 draw_column_head(col_name
);
117 draw_column_head(col_desc
);
122 methodlist::methodlist() : baselist(&methodlistbindings
) {
125 debug(dbg_general
, "methodlist[%p]::methodlist()", this);
127 table
= new struct dselect_option
*[noptions
];
129 struct dselect_option
*opt
, **ip
;
130 for (opt
=options
, ip
=table
, nitems
=0; opt
; opt
=opt
->next
, nitems
++) {
131 if (opt
== coption
) {
133 internerr("multiple methods with same index");
138 if (nitems
!= noptions
)
139 internerr("inconsistent number of items: ntimes=%d != noptions=%d",
142 if (newcursor
==-1) newcursor
= 0;
143 setcursor(newcursor
);
145 debug(dbg_general
, "methodlist[%p]::methodlist done; noptions=%d",
149 methodlist::~methodlist() {
150 debug(dbg_general
, "methodlist[%p]::~methodlist()", this);
154 quitaction
methodlist::display() {
156 const keybindings::interpretation
*interp
;
158 debug(dbg_general
, "methodlist[%p]::display()", this);
162 debug(dbg_general
, "methodlist[%p]::display() entering loop", this);
164 if (whatinfo_height
) wcursyncup(whatinfowin
);
165 if (doupdate() == ERR
) ohshite(_("doupdate failed"));
168 if (response
== KEY_RESIZE
) {
172 } while (response
== ERR
&& errno
== EINTR
);
173 if (response
== ERR
) ohshite(_("getch failed"));
174 interp
= (*bindings
)(response
);
175 debug(dbg_general
, "methodlist[%p]::display() response=%d interp=%s",
176 this, response
, interp
? interp
->action
: "[none]");
179 (this->*(interp
->mfn
))();
180 if (interp
->qa
!= qa_noquit
) break;
184 debug(dbg_general
, "methodlist[%p]::display() done", this);
189 void methodlist::itd_description() {
190 whatinfovb(_("Explanation"));
192 wattrset(infopad
, part_attr
[info_head
]);
193 waddstr(infopad
, table
[cursorline
]->name
);
194 waddstr(infopad
," - ");
195 waddstr(infopad
, table
[cursorline
]->summary
);
196 wattrset(infopad
, part_attr
[info_body
]);
198 const char *m
= table
[cursorline
]->description
;
200 m
= _("No explanation available.");
201 waddstr(infopad
,"\n\n");
205 void methodlist::redrawinfo() {
206 if (!info_height
) return;
208 werase(infopad
); wmove(infopad
,0,0);
210 debug(dbg_general
, "methodlist[%p]::redrawinfo()", this);
222 const struct helpmenuentry
*methodlist::helpmenulist() {
223 static const struct helpmenuentry list
[]= {
224 { 'i', &hlp_methintro
},
225 { 'k', &hlp_methkeys
},