Skip to content

Commit 54590a0

Browse files
peffgitster
authored andcommitted
color: support "italic" attribute
We already support bold, underline, and similar attributes. Let's add italic to the mix. According to the Wikipedia page on ANSI colors, this attribute is "not widely supported", but it does seem to work on my xterm. We don't have to bump the maximum color size because we were already over-allocating it (but we do adjust the comment appropriately). Requested-by: Simon Courtois <scourtois@cubyx.fr> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5621068 commit 54590a0

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

Documentation/config.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,11 @@ Colors may also be given as numbers between 0 and 255; these use ANSI
160160
your terminal supports it, you may also specify 24-bit RGB values as
161161
hex, like `#ff0ab3`.
162162
+
163-
The accepted attributes are `bold`, `dim`, `ul`, `blink`, and `reverse`.
164-
The position of any attributes with respect to the colors (before, after,
165-
or in between), doesn't matter. Specific attributes may be turned off
166-
by prefixing them with `no` or `no-` (e.g., `noreverse`, `no-ul`, etc).
163+
The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`, and
164+
`italic`. The position of any attributes with respect to the colors
165+
(before, after, or in between), doesn't matter. Specific attributes may
166+
be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`,
167+
`no-ul`, etc).
167168
+
168169
For git's pre-defined color slots, the attributes are meant to be reset
169170
at the beginning of each item in the colored output. So setting

color.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ static int parse_attr(const char *name, size_t len)
133133
#define ATTR(x, val, neg) { (x), sizeof(x)-1, (val), (neg) }
134134
ATTR("bold", 1, 22),
135135
ATTR("dim", 2, 22),
136+
ATTR("italic", 3, 23),
136137
ATTR("ul", 4, 24),
137138
ATTR("blink", 5, 25),
138139
ATTR("reverse", 7, 27)

color.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct strbuf;
1616
*
1717
* The space for attributes is also slightly overallocated, as
1818
* the negation for some attributes is the same (e.g., nobold and nodim).
19-
* We also allocate space for 6 attributes (even though we have only 5).
19+
*
20+
* We allocate space for 6 attributes.
2021
*/
2122
#define COLOR_MAXLEN 70
2223

t/t4026-color.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ test_expect_success 'long color specification' '
6060

6161
test_expect_success 'absurdly long color specification' '
6262
color \
63-
"#ffffff #ffffff bold nobold dim nodim ul noul blink noblink reverse noreverse" \
64-
"[1;2;4;5;7;22;24;25;27;38;2;255;255;255;48;2;255;255;255m"
63+
"#ffffff #ffffff bold nobold dim nodim italic noitalic
64+
ul noul blink noblink reverse noreverse" \
65+
"[1;2;3;4;5;7;22;23;24;25;27;38;2;255;255;255;48;2;255;255;255m"
6566
'
6667

6768
test_expect_success '0-7 are aliases for basic ANSI color names' '

0 commit comments

Comments
 (0)