mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
remove unused special color "ignore"
Resolve lint warning about unused method "rgb_color_t::ignore()". Fixes #2893
This commit is contained in:
parent
484c1484c9
commit
8f33b55ccc
6 changed files with 22 additions and 50 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -39,3 +39,5 @@ lexicon.txt
|
||||||
lexicon_filter
|
lexicon_filter
|
||||||
lexicon.log
|
lexicon.log
|
||||||
DerivedData/
|
DerivedData/
|
||||||
|
compile_commands.json
|
||||||
|
xcodebuild.log
|
||||||
|
|
|
@ -137,7 +137,7 @@ static int builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t **
|
||||||
for (; w.woptind < argc; w.woptind++)
|
for (; w.woptind < argc; w.woptind++)
|
||||||
{
|
{
|
||||||
rgb_color_t fg = rgb_color_t(argv[w.woptind]);
|
rgb_color_t fg = rgb_color_t(argv[w.woptind]);
|
||||||
if (fg.is_none() || fg.is_ignore())
|
if (fg.is_none())
|
||||||
{
|
{
|
||||||
streams.err.append_format(_(L"%ls: Unknown color '%ls'\n"), argv[0], argv[w.woptind]);
|
streams.err.append_format(_(L"%ls: Unknown color '%ls'\n"), argv[0], argv[w.woptind]);
|
||||||
return STATUS_BUILTIN_ERROR;
|
return STATUS_BUILTIN_ERROR;
|
||||||
|
@ -155,10 +155,10 @@ static int builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t **
|
||||||
// #1323: We may have multiple foreground colors. Choose the best one.
|
// #1323: We may have multiple foreground colors. Choose the best one.
|
||||||
// If we had no foreground coor, we'll get none(); if we have at least one we expect not-none
|
// If we had no foreground coor, we'll get none(); if we have at least one we expect not-none
|
||||||
const rgb_color_t fg = best_color(fgcolors, output_get_color_support());
|
const rgb_color_t fg = best_color(fgcolors, output_get_color_support());
|
||||||
assert(fgcolors.empty() || !(fg.is_none() || fg.is_ignore()));
|
assert(fgcolors.empty() || !fg.is_none());
|
||||||
|
|
||||||
const rgb_color_t bg = rgb_color_t(bgcolor ? bgcolor : L"");
|
const rgb_color_t bg = rgb_color_t(bgcolor ? bgcolor : L"");
|
||||||
if (bgcolor && (bg.is_none() || bg.is_ignore()))
|
if (bgcolor && bg.is_none())
|
||||||
{
|
{
|
||||||
streams.err.append_format(_(L"%ls: Unknown color '%ls'\n"), argv[0], bgcolor);
|
streams.err.append_format(_(L"%ls: Unknown color '%ls'\n"), argv[0], bgcolor);
|
||||||
return STATUS_BUILTIN_ERROR;
|
return STATUS_BUILTIN_ERROR;
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
/** \file color.cpp Color class implementation
|
// Color class implementation.
|
||||||
*/
|
|
||||||
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "fallback.h" // IWYU pragma: keep
|
#include "fallback.h" // IWYU pragma: keep
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -21,10 +19,6 @@ bool rgb_color_t::try_parse_special(const wcstring &special)
|
||||||
{
|
{
|
||||||
this->type = type_reset;
|
this->type = type_reset;
|
||||||
}
|
}
|
||||||
else if (! wcscasecmp(name, L"ignore"))
|
|
||||||
{
|
|
||||||
this->type = type_ignore;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->type = type_none;
|
this->type = type_none;
|
||||||
|
@ -240,22 +234,22 @@ rgb_color_t rgb_color_t::normal()
|
||||||
{
|
{
|
||||||
return rgb_color_t(type_normal);
|
return rgb_color_t(type_normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
rgb_color_t rgb_color_t::reset()
|
rgb_color_t rgb_color_t::reset()
|
||||||
{
|
{
|
||||||
return rgb_color_t(type_reset);
|
return rgb_color_t(type_reset);
|
||||||
}
|
}
|
||||||
rgb_color_t rgb_color_t::ignore()
|
|
||||||
{
|
|
||||||
return rgb_color_t(type_ignore);
|
|
||||||
}
|
|
||||||
rgb_color_t rgb_color_t::none()
|
rgb_color_t rgb_color_t::none()
|
||||||
{
|
{
|
||||||
return rgb_color_t(type_none);
|
return rgb_color_t(type_none);
|
||||||
}
|
}
|
||||||
|
|
||||||
rgb_color_t rgb_color_t::white()
|
rgb_color_t rgb_color_t::white()
|
||||||
{
|
{
|
||||||
return rgb_color_t(type_named, 7);
|
return rgb_color_t(type_named, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
rgb_color_t rgb_color_t::black()
|
rgb_color_t rgb_color_t::black()
|
||||||
{
|
{
|
||||||
return rgb_color_t(type_named, 0);
|
return rgb_color_t(type_named, 0);
|
||||||
|
@ -382,8 +376,6 @@ wcstring rgb_color_t::description() const
|
||||||
return L"reset";
|
return L"reset";
|
||||||
case type_normal:
|
case type_normal:
|
||||||
return L"normal";
|
return L"normal";
|
||||||
case type_ignore:
|
|
||||||
return L"ignore";
|
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
return L"";
|
return L"";
|
||||||
|
|
15
src/color.h
15
src/color.h
|
@ -1,5 +1,4 @@
|
||||||
/** \file color.h Color class.
|
// Color class.
|
||||||
*/
|
|
||||||
#ifndef FISH_COLOR_H
|
#ifndef FISH_COLOR_H
|
||||||
#define FISH_COLOR_H
|
#define FISH_COLOR_H
|
||||||
|
|
||||||
|
@ -24,8 +23,7 @@ class rgb_color_t
|
||||||
type_named,
|
type_named,
|
||||||
type_rgb,
|
type_rgb,
|
||||||
type_normal,
|
type_normal,
|
||||||
type_reset,
|
type_reset
|
||||||
type_ignore
|
|
||||||
};
|
};
|
||||||
unsigned char type:4;
|
unsigned char type:4;
|
||||||
|
|
||||||
|
@ -79,18 +77,9 @@ public:
|
||||||
/** Returns the normal special color */
|
/** Returns the normal special color */
|
||||||
static rgb_color_t normal();
|
static rgb_color_t normal();
|
||||||
|
|
||||||
/** Returns the ignore special color */
|
|
||||||
static rgb_color_t ignore();
|
|
||||||
|
|
||||||
/** Returns the none special color */
|
/** Returns the none special color */
|
||||||
static rgb_color_t none();
|
static rgb_color_t none();
|
||||||
|
|
||||||
/** Returns whether the color is the ignore special color */
|
|
||||||
bool is_ignore(void) const
|
|
||||||
{
|
|
||||||
return type == type_ignore;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns whether the color is the normal special color */
|
/** Returns whether the color is the normal special color */
|
||||||
bool is_normal(void) const
|
bool is_normal(void) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -246,25 +246,17 @@ void set_color(rgb_color_t c, rgb_color_t c2)
|
||||||
was_underline=0;
|
was_underline=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! last_color2.is_normal() &&
|
if (!last_color2.is_normal() && !last_color2.is_reset())
|
||||||
! last_color2.is_reset() &&
|
|
||||||
! last_color2.is_ignore())
|
|
||||||
{
|
{
|
||||||
/*
|
// Background was set.
|
||||||
Background was set
|
last_bg_set = 1;
|
||||||
*/
|
|
||||||
last_bg_set=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! c2.is_normal() &&
|
if (!c2.is_normal())
|
||||||
! c2.is_ignore())
|
|
||||||
{
|
{
|
||||||
/*
|
// Background is set.
|
||||||
Background is set
|
bg_set = 1;
|
||||||
*/
|
if (c == c2) c = (c2==rgb_color_t::white())?rgb_color_t::black():rgb_color_t::white();
|
||||||
bg_set=1;
|
|
||||||
if (c==c2)
|
|
||||||
c = (c2==rgb_color_t::white())?rgb_color_t::black():rgb_color_t::white();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((enter_bold_mode != 0) && (strlen(enter_bold_mode) > 0))
|
if ((enter_bold_mode != 0) && (strlen(enter_bold_mode) > 0))
|
||||||
|
|
|
@ -27,9 +27,7 @@ enum
|
||||||
FISH_COLOR_MAGENTA,
|
FISH_COLOR_MAGENTA,
|
||||||
FISH_COLOR_CYAN,
|
FISH_COLOR_CYAN,
|
||||||
FISH_COLOR_WHITE,
|
FISH_COLOR_WHITE,
|
||||||
/** The default fg color of the terminal */
|
FISH_COLOR_NORMAL, // the default fg color of the terminal
|
||||||
FISH_COLOR_NORMAL,
|
|
||||||
FISH_COLOR_IGNORE,
|
|
||||||
FISH_COLOR_RESET
|
FISH_COLOR_RESET
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,9 +39,8 @@ enum
|
||||||
screen to flicker, the function takes care to write as little as
|
screen to flicker, the function takes care to write as little as
|
||||||
possible.
|
possible.
|
||||||
|
|
||||||
Possible values for color are any form the FISH_COLOR_* enum,
|
Possible values for color are any form the FISH_COLOR_* enum
|
||||||
FISH_COLOR_IGNORE and FISH_COLOR_RESET. FISH_COLOR_IGNORE will
|
and FISH_COLOR_RESET. FISH_COLOR_RESET will perform an
|
||||||
leave the color unchanged, and FISH_COLOR_RESET will perform an
|
|
||||||
exit_attribute_mode, even if set_color thinks it is already in
|
exit_attribute_mode, even if set_color thinks it is already in
|
||||||
FISH_COLOR_NORMAL mode.
|
FISH_COLOR_NORMAL mode.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue