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:
authorHenrik Aarnio <hjaarnio@gmail.com>2013-11-19 19:31:48 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2013-11-19 19:42:50 +0400
commit035d86402bbb8dab2bfb086a3027e5ec93e52748 (patch)
treeb41a8522214d72b40d1ff7e69d215a11880907d2 /source/blender/editors/interface/interface.c
parent0c0bed3b161ae005821cc68e56ea78223d5fe16c (diff)
Fix: tab completing a filepath name in file browsers asks to create a new
directory if name was not fully matched When hitting tab to complete a directory name in the filepath field in the filebrowser Blender shows a "create new directory?" popup, if the beginning of directory name typed in the field matches many entries. For example if you have directories in the open directory called "test123" and "test456", typing "te", tab would complete up to "test", but ask to create a new folder with the name "test". This patch unsets the boolean storing the info about changing filepath if the folder with the completed name does not exist. Reviewed By: brecht Differential Revision: http://developer.blender.org/D10
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c16
1 files changed, 12 insertions, 4 deletions
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)