Here is a patch I wrote yesterday to introduce wild-card matching in the
component selector dialog.
It retains the current semantics of searching for a string _within_ the
component name, case insensitively. Whilst it "works for me", I'm not
sure if it could cause slow-down on slower CPUs, or whether this would
mainly manifest when actually making use of the glob matches.
---
Allow standard glob matches in the component selector's filter entry.
---
gschem/src/x_compselect.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gschem/src/x_compselect.c b/gschem/src/x_compselect.c
index 72b9ff0..7fdeb7e 100644
--- a/gschem/src/x_compselect.c
+++ b/gschem/src/x_compselect.c
@@ -354,7 +354,7 @@ lib_model_filter_visible_func (GtkTreeModel *model,
Compselect *compselect = (Compselect*)data;
CLibSymbol *sym;
const gchar *compname;
- gchar *compname_upper=NULL, *text_upper=NULL;
+ gchar *compname_upper, *text_upper, *pattern;
const gchar *text;
gboolean ret;
@@ -387,9 +387,11 @@ lib_model_filter_visible_func (GtkTreeModel *model,
to uppercase */
compname_upper = g_ascii_strup(compname, -1);
text_upper = g_ascii_strup(text, -1);
- ret = (strstr (compname_upper, text_upper) != NULL);
+ pattern = g_strconcat ("*", text_upper, "*", NULL);
+ ret = g_pattern_match_simple (pattern, compname_upper);
g_free(compname_upper);
g_free(text_upper);
+ g_free(pattern);
}
return ret;
--
1.5.2.3
--
Peter Clifton
Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA
Tel: +44 (0)7729 980173 - (No signal in the lab!)
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev