aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-07 17:15:48 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-07 17:15:48 +0200
commitcd94bfc187d6a716f00d218e514409d8e65603c4 (patch)
tree80c88c145af78acf3f1b440963693b1a93cbd887 /src
parentca0e381e2a248170f71c236a5070ce349f0206ea (diff)
Matrix: fix posting messages with non-ascii characters
Diffstat (limited to 'src')
-rw-r--r--src/Entry.cpp4
-rw-r--r--src/QuickMedia.cpp8
-rw-r--r--src/SearchBar.cpp21
3 files changed, 20 insertions, 13 deletions
diff --git a/src/Entry.cpp b/src/Entry.cpp
index c57d6cb..2b9e573 100644
--- a/src/Entry.cpp
+++ b/src/Entry.cpp
@@ -26,7 +26,9 @@ namespace QuickMedia {
text.processEvent(event);
if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Enter && !event.key.shift) {
if(on_submit_callback) {
- bool clear_text = on_submit_callback(text.getString());
+ auto u8 = text.getString().toUtf8();
+ std::string *u8_str = (std::string*)&u8;
+ bool clear_text = on_submit_callback(*u8_str);
if(clear_text)
text.setString("");
}
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 283379a..a0e9b78 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1055,7 +1055,7 @@ namespace QuickMedia {
};
search_bar->autocomplete_search_delay = current_plugin->get_autocomplete_delay();
- search_bar->onAutocompleteRequestCallback = [this, &tabs, &selected_tab, &autocomplete_text](const sf::String &text) {
+ search_bar->onAutocompleteRequestCallback = [this, &tabs, &selected_tab, &autocomplete_text](const std::string &text) {
if(tabs[selected_tab].body == body && !current_plugin->search_is_filter())
autocomplete_text = text;
};
@@ -2666,7 +2666,7 @@ namespace QuickMedia {
show_notification("QuickMedia", "File manager failed to get files in directory: " + file_manager->get_current_dir().string(), Urgency::CRITICAL);
}
- search_bar->onTextUpdateCallback = [this](const sf::String &text) {
+ search_bar->onTextUpdateCallback = [this](const std::string &text) {
body->filter_search_fuzzy(text);
body->reset_selected();
};
@@ -3507,9 +3507,9 @@ namespace QuickMedia {
chat_input.draw_background = false;
chat_input.set_editable(false);
- chat_input.on_submit_callback = [matrix, &chat_input, &tabs, &selected_tab, &current_room_id, &new_page, &chat_state, &currently_operating_on_item](const sf::String &text) mutable {
+ chat_input.on_submit_callback = [matrix, &chat_input, &tabs, &selected_tab, &current_room_id, &new_page, &chat_state, &currently_operating_on_item](const std::string &text) mutable {
if(tabs[selected_tab].type == ChatTabType::MESSAGES) {
- if(text.isEmpty())
+ if(text.empty())
return false;
if(chat_state == ChatState::TYPING_MESSAGE && text[0] == '/') {
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index fa81c61..f489779 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -91,15 +91,19 @@ namespace QuickMedia {
sf::Int32 elapsed_time = time_since_search_update.getElapsedTime().asMilliseconds();
if(updated_search && elapsed_time >= text_autosearch_delay) {
updated_search = false;
- sf::String str = text.getString();
+ auto u8 = text.getString().toUtf8();
+ std::string *u8_str = (std::string*)&u8;
if(show_placeholder)
- str.clear();
+ u8_str->clear();
if(onTextUpdateCallback)
- onTextUpdateCallback(str);
+ onTextUpdateCallback(*u8_str);
} else if(updated_autocomplete && elapsed_time >= autocomplete_search_delay) {
updated_autocomplete = false;
- if(!show_placeholder && onAutocompleteRequestCallback)
- onAutocompleteRequestCallback(text.getString());
+ if(!show_placeholder && onAutocompleteRequestCallback) {
+ auto u8 = text.getString().toUtf8();
+ std::string *u8_str = (std::string*)&u8;
+ onAutocompleteRequestCallback(*u8_str);
+ }
}
}
@@ -165,10 +169,11 @@ namespace QuickMedia {
} else if(codepoint == 13) { // Return
bool clear_search = true;
if(onTextSubmitCallback) {
+ auto u8 = text.getString().toUtf8();
+ std::string *u8_str = (std::string*)&u8;
if(show_placeholder)
- clear_search = onTextSubmitCallback("");
- else
- clear_search = onTextSubmitCallback(text.getString());
+ u8_str->clear();
+ clear_search = onTextSubmitCallback(*u8_str);
}
if(clear_search)