summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis van der Schagt <dennisschagt@gmail.com>2024-04-03 23:32:00 +0200
committerDennis van der Schagt <dennisschagt@gmail.com>2024-04-03 23:39:25 +0200
commit73c8b3d065581944a7a91aa9982a389b3ba9619a (patch)
tree331b94f7deb5a270a1145e664ddd64c3d8fc4586
parent0175914ee5a831fea04ecec68cf2857b9002ba3f (diff)
Improve StflRichText naming consistency
-rw-r--r--include/stflrichtext.h6
-rw-r--r--src/dialogsformaction.cpp2
-rw-r--r--src/dirbrowserformaction.cpp2
-rw-r--r--src/feedlistformaction.cpp4
-rw-r--r--src/filebrowserformaction.cpp2
-rw-r--r--src/helpformaction.cpp18
-rw-r--r--src/itemlistformaction.cpp8
-rw-r--r--src/listformatter.cpp6
-rw-r--r--src/listwidgetbackend.cpp2
-rw-r--r--src/pbview.cpp4
-rw-r--r--src/regexmanager.cpp2
-rw-r--r--src/selectformaction.cpp4
-rw-r--r--src/stflrichtext.cpp6
-rw-r--r--src/textformatter.cpp2
-rw-r--r--src/urlviewformaction.cpp2
-rw-r--r--test/listformatter.cpp4
-rw-r--r--test/listwidget.cpp4
-rw-r--r--test/regexmanager.cpp112
-rw-r--r--test/stflrichtext.cpp22
-rw-r--r--test/textviewwidget.cpp2
20 files changed, 107 insertions, 107 deletions
diff --git a/include/stflrichtext.h b/include/stflrichtext.h
index 8a085a12..bf0bd2ed 100644
--- a/include/stflrichtext.h
+++ b/include/stflrichtext.h
@@ -8,7 +8,7 @@ namespace newsboat {
class StflRichText {
public:
- static StflRichText from_plaintext_string(std::string);
+ static StflRichText from_plaintext(std::string);
static StflRichText from_quoted(std::string);
StflRichText(const StflRichText&) = default;
@@ -21,8 +21,8 @@ public:
void apply_style_tag(const std::string& tag, size_t start, size_t end);
- std::string get_plaintext() const;
- std::string stfl_quoted_string() const;
+ std::string plaintext() const;
+ std::string stfl_quoted() const;
private:
StflRichText(std::string&&,
diff --git a/src/dialogsformaction.cpp b/src/dialogsformaction.cpp
index 7e6a2f80..b7eefee9 100644
--- a/src/dialogsformaction.cpp
+++ b/src/dialogsformaction.cpp
@@ -38,7 +38,7 @@ void DialogsFormAction::prepare()
const auto& fa = formaction_names[line];
const bool is_current_formaction =
v.get_formaction(fa.first) == get_parent_formaction();
- return StflRichText::from_plaintext_string(
+ return StflRichText::from_plaintext(
strprintf::fmt("%4u %s %s",
line + 1,
is_current_formaction ? "*" : " ",
diff --git a/src/dirbrowserformaction.cpp b/src/dirbrowserformaction.cpp
index 7cd58de6..03335014 100644
--- a/src/dirbrowserformaction.cpp
+++ b/src/dirbrowserformaction.cpp
@@ -330,7 +330,7 @@ void DirBrowserFormAction::add_directory(
group,
sizestr,
formatteddirname);
- lines.push_back(StflRichText::from_plaintext_string(line));
+ lines.push_back(StflRichText::from_plaintext(line));
id_at_position.push_back(file_system::FileSystemEntry{ftype, dirname});
}
}
diff --git a/src/feedlistformaction.cpp b/src/feedlistformaction.cpp
index 12c631f7..b2877ccc 100644
--- a/src/feedlistformaction.cpp
+++ b/src/feedlistformaction.cpp
@@ -627,7 +627,7 @@ void FeedListFormAction::set_feedlist(
std::uint32_t width) -> StflRichText {
if (line >= visible_feeds.size())
{
- return StflRichText::from_plaintext_string("ERROR");
+ return StflRichText::from_plaintext("ERROR");
}
auto& feed = visible_feeds[line];
return format_line(feedlist_format, feed.first, feed.second, width);
@@ -1085,7 +1085,7 @@ StflRichText FeedListFormAction::format_line(const std::string& feedlist_format,
fmt.register_fmt('d', utils::utf8_to_locale(feed->description()));
const auto formattedLine = fmt.do_format(feedlist_format, width);
- auto stflFormattedLine = StflRichText::from_plaintext_string(formattedLine);
+ auto stflFormattedLine = StflRichText::from_plaintext(formattedLine);
if (unread_count > 0) {
stflFormattedLine.apply_style_tag("<unread>", 0, formattedLine.length());
diff --git a/src/filebrowserformaction.cpp b/src/filebrowserformaction.cpp
index 2deaeb5a..fb307b22 100644
--- a/src/filebrowserformaction.cpp
+++ b/src/filebrowserformaction.cpp
@@ -354,7 +354,7 @@ void FileBrowserFormAction::add_file(
group,
sizestr,
formattedfilename);
- lines.push_back(StflRichText::from_plaintext_string(line));
+ lines.push_back(StflRichText::from_plaintext(line));
id_at_position.push_back(file_system::FileSystemEntry{ftype, filename});
}
}
diff --git a/src/helpformaction.cpp b/src/helpformaction.cpp
index 315b2ebb..2ce2afc2 100644
--- a/src/helpformaction.cpp
+++ b/src/helpformaction.cpp
@@ -125,9 +125,9 @@ void HelpFormAction::prepare()
}
if (!syskey_descriptions.empty()) {
- listfmt.add_line(StflRichText::from_plaintext_string(""));
- listfmt.add_line(StflRichText::from_plaintext_string(_("Generic bindings:")));
- listfmt.add_line(StflRichText::from_plaintext_string(""));
+ listfmt.add_line(StflRichText::from_plaintext(""));
+ listfmt.add_line(StflRichText::from_plaintext(_("Generic bindings:")));
+ listfmt.add_line(StflRichText::from_plaintext(""));
for (const auto& desc : syskey_descriptions) {
if (should_be_visible(desc)) {
@@ -143,9 +143,9 @@ void HelpFormAction::prepare()
}
if (!unbound_descriptions.empty()) {
- listfmt.add_line(StflRichText::from_plaintext_string(""));
- listfmt.add_line(StflRichText::from_plaintext_string(_("Unbound functions:")));
- listfmt.add_line(StflRichText::from_plaintext_string(""));
+ listfmt.add_line(StflRichText::from_plaintext(""));
+ listfmt.add_line(StflRichText::from_plaintext(_("Unbound functions:")));
+ listfmt.add_line(StflRichText::from_plaintext(""));
for (const auto& desc : unbound_descriptions) {
if (should_be_visible(desc)) {
@@ -159,9 +159,9 @@ void HelpFormAction::prepare()
const auto macros = v.get_keymap()->get_macro_descriptions();
if (!macros.empty()) {
- listfmt.add_line(StflRichText::from_plaintext_string(""));
- listfmt.add_line(StflRichText::from_plaintext_string(_("Macros:")));
- listfmt.add_line(StflRichText::from_plaintext_string(""));
+ listfmt.add_line(StflRichText::from_plaintext(""));
+ listfmt.add_line(StflRichText::from_plaintext(_("Macros:")));
+ listfmt.add_line(StflRichText::from_plaintext(""));
for (const auto& macro : macros) {
const std::string key = macro.first.to_bindkey_string();
diff --git a/src/itemlistformaction.cpp b/src/itemlistformaction.cpp
index 0e93a15e..1d1d851f 100644
--- a/src/itemlistformaction.cpp
+++ b/src/itemlistformaction.cpp
@@ -1075,10 +1075,10 @@ void ItemListFormAction::draw_items()
std::uint32_t width) -> StflRichText {
if (line >= visible_items.size())
{
- return StflRichText::from_plaintext_string("ERROR");
+ return StflRichText::from_plaintext("ERROR");
}
auto& item = visible_items[line];
- return item2formatted_line(item, width, itemlist_format, datetime_format);
+ return item2formatted_line(item, width, itemlist_format, datetime_format);
};
list.invalidate_list_content(visible_items.size(), render_line);
@@ -1183,7 +1183,7 @@ StflRichText ItemListFormAction::item2formatted_line(const ItemPtrPosPair& item,
fmt.register_fmt('L', item.first->length());
const auto formattedLine = fmt.do_format(itemlist_format, width);
- auto stflFormattedLine = StflRichText::from_plaintext_string(formattedLine);
+ auto stflFormattedLine = StflRichText::from_plaintext(formattedLine);
const int id = rxman.article_matches(item.first.get());
if (id != -1) {
@@ -1280,7 +1280,7 @@ void ItemListFormAction::set_head(const std::string& s,
bool ItemListFormAction::jump_to_previous_unread_item(bool start_with_last)
{
- const int itempos = list.get_position();
+ const int itempos = list.get_position();
for (int i = (start_with_last ? itempos : (itempos - 1)); i >= 0; --i) {
LOG(Level::DEBUG,
"ItemListFormAction::jump_to_previous_unread_item: "
diff --git a/src/listformatter.cpp b/src/listformatter.cpp
index d18b3be8..c2e61c1a 100644
--- a/src/listformatter.cpp
+++ b/src/listformatter.cpp
@@ -19,14 +19,14 @@ ListFormatter::~ListFormatter() {}
void ListFormatter::add_line(const StflRichText& text)
{
- LOG(Level::DEBUG, "ListFormatter::add_line: `%s'", text.stfl_quoted_string());
+ LOG(Level::DEBUG, "ListFormatter::add_line: `%s'", text.stfl_quoted());
set_line(UINT_MAX, text);
}
void ListFormatter::set_line(const unsigned int itempos,
const StflRichText& text)
{
- const std::wstring wide = utils::str2wstr(text.stfl_quoted_string());
+ const std::wstring wide = utils::str2wstr(text.stfl_quoted());
const std::wstring cleaned = utils::clean_nonprintable_characters(wide);
const std::string formatted_text = utils::wstr2str(cleaned);
const StflRichText stflRichText = StflRichText::from_quoted(formatted_text);
@@ -46,7 +46,7 @@ std::string ListFormatter::format_list() const
rxman->quote_and_highlight(str, location);
}
format_cache.append(strprintf::fmt(
- "{listitem text:%s}", Stfl::quote(str.stfl_quoted_string())));
+ "{listitem text:%s}", Stfl::quote(str.stfl_quoted())));
}
format_cache.push_back('}');
return format_cache;
diff --git a/src/listwidgetbackend.cpp b/src/listwidgetbackend.cpp
index ca7549a3..5872e2d0 100644
--- a/src/listwidgetbackend.cpp
+++ b/src/listwidgetbackend.cpp
@@ -85,7 +85,7 @@ void ListWidgetBackend::render()
listfmt.clear();
for (std::uint32_t i = 0; i < visible_content_lines; ++i) {
const std::uint32_t line = scroll_offset + i;
- auto formatted_line = StflRichText::from_plaintext_string("NO FORMATTER DEFINED");
+ auto formatted_line = StflRichText::from_plaintext("NO FORMATTER DEFINED");
if (line_cache.count(line) >= 1) {
formatted_line = line_cache.at(line);
} else if (get_formatted_line) {
diff --git a/src/pbview.cpp b/src/pbview.cpp
index 8fe483e8..c4113fa8 100644
--- a/src/pbview.cpp
+++ b/src/pbview.cpp
@@ -314,7 +314,7 @@ void PbView::run_help()
desc.cmd,
desc.desc);
- listfmt.add_line(StflRichText::from_plaintext_string(descline));
+ listfmt.add_line(StflRichText::from_plaintext(descline));
}
help_textview.stfl_replace_lines(listfmt.get_lines_count(),
@@ -419,7 +419,7 @@ StflRichText PbView::format_line(const std::string& podlist_format,
fmt.register_fmt('b', strprintf::fmt("%s", dl.basename()));
auto formattedLine = fmt.do_format(podlist_format, width);
- return StflRichText::from_plaintext_string(formattedLine);
+ return StflRichText::from_plaintext(formattedLine);
}
} // namespace podboat
diff --git a/src/regexmanager.cpp b/src/regexmanager.cpp
index e90821db..b32846ce 100644
--- a/src/regexmanager.cpp
+++ b/src/regexmanager.cpp
@@ -84,7 +84,7 @@ void RegexManager::quote_and_highlight(StflRichText& stflString,
{
auto& regexes = locations[location];
- const std::string text = stflString.get_plaintext();
+ const std::string text = stflString.plaintext();
for (unsigned int i = 0; i < regexes.size(); ++i) {
const auto& regex = regexes[i].first;
diff --git a/src/selectformaction.cpp b/src/selectformaction.cpp
index 43e98365..13811b52 100644
--- a/src/selectformaction.cpp
+++ b/src/selectformaction.cpp
@@ -152,7 +152,7 @@ void SelectFormAction::prepare()
render_line = [this, selecttag_format](std::uint32_t line,
std::uint32_t width) -> StflRichText {
const auto& tag = tags[line];
- return StflRichText::from_plaintext_string(
+ return StflRichText::from_plaintext(
format_line(selecttag_format,
tag,
line + 1,
@@ -164,7 +164,7 @@ void SelectFormAction::prepare()
render_line = [this](std::uint32_t line, std::uint32_t width) -> StflRichText {
(void)width;
const auto& filter = filters[line];
- return StflRichText::from_plaintext_string(
+ return StflRichText::from_plaintext(
strprintf::fmt(
"%4u %s",
line + 1,
diff --git a/src/stflrichtext.cpp b/src/stflrichtext.cpp
index 46cf6c16..be34e1b9 100644
--- a/src/stflrichtext.cpp
+++ b/src/stflrichtext.cpp
@@ -24,7 +24,7 @@ StflRichText operator+(StflRichText left, const StflRichText& right)
return StflRichText(std::move(text), std::move(tags));
}
-StflRichText StflRichText::from_plaintext_string(std::string text)
+StflRichText StflRichText::from_plaintext(std::string text)
{
text = utils::quote_for_stfl(text);
@@ -43,12 +43,12 @@ void StflRichText::apply_style_tag(const std::string& tag, size_t start, size_t
merge_style_tag(style_tags, tag, start, end);
}
-std::string StflRichText::get_plaintext() const
+std::string StflRichText::plaintext() const
{
return text;
}
-std::string StflRichText::stfl_quoted_string() const
+std::string StflRichText::stfl_quoted() const
{
return insert_style_tags(text, style_tags);
}
diff --git a/src/textformatter.cpp b/src/textformatter.cpp
index 6f9d2459..f3cbb368 100644
--- a/src/textformatter.cpp
+++ b/src/textformatter.cpp
@@ -164,7 +164,7 @@ std::vector<std::string> format_text_plain_helper(
// TODO: Propagate usage of StflRichText
auto x = StflRichText::from_quoted(text);
rxman->quote_and_highlight(x, location);
- text = x.stfl_quoted_string();
+ text = x.stfl_quoted();
}
switch (type) {
diff --git a/src/urlviewformaction.cpp b/src/urlviewformaction.cpp
index 79453ef8..3a4b1075 100644
--- a/src/urlviewformaction.cpp
+++ b/src/urlviewformaction.cpp
@@ -129,7 +129,7 @@ void UrlViewFormAction::prepare()
auto render_line = [this](std::uint32_t line, std::uint32_t width) -> StflRichText {
(void)width;
const auto& link = links[line];
- return StflRichText::from_plaintext_string(strprintf::fmt("%2u %s", line + 1, link.url));
+ return StflRichText::from_plaintext(strprintf::fmt("%2u %s", line + 1, link.url));
};
urls_list.invalidate_list_content(links.size(), render_line);
diff --git a/test/listformatter.cpp b/test/listformatter.cpp
index b6fa99f4..2d3ca554 100644
--- a/test/listformatter.cpp
+++ b/test/listformatter.cpp
@@ -9,7 +9,7 @@ namespace {
void add_lines(ListFormatter& listfmt, std::vector<std::string> lines)
{
for (const auto& line : lines) {
- listfmt.add_line(StflRichText::from_plaintext_string(line));
+ listfmt.add_line(StflRichText::from_plaintext(line));
}
}
@@ -54,7 +54,7 @@ TEST_CASE("set_line() replaces the item in a list", "[ListFormatter]")
"}";
REQUIRE(fmt.format_list() == expected);
- fmt.set_line(1, StflRichText::from_plaintext_string("oh"));
+ fmt.set_line(1, StflRichText::from_plaintext("oh"));
expected =
"{list"
diff --git a/test/listwidget.cpp b/test/listwidget.cpp
index 9d374103..458e11ef 100644
--- a/test/listwidget.cpp
+++ b/test/listwidget.cpp
@@ -20,7 +20,7 @@ const static std::string stflListForm =
StflRichText render_empty_line(std::uint32_t, std::uint32_t)
{
- return StflRichText::from_plaintext_string("");
+ return StflRichText::from_plaintext("");
}
@@ -104,7 +104,7 @@ TEST_CASE("invalidate_list_content() clears internal caches", "[ListWidget]")
std::set<std::uint32_t> requested_lines;
auto render_line = [&](std::uint32_t line, std::uint32_t) -> StflRichText {
requested_lines.insert(line);
- return StflRichText::from_plaintext_string("");
+ return StflRichText::from_plaintext("");
};
GIVEN("a ListWidget with 3 lines") {
diff --git a/test/regexmanager.cpp b/test/regexmanager.cpp
index ed74e945..a47585db 100644
--- a/test/regexmanager.cpp
+++ b/test/regexmanager.cpp
@@ -70,16 +70,16 @@ TEST_CASE("RegexManager highlights according to definition", "[RegexManager]")
SECTION("In articlelist") {
rxman.handle_action("highlight", {"articlelist", "foo", "blue", "red"});
- auto input = StflRichText::from_plaintext_string("xfoox");
+ auto input = StflRichText::from_plaintext("xfoox");
rxman.quote_and_highlight(input, "articlelist");
- REQUIRE(input.stfl_quoted_string() == "x<0>foo</>x");
+ REQUIRE(input.stfl_quoted() == "x<0>foo</>x");
}
SECTION("In feedlist") {
rxman.handle_action("highlight", {"feedlist", "foo", "blue", "red"});
- auto input = StflRichText::from_plaintext_string("yfooy");
+ auto input = StflRichText::from_plaintext("yfooy");
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == "y<0>foo</>y");
+ REQUIRE(input.stfl_quoted() == "y<0>foo</>y");
}
}
@@ -92,13 +92,13 @@ TEST_CASE("quote_and_highlight() only matches `^` at the start of the line",
SECTION("^.") {
rxman.handle_action("highlight", {"article", "^.", "blue", "red"});
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == "<0>T</>his is a test");
+ REQUIRE(input.stfl_quoted() == "<0>T</>his is a test");
}
SECTION("(^Th|^is)") {
rxman.handle_action("highlight", {"article", "(^Th|^is)", "blue", "red"});
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == "<0>Th</>is is a test");
+ REQUIRE(input.stfl_quoted() == "<0>Th</>is is a test");
}
}
@@ -115,27 +115,27 @@ TEST_CASE("RegexManager::quote_and_highlight works fine even if there were "
rxman.handle_action("highlight", {"articlelist", "foo", "blue", "red"});
rxman.handle_action("highlight-article", {"title==\"\"", "blue", "red"});
- auto input = StflRichText::from_plaintext_string("xfoox");
+ auto input = StflRichText::from_plaintext("xfoox");
rxman.quote_and_highlight(input, "articlelist");
- REQUIRE(input.stfl_quoted_string() == "x<0>foo</>x");
+ REQUIRE(input.stfl_quoted() == "x<0>foo</>x");
}
TEST_CASE("RegexManager preserves text when there's nothing to highlight",
"[RegexManager]")
{
RegexManager rxman;
- auto input = StflRichText::from_plaintext_string("xbarx");
+ auto input = StflRichText::from_plaintext("xbarx");
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == "xbarx");
+ REQUIRE(input.stfl_quoted() == "xbarx");
input = StflRichText::from_quoted("a<b>");
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == "a<b>");
+ REQUIRE(input.stfl_quoted() == "a<b>");
SECTION("encode `<` as `<>` for stfl") {
- input = StflRichText::from_plaintext_string("<");
+ input = StflRichText::from_plaintext("<");
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == "<>");
+ REQUIRE(input.stfl_quoted() == "<>");
}
}
@@ -144,14 +144,14 @@ TEST_CASE("`highlight all` adds rules for all locations", "[RegexManager]")
RegexManager rxman;
std::vector<std::string> params = {"all", "foo", "red"};
REQUIRE_NOTHROW(rxman.handle_action("highlight", params));
- auto input = StflRichText::from_plaintext_string("xxfooyy");
+ auto input = StflRichText::from_plaintext("xxfooyy");
for (auto location : {
"article", "articlelist", "feedlist"
}) {
SECTION(location) {
rxman.quote_and_highlight(input, location);
- REQUIRE(input.stfl_quoted_string() == "xx<0>foo</>yy");
+ REQUIRE(input.stfl_quoted() == "xx<0>foo</>yy");
}
}
}
@@ -161,11 +161,11 @@ TEST_CASE("RegexManager does not hang on regexes that can match empty strings",
{
RegexManager rxman;
auto input =
- StflRichText::from_plaintext_string("The quick brown fox jumps over the lazy dog");
+ StflRichText::from_plaintext("The quick brown fox jumps over the lazy dog");
rxman.handle_action("highlight", {"feedlist", "w*", "blue", "red"});
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == "The quick bro<0>w</>n fox jumps over the lazy dog");
+ REQUIRE(input.stfl_quoted() == "The quick bro<0>w</>n fox jumps over the lazy dog");
}
TEST_CASE("RegexManager does not hang on regexes that match empty strings",
@@ -173,25 +173,25 @@ TEST_CASE("RegexManager does not hang on regexes that match empty strings",
{
RegexManager rxman;
auto input =
- StflRichText::from_plaintext_string("The quick brown fox jumps over the lazy dog");
- const std::string compare = input.get_plaintext();
+ StflRichText::from_plaintext("The quick brown fox jumps over the lazy dog");
+ const std::string compare = input.plaintext();
SECTION("testing end of line empty.") {
rxman.handle_action("highlight", {"feedlist", "$", "blue", "red"});
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == compare);
+ REQUIRE(input.stfl_quoted() == compare);
}
SECTION("testing beginning of line empty") {
rxman.handle_action("highlight", {"feedlist", "^", "blue", "red"});
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == compare);
+ REQUIRE(input.stfl_quoted() == compare);
}
SECTION("testing empty line") {
rxman.handle_action("highlight", {"feedlist", "^$", "blue", "red"});
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == compare);
+ REQUIRE(input.stfl_quoted() == compare);
}
}
@@ -200,7 +200,7 @@ TEST_CASE("quote_and_highlight wraps highlighted text in numbered tags",
{
RegexManager rxman;
auto input =
- StflRichText::from_plaintext_string("The quick brown fox jumps over the lazy dog");
+ StflRichText::from_plaintext("The quick brown fox jumps over the lazy dog");
SECTION("Beginning of line match first") {
const std::string output =
@@ -208,7 +208,7 @@ TEST_CASE("quote_and_highlight wraps highlighted text in numbered tags",
rxman.handle_action("highlight", {"article", "the", "red"});
rxman.handle_action("highlight", {"article", "brown", "blue"});
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
SECTION("Beginning of line match second") {
@@ -217,7 +217,7 @@ TEST_CASE("quote_and_highlight wraps highlighted text in numbered tags",
rxman.handle_action("highlight", {"article", "brown", "blue"});
rxman.handle_action("highlight", {"article", "the", "red"});
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
SECTION("2 non-overlapping highlights") {
@@ -226,7 +226,7 @@ TEST_CASE("quote_and_highlight wraps highlighted text in numbered tags",
rxman.handle_action("highlight", {"article", "quick", "red"});
rxman.handle_action("highlight", {"article", "brown", "blue"});
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
@@ -607,23 +607,23 @@ TEST_CASE("RegexManager::remove_last_regex removes last added `highlight` rule",
const auto INPUT = std::string("xfoobarx");
- auto input = StflRichText::from_plaintext_string(INPUT);
+ auto input = StflRichText::from_plaintext(INPUT);
rxman.quote_and_highlight(input, "articlelist");
- REQUIRE(input.stfl_quoted_string() == "x<0>foo<1>bar</>x");
+ REQUIRE(input.stfl_quoted() == "x<0>foo<1>bar</>x");
- input = StflRichText::from_plaintext_string(INPUT);
+ input = StflRichText::from_plaintext(INPUT);
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == INPUT);
+ REQUIRE(input.stfl_quoted() == INPUT);
REQUIRE_NOTHROW(rxman.remove_last_regex("articlelist"));
- input = StflRichText::from_plaintext_string(INPUT);
+ input = StflRichText::from_plaintext(INPUT);
rxman.quote_and_highlight(input, "articlelist");
- REQUIRE(input.stfl_quoted_string() == "x<0>foo</>barx");
+ REQUIRE(input.stfl_quoted() == "x<0>foo</>barx");
- input = StflRichText::from_plaintext_string(INPUT);
+ input = StflRichText::from_plaintext(INPUT);
rxman.quote_and_highlight(input, "feedlist");
- REQUIRE(input.stfl_quoted_string() == INPUT);
+ REQUIRE(input.stfl_quoted() == INPUT);
}
TEST_CASE("RegexManager::remove_last_regex does not crash if there are "
@@ -694,9 +694,9 @@ TEST_CASE("RegexManager uses POSIX extended regex syntax",
REQUIRE(e.what() == expected);
}
- auto input = StflRichText::from_plaintext_string("*]+");
+ auto input = StflRichText::from_plaintext("*]+");
rxman.quote_and_highlight(input, "articlelist");
- REQUIRE(input.stfl_quoted_string() == "*]+");
+ REQUIRE(input.stfl_quoted() == "*]+");
}
SECTION("No support for hexadecimal escape") {
@@ -708,9 +708,9 @@ TEST_CASE("RegexManager uses POSIX extended regex syntax",
REQUIRE(e.what() == expected);
}
- auto input = StflRichText::from_plaintext_string("value");
+ auto input = StflRichText::from_plaintext("value");
rxman.quote_and_highlight(input, "articlelist");
- REQUIRE(input.stfl_quoted_string() == "value");
+ REQUIRE(input.stfl_quoted() == "value");
}
SECTION("No support for \\a as alert/bell control character") {
@@ -722,9 +722,9 @@ TEST_CASE("RegexManager uses POSIX extended regex syntax",
REQUIRE(e.what() == expected);
}
- auto input = StflRichText::from_plaintext_string("\x07");
+ auto input = StflRichText::from_plaintext("\x07");
rxman.quote_and_highlight(input, "articlelist");
- REQUIRE(input.stfl_quoted_string() == "\x07");
+ REQUIRE(input.stfl_quoted() == "\x07");
}
SECTION("No support for \\b as backspace control character") {
@@ -736,9 +736,9 @@ TEST_CASE("RegexManager uses POSIX extended regex syntax",
REQUIRE(e.what() == expected);
}
- auto input = StflRichText::from_plaintext_string("\x08");
+ auto input = StflRichText::from_plaintext("\x08");
rxman.quote_and_highlight(input, "articlelist");
- REQUIRE(input.stfl_quoted_string() == "\x08");
+ REQUIRE(input.stfl_quoted() == "\x08");
}
// If you add more checks to this test, consider adding the same to Matcher tests
@@ -754,14 +754,14 @@ TEST_CASE("quote_and_highlight() does not break existing tags like <unread>",
const std::string output = "<unread>This entry is un<0>read</>";
rxman.handle_action("highlight", {"article", "read", "red"});
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
WHEN("matching `unread`") {
const std::string output = "<unread>This entry is <0>unread</>";
rxman.handle_action("highlight", {"article", "unread", "red"});
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
WHEN("matching the full line") {
@@ -770,7 +770,7 @@ TEST_CASE("quote_and_highlight() does not break existing tags like <unread>",
THEN("the <unread> tag is overwritten") {
const std::string output = "<0>This entry is unread</>";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
}
@@ -787,7 +787,7 @@ TEST_CASE("quote_and_highlight() ignores tags when matching the regular expressi
THEN("the <unread> tag should be ignored") {
const std::string output = "<0>This<unread> entry is unread</>";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
@@ -797,7 +797,7 @@ TEST_CASE("quote_and_highlight() ignores tags when matching the regular expressi
THEN("the closing tag `</>` (related to <unread>) should be ignored") {
const std::string output = "<unread>This entry is <0>unread</>";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
@@ -808,7 +808,7 @@ TEST_CASE("quote_and_highlight() ignores tags when matching the regular expressi
THEN("the tags should be ignored when matching text with a regular expression") {
const std::string output = "<0>Something</> is underlined";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
}
@@ -818,7 +818,7 @@ TEST_CASE("quote_and_highlight() generates a sensible output when multiple match
{
RegexManager rxman;
auto input =
- StflRichText::from_plaintext_string("The quick brown fox jumps over the lazy dog");
+ StflRichText::from_plaintext("The quick brown fox jumps over the lazy dog");
WHEN("a second match is completely inside of the first match") {
rxman.handle_action("highlight", {"article", "The quick brown", "red"});
@@ -828,7 +828,7 @@ TEST_CASE("quote_and_highlight() generates a sensible output when multiple match
const std::string output =
"<0>The <1>quick<0> brown</> fox jumps over the lazy dog";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
@@ -840,7 +840,7 @@ TEST_CASE("quote_and_highlight() generates a sensible output when multiple match
const std::string output =
"<1>The quick brown</> fox jumps over the lazy dog";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
@@ -852,7 +852,7 @@ TEST_CASE("quote_and_highlight() generates a sensible output when multiple match
const std::string output =
"The <0>quick <1>brown fox</> jumps over the lazy dog";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
@@ -864,7 +864,7 @@ TEST_CASE("quote_and_highlight() generates a sensible output when multiple match
const std::string output =
"The <1>quick brown<0> fox</> jumps over the lazy dog";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
@@ -877,7 +877,7 @@ TEST_CASE("quote_and_highlight() generates a sensible output when multiple match
const std::string output =
"The <0>quick <2>brown fox<1> jumps over<0> the lazy dog</>";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
}
}
@@ -891,7 +891,7 @@ TEST_CASE("quote_and_highlight() keeps stfl-encoded angle brackets and allows ma
SECTION("stfl-encoded angle brackets are kept/restored") {
const std::string output = "<unread>title with <>literal> angle brackets</>";
rxman.quote_and_highlight(input, "article");
- REQUIRE(input.stfl_quoted_string() == output);
+ REQUIRE(input.stfl_quoted() == output);
}
SECTION("angle brackets can be matched directly") {
@@ -899,6 +899,6 @@ TEST_CASE("quote_and_hi