window: compress Color inline function definitions
This commit is contained in:
46
src/window.h
46
src/window.h
@@ -135,36 +135,21 @@ struct Color
|
|||||||
static const short transparent;
|
static const short transparent;
|
||||||
static const short previous;
|
static const short previous;
|
||||||
|
|
||||||
Color() : m_rep(0, transparent, true, false) { }
|
Color() : m_impl(0, transparent, true, false) { }
|
||||||
Color(short foreground_value, short background_value,
|
Color(short foreground_value, short background_value,
|
||||||
bool is_default = false, bool is_end = false)
|
bool is_default = false, bool is_end = false)
|
||||||
: m_rep(foreground_value, background_value, is_default, is_end)
|
: m_impl(foreground_value, background_value, is_default, is_end)
|
||||||
{
|
{
|
||||||
if (isDefault() && isEnd())
|
if (isDefault() && isEnd())
|
||||||
throw std::logic_error("Color flag can't be marked as both 'default' and 'end'");
|
throw std::logic_error("Color flag can't be marked as both 'default' and 'end'");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Color &rhs) const
|
bool operator==(const Color &rhs) const { return m_impl == rhs.m_impl; }
|
||||||
{
|
bool operator!=(const Color &rhs) const { return m_impl != rhs.m_impl; }
|
||||||
return m_rep == rhs.m_rep;
|
bool operator<(const Color &rhs) const { return m_impl < rhs.m_impl; }
|
||||||
}
|
|
||||||
bool operator!=(const Color &rhs) const
|
|
||||||
{
|
|
||||||
return m_rep != rhs.m_rep;
|
|
||||||
}
|
|
||||||
bool operator<(const Color &rhs) const
|
|
||||||
{
|
|
||||||
return m_rep < rhs.m_rep;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isDefault() const
|
bool isDefault() const { return std::get<2>(m_impl); }
|
||||||
{
|
bool isEnd() const { return std::get<3>(m_impl); }
|
||||||
return std::get<2>(m_rep);
|
|
||||||
}
|
|
||||||
bool isEnd() const
|
|
||||||
{
|
|
||||||
return std::get<3>(m_rep);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pairNumber() const;
|
int pairNumber() const;
|
||||||
|
|
||||||
@@ -180,20 +165,11 @@ struct Color
|
|||||||
static Color End;
|
static Color End;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
short foreground() const
|
short foreground() const { return std::get<0>(m_impl); }
|
||||||
{
|
short background() const { return std::get<1>(m_impl); }
|
||||||
return std::get<0>(m_rep);
|
bool previousBackground() const { return background() == previous; }
|
||||||
}
|
|
||||||
short background() const
|
|
||||||
{
|
|
||||||
return std::get<1>(m_rep);
|
|
||||||
}
|
|
||||||
bool previousBackground() const
|
|
||||||
{
|
|
||||||
return background() == previous;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::tuple<short, short, bool, bool> m_rep;
|
std::tuple<short, short, bool, bool> m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::istream &operator>>(std::istream &is, Color &f);
|
std::istream &operator>>(std::istream &is, Color &f);
|
||||||
|
|||||||
Reference in New Issue
Block a user