>From 651569ec2fba50adf5457a854dcfa660e1c62d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Tue, 31 May 2011 00:46:04 +0200 Subject: [PATCH 1/6] Colored completion, readline.h (1/6) Adds the basic data structures needed by readline to support the colored output of filename completions. --- lib/readline/readline.h | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/lib/readline/readline.h b/lib/readline/readline.h index 49b40d3..dc8b29a 100644 --- a/lib/readline/readline.h +++ b/lib/readline/readline.h @@ -72,6 +72,32 @@ typedef struct _funmap { extern FUNMAP **funmap; + +/* Null is a valid character in a color indicator (think about Epson + printers, for example) so we have to use a length/buffer string + type. */ +struct bin_str { + size_t len; + const char *string; +}; + +/* file type indicators (dir, sock, fifo, ...) + Default value is initialized in parse-colors.c. + It is then modified from the values of $LS_COLORS. */ +extern struct bin_str color_indicator[]; + +/* The LS_COLORS variable is in a termcap-like format. */ +typedef struct _color_ext_type { + struct bin_str ext; /* The extension we're looking for */ + struct bin_str seq; /* The sequence to output when we do */ + struct _color_ext_type *next; /* Next in list */ +} COLOR_EXT_TYPE; + +/* file extensions indicators (.txt, .log, .jpg, ...) + Values are taken from $LS_COLORS in rl_parse_colors().*/ +extern COLOR_EXT_TYPE *_rl_color_ext_list; + + /* **************************************************************** */ /* */ /* Functions available to bind to key sequences */ @@ -893,6 +919,12 @@ struct readline_state { extern int rl_save_state PARAMS((struct readline_state *)); extern int rl_restore_state PARAMS((struct readline_state *)); +/* This is the function which parses the environment variable LS_COLORS + to fill _rl_color_ext_list. + This is not necessary in order to support basic colorization (file type). + But this is needed to add specific colors according to file extension. */ +extern void rl_parse_colors PARAMS((void)); + #ifdef __cplusplus } #endif -- 1.7.3.4