new feature: support for underlined text

master
Andrzej Rybczak 17 years ago
parent ad685091bc
commit 0a2a7290f6
  1. 1
      doc/config
  2. 6
      src/helpers.h
  3. 14
      src/window.cpp
  4. 14
      src/window.h

@ -123,6 +123,7 @@
## After that you can put:
##
## - b - bold text
## - u - underlined text
## - r - reverse colors
## - a - use alternative character set
##

@ -103,6 +103,9 @@ template <typename C> void String2Buffer(const std::basic_string<C> &s, basic_bu
case 'b':
buf << fmtBold;
break;
case 'u':
buf << fmtUnderline;
break;
case 'a':
buf << fmtAltCharset;
break;
@ -115,6 +118,9 @@ template <typename C> void String2Buffer(const std::basic_string<C> &s, basic_bu
case 'b':
buf << fmtBoldEnd;
break;
case 'u':
buf << fmtUnderlineEnd;
break;
case 'a':
buf << fmtAltCharsetEnd;
break;

@ -87,6 +87,7 @@ Window::Window(size_t startx,
itsBorder(border),
itsHistory(0),
itsBoldCounter(0),
itsUnderlineCounter(0),
itsReverseCounter(0),
itsAltCharsetCounter(0)
{
@ -137,6 +138,7 @@ Window::Window(const Window &w) : itsWindow(dupwin(w.itsWindow)),
itsBorder(w.itsBorder),
itsHistory(w.itsHistory),
itsBoldCounter(w.itsBoldCounter),
itsUnderlineCounter(w.itsUnderlineCounter),
itsReverseCounter(w.itsReverseCounter),
itsAltCharsetCounter(w.itsAltCharsetCounter)
{
@ -328,6 +330,11 @@ void Window::Bold(bool bold_state) const
(bold_state ? wattron : wattroff)(itsWindow, A_BOLD);
}
void Window::Underline(bool underline_state) const
{
(underline_state ? wattron : wattroff)(itsWindow, A_UNDERLINE);
}
void Window::Reverse(bool reverse_state) const
{
(reverse_state ? wattron : wattroff)(itsWindow, A_REVERSE);
@ -745,6 +752,13 @@ Window &Window::operator<<(Format format)
if (--itsBoldCounter <= 0)
Bold((itsBoldCounter = 0));
break;
case fmtUnderline:
Underline(++itsUnderlineCounter);
break;
case fmtUnderlineEnd:
if (--itsUnderlineCounter <= 0)
Underline((itsUnderlineCounter = 0));
break;
case fmtReverse:
Reverse(++itsReverseCounter);
break;

@ -85,7 +85,13 @@ namespace NCurses
/// Format flags used by NCurses
///
enum Format { fmtNone = 100, fmtBold, fmtBoldEnd, fmtReverse, fmtReverseEnd, fmtAltCharset, fmtAltCharsetEnd };
enum Format {
fmtNone = clEnd+1,
fmtBold, fmtBoldEnd,
fmtUnderline, fmtUnderlineEnd,
fmtReverse, fmtReverseEnd,
fmtAltCharset, fmtAltCharsetEnd
};
/// Available border colors for window
///
@ -458,6 +464,11 @@ namespace NCurses
///
void Bold(bool bold_state) const;
/// Sets state of underline attribute (internal use only)
/// @param underline_state state of underline attribute
///
void Underline(bool underline_state) const;
/// Sets state of reverse attribute (internal use only)
/// @param reverse_state state of reverse attribute
///
@ -543,6 +554,7 @@ namespace NCurses
/// counters for format flags
int itsBoldCounter;
int itsUnderlineCounter;
int itsReverseCounter;
int itsAltCharsetCounter;
};

Loading…
Cancel
Save