Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/filesel.c
| Show First 20 Lines • Show All 438 Lines • ▼ Show 20 Lines | else { | ||||
| } | } | ||||
| } | } | ||||
| return sw; | return sw; | ||||
| } | } | ||||
| float file_string_width(const char *str) | float file_string_width(const char *str) | ||||
| { | { | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| uiStyleFontSet(&style->widget); | UI_fontstyle_set(&style->widget); | ||||
| return BLF_width(style->widget.uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); | return BLF_width(style->widget.uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); | ||||
| } | } | ||||
| float file_font_pointsize(void) | float file_font_pointsize(void) | ||||
| { | { | ||||
| #if 0 | #if 0 | ||||
| float s; | float s; | ||||
| char tmp[2] = "X"; | char tmp[2] = "X"; | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| uiStyleFontSet(&style->widget); | UI_fontstyle_set(&style->widget); | ||||
| s = BLF_height(style->widget.uifont_id, tmp); | s = BLF_height(style->widget.uifont_id, tmp); | ||||
| return style->widget.points; | return style->widget.points; | ||||
| #else | #else | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| uiStyleFontSet(&style->widget); | UI_fontstyle_set(&style->widget); | ||||
| return style->widget.points * UI_DPI_FAC; | return style->widget.points * UI_DPI_FAC; | ||||
| #endif | #endif | ||||
| } | } | ||||
| static void column_widths(struct FileList *files, struct FileLayout *layout) | static void column_widths(struct FileList *files, struct FileLayout *layout) | ||||
| { | { | ||||
| int i; | int i; | ||||
| int numfiles = filelist_numfiles(files); | int numfiles = filelist_numfiles(files); | ||||
| ▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | if (str[0] && sfile->files) { | ||||
| DIR *dir; | DIR *dir; | ||||
| struct dirent *de; | struct dirent *de; | ||||
| BLI_split_dir_part(str, dirname, sizeof(dirname)); | BLI_split_dir_part(str, dirname, sizeof(dirname)); | ||||
| dir = opendir(dirname); | dir = opendir(dirname); | ||||
| if (dir) { | if (dir) { | ||||
| AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); | AutoComplete *autocpl = UI_autocomplete_begin(str, FILE_MAX); | ||||
| while ((de = readdir(dir)) != NULL) { | while ((de = readdir(dir)) != NULL) { | ||||
| if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0) { | if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0) { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| else { | else { | ||||
| char path[FILE_MAX]; | char path[FILE_MAX]; | ||||
| BLI_stat_t status; | BLI_stat_t status; | ||||
| BLI_join_dirfile(path, sizeof(path), dirname, de->d_name); | BLI_join_dirfile(path, sizeof(path), dirname, de->d_name); | ||||
| if (BLI_stat(path, &status) == 0) { | if (BLI_stat(path, &status) == 0) { | ||||
| if (S_ISDIR(status.st_mode)) { /* is subdir */ | if (S_ISDIR(status.st_mode)) { /* is subdir */ | ||||
| autocomplete_do_name(autocpl, path); | UI_autocomplete_update_name(autocpl, path); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| closedir(dir); | closedir(dir); | ||||
| match = autocomplete_end(autocpl, str); | match = UI_autocomplete_end(autocpl, str); | ||||
| if (match) { | if (match) { | ||||
| if (match == AUTOCOMPLETE_FULL_MATCH) { | if (match == AUTOCOMPLETE_FULL_MATCH) { | ||||
| BLI_add_slash(str); | BLI_add_slash(str); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_strncpy(sfile->params->dir, str, sizeof(sfile->params->dir)); | BLI_strncpy(sfile->params->dir, str, sizeof(sfile->params->dir)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return match; | return match; | ||||
| } | } | ||||
| int autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) | int autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) | ||||
| { | { | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| int match = AUTOCOMPLETE_NO_MATCH; | int match = AUTOCOMPLETE_NO_MATCH; | ||||
| /* search if str matches the beginning of name */ | /* search if str matches the beginning of name */ | ||||
| if (str[0] && sfile->files) { | if (str[0] && sfile->files) { | ||||
| AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); | AutoComplete *autocpl = UI_autocomplete_begin(str, FILE_MAX); | ||||
| int nentries = filelist_numfiles(sfile->files); | int nentries = filelist_numfiles(sfile->files); | ||||
| int i; | int i; | ||||
| for (i = 0; i < nentries; ++i) { | for (i = 0; i < nentries; ++i) { | ||||
| struct direntry *file = filelist_file(sfile->files, i); | struct direntry *file = filelist_file(sfile->files, i); | ||||
| if (file && (S_ISREG(file->type) || S_ISDIR(file->type))) { | if (file && (S_ISREG(file->type) || S_ISDIR(file->type))) { | ||||
| autocomplete_do_name(autocpl, file->relname); | UI_autocomplete_update_name(autocpl, file->relname); | ||||
| } | } | ||||
| } | } | ||||
| match = autocomplete_end(autocpl, str); | match = UI_autocomplete_end(autocpl, str); | ||||
| } | } | ||||
| return match; | return match; | ||||
| } | } | ||||
| void ED_fileselect_clear(struct wmWindowManager *wm, struct SpaceFile *sfile) | void ED_fileselect_clear(struct wmWindowManager *wm, struct SpaceFile *sfile) | ||||
| { | { | ||||
| /* only NULL in rare cases - [#29734] */ | /* only NULL in rare cases - [#29734] */ | ||||
| Show All 28 Lines | |||||