summaryrefslogtreecommitdiff
path: root/wx+/no_flicker.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2021-02-02 11:44:31 -0500
committerB Stack <bgstack15@gmail.com>2021-02-02 11:44:31 -0500
commitd299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8 (patch)
tree4d7c950512836f473a6a8cbb521c61e800db6584 /wx+/no_flicker.h
parentMerge branch '11.5' into 'master' (diff)
downloadFreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.tar.gz
FreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.tar.bz2
FreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.zip
add upstream 11.6
Diffstat (limited to 'wx+/no_flicker.h')
-rw-r--r--wx+/no_flicker.h42
1 files changed, 20 insertions, 22 deletions
diff --git a/wx+/no_flicker.h b/wx+/no_flicker.h
index 53e47bb5..a84a7228 100644
--- a/wx+/no_flicker.h
+++ b/wx+/no_flicker.h
@@ -79,28 +79,28 @@ void setTextWithUrls(wxRichTextCtrl& richCtrl, const wxString& newText)
richCtrl.Clear();
+ wxRichTextAttr urlStyle;
+ urlStyle.SetTextColour(*wxBLUE);
+ urlStyle.SetFontUnderlined(true);
+
+ for (const auto& [type, text] : blocks)
+ switch (type)
+ {
+ case BlockType::text:
+ richCtrl.WriteText(text);
+ break;
+
+ case BlockType::url:
+ richCtrl.BeginStyle(urlStyle);
+ ZEN_ON_SCOPE_EXIT(richCtrl.EndStyle());
+ richCtrl.BeginURL(text);
+ ZEN_ON_SCOPE_EXIT(richCtrl.EndURL());
+ richCtrl.WriteText(text);
+ break;
+ }
+
if (std::any_of(blocks.begin(), blocks.end(), [](const auto& item) { return item.first == BlockType::url; }))
{
- wxRichTextAttr urlStyle;
- urlStyle.SetTextColour(*wxBLUE);
- urlStyle.SetFontUnderlined(true);
-
- for (const auto& [type, text] : blocks)
- switch (type)
- {
- case BlockType::text:
- richCtrl.WriteText(text);
- break;
-
- case BlockType::url:
- richCtrl.BeginStyle(urlStyle);
- ZEN_ON_SCOPE_EXIT(richCtrl.EndStyle());
- richCtrl.BeginURL(text);
- ZEN_ON_SCOPE_EXIT(richCtrl.EndURL());
- richCtrl.WriteText(text);
- break;
- }
-
//register only once! => use a global function pointer, so that Unbind() works correctly:
using LaunchUrlFun = void(*)(wxTextUrlEvent& event);
static const LaunchUrlFun launchUrl = [](wxTextUrlEvent& event) { wxLaunchDefaultBrowser(event.GetString()); };
@@ -108,8 +108,6 @@ void setTextWithUrls(wxRichTextCtrl& richCtrl, const wxString& newText)
[[maybe_unused]] const bool unbindOk = richCtrl.Unbind(wxEVT_TEXT_URL, launchUrl);
richCtrl.Bind(wxEVT_TEXT_URL, launchUrl);
}
- else
- richCtrl.WriteText(newText);
}
}
}
bgstack15