diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-05-06 08:51:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-05-06 09:00:09 +0300 |
commit | c0bbf1553f680dbcc67022d1e8b1d16dc2f3a5eb (patch) | |
tree | c0903563353275a040d27bd0fc9c604970ab0254 /source/blender/editors/interface/interface_utils.c | |
parent | 6fe3bbed3438e6dc4f4cf3e45b4c0628b8f70bc9 (diff) |
Cleanup: move search templates into their own files
Diffstat (limited to 'source/blender/editors/interface/interface_utils.c')
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index d8c168a1423..9688d21f5dc 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -22,6 +22,7 @@ */ #include <assert.h> +#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -51,6 +52,22 @@ #include "interface_intern.h" +bool ui_str_has_word_prefix(const char *haystack, const char *needle, size_t needle_len) +{ + const char *match = BLI_strncasestr(haystack, needle, needle_len); + if (match) { + if ((match == haystack) || (*(match - 1) == ' ') || ispunct(*(match - 1))) { + return true; + } + else { + return ui_str_has_word_prefix(match + 1, needle, needle_len); + } + } + else { + return false; + } +} + /*************************** RNA Utilities ******************************/ uiBut *uiDefAutoButR(uiBlock *block, |