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.log
|
||||
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++)
|
||||
{
|
||||
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]);
|
||||
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.
|
||||
// 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());
|
||||
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"");
|
||||
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);
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/** \file color.cpp Color class implementation
|
||||
*/
|
||||
|
||||
// Color class implementation.
|
||||
#include "color.h"
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
#include <assert.h>
|
||||
|
@ -21,10 +19,6 @@ bool rgb_color_t::try_parse_special(const wcstring &special)
|
|||
{
|
||||
this->type = type_reset;
|
||||
}
|
||||
else if (! wcscasecmp(name, L"ignore"))
|
||||
{
|
||||
this->type = type_ignore;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->type = type_none;
|
||||
|
@ -240,22 +234,22 @@ rgb_color_t rgb_color_t::normal()
|
|||
{
|
||||
return rgb_color_t(type_normal);
|
||||
}
|
||||
|
||||
rgb_color_t rgb_color_t::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()
|
||||
{
|
||||
return rgb_color_t(type_none);
|
||||
}
|
||||
|
||||
rgb_color_t rgb_color_t::white()
|
||||
{
|
||||
return rgb_color_t(type_named, 7);
|
||||
}
|
||||
|
||||
rgb_color_t rgb_color_t::black()
|
||||
{
|
||||
return rgb_color_t(type_named, 0);
|
||||
|
@ -382,8 +376,6 @@ wcstring rgb_color_t::description() const
|
|||
return L"reset";
|
||||
case type_normal:
|
||||
return L"normal";
|
||||
case type_ignore:
|
||||
return L"ignore";
|
||||
default:
|
||||
abort();
|
||||
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
|
||||
#define FISH_COLOR_H
|
||||
|
||||
|
@ -24,8 +23,7 @@ class rgb_color_t
|
|||
type_named,
|
||||
type_rgb,
|
||||
type_normal,
|
||||
type_reset,
|
||||
type_ignore
|
||||
type_reset
|
||||
};
|
||||
unsigned char type:4;
|
||||
|
||||
|
@ -79,18 +77,9 @@ public:
|
|||
/** Returns the normal special color */
|
||||
static rgb_color_t normal();
|
||||
|
||||
/** Returns the ignore special color */
|
||||
static rgb_color_t ignore();
|
||||
|
||||
/** Returns the none special color */
|
||||
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 */
|
||||
bool is_normal(void) const
|
||||
{
|
||||
|
|
|
@ -246,25 +246,17 @@ void set_color(rgb_color_t c, rgb_color_t c2)
|
|||
was_underline=0;
|
||||
}
|
||||
|
||||
if (! last_color2.is_normal() &&
|
||||
! last_color2.is_reset() &&
|
||||
! last_color2.is_ignore())
|
||||
if (!last_color2.is_normal() && !last_color2.is_reset())
|
||||
{
|
||||
/*
|
||||
Background was set
|
||||
*/
|
||||
last_bg_set=1;
|
||||
// Background was set.
|
||||
last_bg_set = 1;
|
||||
}
|
||||
|
||||
if (! c2.is_normal() &&
|
||||
! c2.is_ignore())
|
||||
if (!c2.is_normal())
|
||||
{
|
||||
/*
|
||||
Background is set
|
||||
*/
|
||||
bg_set=1;
|
||||
if (c==c2)
|
||||
c = (c2==rgb_color_t::white())?rgb_color_t::black():rgb_color_t::white();
|
||||
// Background is set.
|
||||
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))
|
||||
|
|
|
@ -27,9 +27,7 @@ enum
|
|||
FISH_COLOR_MAGENTA,
|
||||
FISH_COLOR_CYAN,
|
||||
FISH_COLOR_WHITE,
|
||||
/** The default fg color of the terminal */
|
||||
FISH_COLOR_NORMAL,
|
||||
FISH_COLOR_IGNORE,
|
||||
FISH_COLOR_NORMAL, // the default fg color of the terminal
|
||||
FISH_COLOR_RESET
|
||||
};
|
||||
|
||||
|
@ -41,9 +39,8 @@ enum
|
|||
screen to flicker, the function takes care to write as little as
|
||||
possible.
|
||||
|
||||
Possible values for color are any form the FISH_COLOR_* enum,
|
||||
FISH_COLOR_IGNORE and FISH_COLOR_RESET. FISH_COLOR_IGNORE will
|
||||
leave the color unchanged, and FISH_COLOR_RESET will perform an
|
||||
Possible values for color are any form the FISH_COLOR_* enum
|
||||
and FISH_COLOR_RESET. FISH_COLOR_RESET will perform an
|
||||
exit_attribute_mode, even if set_color thinks it is already in
|
||||
FISH_COLOR_NORMAL mode.
|
||||
|
||||
|
|
Loading…
Reference in a new issue