init version.
[bush.git] / lib / readline / colors.h
blob6561ad90c1cf7c017bb1bdde130b655fe69e6110
1 /* `dir', `vdir' and `ls' directory listing programs for GNU.
3 Modified by Chet Ramey for Readline.
5 Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015
6 Free Software Foundation, Inc.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* Written by Richard Stallman and David MacKenzie. */
23 /* Color support by Peter Anvin <Peter.Anvin@linux.org> and Dennis
24 Flaherty <dennisf@denix.elk.miles.com> based on original patches by
25 Greg Lee <lee@uhunix.uhcc.hawaii.edu>. */
27 #ifndef _COLORS_H_
28 #define _COLORS_H_
30 #include <stdio.h> // size_t
32 #if defined(__TANDEM) && defined(HAVE_STDBOOL_H) && (__STDC_VERSION__ < 199901L)
33 typedef int _Bool;
34 #endif
36 #if defined (HAVE_STDBOOL_H)
37 # include <stdbool.h> // bool
38 #else
39 typedef int _rl_bool_t;
41 #ifdef bool
42 # undef bool
43 #endif
44 #define bool _rl_bool_t
46 #ifndef true
47 # define true 1
48 # define false 0
49 #endif
51 #endif /* !HAVE_STDBOOL_H */
53 /* Null is a valid character in a color indicator (think about Epson
54 printers, for example) so we have to use a length/buffer string
55 type. */
56 struct bin_str
58 size_t len;
59 const char *string;
62 /* file type indicators (dir, sock, fifo, ...)
63 Default value is initialized in parse-colors.c.
64 It is then modified from the values of $LS_COLORS. */
65 extern struct bin_str _rl_color_indicator[];
67 /* The LS_COLORS variable is in a termcap-like format. */
68 typedef struct _color_ext_type
70 struct bin_str ext; /* The extension we're looking for */
71 struct bin_str seq; /* The sequence to output when we do */
72 struct _color_ext_type *next; /* Next in list */
73 } COLOR_EXT_TYPE;
75 /* file extensions indicators (.txt, .log, .jpg, ...)
76 Values are taken from $LS_COLORS in rl_parse_colors(). */
77 extern COLOR_EXT_TYPE *_rl_color_ext_list;
79 #define FILETYPE_INDICATORS \
80 { \
81 C_ORPHAN, C_FIFO, C_CHR, C_DIR, C_BLK, C_FILE, \
82 C_LINK, C_SOCK, C_FILE, C_DIR \
85 /* Whether we used any colors in the output so far. If so, we will
86 need to restore the default color later. If not, we will need to
87 call prep_non_filename_text before using color for the first time. */
89 enum indicator_no
91 C_LEFT, C_RIGHT, C_END, C_RESET, C_NORM, C_FILE, C_DIR, C_LINK,
92 C_FIFO, C_SOCK,
93 C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC, C_DOOR, C_SETUID, C_SETGID,
94 C_STICKY, C_OTHER_WRITABLE, C_STICKY_OTHER_WRITABLE, C_CAP, C_MULTIHARDLINK,
95 C_CLR_TO_EOL
99 #if !S_IXUGO
100 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
101 #endif
103 enum filetype
105 unknown,
106 fifo,
107 chardev,
108 directory,
109 blockdev,
110 normal,
111 symbolic_link,
112 sock,
113 whiteout,
114 arg_directory
117 /* Prefix color, currently same as socket */
118 #define C_PREFIX C_SOCK
120 extern void _rl_put_indicator (const struct bin_str *ind);
121 extern void _rl_set_normal_color (void);
122 extern bool _rl_print_prefix_color (void);
123 extern bool _rl_print_color_indicator (const char *f);
124 extern void _rl_prep_non_filename_text (void);
126 #endif /* !_COLORS_H_ */