From 40cd04f9dd15d951b441a233832a00a0da32a089 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sat, 29 Jul 2023 21:13:08 +0200 Subject: [PATCH] fix cross platform file paths to string --- src/chat_gui4.cpp | 3 ++- src/file_selector.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index b527efe8..b9f2f314 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -249,7 +249,7 @@ void ChatGui4::render(void) { _fss.requestFile( [](const auto& path) -> bool { return std::filesystem::is_regular_file(path); }, [this](const auto& path){ - _rmm.sendFilePath(*_selected_contact, path.filename().c_str(), path.c_str()); + _rmm.sendFilePath(*_selected_contact, path.filename().u8string(), path.u8string()); }, [](){} ); @@ -272,6 +272,7 @@ void ChatGui4::render(void) { void ChatGui4::renderMessageBodyText(Message3Registry& reg, const Message3 e) { const auto& msgtext = reg.get(e).text; + // TODO: set word wrap ImVec2 text_size = ImGui::CalcTextSize(msgtext.c_str(), msgtext.c_str()+msgtext.size()); text_size.x = -FLT_MIN; // fill width (suppresses label) text_size.y += ImGui::GetStyle().FramePadding.y; // single pad diff --git a/src/file_selector.cpp b/src/file_selector.cpp index 4fa1734c..b54e01ae 100644 --- a/src/file_selector.cpp +++ b/src/file_selector.cpp @@ -46,7 +46,7 @@ void FileSelector::render(void) { std::filesystem::path current_path = _current_file_path; current_path.remove_filename(); - ImGui::Text("path: %s", _current_file_path.c_str()); + ImGui::Text("path: %s", _current_file_path.u8string().c_str()); // begin table with selectables constexpr ImGuiTableFlags table_flags = @@ -174,7 +174,7 @@ void FileSelector::render(void) { } if (ImGui::TableNextColumn()) { - ImGui::TextUnformatted((dir_entry.path().filename().string() + "/").c_str()); + ImGui::TextUnformatted((dir_entry.path().filename().u8string() + "/").c_str()); } if (ImGui::TableNextColumn()) { @@ -199,7 +199,7 @@ void FileSelector::render(void) { } if (ImGui::TableNextColumn()) { - ImGui::TextUnformatted(dir_entry.path().filename().c_str()); + ImGui::TextUnformatted(dir_entry.path().filename().u8string().c_str()); } if (ImGui::TableNextColumn()) {