diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-05-25 15:41:18 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-05-25 15:41:18 -0700 |
commit | 908b07527ed5fe4952f357db73e270da9d09baba (patch) | |
tree | 53df9b5a78c5a43235aa0a2b0ec42d36a0cab8b9 /complete.h | |
parent | ee7339b66102c0a183b6cf37dbee83c5de6f4d91 (diff) |
Support for fuzzy completions
https://github.com/fish-shell/fish-shell/issues/568
https://github.com/fish-shell/fish-shell/issues/528
Diffstat (limited to 'complete.h')
-rw-r--r-- | complete.h | 31 |
1 files changed, 10 insertions, 21 deletions
@@ -75,16 +75,11 @@ enum */ COMPLETE_NO_SPACE = 1 << 0, - /** This completion is case insensitive. */ - COMPLETE_CASE_INSENSITIVE = 1 << 1, - /** This is not the suffix of a token, but replaces it entirely */ COMPLETE_REPLACES_TOKEN = 1 << 2, - /** - This completion may or may not want a space at the end - guess by - checking the last character of the completion. - */ + /** This completion may or may not want a space at the end - guess by + checking the last character of the completion. */ COMPLETE_AUTO_SPACE = 1 << 3, /** This completion should be inserted as-is, without escaping. */ @@ -107,16 +102,15 @@ public: /* Destructor. Not inlining it saves code size. */ ~completion_t(); - /** - The completion string - */ + /** The completion string */ wcstring completion; - /** - The description for this completion - */ + /** The description for this completion */ wcstring description; + /** The type of fuzzy match */ + string_fuzzy_match_t match; + /** Flags determining the completion behaviour. @@ -128,14 +122,9 @@ public: is case insensitive. */ int flags; - - bool is_case_insensitive() const - { - return !!(flags & COMPLETE_CASE_INSENSITIVE); - } - + /* Construction. Note: defining these so that they are not inlined reduces the executable size. */ - completion_t(const wcstring &comp, const wcstring &desc = L"", int flags_val = 0); + completion_t(const wcstring &comp, const wcstring &desc = L"", string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), int flags_val = 0); completion_t(const completion_t &); completion_t &operator=(const completion_t &); @@ -286,7 +275,7 @@ void complete_load(const wcstring &cmd, bool reload); \param flags completion flags */ -void append_completion(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc = L"", int flags = 0); +void append_completion(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc = L"", int flags = 0, string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact)); /* Function used for testing */ void complete_set_variable_names(const wcstring_list_t *names); |