diff --git a/profiler/src/profiler/TracyImGui.cpp b/profiler/src/profiler/TracyImGui.cpp index dce67d55..45e06292 100644 --- a/profiler/src/profiler/TracyImGui.cpp +++ b/profiler/src/profiler/TracyImGui.cpp @@ -127,4 +127,24 @@ void PrintSource( const std::vector& lines ) } } +void PrintTextWrapped( const char* text, const char* end ) +{ + if( !end ) end = text + strlen( text ); + + auto scale = ImGui::GetIO().FontGlobalScale; + auto left = ImGui::GetContentRegionAvail().x; + auto endLine = ImGui::GetFont()->CalcWordWrapPositionA( scale, text, end, left ); + ImGui::TextUnformatted( text, endLine ); + + left = ImGui::GetContentRegionAvail().x; + while( endLine < end ) + { + text = endLine; + if( *text == ' ' ) text++; + endLine = ImGui::GetFont()->CalcWordWrapPositionA( scale, text, end, left ); + if( text == endLine ) endLine++; + ImGui::TextUnformatted( text, endLine ); + } +} + } diff --git a/profiler/src/profiler/TracyImGui.hpp b/profiler/src/profiler/TracyImGui.hpp index 505d91d0..5707f265 100644 --- a/profiler/src/profiler/TracyImGui.hpp +++ b/profiler/src/profiler/TracyImGui.hpp @@ -32,6 +32,7 @@ void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end, void DrawStripedRect( ImDrawList* draw, const ImVec2& wpos, double x0, double y0, double x1, double y1, double sw, uint32_t color, bool fix_stripes_in_screen_space, bool inverted ); void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty ); void PrintSource( const std::vector& lines ); +void PrintTextWrapped( const char* text, const char* end = nullptr ); static constexpr const uint32_t SyntaxColors[] = {