feat: add internal support for underlined text (closes #29)

This commit is contained in:
Brendan Hagan
2022-07-26 22:11:09 -04:00
parent 393923a292
commit 78227a30da
4 changed files with 14 additions and 8 deletions
+6 -3
View File
@@ -34,7 +34,7 @@ struct Margins {
// Helper class for TextElements::fromString, to allow persistent formating state accross recusive calls
struct TextElementsFromString {
// What formatting is enabled?
int bold = 0, italic = 0, symbol = 0;
int bold = 0, italic = 0, underline = 0, symbol = 0;
int soft = 0, kwpph = 0, param = 0, line = 0, soft_line = 0;
int code = 0, code_kw = 0, code_string = 0, param_ref = 0;
int param_id = 0, li = 0;
@@ -78,7 +78,9 @@ private:
if (is_tag(text, tag_start, _( "<b"))) bold += 1;
else if (is_tag(text, tag_start, _("</b"))) bold -= 1;
else if (is_tag(text, tag_start, _( "<i"))) italic += 1;
else if (is_tag(text, tag_start, _("</i"))) italic -= 1;
else if (is_tag(text, tag_start, _("</i"))) italic -= 1;
else if (is_tag(text, tag_start, _("<u"))) underline += 1;
else if (is_tag(text, tag_start, _("</u"))) underline -= 1;
else if (is_tag(text, tag_start, _( "<sym"))) symbol += 1;
else if (is_tag(text, tag_start, _("</sym"))) symbol -= 1;
else if (is_tag(text, tag_start, _( "<line"))) line += 1;
@@ -299,7 +301,8 @@ private:
(kwpph > 0 ? FONT_SOFT : FONT_NORMAL) |
(code > 0 ? FONT_CODE : FONT_NORMAL) |
(code_kw > 0 ? FONT_CODE_KW : FONT_NORMAL) |
(code_string > 0 ? FONT_CODE_STRING : FONT_NORMAL),
(code_string > 0 ? FONT_CODE_STRING : FONT_NORMAL),
underline > 0,
fonts.empty() ? nullptr : &fonts.back(),
param > 0 || param_ref > 0
? &param_colors[(param_id++) % param_colors_count]