Files
test2/source/blender/editors/include/UI_string_search.hh
Jacques Lucke 09e6ebb5f0 UI: support different main word heuristics in string search
Currently, we always prioritize the words in the last section of a search item
(the words that are highlighted). This generally works well, but the situation
is a bit different for link-drag-search, because there the last part is the socket
name, which is usually less descriptive than the node name.

This patch allows us to use different heuristics to select the prioritized section
per search.

Unfortunately, the link-drag-search is not fully consistent with itself. Sometimes
the last group is a socket name, but sometimes it's also the mode of a node
(`Math > Add`). Therefore, the patch currently simply prioritizes all words in the
same instead of prioritizing only the first part. This seems to work much better
than before even if not perfect in all cases yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/113648
2023-10-20 13:50:10 +02:00

39 lines
1.1 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "BLI_string_search.hh"
namespace blender::ui::string_search {
/**
* Remember the string that the user chose. This allows us to put it higher up in the search items
* later on.
*/
void add_recent_search(StringRef chosen_str);
/**
* Depending on the user preferences, either outputs the recent cache or null.
*/
const blender::string_search::RecentCache *get_recent_cache_or_null();
void write_recent_searches_file();
void read_recent_searches_file();
/**
* Wrapper for the lower level #StringSearch in blenlib that takes recent searches into account
* automatically.
*/
template<typename T> class StringSearch : public blender::string_search::StringSearch<T> {
public:
StringSearch(const blender::string_search::MainWordsHeuristic main_word_heuristic =
blender::string_search::MainWordsHeuristic::LastGroup)
: blender::string_search::StringSearch<T>(get_recent_cache_or_null(), main_word_heuristic)
{
}
};
} // namespace blender::ui::string_search