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/>.
30 #include <dpkg/i18n.h>
31 #include <dpkg/dpkg.h>
32 #include <dpkg/dpkg-db.h>
33 #include <dpkg/string.h>
40 static keybindings
methodlistbindings(methodlist_kinterps
,methodlist_korgbindings
);
42 const char *methodlist
::itemname(int index
) {
43 return table
[index
]->name
;
46 void methodlist
::kd_abort() { }
48 void methodlist
::kd_quit() {
49 debug(dbg_general
, "methodlist[%p]::kd_quit() setting coption=%p",
50 this, table
[cursorline
]);
51 coption
= table
[cursorline
];
54 void methodlist
::setheights() {
55 debug(dbg_general
, "methodlist[%p]::setheights()", this);
56 baselist
::setheights();
60 void methodlist
::setwidths() {
61 debug(dbg_general
, "methodlist[%p]::setwidths()", this);
65 add_column(col_status
, " ", 1);
66 add_column(col_name
, _("Abbrev."), 14);
67 end_column(col_desc
, _("Description"));
70 void methodlist
::redrawtitle() {
73 mvwaddnstr(titlewin
,0,0,_("dselect - list of access methods"),xmax
);
74 wnoutrefresh(titlewin
);
78 void methodlist
::redrawthisstate() {
79 if (!thisstate_height
) return;
80 mywerase(thisstatepad
);
82 _("Access method '%s'."),
83 table
[cursorline
]->name
);
84 pnoutrefresh(thisstatepad
, 0,0, thisstate_row
,0,
85 thisstate_row
, min(total_width
- 1, xmax
- 1));
88 void methodlist
::redraw1itemsel(int index
, int selected
) {
92 wattrset(listpad
, part_attr
[selected ? listsel
: list
]);
93 mvwaddch(listpad
,index
,0,
94 table
[index
] == coption ?
'*' : ' ');
95 wattrset(listpad
, part_attr
[selected ? listsel
: list
]);
96 draw_column_sep(col_name
, index
);
97 draw_column_item(col_name
, index
, table
[index
]->name
);
99 draw_column_sep(col_desc
, index
);
101 p
= table
[index
]->summary ? table
[index
]->summary
: "";
102 while (i
>0 && *p
&& *p
!= '\n') {
112 void methodlist
::redrawcolheads() {
113 if (colheads_height
) {
114 wattrset(colheadspad
, part_attr
[colheads
]);
115 mywerase(colheadspad
);
116 draw_column_head(col_status
);
117 draw_column_head(col_name
);
118 draw_column_head(col_desc
);
123 methodlist
::methodlist() : baselist(&methodlistbindings
) {
126 debug(dbg_general
, "methodlist[%p]::methodlist()", this);
128 table
= new struct dselect_option
*[noptions
];
130 struct dselect_option
*opt
, **ip
;
131 for (opt
=options
, ip
=table
, nitems
=0; opt
; opt
=opt
->next
, nitems
++) {
132 if (opt
== coption
) { assert(newcursor
==-1); newcursor
= nitems
; }
135 assert(nitems
==noptions
);
137 if (newcursor
==-1) newcursor
= 0;
138 setcursor(newcursor
);
140 debug(dbg_general
, "methodlist[%p]::methodlist done; noptions=%d",
144 methodlist
::~methodlist() {
145 debug(dbg_general
, "methodlist[%p]::~methodlist()", this);
149 quitaction methodlist
::display() {
151 const keybindings
::interpretation
*interp
;
153 debug(dbg_general
, "methodlist[%p]::display()", this);
158 debug(dbg_general
, "methodlist[%p]::display() entering loop", this);
160 if (whatinfo_height
) wcursyncup(whatinfowin
);
161 if (doupdate() == ERR
) ohshite(_("doupdate failed"));
163 sigwinch_mask(SIG_UNBLOCK
);
166 while (response
== ERR
&& errno
== EINTR
);
167 sigwinch_mask(SIG_BLOCK
);
168 if (response
== ERR
) ohshite(_("getch failed"));
169 interp
= (*bindings
)(response
);
170 debug(dbg_general
, "methodlist[%p]::display() response=%d interp=%s",
171 this, response
, interp ? interp
->action
: "[none]");
172 if (!interp
) { beep(); continue; }
173 (this->*(interp
->mfn
))();
174 if (interp
->qa
!= qa_noquit
) break;
176 pop_cleanup(ehflag_normaltidy
); // unset the SIGWINCH handler
179 debug(dbg_general
, "methodlist[%p]::display() done", this);
184 void methodlist
::itd_description() {
185 whatinfovb(_("Explanation"));
187 wattrset(infopad
, part_attr
[info_head
]);
188 waddstr(infopad
, table
[cursorline
]->name
);
189 waddstr(infopad
," - ");
190 waddstr(infopad
, table
[cursorline
]->summary
);
191 wattrset(infopad
, part_attr
[info_body
]);
193 const char *m
= table
[cursorline
]->description
;
195 m
= _("No explanation available.");
196 waddstr(infopad
,"\n\n");
200 void methodlist
::redrawinfo() {
201 if (!info_height
) return;
203 werase(infopad
); wmove(infopad
,0,0);
205 debug(dbg_general
, "methodlist[%p]::redrawinfo()", this);
217 const struct helpmenuentry
*methodlist
::helpmenulist() {
218 static const struct helpmenuentry list
[]= {
219 { 'i', &hlp_methintro
},
220 { 'k', &hlp_methkeys
},