summaryrefslogtreecommitdiff
path: root/colors.c
diff options
context:
space:
mode:
Diffstat (limited to 'colors.c')
-rw-r--r--colors.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/colors.c b/colors.c
index 9e37527..dba81a2 100644
--- a/colors.c
+++ b/colors.c
@@ -2,7 +2,7 @@
Modified by Chet Ramey for Readline.
- Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015, 2017, 2019
+ Copyright (C) 1985, 1988, 1990-1991, 1995-2021
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -73,6 +73,8 @@
static bool is_colored (enum indicator_no type);
static void restore_default_color (void);
+#define RL_COLOR_PREFIX_EXTENSION "readline-colored-completion-prefix"
+
COLOR_EXT_TYPE *_rl_color_ext_list = 0;
/* Output a color indicator (which may contain nulls). */
@@ -110,13 +112,28 @@ _rl_set_normal_color (void)
}
}
+static struct bin_str *
+_rl_custom_readline_prefix (void)
+{
+ size_t len;
+ COLOR_EXT_TYPE *ext;
+
+ len = strlen (RL_COLOR_PREFIX_EXTENSION);
+ for (ext = _rl_color_ext_list; ext; ext = ext->next)
+ if (ext->ext.len == len && STREQN (ext->ext.string, RL_COLOR_PREFIX_EXTENSION, len))
+ return (&ext->seq);
+ return (NULL);
+}
+
bool
_rl_print_prefix_color (void)
{
struct bin_str *s;
/* What do we want to use for the prefix? Let's try cyan first, see colors.h */
- s = &_rl_color_indicator[C_PREFIX];
+ s = _rl_custom_readline_prefix ();
+ if (s == 0)
+ s = &_rl_color_indicator[C_PREFIX];
if (s->string != NULL)
{
if (is_colored (C_NORM))
@@ -239,8 +256,10 @@ _rl_print_color_indicator (const char *f)
else if (S_ISSOCK (mode))
colored_filetype = C_SOCK;
#endif
+#if defined (S_ISBLK)
else if (S_ISBLK (mode))
colored_filetype = C_BLK;
+#endif
else if (S_ISCHR (mode))
colored_filetype = C_CHR;
else