Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------release/scripts/addons0
-rw-r--r--source/blender/editors/include/UI_interface.h6
-rw-r--r--source/blender/editors/interface/interface.c16
-rw-r--r--source/blender/editors/interface/interface_regions.c6
-rw-r--r--source/blender/editors/space_file/filesel.c16
5 files changed, 28 insertions, 16 deletions
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject 3adbc8f30b229e7c9ff465183d5ab0acbbdf921
+Subproject 2c7464fb9510bedc6a19c43064ae83ed15f3f7c
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 38aad640ee1..50e2e53dbf0 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -641,9 +641,13 @@ void uiButSetFocusOnEnter(struct wmWindow *win, uiBut *but);
typedef struct AutoComplete AutoComplete;
+#define AUTOCOMPLETE_NO_MATCH 0
+#define AUTOCOMPLETE_FULL_MATCH 1
+#define AUTOCOMPLETE_PARTIAL_MATCH 2
+
AutoComplete *autocomplete_begin(const char *startname, size_t maxlen);
void autocomplete_do_name(AutoComplete *autocpl, const char *name);
-bool autocomplete_end(AutoComplete *autocpl, char *autoname);
+int autocomplete_end(AutoComplete *autocpl, char *autoname);
/* Panels
*
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 96638f77b10..6ee097b066f 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3188,6 +3188,7 @@ static int findBitIndex(unsigned int x)
/* autocomplete helper functions */
struct AutoComplete {
size_t maxlen;
+ int matches;
char *truncate;
const char *startname;
};
@@ -3198,6 +3199,7 @@ AutoComplete *autocomplete_begin(const char *startname, size_t maxlen)
autocpl = MEM_callocN(sizeof(AutoComplete), "AutoComplete");
autocpl->maxlen = maxlen;
+ autocpl->matches = 0;
autocpl->truncate = MEM_callocN(sizeof(char) * maxlen, "AutoCompleteTruncate");
autocpl->startname = startname;
@@ -3216,6 +3218,7 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name)
}
/* found a match */
if (startname[a] == 0) {
+ autocpl->matches++;
/* first match */
if (truncate[0] == 0)
BLI_strncpy(truncate, name, autocpl->maxlen);
@@ -3233,21 +3236,26 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name)
}
}
-bool autocomplete_end(AutoComplete *autocpl, char *autoname)
+int autocomplete_end(AutoComplete *autocpl, char *autoname)
{
- bool change = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
if (autocpl->truncate[0]) {
+ if (autocpl->matches == 1) {
+ match = AUTOCOMPLETE_FULL_MATCH;
+ } else {
+ match = AUTOCOMPLETE_PARTIAL_MATCH;
+ }
BLI_strncpy(autoname, autocpl->truncate, autocpl->maxlen);
- change = true;
}
else {
if (autoname != autocpl->startname) { /* don't copy a string over its self */
BLI_strncpy(autoname, autocpl->startname, autocpl->maxlen);
}
}
+
MEM_freeN(autocpl->truncate);
MEM_freeN(autocpl);
- return change;
+ return match;
}
static void ui_check_but_and_iconize(uiBut *but, int icon)
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 3ef613f5867..1de0a278b56 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1054,17 +1054,17 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
bool ui_searchbox_autocomplete(bContext *C, ARegion *ar, uiBut *but, char *str)
{
uiSearchboxData *data = ar->regiondata;
- bool changed = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
if (str[0]) {
data->items.autocpl = autocomplete_begin(str, ui_get_but_string_max_length(but));
but->search_func(C, but->search_arg, but->editstr, &data->items);
- changed = autocomplete_end(data->items.autocpl, str);
+ match = autocomplete_end(data->items.autocpl, str);
data->items.autocpl = NULL;
}
- return changed;
+ return match != AUTOCOMPLETE_NO_MATCH;
}
static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 9d762c80405..c6e1541352d 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -637,7 +637,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche
bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
{
SpaceFile *sfile = CTX_wm_space_file(C);
- bool change = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
/* search if str matches the beginning of name */
if (str[0] && sfile->files) {
@@ -672,9 +672,9 @@ bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
}
closedir(dir);
- change = autocomplete_end(autocpl, str);
- if (change) {
- if (BLI_exists(str)) {
+ match = autocomplete_end(autocpl, str);
+ if (match) {
+ if (match == AUTOCOMPLETE_FULL_MATCH) {
BLI_add_slash(str);
}
else {
@@ -684,13 +684,13 @@ bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
}
}
- return change;
+ return match == AUTOCOMPLETE_FULL_MATCH;
}
bool autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v))
{
SpaceFile *sfile = CTX_wm_space_file(C);
- bool change = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
/* search if str matches the beginning of name */
if (str[0] && sfile->files) {
@@ -704,9 +704,9 @@ bool autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v))
autocomplete_do_name(autocpl, file->relname);
}
}
- change = autocomplete_end(autocpl, str);
+ match = autocomplete_end(autocpl, str);
}
- return change;
+ return match != AUTOCOMPLETE_NO_MATCH;
}
void ED_fileselect_clear(struct wmWindowManager *wm, struct SpaceFile *sfile)