Added case insensitive searching
This commit is contained in:
parent
a30d5c09e5
commit
3c03f89918
17
src/main.c
17
src/main.c
@ -69,6 +69,7 @@ static void print_usage(char** argv) {
|
|||||||
printf("--exec-search\t-e\tMakes enter always use the search contents not the first result\n");
|
printf("--exec-search\t-e\tMakes enter always use the search contents not the first result\n");
|
||||||
printf("--hide-scroll\t-b\tHides the scroll bars\n");
|
printf("--hide-scroll\t-b\tHides the scroll bars\n");
|
||||||
printf("--matching\t-M\tSets the matching method, default is contains\n");
|
printf("--matching\t-M\tSets the matching method, default is contains\n");
|
||||||
|
printf("--insensitive\t-I\tAllows case insensitive searching\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +305,12 @@ int main(int argc, char** argv) {
|
|||||||
.flag = NULL,
|
.flag = NULL,
|
||||||
.val = 'M'
|
.val = 'M'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "insensitive",
|
||||||
|
.has_arg = no_argument,
|
||||||
|
.flag = NULL,
|
||||||
|
.val = 'I'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = NULL,
|
.name = NULL,
|
||||||
.has_arg = 0,
|
.has_arg = 0,
|
||||||
@ -330,8 +337,9 @@ int main(int argc, char** argv) {
|
|||||||
char* exec_search = NULL;
|
char* exec_search = NULL;
|
||||||
char* hide_scroll = NULL;
|
char* hide_scroll = NULL;
|
||||||
char* matching = NULL;
|
char* matching = NULL;
|
||||||
|
char* insensitive = NULL;
|
||||||
int opt;
|
int opt;
|
||||||
while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nimk:t:P::ebM:", opts, NULL)) != -1) {
|
while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nimk:t:P::ebM:I", opts, NULL)) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
print_usage(argv);
|
print_usage(argv);
|
||||||
@ -401,6 +409,9 @@ int main(int argc, char** argv) {
|
|||||||
case 'M':
|
case 'M':
|
||||||
matching = optarg;
|
matching = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'I':
|
||||||
|
insensitive = "true";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,6 +551,10 @@ int main(int argc, char** argv) {
|
|||||||
if(matching != NULL) {
|
if(matching != NULL) {
|
||||||
map_put(config, "matching", matching);
|
map_put(config, "matching", matching);
|
||||||
}
|
}
|
||||||
|
if(insensitive != NULL) {
|
||||||
|
map_put(config, "insensitive", insensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ static GtkOrientation outer_orientation;
|
|||||||
static bool exec_search;
|
static bool exec_search;
|
||||||
static struct map* modes;
|
static struct map* modes;
|
||||||
static enum matching_mode matching;
|
static enum matching_mode matching;
|
||||||
|
static bool insensitive;
|
||||||
|
|
||||||
struct node {
|
struct node {
|
||||||
size_t action_count;
|
size_t action_count;
|
||||||
@ -443,7 +444,11 @@ static gboolean do_filter(GtkFlowBoxChild* row, gpointer data) {
|
|||||||
if(text == NULL) {
|
if(text == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
if(insensitive) {
|
||||||
|
return strcasestr(text, filter) != NULL;
|
||||||
|
} else {
|
||||||
return strstr(text, filter) != NULL;
|
return strstr(text, filter) != NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint do_sort(GtkFlowBoxChild* child1, GtkFlowBoxChild* child2, gpointer data) {
|
static gint do_sort(GtkFlowBoxChild* child1, GtkFlowBoxChild* child2, gpointer data) {
|
||||||
@ -602,6 +607,7 @@ void wofi_init(struct map* config) {
|
|||||||
exec_search = strcmp(config_get(config, "exec_search", "false"), "true") == 0;
|
exec_search = strcmp(config_get(config, "exec_search", "false"), "true") == 0;
|
||||||
bool hide_scroll = strcmp(config_get(config, "hide_scroll", "false"), "true") == 0;
|
bool hide_scroll = strcmp(config_get(config, "hide_scroll", "false"), "true") == 0;
|
||||||
matching = config_get_mnemonic(config, "matching", "contains", 2, "contains", "fuzzy");
|
matching = config_get_mnemonic(config, "matching", "contains", 2, "contains", "fuzzy");
|
||||||
|
insensitive = strcmp(config_get(config, "insensitive", "false"), "true") == 0;
|
||||||
modes = map_init_void();
|
modes = map_init_void();
|
||||||
|
|
||||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
|
Loading…
Reference in New Issue
Block a user