summaryrefslogtreecommitdiff
path: root/wx+/no_flicker.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2021-02-02 21:49:34 +0000
committerB Stack <bgstack15@gmail.com>2021-02-02 21:49:34 +0000
commit26b8bd6eb07b78adad36049e03494a2931b231af (patch)
tree4d7c950512836f473a6a8cbb521c61e800db6584 /wx+/no_flicker.h
parentMerge branch '11.5' into 'master' (diff)
parentadd upstream 11.6 (diff)
downloadFreeFileSync-26b8bd6eb07b78adad36049e03494a2931b231af.tar.gz
FreeFileSync-26b8bd6eb07b78adad36049e03494a2931b231af.tar.bz2
FreeFileSync-26b8bd6eb07b78adad36049e03494a2931b231af.zip
Merge branch '11.6' into 'master'11.6
add upstream 11.6 See merge request opensource-tracking/FreeFileSync!30
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