mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-04 00:58:46 +00:00
builtin_set_color.cpp: colorize set_color --print-colors
Each named color is now printed in that color, only if hooked up to a TTY. Shouldn't affect scripts.
This commit is contained in:
parent
61f0756fe6
commit
5f05d9734c
1 changed files with 12 additions and 6 deletions
|
@ -34,12 +34,18 @@
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
||||||
static void print_colors(io_streams_t &streams) {
|
static void print_colors(io_streams_t &streams) {
|
||||||
const wcstring_list_t result = rgb_color_t::named_color_names();
|
outputter_t outp;
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < result.size(); i++) {
|
for (wcstring color_name : rgb_color_t::named_color_names()) {
|
||||||
streams.out.append(result.at(i));
|
if (!streams.out_is_redirected && isatty(STDOUT_FILENO)) {
|
||||||
streams.out.push_back(L'\n');
|
rgb_color_t color = rgb_color_t(color_name);
|
||||||
}
|
outp.set_color(color, rgb_color_t::none());
|
||||||
|
}
|
||||||
|
outp.writestr(color_name.c_str());
|
||||||
|
outp.writech(L'\n');
|
||||||
|
} // conveniently, 'normal' is always the last color so we don't need to reset here
|
||||||
|
|
||||||
|
streams.out.append(str2wcstring(outp.contents()));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const wchar_t *const short_options = L":b:hvoidrcu";
|
static const wchar_t *const short_options = L":b:hvoidrcu";
|
||||||
|
|
Loading…
Reference in a new issue