The text used for searches is no longer the same as the text displayed, this allows for a lot more powerful searching especially in drun mode
This commit is contained in:
@@ -23,7 +23,7 @@ void dmenu_init() {
|
||||
|
||||
struct cache_line* node, *tmp;
|
||||
wl_list_for_each_safe(node, tmp, cache, link) {
|
||||
wofi_insert_widget(node->line, node->line);
|
||||
wofi_insert_widget(node->line, node->line, node->line);
|
||||
map_put(cached, node->line, "true");
|
||||
free(node->line);
|
||||
wl_list_remove(&node->link);
|
||||
@@ -42,7 +42,7 @@ void dmenu_init() {
|
||||
if(map_contains(cached, line)) {
|
||||
continue;
|
||||
}
|
||||
wofi_insert_widget(line, line);
|
||||
wofi_insert_widget(line, line, line);
|
||||
}
|
||||
free(line);
|
||||
map_free(cached);
|
||||
|
16
modes/drun.c
16
modes/drun.c
@@ -50,6 +50,14 @@ static char* get_text(char* file) {
|
||||
}
|
||||
}
|
||||
|
||||
static char* get_search_text(char* file, char* name) {
|
||||
GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(file);
|
||||
const char* exec = g_app_info_get_executable(G_APP_INFO(info));
|
||||
const char* description = g_app_info_get_description(G_APP_INFO(info));
|
||||
const char* const* keywords = g_desktop_app_info_get_keywords(info);
|
||||
return utils_concat(5, name, file, exec == NULL ? "" : exec, description == NULL ? "" : description, keywords == NULL ? (const char* const*) "" : keywords);
|
||||
}
|
||||
|
||||
void drun_init() {
|
||||
struct map* cached = map_init();
|
||||
struct map* entries = map_init();
|
||||
@@ -61,8 +69,10 @@ void drun_init() {
|
||||
if(text == NULL) {
|
||||
goto cache_cont;
|
||||
}
|
||||
wofi_insert_widget(text, node->line);
|
||||
char* search_text = get_search_text(node->line, text);
|
||||
wofi_insert_widget(text, search_text, node->line);
|
||||
map_put(cached, node->line, "true");
|
||||
free(search_text);
|
||||
free(text);
|
||||
|
||||
cache_cont:
|
||||
@@ -113,8 +123,10 @@ void drun_init() {
|
||||
continue;
|
||||
}
|
||||
map_put(entries, entry->d_name, "true");
|
||||
wofi_insert_widget(text, full_path);
|
||||
char* search_text = get_search_text(full_path, text);
|
||||
wofi_insert_widget(text, search_text, full_path);
|
||||
free(text);
|
||||
free(search_text);
|
||||
free(full_path);
|
||||
}
|
||||
closedir(dir);
|
||||
|
@@ -24,8 +24,10 @@ void run_init() {
|
||||
struct cache_line* node, *tmp;
|
||||
wl_list_for_each_safe(node, tmp, cache, link) {
|
||||
char* text = strrchr(node->line, '/') + 1;
|
||||
wofi_insert_widget(text, node->line);
|
||||
char* search_text = utils_concat(2, text, node->line);
|
||||
wofi_insert_widget(text, search_text, node->line);
|
||||
map_put(cached, node->line, "true");
|
||||
free(search_text);
|
||||
free(node->line);
|
||||
wl_list_remove(&node->link);
|
||||
free(node);
|
||||
@@ -50,7 +52,9 @@ void run_init() {
|
||||
struct stat info;
|
||||
stat(full_path, &info);
|
||||
if(access(full_path, X_OK) == 0 && S_ISREG(info.st_mode) && !map_contains(cached, full_path)) {
|
||||
wofi_insert_widget(entry->d_name, full_path);
|
||||
char* search_text = utils_concat(2, entry->d_name, full_path);
|
||||
wofi_insert_widget(entry->d_name, search_text, full_path);
|
||||
free(search_text);
|
||||
}
|
||||
free(full_path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user