mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 20:22:45 +08:00
Remove RgbColor::description
This was unused; deriving Debug is sufficient.
This commit is contained in:
parent
eeecd6517d
commit
04299cb4c9
|
@ -184,22 +184,6 @@ impl RgbColor {
|
|||
self.flags.reverse = reverse;
|
||||
}
|
||||
|
||||
/// Returns a description of the color.
|
||||
#[widestrs]
|
||||
pub fn description(self) -> WString {
|
||||
match self.typ {
|
||||
Type::None => WString::from_str("none"),
|
||||
Type::Named { idx } => {
|
||||
sprintf!("named(%d, %ls)"L, idx, name_for_color_idx(idx).unwrap())
|
||||
}
|
||||
Type::Rgb(c) => {
|
||||
sprintf!("rgb(0x%02x%02x%02x"L, c.r, c.g, c.b)
|
||||
}
|
||||
Type::Normal => WString::from_str("normal"),
|
||||
Type::Reset => WString::from_str("reset"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the name index for the given color. Requires that the color be named or RGB.
|
||||
pub fn to_name_index(self) -> u8 {
|
||||
// TODO: This should look for the nearest color.
|
||||
|
@ -387,12 +371,6 @@ fn convert_color(color: Color24, colors: &[u32]) -> usize {
|
|||
.0
|
||||
}
|
||||
|
||||
fn name_for_color_idx(target_idx: u8) -> Option<&'static wstr> {
|
||||
NAMED_COLORS
|
||||
.iter()
|
||||
.find_map(|&NamedColor { name, idx, .. }| (idx == target_idx).then_some(name))
|
||||
}
|
||||
|
||||
fn term16_color_for_rgb(color: Color24) -> u8 {
|
||||
const COLORS: &[u32] = &[
|
||||
0x000000, // Black
|
||||
|
|
|
@ -178,18 +178,6 @@ bool rgb_color_t::try_parse_named(const wcstring &str) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static const wchar_t *name_for_color_idx(uint8_t idx) {
|
||||
constexpr size_t colors_count = sizeof(named_colors) / sizeof(named_colors[0]);
|
||||
if (idx < colors_count) {
|
||||
for (auto &color : named_colors) {
|
||||
if (idx == color.idx) {
|
||||
return color.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return L"unknown";
|
||||
}
|
||||
|
||||
rgb_color_t::rgb_color_t(uint8_t t, uint8_t i) : type(t), flags(), data() { data.name_idx = i; }
|
||||
|
||||
rgb_color_t rgb_color_t::normal() { return rgb_color_t(type_normal); }
|
||||
|
@ -290,29 +278,3 @@ rgb_color_t::rgb_color_t(const wcstring &str) : type(), flags() { this->parse(st
|
|||
rgb_color_t::rgb_color_t(const std::string &str) : type(), flags() {
|
||||
this->parse(str2wcstring(str));
|
||||
}
|
||||
|
||||
wcstring rgb_color_t::description() const {
|
||||
switch (type) {
|
||||
case type_none: {
|
||||
return L"none";
|
||||
}
|
||||
case type_named: {
|
||||
return format_string(L"named(%d: %ls)", static_cast<int>(data.name_idx),
|
||||
name_for_color_idx(data.name_idx));
|
||||
}
|
||||
case type_rgb: {
|
||||
return format_string(L"rgb(0x%02x%02x%02x)", data.color.rgb[0], data.color.rgb[1],
|
||||
data.color.rgb[2]);
|
||||
}
|
||||
case type_reset: {
|
||||
return L"reset";
|
||||
}
|
||||
case type_normal: {
|
||||
return L"normal";
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
DIE("unknown color type");
|
||||
}
|
||||
|
|
|
@ -91,9 +91,6 @@ class rgb_color_t {
|
|||
/// Returns whether the color is special, that is, not rgb or named.
|
||||
bool is_special(void) const { return type != type_named && type != type_rgb; }
|
||||
|
||||
/// Returns a description of the color.
|
||||
wcstring description() const;
|
||||
|
||||
/// Returns the name index for the given color. Requires that the color be named or RGB.
|
||||
uint8_t to_name_index() const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user