diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-07-11 07:23:45 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-07-11 07:23:45 +0400 |
commit | 576a642ff9b5ca5094f5bb84ada3c5639ae01a92 (patch) | |
tree | 950a5f5ce861a8fa04fb2727e0e65a464ccbab9c /source/blender/editors/space_file/filesel.c | |
parent | 1105ee701ed20d6301a174fc4285de00f8e0f95e (diff) | |
parent | b80b581bc03b6df28bd3a10118d85b78d5ca011b (diff) |
NLA SoC: Merge from 2.5 soc-2009-aligorith
21470 to 21512
Next up, NLA-branch to 2.5 :)
Diffstat (limited to 'source/blender/editors/space_file/filesel.c')
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 476145d11a2..d34eb29a78d 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -80,6 +80,17 @@ #include "file_intern.h" #include "filelist.h" +#if defined __BeOS +static int fnmatch(const char *pattern, const char *string, int flags) +{ + return 0; +} +#elif defined WIN32 && !defined _LIBC + /* use fnmatch included in blenlib */ + #include "BLI_fnmatch.h" +#else + #include <fnmatch.h> +#endif FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile) { @@ -290,7 +301,7 @@ FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar void file_change_dir(struct SpaceFile *sfile) { - if (sfile->params) { + if (sfile->params && BLI_exists(sfile->params->dir)) { filelist_setdir(sfile->files, sfile->params->dir); if(folderlist_clear_next(sfile)) @@ -302,3 +313,46 @@ void file_change_dir(struct SpaceFile *sfile) sfile->params->active_file = -1; } } + +int file_select_match(struct SpaceFile *sfile, const char *pattern) +{ + int match = 0; + if (strchr(pattern, '*') || strchr(pattern, '?') || strchr(pattern, '[')) { + int i; + struct direntry *file; + int n = filelist_numfiles(sfile->files); + + for (i = 0; i < n; i++) { + file = filelist_file(sfile->files, i); + if (fnmatch(pattern, file->relname, 0) == 0) { + file->flags |= ACTIVE; + match = 1; + } + } + } + return match; +} + + +void autocomplete_directory(struct bContext *C, char *str, void *arg_v) +{ + char tmp[FILE_MAX]; + SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + + /* search if str matches the beginning of name */ + if(str[0] && sfile->files) { + AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); + int nentries = filelist_numfiles(sfile->files); + int i; + + for(i= 0; i<nentries; ++i) { + struct direntry* file = filelist_file(sfile->files, i); + char* dir = filelist_dir(sfile->files); + if (file && S_ISDIR(file->type)) { + BLI_make_file_string(G.sce, tmp, dir, file->relname); + autocomplete_do_name(autocpl,tmp); + } + } + autocomplete_end(autocpl, str); + } +}
\ No newline at end of file |