summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2023-04-17 23:43:05 +0100
committerPhil Jones <philj56@gmail.com>2023-04-17 23:43:05 +0100
commit574eff0df1aff9bdc6d32939a03312cc08803de3 (patch)
tree5aeca72f70314bee3bf95db99f10d89f0a7b4032 /src/input.c
parent71a4801d20d8904cfcfa5e92c96d53ee06a2c69f (diff)
Add --matching-algorithm option.
This replaces the --fuzzy-match algorithm. Available choices are normal, prefix and fuzzy. Levenshtein distance was investigated, but it seems pretty rubbish for tofi's use case, where you normally want a good match when you've only typed a small portion of the target string.
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/input.c b/src/input.c
index 1049fa9..ad89dbd 100644
--- a/src/input.c
+++ b/src/input.c
@@ -148,12 +148,12 @@ void add_character(struct tofi *tofi, xkb_keycode_t keycode)
entry->input_utf8_length += len;
if (entry->drun) {
- struct string_ref_vec results = desktop_vec_filter(&entry->apps, entry->input_utf8, tofi->fuzzy_match);
+ struct string_ref_vec results = desktop_vec_filter(&entry->apps, entry->input_utf8, tofi->matching_algorithm);
string_ref_vec_destroy(&entry->results);
entry->results = results;
} else {
struct string_ref_vec tmp = entry->results;
- entry->results = string_ref_vec_filter(&entry->results, entry->input_utf8, tofi->fuzzy_match);
+ entry->results = string_ref_vec_filter(&entry->results, entry->input_utf8, tofi->matching_algorithm);
string_ref_vec_destroy(&tmp);
}
@@ -186,9 +186,9 @@ void input_refresh_results(struct tofi *tofi)
entry->input_utf8_length = bytes_written;
string_ref_vec_destroy(&entry->results);
if (entry->drun) {
- entry->results = desktop_vec_filter(&entry->apps, entry->input_utf8, tofi->fuzzy_match);
+ entry->results = desktop_vec_filter(&entry->apps, entry->input_utf8, tofi->matching_algorithm);
} else {
- entry->results = string_ref_vec_filter(&entry->commands, entry->input_utf8, tofi->fuzzy_match);
+ entry->results = string_ref_vec_filter(&entry->commands, entry->input_utf8, tofi->matching_algorithm);
}
reset_selection(tofi);