Skip to content

Commit d2ae7ec

Browse files
committed
flux-overlay: use common header for ANSI colors
Problem: flux-overlay defines ANSI color terminal escapes but they are now defined in a common header. Use ansi_color.h.
1 parent 2c94ac0 commit d2ae7ec

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/cmd/builtin/overlay.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,14 @@
2222
#include "src/common/libhostlist/hostlist.h"
2323
#include "src/common/librlist/rlist.h"
2424
#include "src/common/libutil/errprintf.h"
25+
#include "src/common/libutil/ansi_color.h"
2526
#include "src/common/libczmqcontainers/czmq_containers.h"
2627
#include "ccan/str/str.h"
2728

2829
#include "builtin.h"
2930

3031
static double default_timeout = 0.5;
3132

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-
4133
static struct optparse_option errors_opts[] = {
4234
{ .name = "timeout", .key = 't', .has_arg = 1, .arginfo = "FSD",
4335
.usage = "Set RPC timeout, 0=disable (default 0.5s)",
@@ -199,17 +191,17 @@ static const char *status_colorize (struct status *ctx,
199191
if (ctx->color) {
200192
if (streq (status, "lost") && !ghost) {
201193
snprintf (buf, sizeof (buf), "%s%s%s",
202-
ansi_red, status, ansi_default);
194+
ANSI_COLOR_RED, status, ANSI_COLOR_DEFAULT);
203195
status = buf;
204196
}
205197
else if (streq (status, "offline") && !ghost) {
206198
snprintf (buf, sizeof (buf), "%s%s%s",
207-
ansi_yellow, status, ansi_default);
199+
ANSI_COLOR_YELLOW, status, ANSI_COLOR_DEFAULT);
208200
status = buf;
209201
}
210202
else if (ghost) {
211203
snprintf (buf, sizeof (buf), "%s%s%s",
212-
ansi_dark_gray, status, ansi_default);
204+
ANSI_COLOR_DARK_GRAY, status, ANSI_COLOR_DEFAULT);
213205
status = buf;
214206
}
215207
}
@@ -274,8 +266,8 @@ static const char *status_getname (struct status *ctx,
274266
*/
275267
if (node->subtree_ranks
276268
&& 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 : ">>";
279271
}
280272

281273
snprintf (buf,

0 commit comments

Comments
 (0)