| File src/Makefile.in changed (mode: 100644) (index 165cb82ae..77cd95ca5) |
| ... |
... |
am_vifm_OBJECTS = cfg/config.$(OBJEXT) cfg/info.$(OBJEXT) \ |
| 196 |
196 |
modes/normal.$(OBJEXT) modes/view.$(OBJEXT) \ |
modes/normal.$(OBJEXT) modes/view.$(OBJEXT) \ |
| 197 |
197 |
modes/visual.$(OBJEXT) ui/cancellation.$(OBJEXT) \ |
modes/visual.$(OBJEXT) ui/cancellation.$(OBJEXT) \ |
| 198 |
198 |
ui/color_manager.$(OBJEXT) ui/color_scheme.$(OBJEXT) \ |
ui/color_manager.$(OBJEXT) ui/color_scheme.$(OBJEXT) \ |
| 199 |
|
ui/colored_line.$(OBJEXT) ui/column_view.$(OBJEXT) \ |
|
| 200 |
|
ui/escape.$(OBJEXT) ui/fileview.$(OBJEXT) \ |
|
| 201 |
|
ui/quickview.$(OBJEXT) ui/statusbar.$(OBJEXT) \ |
|
| 202 |
|
ui/statusline.$(OBJEXT) ui/tabs.$(OBJEXT) ui/ui.$(OBJEXT) \ |
|
| 203 |
|
utils/cancellation.$(OBJEXT) utils/dynarray.$(OBJEXT) \ |
|
| 204 |
|
utils/env.$(OBJEXT) utils/event_nix.$(OBJEXT) \ |
|
| 205 |
|
utils/file_streams.$(OBJEXT) utils/filemon.$(OBJEXT) \ |
|
| 206 |
|
utils/filter.$(OBJEXT) utils/fs.$(OBJEXT) \ |
|
| 207 |
|
utils/fsdata.$(OBJEXT) utils/fsddata.$(OBJEXT) \ |
|
| 208 |
|
utils/fswatch_nix.$(OBJEXT) utils/globs.$(OBJEXT) \ |
|
| 209 |
|
utils/gmux_nix.$(OBJEXT) utils/hist.$(OBJEXT) \ |
|
| 210 |
|
utils/int_stack.$(OBJEXT) utils/log.$(OBJEXT) \ |
|
| 211 |
|
utils/matcher.$(OBJEXT) utils/matchers.$(OBJEXT) \ |
|
| 212 |
|
utils/mem.$(OBJEXT) utils/parson.$(OBJEXT) \ |
|
| 213 |
|
utils/path.$(OBJEXT) utils/regexp.$(OBJEXT) \ |
|
| 214 |
|
utils/selector_nix.$(OBJEXT) utils/shmem_nix.$(OBJEXT) \ |
|
| 215 |
|
utils/str.$(OBJEXT) utils/string_array.$(OBJEXT) \ |
|
| 216 |
|
utils/trie.$(OBJEXT) utils/utf8.$(OBJEXT) \ |
|
| 217 |
|
utils/utf8proc.$(OBJEXT) utils/utils.$(OBJEXT) \ |
|
| 218 |
|
utils/utils_nix.$(OBJEXT) args.$(OBJEXT) background.$(OBJEXT) \ |
|
| 219 |
|
bmarks.$(OBJEXT) bracket_notation.$(OBJEXT) \ |
|
| 220 |
|
builtin_functions.$(OBJEXT) cmd_actions.$(OBJEXT) \ |
|
| 221 |
|
cmd_completion.$(OBJEXT) cmd_core.$(OBJEXT) \ |
|
| 222 |
|
cmd_handlers.$(OBJEXT) compare.$(OBJEXT) dir_stack.$(OBJEXT) \ |
|
| 223 |
|
event_loop.$(OBJEXT) filelist.$(OBJEXT) \ |
|
|
199 |
|
ui/colored_line.$(OBJEXT) ui/colors.$(OBJEXT) \ |
|
200 |
|
ui/column_view.$(OBJEXT) ui/escape.$(OBJEXT) \ |
|
201 |
|
ui/fileview.$(OBJEXT) ui/quickview.$(OBJEXT) \ |
|
202 |
|
ui/statusbar.$(OBJEXT) ui/statusline.$(OBJEXT) \ |
|
203 |
|
ui/tabs.$(OBJEXT) ui/ui.$(OBJEXT) utils/cancellation.$(OBJEXT) \ |
|
204 |
|
utils/dynarray.$(OBJEXT) utils/env.$(OBJEXT) \ |
|
205 |
|
utils/event_nix.$(OBJEXT) utils/file_streams.$(OBJEXT) \ |
|
206 |
|
utils/filemon.$(OBJEXT) utils/filter.$(OBJEXT) \ |
|
207 |
|
utils/fs.$(OBJEXT) utils/fsdata.$(OBJEXT) \ |
|
208 |
|
utils/fsddata.$(OBJEXT) utils/fswatch_nix.$(OBJEXT) \ |
|
209 |
|
utils/globs.$(OBJEXT) utils/gmux_nix.$(OBJEXT) \ |
|
210 |
|
utils/hist.$(OBJEXT) utils/int_stack.$(OBJEXT) \ |
|
211 |
|
utils/log.$(OBJEXT) utils/matcher.$(OBJEXT) \ |
|
212 |
|
utils/matchers.$(OBJEXT) utils/mem.$(OBJEXT) \ |
|
213 |
|
utils/parson.$(OBJEXT) utils/path.$(OBJEXT) \ |
|
214 |
|
utils/regexp.$(OBJEXT) utils/selector_nix.$(OBJEXT) \ |
|
215 |
|
utils/shmem_nix.$(OBJEXT) utils/str.$(OBJEXT) \ |
|
216 |
|
utils/string_array.$(OBJEXT) utils/trie.$(OBJEXT) \ |
|
217 |
|
utils/utf8.$(OBJEXT) utils/utf8proc.$(OBJEXT) \ |
|
218 |
|
utils/utils.$(OBJEXT) utils/utils_nix.$(OBJEXT) args.$(OBJEXT) \ |
|
219 |
|
background.$(OBJEXT) bmarks.$(OBJEXT) \ |
|
220 |
|
bracket_notation.$(OBJEXT) builtin_functions.$(OBJEXT) \ |
|
221 |
|
cmd_actions.$(OBJEXT) cmd_completion.$(OBJEXT) \ |
|
222 |
|
cmd_core.$(OBJEXT) cmd_handlers.$(OBJEXT) compare.$(OBJEXT) \ |
|
223 |
|
dir_stack.$(OBJEXT) event_loop.$(OBJEXT) filelist.$(OBJEXT) \ |
| 224 |
224 |
filename_modifiers.$(OBJEXT) fops_common.$(OBJEXT) \ |
filename_modifiers.$(OBJEXT) fops_common.$(OBJEXT) \ |
| 225 |
225 |
fops_cpmv.$(OBJEXT) fops_misc.$(OBJEXT) fops_put.$(OBJEXT) \ |
fops_cpmv.$(OBJEXT) fops_misc.$(OBJEXT) fops_put.$(OBJEXT) \ |
| 226 |
226 |
fops_rename.$(OBJEXT) filetype.$(OBJEXT) filtering.$(OBJEXT) \ |
fops_rename.$(OBJEXT) filetype.$(OBJEXT) filtering.$(OBJEXT) \ |
| |
| ... |
... |
am__depfiles_remade = ./$(DEPDIR)/args.Po ./$(DEPDIR)/background.Po \ |
| 369 |
369 |
modes/dialogs/$(DEPDIR)/sort_dialog.Po \ |
modes/dialogs/$(DEPDIR)/sort_dialog.Po \ |
| 370 |
370 |
ui/$(DEPDIR)/cancellation.Po ui/$(DEPDIR)/color_manager.Po \ |
ui/$(DEPDIR)/cancellation.Po ui/$(DEPDIR)/color_manager.Po \ |
| 371 |
371 |
ui/$(DEPDIR)/color_scheme.Po ui/$(DEPDIR)/colored_line.Po \ |
ui/$(DEPDIR)/color_scheme.Po ui/$(DEPDIR)/colored_line.Po \ |
| 372 |
|
ui/$(DEPDIR)/column_view.Po ui/$(DEPDIR)/escape.Po \ |
|
| 373 |
|
ui/$(DEPDIR)/fileview.Po ui/$(DEPDIR)/quickview.Po \ |
|
| 374 |
|
ui/$(DEPDIR)/statusbar.Po ui/$(DEPDIR)/statusline.Po \ |
|
| 375 |
|
ui/$(DEPDIR)/tabs.Po ui/$(DEPDIR)/ui.Po \ |
|
| 376 |
|
utils/$(DEPDIR)/cancellation.Po utils/$(DEPDIR)/dynarray.Po \ |
|
| 377 |
|
utils/$(DEPDIR)/env.Po utils/$(DEPDIR)/event_nix.Po \ |
|
| 378 |
|
utils/$(DEPDIR)/file_streams.Po utils/$(DEPDIR)/filemon.Po \ |
|
| 379 |
|
utils/$(DEPDIR)/filter.Po utils/$(DEPDIR)/fs.Po \ |
|
| 380 |
|
utils/$(DEPDIR)/fsdata.Po utils/$(DEPDIR)/fsddata.Po \ |
|
| 381 |
|
utils/$(DEPDIR)/fswatch_nix.Po utils/$(DEPDIR)/globs.Po \ |
|
| 382 |
|
utils/$(DEPDIR)/gmux_nix.Po utils/$(DEPDIR)/hist.Po \ |
|
| 383 |
|
utils/$(DEPDIR)/int_stack.Po utils/$(DEPDIR)/log.Po \ |
|
| 384 |
|
utils/$(DEPDIR)/matcher.Po utils/$(DEPDIR)/matchers.Po \ |
|
| 385 |
|
utils/$(DEPDIR)/mem.Po utils/$(DEPDIR)/parson.Po \ |
|
| 386 |
|
utils/$(DEPDIR)/path.Po utils/$(DEPDIR)/regexp.Po \ |
|
| 387 |
|
utils/$(DEPDIR)/selector_nix.Po utils/$(DEPDIR)/shmem_nix.Po \ |
|
| 388 |
|
utils/$(DEPDIR)/str.Po utils/$(DEPDIR)/string_array.Po \ |
|
| 389 |
|
utils/$(DEPDIR)/trie.Po utils/$(DEPDIR)/utf8.Po \ |
|
| 390 |
|
utils/$(DEPDIR)/utf8proc.Po utils/$(DEPDIR)/utils.Po \ |
|
| 391 |
|
utils/$(DEPDIR)/utils_nix.Po |
|
|
372 |
|
ui/$(DEPDIR)/colors.Po ui/$(DEPDIR)/column_view.Po \ |
|
373 |
|
ui/$(DEPDIR)/escape.Po ui/$(DEPDIR)/fileview.Po \ |
|
374 |
|
ui/$(DEPDIR)/quickview.Po ui/$(DEPDIR)/statusbar.Po \ |
|
375 |
|
ui/$(DEPDIR)/statusline.Po ui/$(DEPDIR)/tabs.Po \ |
|
376 |
|
ui/$(DEPDIR)/ui.Po utils/$(DEPDIR)/cancellation.Po \ |
|
377 |
|
utils/$(DEPDIR)/dynarray.Po utils/$(DEPDIR)/env.Po \ |
|
378 |
|
utils/$(DEPDIR)/event_nix.Po utils/$(DEPDIR)/file_streams.Po \ |
|
379 |
|
utils/$(DEPDIR)/filemon.Po utils/$(DEPDIR)/filter.Po \ |
|
380 |
|
utils/$(DEPDIR)/fs.Po utils/$(DEPDIR)/fsdata.Po \ |
|
381 |
|
utils/$(DEPDIR)/fsddata.Po utils/$(DEPDIR)/fswatch_nix.Po \ |
|
382 |
|
utils/$(DEPDIR)/globs.Po utils/$(DEPDIR)/gmux_nix.Po \ |
|
383 |
|
utils/$(DEPDIR)/hist.Po utils/$(DEPDIR)/int_stack.Po \ |
|
384 |
|
utils/$(DEPDIR)/log.Po utils/$(DEPDIR)/matcher.Po \ |
|
385 |
|
utils/$(DEPDIR)/matchers.Po utils/$(DEPDIR)/mem.Po \ |
|
386 |
|
utils/$(DEPDIR)/parson.Po utils/$(DEPDIR)/path.Po \ |
|
387 |
|
utils/$(DEPDIR)/regexp.Po utils/$(DEPDIR)/selector_nix.Po \ |
|
388 |
|
utils/$(DEPDIR)/shmem_nix.Po utils/$(DEPDIR)/str.Po \ |
|
389 |
|
utils/$(DEPDIR)/string_array.Po utils/$(DEPDIR)/trie.Po \ |
|
390 |
|
utils/$(DEPDIR)/utf8.Po utils/$(DEPDIR)/utf8proc.Po \ |
|
391 |
|
utils/$(DEPDIR)/utils.Po utils/$(DEPDIR)/utils_nix.Po |
| 392 |
392 |
am__mv = mv -f |
am__mv = mv -f |
| 393 |
393 |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
| 394 |
394 |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
| |
| ... |
... |
vifm_SOURCES = \ |
| 983 |
983 |
ui/color_manager.c ui/color_manager.h \ |
ui/color_manager.c ui/color_manager.h \ |
| 984 |
984 |
ui/color_scheme.c ui/color_scheme.h \ |
ui/color_scheme.c ui/color_scheme.h \ |
| 985 |
985 |
ui/colored_line.c ui/colored_line.h \ |
ui/colored_line.c ui/colored_line.h \ |
| 986 |
|
ui/colors.h \ |
|
|
986 |
|
ui/colors.c ui/colors.h \ |
| 987 |
987 |
ui/column_view.c ui/column_view.h \ |
ui/column_view.c ui/column_view.h \ |
| 988 |
988 |
ui/escape.c ui/escape.h \ |
ui/escape.c ui/escape.h \ |
| 989 |
989 |
ui/fileview.c ui/fileview.h \ |
ui/fileview.c ui/fileview.h \ |
| |
| ... |
... |
ui/color_scheme.$(OBJEXT): ui/$(am__dirstamp) \ |
| 1507 |
1507 |
ui/$(DEPDIR)/$(am__dirstamp) |
ui/$(DEPDIR)/$(am__dirstamp) |
| 1508 |
1508 |
ui/colored_line.$(OBJEXT): ui/$(am__dirstamp) \ |
ui/colored_line.$(OBJEXT): ui/$(am__dirstamp) \ |
| 1509 |
1509 |
ui/$(DEPDIR)/$(am__dirstamp) |
ui/$(DEPDIR)/$(am__dirstamp) |
|
1510 |
|
ui/colors.$(OBJEXT): ui/$(am__dirstamp) ui/$(DEPDIR)/$(am__dirstamp) |
| 1510 |
1511 |
ui/column_view.$(OBJEXT): ui/$(am__dirstamp) \ |
ui/column_view.$(OBJEXT): ui/$(am__dirstamp) \ |
| 1511 |
1512 |
ui/$(DEPDIR)/$(am__dirstamp) |
ui/$(DEPDIR)/$(am__dirstamp) |
| 1512 |
1513 |
ui/escape.$(OBJEXT): ui/$(am__dirstamp) ui/$(DEPDIR)/$(am__dirstamp) |
ui/escape.$(OBJEXT): ui/$(am__dirstamp) ui/$(DEPDIR)/$(am__dirstamp) |
| |
| ... |
... |
distclean-compile: |
| 1855 |
1856 |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/color_manager.Po@am__quote@ # am--include-marker |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/color_manager.Po@am__quote@ # am--include-marker |
| 1856 |
1857 |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/color_scheme.Po@am__quote@ # am--include-marker |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/color_scheme.Po@am__quote@ # am--include-marker |
| 1857 |
1858 |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/colored_line.Po@am__quote@ # am--include-marker |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/colored_line.Po@am__quote@ # am--include-marker |
|
1859 |
|
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/colors.Po@am__quote@ # am--include-marker |
| 1858 |
1860 |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/column_view.Po@am__quote@ # am--include-marker |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/column_view.Po@am__quote@ # am--include-marker |
| 1859 |
1861 |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/escape.Po@am__quote@ # am--include-marker |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/escape.Po@am__quote@ # am--include-marker |
| 1860 |
1862 |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/fileview.Po@am__quote@ # am--include-marker |
@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/fileview.Po@am__quote@ # am--include-marker |
| |
| ... |
... |
distclean: distclean-am |
| 2923 |
2925 |
-rm -f ui/$(DEPDIR)/color_manager.Po |
-rm -f ui/$(DEPDIR)/color_manager.Po |
| 2924 |
2926 |
-rm -f ui/$(DEPDIR)/color_scheme.Po |
-rm -f ui/$(DEPDIR)/color_scheme.Po |
| 2925 |
2927 |
-rm -f ui/$(DEPDIR)/colored_line.Po |
-rm -f ui/$(DEPDIR)/colored_line.Po |
|
2928 |
|
-rm -f ui/$(DEPDIR)/colors.Po |
| 2926 |
2929 |
-rm -f ui/$(DEPDIR)/column_view.Po |
-rm -f ui/$(DEPDIR)/column_view.Po |
| 2927 |
2930 |
-rm -f ui/$(DEPDIR)/escape.Po |
-rm -f ui/$(DEPDIR)/escape.Po |
| 2928 |
2931 |
-rm -f ui/$(DEPDIR)/fileview.Po |
-rm -f ui/$(DEPDIR)/fileview.Po |
| |
| ... |
... |
maintainer-clean: maintainer-clean-am |
| 3192 |
3195 |
-rm -f ui/$(DEPDIR)/color_manager.Po |
-rm -f ui/$(DEPDIR)/color_manager.Po |
| 3193 |
3196 |
-rm -f ui/$(DEPDIR)/color_scheme.Po |
-rm -f ui/$(DEPDIR)/color_scheme.Po |
| 3194 |
3197 |
-rm -f ui/$(DEPDIR)/colored_line.Po |
-rm -f ui/$(DEPDIR)/colored_line.Po |
|
3198 |
|
-rm -f ui/$(DEPDIR)/colors.Po |
| 3195 |
3199 |
-rm -f ui/$(DEPDIR)/column_view.Po |
-rm -f ui/$(DEPDIR)/column_view.Po |
| 3196 |
3200 |
-rm -f ui/$(DEPDIR)/escape.Po |
-rm -f ui/$(DEPDIR)/escape.Po |
| 3197 |
3201 |
-rm -f ui/$(DEPDIR)/fileview.Po |
-rm -f ui/$(DEPDIR)/fileview.Po |
| File src/cmd_handlers.c changed (mode: 100644) (index ec647b33c..1f3752008) |
| 32 |
32 |
#include <signal.h> |
#include <signal.h> |
| 33 |
33 |
#include <stddef.h> /* NULL size_t */ |
#include <stddef.h> /* NULL size_t */ |
| 34 |
34 |
#include <stdio.h> /* snprintf() */ |
#include <stdio.h> /* snprintf() */ |
| 35 |
|
#include <stdlib.h> /* EXIT_SUCCESS atoi() free() realloc() */ |
|
|
35 |
|
#include <stdlib.h> /* EXIT_SUCCESS atoi() free() */ |
| 36 |
36 |
#include <string.h> /* strchr() strcmp() strcspn() strcasecmp() strcpy() |
#include <string.h> /* strchr() strcmp() strcspn() strcasecmp() strcpy() |
| 37 |
|
strdup() strerror() strlen() strrchr() strspn() */ |
|
|
37 |
|
strdup() strerror() strlen() strrchr() */ |
| 38 |
38 |
#include <wctype.h> /* iswspace() */ |
#include <wctype.h> /* iswspace() */ |
| 39 |
39 |
#include <wchar.h> /* wcslen() wcsncmp() */ |
#include <wchar.h> /* wcslen() wcsncmp() */ |
| 40 |
40 |
|
|
| |
| ... |
... |
static int parse_highlight_attrs(const cmd_info_t *cmd_info, |
| 222 |
222 |
static int try_parse_cterm_color(const char str[], int is_fg, |
static int try_parse_cterm_color(const char str[], int is_fg, |
| 223 |
223 |
col_attr_t *color); |
col_attr_t *color); |
| 224 |
224 |
static int try_parse_gui_color(const char str[], int *color); |
static int try_parse_gui_color(const char str[], int *color); |
| 225 |
|
static int parse_color_name_value(const char str[], int fg, int *attr); |
|
| 226 |
|
static int is_default_color(const char str[]); |
|
| 227 |
225 |
static int get_attrs(const char text[], int *combine_attrs); |
static int get_attrs(const char text[], int *combine_attrs); |
| 228 |
226 |
static int history_cmd(const cmd_info_t *cmd_info); |
static int history_cmd(const cmd_info_t *cmd_info); |
| 229 |
227 |
static int histnext_cmd(const cmd_info_t *cmd_info); |
static int histnext_cmd(const cmd_info_t *cmd_info); |
| |
| ... |
... |
static int |
| 3291 |
3289 |
try_parse_cterm_color(const char str[], int is_fg, col_attr_t *color) |
try_parse_cterm_color(const char str[], int is_fg, col_attr_t *color) |
| 3292 |
3290 |
{ |
{ |
| 3293 |
3291 |
col_scheme_t *const cs = curr_stats.cs; |
col_scheme_t *const cs = curr_stats.cs; |
| 3294 |
|
const int col_num = parse_color_name_value(str, is_fg, &color->attr); |
|
|
3292 |
|
const int col_num = cols_parse_value(str, is_fg, &color->attr); |
| 3295 |
3293 |
|
|
| 3296 |
3294 |
if(col_num < -1) |
if(col_num < -1) |
| 3297 |
3295 |
{ |
{ |
| |
| ... |
... |
try_parse_cterm_color(const char str[], int is_fg, col_attr_t *color) |
| 3321 |
3319 |
static int |
static int |
| 3322 |
3320 |
try_parse_gui_color(const char str[], int *color) |
try_parse_gui_color(const char str[], int *color) |
| 3323 |
3321 |
{ |
{ |
| 3324 |
|
const char *hex_digits = "0123456789abcdefABCDEF"; |
|
| 3325 |
|
|
|
| 3326 |
|
if(is_default_color(str)) |
|
| 3327 |
|
{ |
|
| 3328 |
|
*color = -1; |
|
| 3329 |
|
return 0; |
|
| 3330 |
|
} |
|
| 3331 |
|
|
|
| 3332 |
|
*color = string_array_pos_case(XTERM256_COLOR_NAMES, |
|
| 3333 |
|
ARRAY_LEN(XTERM256_COLOR_NAMES), str); |
|
| 3334 |
|
if(*color >= 0 && *color < 8) |
|
| 3335 |
|
{ |
|
| 3336 |
|
return 0; |
|
| 3337 |
|
} |
|
| 3338 |
|
|
|
| 3339 |
|
if(str[0] != '#' || strlen(str) != 7 || strspn(str + 1, hex_digits) != 6) |
|
|
3322 |
|
if(cols_parse_gui_value(str, color) != 0) |
| 3340 |
3323 |
{ |
{ |
| 3341 |
3324 |
ui_sb_errf("Unrecognized color value format: %s", str); |
ui_sb_errf("Unrecognized color value format: %s", str); |
| 3342 |
3325 |
if(curr_stats.cs->state == CSS_LOADING) |
if(curr_stats.cs->state == CSS_LOADING) |
| |
| ... |
... |
try_parse_gui_color(const char str[], int *color) |
| 3346 |
3329 |
return 1; |
return 1; |
| 3347 |
3330 |
} |
} |
| 3348 |
3331 |
|
|
| 3349 |
|
unsigned int value; |
|
| 3350 |
|
(void)sscanf(str, "#%x", &value); |
|
| 3351 |
|
|
|
| 3352 |
|
*color = value; |
|
| 3353 |
3332 |
return 0; |
return 0; |
| 3354 |
3333 |
} |
} |
| 3355 |
3334 |
|
|
| 3356 |
|
/* Parses color string into color number and alters *attr in some cases. |
|
| 3357 |
|
* Returns value less than -1 to indicate error as -1 is valid return value. */ |
|
| 3358 |
|
static int |
|
| 3359 |
|
parse_color_name_value(const char str[], int fg, int *attr) |
|
| 3360 |
|
{ |
|
| 3361 |
|
int col_pos; |
|
| 3362 |
|
int light_col_pos; |
|
| 3363 |
|
int col_num; |
|
| 3364 |
|
|
|
| 3365 |
|
if(is_default_color(str)) |
|
| 3366 |
|
{ |
|
| 3367 |
|
return -1; |
|
| 3368 |
|
} |
|
| 3369 |
|
|
|
| 3370 |
|
light_col_pos = string_array_pos_case(LIGHT_COLOR_NAMES, |
|
| 3371 |
|
ARRAY_LEN(LIGHT_COLOR_NAMES), str); |
|
| 3372 |
|
if(light_col_pos >= 0 && COLORS < 16) |
|
| 3373 |
|
{ |
|
| 3374 |
|
*attr |= (!fg && curr_stats.exec_env_type == EET_LINUX_NATIVE) ? |
|
| 3375 |
|
A_BLINK : A_BOLD; |
|
| 3376 |
|
return light_col_pos; |
|
| 3377 |
|
} |
|
| 3378 |
|
|
|
| 3379 |
|
col_pos = string_array_pos_case(XTERM256_COLOR_NAMES, |
|
| 3380 |
|
ARRAY_LEN(XTERM256_COLOR_NAMES), str); |
|
| 3381 |
|
if(col_pos >= 0) |
|
| 3382 |
|
{ |
|
| 3383 |
|
if(!fg && curr_stats.exec_env_type == EET_LINUX_NATIVE) |
|
| 3384 |
|
{ |
|
| 3385 |
|
*attr &= ~A_BLINK; |
|
| 3386 |
|
} |
|
| 3387 |
|
return col_pos; |
|
| 3388 |
|
} |
|
| 3389 |
|
|
|
| 3390 |
|
col_num = isdigit(*str) ? atoi(str) : -1; |
|
| 3391 |
|
if(col_num >= 0 && col_num < COLORS) |
|
| 3392 |
|
{ |
|
| 3393 |
|
return col_num; |
|
| 3394 |
|
} |
|
| 3395 |
|
|
|
| 3396 |
|
/* Fail if all possible parsing ways failed. */ |
|
| 3397 |
|
return -2; |
|
| 3398 |
|
} |
|
| 3399 |
|
|
|
| 3400 |
|
/* Checks whether a string signifies a default color. Returns non-zero if so, |
|
| 3401 |
|
* otherwise zero is returned. */ |
|
| 3402 |
|
static int |
|
| 3403 |
|
is_default_color(const char str[]) |
|
| 3404 |
|
{ |
|
| 3405 |
|
return (strcmp(str, "-1") == 0) |
|
| 3406 |
|
|| (strcasecmp(str, "default") == 0) |
|
| 3407 |
|
|| (strcasecmp(str, "none") == 0); |
|
| 3408 |
|
} |
|
| 3409 |
|
|
|
| 3410 |
3335 |
/* Parses comma-separated list of attributes. Returns parsed result or -1 on |
/* Parses comma-separated list of attributes. Returns parsed result or -1 on |
| 3411 |
3336 |
* error. *combine_attrs is always assigned to. */ |
* error. *combine_attrs is always assigned to. */ |
| 3412 |
3337 |
static int |
static int |
| 3413 |
3338 |
get_attrs(const char text[], int *combine_attrs) |
get_attrs(const char text[], int *combine_attrs) |
| 3414 |
3339 |
{ |
{ |
| 3415 |
|
#ifdef HAVE_A_ITALIC_DECL |
|
| 3416 |
|
const int italic_attr = A_ITALIC; |
|
| 3417 |
|
#else |
|
| 3418 |
|
/* If A_ITALIC is missing (it's an extension), use A_REVERSE instead. */ |
|
| 3419 |
|
const int italic_attr = A_REVERSE; |
|
| 3420 |
|
#endif |
|
| 3421 |
|
|
|
| 3422 |
3340 |
*combine_attrs = 0; |
*combine_attrs = 0; |
| 3423 |
3341 |
|
|
| 3424 |
3342 |
int result = 0; |
int result = 0; |
| |
| ... |
... |
get_attrs(const char text[], int *combine_attrs) |
| 3428 |
3346 |
char buf[64]; |
char buf[64]; |
| 3429 |
3347 |
|
|
| 3430 |
3348 |
copy_str(buf, p - text + 1, text); |
copy_str(buf, p - text + 1, text); |
| 3431 |
|
if(strcasecmp(buf, "bold") == 0) |
|
| 3432 |
|
result |= A_BOLD; |
|
| 3433 |
|
else if(strcasecmp(buf, "underline") == 0) |
|
| 3434 |
|
result |= A_UNDERLINE; |
|
| 3435 |
|
else if(strcasecmp(buf, "reverse") == 0) |
|
| 3436 |
|
result |= A_REVERSE; |
|
| 3437 |
|
else if(strcasecmp(buf, "inverse") == 0) |
|
| 3438 |
|
result |= A_REVERSE; |
|
| 3439 |
|
else if(strcasecmp(buf, "standout") == 0) |
|
| 3440 |
|
result |= A_STANDOUT; |
|
| 3441 |
|
else if(strcasecmp(buf, "italic") == 0) |
|
| 3442 |
|
result |= italic_attr; |
|
| 3443 |
|
else if(strcasecmp(buf, "none") == 0) |
|
| 3444 |
|
result = *combine_attrs = 0; |
|
| 3445 |
|
else if(strcasecmp(buf, "combine") == 0) |
|
| 3446 |
|
*combine_attrs = 1; |
|
| 3447 |
|
else |
|
|
3349 |
|
if(cols_parse_attr(buf, &result, combine_attrs) != 0) |
|
3350 |
|
{ |
| 3448 |
3351 |
return -1; |
return -1; |
|
3352 |
|
} |
| 3449 |
3353 |
|
|
| 3450 |
3354 |
text = (*p == '\0') ? p : p + 1; |
text = (*p == '\0') ? p : p + 1; |
| 3451 |
3355 |
} |
} |
| File src/ui/colors.c added (mode: 100644) (index 000000000..78b1ae36a) |
|
1 |
|
/* vifm |
|
2 |
|
* Copyright (C) 2026 xaizek. |
|
3 |
|
* |
|
4 |
|
* This program is free software; you can redistribute it and/or modify |
|
5 |
|
* it under the terms of the GNU General Public License as published by |
|
6 |
|
* the Free Software Foundation; either version 2 of the License, or |
|
7 |
|
* (at your option) any later version. |
|
8 |
|
* |
|
9 |
|
* This program is distributed in the hope that it will be useful, |
|
10 |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
|
* GNU General Public License for more details. |
|
13 |
|
* |
|
14 |
|
* You should have received a copy of the GNU General Public License |
|
15 |
|
* along with this program; if not, write to the Free Software |
|
16 |
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|
17 |
|
*/ |
|
18 |
|
|
|
19 |
|
#include "colors.h" |
|
20 |
|
|
|
21 |
|
#include <curses.h> /* COLORS */ |
|
22 |
|
|
|
23 |
|
#include <ctype.h> /* isdigit() */ |
|
24 |
|
#include <stdlib.h> /* atoi() */ |
|
25 |
|
#include <stdio.h> /* sscanf() */ |
|
26 |
|
#include <string.h> /* strcmp() strcasecmp() strlen() strspn() */ |
|
27 |
|
|
|
28 |
|
#include "../utils/macros.h" |
|
29 |
|
#include "../utils/string_array.h" |
|
30 |
|
#include "../status.h" |
|
31 |
|
#include "color_scheme.h" |
|
32 |
|
|
|
33 |
|
static int is_def_color(const char str[]); |
|
34 |
|
|
|
35 |
|
int |
|
36 |
|
cols_parse_value(const char str[], int is_fg, int *attr) |
|
37 |
|
{ |
|
38 |
|
if(is_def_color(str)) |
|
39 |
|
{ |
|
40 |
|
return -1; |
|
41 |
|
} |
|
42 |
|
|
|
43 |
|
const int light_col_pos = string_array_pos_case(LIGHT_COLOR_NAMES, |
|
44 |
|
ARRAY_LEN(LIGHT_COLOR_NAMES), str); |
|
45 |
|
if(light_col_pos >= 0 && COLORS < 16) |
|
46 |
|
{ |
|
47 |
|
*attr |= (!is_fg && curr_stats.exec_env_type == EET_LINUX_NATIVE) ? |
|
48 |
|
A_BLINK : A_BOLD; |
|
49 |
|
return light_col_pos; |
|
50 |
|
} |
|
51 |
|
|
|
52 |
|
const int col_pos = string_array_pos_case(XTERM256_COLOR_NAMES, |
|
53 |
|
ARRAY_LEN(XTERM256_COLOR_NAMES), str); |
|
54 |
|
if(col_pos >= 0) |
|
55 |
|
{ |
|
56 |
|
if(!is_fg && curr_stats.exec_env_type == EET_LINUX_NATIVE) |
|
57 |
|
{ |
|
58 |
|
*attr &= ~A_BLINK; |
|
59 |
|
} |
|
60 |
|
return col_pos; |
|
61 |
|
} |
|
62 |
|
|
|
63 |
|
const int col_num = isdigit(*str) ? atoi(str) : -1; |
|
64 |
|
if(col_num >= 0 && col_num < COLORS) |
|
65 |
|
{ |
|
66 |
|
return col_num; |
|
67 |
|
} |
|
68 |
|
|
|
69 |
|
/* Fail if all possible parsing ways failed. */ |
|
70 |
|
return -2; |
|
71 |
|
} |
|
72 |
|
|
|
73 |
|
int |
|
74 |
|
cols_parse_gui_value(const char str[], int *color) |
|
75 |
|
{ |
|
76 |
|
const char *hex_digits = "0123456789abcdefABCDEF"; |
|
77 |
|
|
|
78 |
|
if(is_def_color(str)) |
|
79 |
|
{ |
|
80 |
|
*color = -1; |
|
81 |
|
return 0; |
|
82 |
|
} |
|
83 |
|
|
|
84 |
|
*color = string_array_pos_case(XTERM256_COLOR_NAMES, |
|
85 |
|
ARRAY_LEN(XTERM256_COLOR_NAMES), str); |
|
86 |
|
if(*color >= 0 && *color < 8) |
|
87 |
|
{ |
|
88 |
|
return 0; |
|
89 |
|
} |
|
90 |
|
|
|
91 |
|
if(str[0] != '#' || strlen(str) != 7 || strspn(str + 1, hex_digits) != 6) |
|
92 |
|
{ |
|
93 |
|
return 1; |
|
94 |
|
} |
|
95 |
|
|
|
96 |
|
unsigned int value; |
|
97 |
|
if(sscanf(str, "#%x", &value) != 1) |
|
98 |
|
{ |
|
99 |
|
return 1; |
|
100 |
|
} |
|
101 |
|
|
|
102 |
|
*color = value; |
|
103 |
|
return 0; |
|
104 |
|
} |
|
105 |
|
|
|
106 |
|
/* Checks whether a string signifies a default color. Returns non-zero if so, |
|
107 |
|
* otherwise zero is returned. */ |
|
108 |
|
static int |
|
109 |
|
is_def_color(const char str[]) |
|
110 |
|
{ |
|
111 |
|
return (strcmp(str, "-1") == 0) |
|
112 |
|
|| (strcasecmp(str, "default") == 0) |
|
113 |
|
|| (strcasecmp(str, "none") == 0); |
|
114 |
|
} |
|
115 |
|
|
|
116 |
|
int |
|
117 |
|
cols_parse_attr(const char str[], int *attrs, int *combine_attrs) |
|
118 |
|
{ |
|
119 |
|
#ifdef HAVE_A_ITALIC_DECL |
|
120 |
|
const int italic_attr = A_ITALIC; |
|
121 |
|
#else |
|
122 |
|
/* If A_ITALIC is missing (it's an extension), use A_REVERSE instead. */ |
|
123 |
|
const int italic_attr = A_REVERSE; |
|
124 |
|
#endif |
|
125 |
|
|
|
126 |
|
if(strcasecmp(str, "bold") == 0) |
|
127 |
|
*attrs |= A_BOLD; |
|
128 |
|
else if(strcasecmp(str, "underline") == 0) |
|
129 |
|
*attrs |= A_UNDERLINE; |
|
130 |
|
else if(strcasecmp(str, "reverse") == 0) |
|
131 |
|
*attrs |= A_REVERSE; |
|
132 |
|
else if(strcasecmp(str, "inverse") == 0) |
|
133 |
|
*attrs |= A_REVERSE; |
|
134 |
|
else if(strcasecmp(str, "standout") == 0) |
|
135 |
|
*attrs |= A_STANDOUT; |
|
136 |
|
else if(strcasecmp(str, "italic") == 0) |
|
137 |
|
*attrs |= italic_attr; |
|
138 |
|
else if(strcasecmp(str, "none") == 0) |
|
139 |
|
*attrs = *combine_attrs = 0; |
|
140 |
|
else if(strcasecmp(str, "combine") == 0) |
|
141 |
|
*combine_attrs = 1; |
|
142 |
|
else |
|
143 |
|
return -1; |
|
144 |
|
|
|
145 |
|
return 0; |
|
146 |
|
} |
|
147 |
|
|
|
148 |
|
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
|
149 |
|
/* vim: set cinoptions+=t0 filetype=c : */ |