aboutsummaryrefslogtreecommitdiff
path: root/src/Text.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-06 06:16:47 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-06 06:16:47 +0200
commit04e852c45a3f309d5e139b0ca059b32277c250e4 (patch)
treed704413fa0d76bf7f8c92eacce5e96e0a3d4c874 /src/Text.cpp
parent797a36228bdb3b77b7314585a31de6f27feab51d (diff)
Create a unified launcher for quickmedia
Diffstat (limited to 'src/Text.cpp')
-rw-r--r--src/Text.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/Text.cpp b/src/Text.cpp
index a9f1147..2abc276 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -29,15 +29,16 @@ namespace QuickMedia
Text::Text(bool bold_font) : Text("", bold_font, 0, 0.0f) {}
- Text::Text(sf::String _str, bool bold_font, unsigned int _characterSize, float _maxWidth) :
+ Text::Text(sf::String _str, bool bold_font, unsigned int characterSize, float maxWidth, bool highlight_urls) :
bold_font(bold_font),
- characterSize(_characterSize),
- maxWidth(_maxWidth),
+ characterSize(characterSize),
+ maxWidth(maxWidth),
color(sf::Color::White),
dirty(true),
dirtyText(false),
dirtyCaret(false),
editable(false),
+ highlight_urls(highlight_urls),
caretMoveDirection(CaretMoveDirection::NONE),
num_lines(1),
lineSpacing(0.0f),
@@ -324,10 +325,14 @@ namespace QuickMedia
dirtyText = false;
splitTextByFont();
// TODO: Optimize
- auto u8 = str.toUtf8();
- std::string *u8_str = (std::string*)&u8;
- url_ranges = extract_urls(*u8_str);
- convert_utf8_to_utf32_ranges(*u8_str, url_ranges);
+ if(highlight_urls) {
+ auto u8 = str.toUtf8();
+ std::string *u8_str = (std::string*)&u8;
+ url_ranges = extract_urls(*u8_str);
+ convert_utf8_to_utf32_ranges(*u8_str, url_ranges);
+ } else {
+ url_ranges.clear();
+ }
dirty = true;
}