* bcommands.cc - base list keyboard commands display
*
* Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk>
- * Copyright (C) 2000 Wichert Akkerman <wakkerma@debian.org>
+ * Copyright (C) 2000,2001 Wichert Akkerman <wakkerma@debian.org>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
dosearch();
}
+int baselist::checksearch(char* str) {
+ return 1;
+}
+
+int baselist::matchsearch(int index) {
+ int lendiff, searchlen, i;
+ const char* thisname;
+
+ thisname=itemname(index);
+ if (!thisname) return 0; /* Skip things without a name (seperators) */
+
+ searchlen=strlen(searchstring);
+ lendiff= strlen(thisname) - searchlen;
+ for (i=0; i<=lendiff; i++)
+ if (!strncasecmp(thisname + i, searchstring, searchlen))
+ return 1;
+
+ return 0;
+}
+
void baselist::kd_search() {
- char newsearchstring[50];
+ char newsearchstring[128];
strcpy(newsearchstring,searchstring);
werase(querywin);
mvwaddstr(querywin,0,0, _("Search for ? "));
else if (thisstate_height) redrawthisstate();
else { touchwin(listpad); refreshlist(); }
if (newsearchstring[0]) {
+ if (!checksearch(newsearchstring)) {
+ beep();
+ return;
+ }
strcpy(searchstring,newsearchstring);
dosearch();
} else
kd_searchagain();
}
+void baselist::displayerror(const char* str) {
+ const char* pr = _("Error: ");
+ int prlen=strlen(pr);
+
+ beep();
+ werase(querywin);
+ mvwaddstr(querywin,0,0,pr);
+ mvwaddstr(querywin,0,prlen,str);
+ wgetch(querywin);
+ if (whatinfo_height) { touchwin(whatinfowin); refreshinfo(); }
+ else if (info_height) { touchwin(infopad); refreshinfo(); }
+ else if (thisstate_height) redrawthisstate();
+}
+
+
void baselist::displayhelp(const struct helpmenuentry *helpmenu, int key) {
const struct helpmenuentry *hme;
int maxx, maxy, i, y, x, nextkey;
* dselect.h - external definitions for this program
*
* Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk>
+ * Copyright (C) 2001 Wichert Akkerman <wakkerma@debian.org>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
int topofscreen, leftofscreen, cursorline;
int infotopofscreen, infolines;
varbuf whatinfovb;
- char searchstring[50];
+ char searchstring[128];
virtual void setheights();
void unsizes();
void dosearch();
void displayhelp(const struct helpmenuentry *menu, int key);
+ void displayerror(const char* str);
void redrawall();
void redrawitemsrange(int start /*inclusive*/, int end /*exclusive*/);
virtual const char *itemname(int index) =0;
virtual const struct helpmenuentry *helpmenulist() =0;
+ virtual int checksearch(char* str);
+ virtual int matchsearch(int index);
void wordwrapinfo(int offset, const char *string);
public: