X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=color.h;h=bcb28cf10f2cbef11d9dba0e5a7f3f0515cbbd70;hb=ea640cc691d56f7151c5ba654b09c4a987dbef93;hp=3cb4b7fc890880b0fcf19a11c6bc7de6b10d6e8d;hpb=11a1a49a16a52ff9b684a430d68b8982ed313427;p=git.git diff --git a/color.h b/color.h index 3cb4b7fc8..bcb28cf10 100644 --- a/color.h +++ b/color.h @@ -1,8 +1,20 @@ #ifndef COLOR_H #define COLOR_H -/* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */ -#define COLOR_MAXLEN 24 +/* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */ +/* "\033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0" */ +/* + * The maximum length of ANSI color sequence we would generate: + * - leading ESC '[' 2 + * - attr + ';' 2 * 8 (e.g. "1;") + * - fg color + ';' 9 (e.g. "38;5;2xx;") + * - fg color + ';' 9 (e.g. "48;5;2xx;") + * - terminating 'm' NUL 2 + * + * The above overcounts attr (we only use 5 not 8) and one semicolon + * but it is close enough. + */ +#define COLOR_MAXLEN 40 /* * IMPORTANT: Due to the way these color codes are emulated on Windows,