2 * dselect - Debian GNU/Linux package maintenance user interface
3 * methlist.cc - list of access methods and options
5 * Copyright (C) 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.
38 static keybindings
methodlistbindings(methodlist_kinterps
,methodlist_korgbindings
);
40 const char *methodlist::itemname(int index
) {
41 return table
[index
]->name
;
44 void methodlist::kd_abort() { }
46 void methodlist::kd_quit() {
47 if (debug
) fprintf(debug
,"methodlist[%p]::kd_quit() setting coption=%p\n",
48 this, table
[cursorline
]);
49 coption
= table
[cursorline
];
52 void methodlist::setwidths() {
53 if (debug
) fprintf(debug
,"methodlist[%p]::setwidths()\n",this);
58 name_column
= status_width
+ gap_width
;
59 description_column
= name_column
+ name_width
+ gap_width
;
61 total_width
= TOTAL_LIST_WIDTH
;
62 description_width
= total_width
- description_column
;
65 void methodlist::redrawtitle() {
68 mvwaddnstr(titlewin
,0,0,"dselect - list of access methods",xmax
);
69 wnoutrefresh(titlewin
);
73 void methodlist::redrawthisstate() {
74 if (!thisstate_height
) return;
75 mywerase(thisstatepad
);
77 "Access method `%s'.",
78 table
[cursorline
]->name
);
79 pnoutrefresh(thisstatepad
, 0,0, thisstate_row
,0,
80 thisstate_row
, lesserint(total_width
- 1, xmax
- 1));
83 void methodlist::redraw1itemsel(int index
, int selected
) {
87 wattrset(listpad
, selected
? listsel_attr
: list_attr
);
88 mvwaddch(listpad
,index
,0,
89 table
[index
] == coption
? '*' : ' ');
90 wattrset(listpad
, selected
? listsel_attr
: list_attr
);
91 mvwprintw(listpad
,index
,name_column
-1, " %-*.*s ",
92 name_width
, name_width
, table
[index
]->name
);
95 p
= table
[index
]->summary
? table
[index
]->summary
: "";
96 while (i
>0 && *p
&& *p
!= '\n') {
106 void methodlist::redrawcolheads() {
107 if (colheads_height
) {
108 wattrset(colheadspad
,colheads_attr
);
109 mywerase(colheadspad
);
110 mvwaddstr(colheadspad
,0,0, " ");
111 mvwaddnstr(colheadspad
,0,name_column
, "Abbrev.", name_width
);
112 mvwaddnstr(colheadspad
,0,description_column
, "Description", description_width
);
117 methodlist::methodlist() : baselist(&methodlistbindings
) {
121 fprintf(debug
,"methodlist[%p]::methodlist()\n",this);
123 table
= new struct option
*[noptions
];
125 struct option
*opt
, **ip
;
126 for (opt
=options
, ip
=table
, nitems
=0; opt
; opt
=opt
->next
, nitems
++) {
127 if (opt
== coption
) { assert(newcursor
==-1); newcursor
= nitems
; }
130 assert(nitems
==noptions
);
132 if (newcursor
==-1) newcursor
= 0;
133 setcursor(newcursor
);
136 fprintf(debug
,"methodlist[%p]::methodlist done; noptions=%d\n", this, noptions
);
139 methodlist::~methodlist() {
140 if (debug
) fprintf(debug
,"methodlist[%p]::~methodlist()\n",this);
144 quitaction
methodlist::display() {
146 const keybindings::interpretation
*interp
;
148 if (debug
) fprintf(debug
,"methodlist[%p]::display()\n",this);
153 if (debug
) fprintf(debug
,"methodlist[%p]::display() entering loop\n",this);
155 if (whatinfo_height
) wcursyncup(whatinfowin
);
156 if (doupdate() == ERR
) ohshite("doupdate failed");
158 if (sigprocmask(SIG_UNBLOCK
,&sigwinchset
,0)) ohshite("failed to unblock SIGWINCH");
160 if (sigprocmask(SIG_BLOCK
,&sigwinchset
,0)) ohshite("failed to re-block SIGWINCH");
161 if (response
== ERR
) ohshite("getch failed");
162 interp
= (*bindings
)(response
);
164 fprintf(debug
,"methodlist[%p]::display() response=%d interp=%s\n",
165 this,response
, interp
? interp
->action
: "[none]");
166 if (!interp
) { beep(); continue; }
167 (this->*(interp
->mfn
))();
168 if (interp
->qa
!= qa_noquit
) break;
170 pop_cleanup(ehflag_normaltidy
); // unset the SIGWINCH handler
173 if (debug
) fprintf(debug
,"methodlist[%p]::display() done\n",this);
178 void methodlist::itd_description() {
179 whatinfovb("explanation of ");
180 whatinfovb(table
[cursorline
]->name
);
182 wattrset(infopad
,info_headattr
);
183 waddstr(infopad
, table
[cursorline
]->name
);
184 waddstr(infopad
," - ");
185 waddstr(infopad
, table
[cursorline
]->summary
);
186 wattrset(infopad
,info_attr
);
188 const char *m
= table
[cursorline
]->description
;
189 if (!m
|| !*m
) m
= "No explanation available.";
190 waddstr(infopad
,"\n\n");
194 void methodlist::redrawinfo() {
195 if (!info_height
) return;
197 werase(infopad
); wmove(infopad
,0,0);
199 if (debug
) fprintf(debug
,"methodlist[%p]::redrawinfo()\n", this);
203 whatinfovb
.terminate();
212 const struct helpmenuentry
*methodlist::helpmenulist() {
213 static const struct helpmenuentry list
[]= {
214 { 'i', &hlp_methintro
},
215 { 'k', &hlp_methkeys
},