|
22 | 22 | #include "src/common/libhostlist/hostlist.h" |
23 | 23 | #include "src/common/librlist/rlist.h" |
24 | 24 | #include "src/common/libutil/errprintf.h" |
| 25 | +#include "src/common/libutil/ansi_color.h" |
25 | 26 | #include "src/common/libczmqcontainers/czmq_containers.h" |
26 | 27 | #include "ccan/str/str.h" |
27 | 28 |
|
28 | 29 | #include "builtin.h" |
29 | 30 |
|
30 | 31 | static double default_timeout = 0.5; |
31 | 32 |
|
32 | | -static const char *ansi_default = "\033[39m"; |
33 | | -static const char *ansi_red = "\033[31m"; |
34 | | -static const char *ansi_yellow = "\033[33m"; |
35 | | -static const char *ansi_blue = "\033[01;34m"; |
36 | | -static const char *ansi_reset = "\033[0m"; |
37 | | - |
38 | | -//static const char *ansi_green = "\033[32m"; |
39 | | -static const char *ansi_dark_gray = "\033[90m"; |
40 | | - |
41 | 33 | static struct optparse_option errors_opts[] = { |
42 | 34 | { .name = "timeout", .key = 't', .has_arg = 1, .arginfo = "FSD", |
43 | 35 | .usage = "Set RPC timeout, 0=disable (default 0.5s)", |
@@ -199,17 +191,17 @@ static const char *status_colorize (struct status *ctx, |
199 | 191 | if (ctx->color) { |
200 | 192 | if (streq (status, "lost") && !ghost) { |
201 | 193 | snprintf (buf, sizeof (buf), "%s%s%s", |
202 | | - ansi_red, status, ansi_default); |
| 194 | + ANSI_COLOR_RED, status, ANSI_COLOR_DEFAULT); |
203 | 195 | status = buf; |
204 | 196 | } |
205 | 197 | else if (streq (status, "offline") && !ghost) { |
206 | 198 | snprintf (buf, sizeof (buf), "%s%s%s", |
207 | | - ansi_yellow, status, ansi_default); |
| 199 | + ANSI_COLOR_YELLOW, status, ANSI_COLOR_DEFAULT); |
208 | 200 | status = buf; |
209 | 201 | } |
210 | 202 | else if (ghost) { |
211 | 203 | snprintf (buf, sizeof (buf), "%s%s%s", |
212 | | - ansi_dark_gray, status, ansi_default); |
| 204 | + ANSI_COLOR_DARK_GRAY, status, ANSI_COLOR_DEFAULT); |
213 | 205 | status = buf; |
214 | 206 | } |
215 | 207 | } |
@@ -274,8 +266,8 @@ static const char *status_getname (struct status *ctx, |
274 | 266 | */ |
275 | 267 | if (node->subtree_ranks |
276 | 268 | && idset_has_intersection (ctx->highlight, node->subtree_ranks)) { |
277 | | - highlight_start = ctx->color ? ansi_blue : "<<"; |
278 | | - highlight_end = ctx->color ? ansi_reset : ">>"; |
| 269 | + highlight_start = ctx->color ? ANSI_COLOR_BOLD_BLUE : "<<"; |
| 270 | + highlight_end = ctx->color ? ANSI_COLOR_RESET : ">>"; |
279 | 271 | } |
280 | 272 |
|
281 | 273 | snprintf (buf, |
|
0 commit comments