diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/filetypes.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c index cd4f4e79b7..f23026ea69 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -196,6 +196,21 @@ static char *filetypes_store_plugin(char *plugin, int n) | |||
196 | viewers[viewer_count++] = n; | 196 | viewers[viewer_count++] = n; |
197 | return filetypes_strdup(plugin); | 197 | return filetypes_strdup(plugin); |
198 | } | 198 | } |
199 | |||
200 | static int find_extension(const char* extension) | ||
201 | { | ||
202 | int i; | ||
203 | if (!extension) | ||
204 | return -1; | ||
205 | for (i=1; i<filetype_count; i++) | ||
206 | { | ||
207 | if (filetypes[i].extension && | ||
208 | !strcasecmp(extension, filetypes[i].extension)) | ||
209 | return i; | ||
210 | } | ||
211 | return -1; | ||
212 | } | ||
213 | |||
199 | static void read_builtin_types(void); | 214 | static void read_builtin_types(void); |
200 | static void read_config(const char* config_file); | 215 | static void read_config(const char* config_file); |
201 | #ifdef HAVE_LCD_COLOR | 216 | #ifdef HAVE_LCD_COLOR |
@@ -231,15 +246,9 @@ void read_color_theme_file(void) { | |||
231 | hex_to_rgb(color, &custom_colors[MAX_FILETYPES]); | 246 | hex_to_rgb(color, &custom_colors[MAX_FILETYPES]); |
232 | continue; | 247 | continue; |
233 | } | 248 | } |
234 | for (i=1; i<filetype_count; i++) | 249 | i = find_extension(ext); |
235 | { | 250 | if (i >= 0) |
236 | if (filetypes[i].extension && | 251 | hex_to_rgb(color, &custom_colors[i]); |
237 | !strcasecmp(ext, filetypes[i].extension)) | ||
238 | { | ||
239 | hex_to_rgb(color, &custom_colors[i]); | ||
240 | break; | ||
241 | } | ||
242 | } | ||
243 | } | 252 | } |
244 | close(fd); | 253 | close(fd); |
245 | } | 254 | } |
@@ -268,23 +277,19 @@ void read_viewer_theme_file(void) | |||
268 | { | 277 | { |
269 | if (!settings_parseline(buffer, &ext, &icon)) | 278 | if (!settings_parseline(buffer, &ext, &icon)) |
270 | continue; | 279 | continue; |
271 | for (i=0; i<filetype_count; i++) | 280 | i = find_extension(ext); |
281 | if (i >= 0) | ||
272 | { | 282 | { |
273 | if (filetypes[i].extension && | 283 | if (*icon == '*') |
274 | !strcasecmp(ext, filetypes[i].extension)) | 284 | custom_filetype_icons[i] = atoi(icon+1); |
285 | else if (*icon == '-') | ||
286 | custom_filetype_icons[i] = Icon_NOICON; | ||
287 | else if (*icon >= '0' && *icon <= '9') | ||
275 | { | 288 | { |
276 | if (*icon == '*') | 289 | int number = atoi(icon); |
277 | custom_filetype_icons[i] = atoi(icon+1); | 290 | if (number > global_status.viewer_icon_count) |
278 | else if (*icon == '-') | 291 | global_status.viewer_icon_count++; |
279 | custom_filetype_icons[i] = Icon_NOICON; | 292 | custom_filetype_icons[i] = Icon_Last_Themeable + number; |
280 | else if (*icon >= '0' && *icon <= '9') | ||
281 | { | ||
282 | int number = atoi(icon); | ||
283 | if (number > global_status.viewer_icon_count) | ||
284 | global_status.viewer_icon_count++; | ||
285 | custom_filetype_icons[i] = Icon_Last_Themeable + number; | ||
286 | } | ||
287 | break; | ||
288 | } | 293 | } |
289 | } | 294 | } |
290 | } | 295 | } |
@@ -363,7 +368,7 @@ static void read_config(const char* config_file) | |||
363 | break; | 368 | break; |
364 | } | 369 | } |
365 | rm_whitespaces(line); | 370 | rm_whitespaces(line); |
366 | /* get the extention */ | 371 | /* get the extension */ |
367 | s = line; | 372 | s = line; |
368 | e = strchr(s, ','); | 373 | e = strchr(s, ','); |
369 | if (!e) | 374 | if (!e) |
@@ -406,12 +411,10 @@ int filetype_get_attr(const char* file) | |||
406 | if (!extension) | 411 | if (!extension) |
407 | return 0; | 412 | return 0; |
408 | extension++; | 413 | extension++; |
409 | for (i=0; i<filetype_count; i++) | 414 | |
410 | { | 415 | i = find_extension(extension); |
411 | if (filetypes[i].extension && | 416 | if (i >= 0) |
412 | !strcasecmp(extension, filetypes[i].extension)) | 417 | return (filetypes[i].attr<<8)&FILE_ATTR_MASK; |
413 | return (filetypes[i].attr<<8)&FILE_ATTR_MASK; | ||
414 | } | ||
415 | return 0; | 418 | return 0; |
416 | } | 419 | } |
417 | 420 | ||
@@ -440,13 +443,10 @@ int filetype_get_color(const char * name, int attr) | |||
440 | if (!extension) | 443 | if (!extension) |
441 | return custom_colors[MAX_FILETYPES]; | 444 | return custom_colors[MAX_FILETYPES]; |
442 | extension++; | 445 | extension++; |
443 | 446 | ||
444 | for (i=1; i<filetype_count; i++) | 447 | i = find_extension(extension); |
445 | { | 448 | if (i >= 0) |
446 | if (filetypes[i].extension && | 449 | return custom_colors[i]; |
447 | !strcasecmp(extension, filetypes[i].extension)) | ||
448 | return custom_colors[i]; | ||
449 | } | ||
450 | return custom_colors[MAX_FILETYPES]; | 450 | return custom_colors[MAX_FILETYPES]; |
451 | } | 451 | } |
452 | #endif | 452 | #endif |