diff --git a/doc/config b/doc/config index 23720fc7..57daa8ef 100644 --- a/doc/config +++ b/doc/config @@ -215,6 +215,7 @@ ## - 9 - end of current color ## - b - bold text ## - u - underline text +## - i - italic text ## - r - reverse colors ## - a - use alternative character set ## diff --git a/src/curses/formatted_color.cpp b/src/curses/formatted_color.cpp index 56b22e61..9c1e96c7 100644 --- a/src/curses/formatted_color.cpp +++ b/src/curses/formatted_color.cpp @@ -30,7 +30,8 @@ void verifyFormats(const NC::FormattedColor::Formats &formats) if (fmt == NC::Format::NoBold || fmt == NC::Format::NoUnderline || fmt == NC::Format::NoReverse - || fmt == NC::Format::NoAltCharset) + || fmt == NC::Format::NoAltCharset + || fmt == NC::Format::NoItalic) throw std::logic_error("FormattedColor can't hold disabling formats"); } } @@ -71,6 +72,9 @@ std::istream &NC::operator>>(std::istream &is, NC::FormattedColor &fc) case 'a': formats.push_back(NC::Format::AltCharset); break; + case 'i': + formats.push_back(NC::Format::Italic); + break; default: is.setstate(std::ios::failbit); break; diff --git a/src/curses/window.cpp b/src/curses/window.cpp index d3f9efd6..59c45456 100644 --- a/src/curses/window.cpp +++ b/src/curses/window.cpp @@ -346,6 +346,10 @@ NC::Format reverseFormat(NC::Format fmt) return NC::Format::NoAltCharset; case NC::Format::NoAltCharset: return NC::Format::AltCharset; + case NC::Format::Italic: + return NC::Format::NoItalic; + case NC::Format::NoItalic: + return NC::Format::Italic; } // Unreachable, silence GCC. return fmt; @@ -494,7 +498,8 @@ Window::Window(size_t startx, size_t starty, size_t width, size_t height, m_bold_counter(0), m_underline_counter(0), m_reverse_counter(0), - m_alt_charset_counter(0) + m_alt_charset_counter(0), + m_italic_counter(0) { if (m_start_x > size_t(COLS) || m_start_y > size_t(LINES) @@ -542,6 +547,7 @@ Window::Window(const Window &rhs) , m_underline_counter(rhs.m_underline_counter) , m_reverse_counter(rhs.m_reverse_counter) , m_alt_charset_counter(rhs.m_alt_charset_counter) +, m_italic_counter(rhs.m_italic_counter) { setColor(m_color); } @@ -566,6 +572,7 @@ Window::Window(Window &&rhs) , m_underline_counter(rhs.m_underline_counter) , m_reverse_counter(rhs.m_reverse_counter) , m_alt_charset_counter(rhs.m_alt_charset_counter) +, m_italic_counter(rhs.m_italic_counter) { rhs.m_window = nullptr; } @@ -591,6 +598,7 @@ Window &Window::operator=(Window rhs) std::swap(m_underline_counter, rhs.m_underline_counter); std::swap(m_reverse_counter, rhs.m_reverse_counter); std::swap(m_alt_charset_counter, rhs.m_alt_charset_counter); + std::swap(m_italic_counter, rhs.m_italic_counter); return *this; } @@ -780,6 +788,11 @@ void Window::altCharset(bool altcharset_state) const (altcharset_state ? wattron : wattroff)(m_window, A_ALTCHARSET); } +void Window::italic(bool italic_state) const +{ + (italic_state ? wattron : wattroff)(m_window, A_ITALIC); +} + void Window::setTimeout(int timeout) { m_window_timeout = timeout; @@ -1413,6 +1426,12 @@ Window &Window::operator<<(Format format) case Format::NoAltCharset: decrease_flag(*this, m_alt_charset_counter, &Window::altCharset); break; + case Format::Italic: + increase_flag(*this, m_italic_counter, &Window::italic); + break; + case Format::NoItalic: + decrease_flag(*this, m_italic_counter, &Window::italic); + break; } return *this; } diff --git a/src/curses/window.h b/src/curses/window.h index 380dc12a..15728c41 100644 --- a/src/curses/window.h +++ b/src/curses/window.h @@ -200,7 +200,8 @@ enum class Format { Bold, NoBold, Underline, NoUnderline, Reverse, NoReverse, - AltCharset, NoAltCharset + AltCharset, NoAltCharset, + Italic, NoItalic }; NC::Format reverseFormat(NC::Format fmt); @@ -531,6 +532,11 @@ private: /// @param altcharset_state state of altcharset attribute /// void altCharset(bool altcharset_state) const; + + /// Sets state of italic attribute (internal use only) + /// @param italic_state state of italic attribute + /// + void italic(bool italic_state) const; /// pointer to helper function used by getString() /// @see getString() @@ -562,6 +568,7 @@ private: int m_underline_counter; int m_reverse_counter; int m_alt_charset_counter; + int m_italic_counter; }; } diff --git a/src/format.cpp b/src/format.cpp index 2316bccd..6050ab7b 100644 --- a/src/format.cpp +++ b/src/format.cpp @@ -192,6 +192,8 @@ expressions parseBracket(const string &s, result.push_back(NC::Format::AltCharset); else if (flags & Format::Flags::Format && *it == 'r') result.push_back(NC::Format::Reverse); + else if (flags & Format::Flags::Format && *it == 'i') + result.push_back(NC::Format::Italic); else if (flags & Format::Flags::Format && *it == '/') { ++it; @@ -204,6 +206,8 @@ expressions parseBracket(const string &s, result.push_back(NC::Format::NoAltCharset); else if (*it == 'r') result.push_back(NC::Format::NoReverse); + else if (*it == 'i') + result.push_back(NC::Format::NoItalic); else throwError(s, it, invalidCharacter(*it)); }