mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Add source code printer helper.
This commit is contained in:
parent
ef1c8e8512
commit
e09379bd16
@ -98,4 +98,33 @@ void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImV
|
||||
draw->AddText( wpos + ImVec2( round( (w-1-rsz) * 0.5 ), ty15 ), 0x66FFFFFF, range );
|
||||
}
|
||||
|
||||
void PrintSource( const std::vector<Tokenizer::Line>& lines )
|
||||
{
|
||||
for( auto& line: lines )
|
||||
{
|
||||
auto ptr = line.begin;
|
||||
auto it = line.tokens.begin();
|
||||
while( ptr < line.end )
|
||||
{
|
||||
if( it == line.tokens.end() )
|
||||
{
|
||||
ImGui::TextUnformatted( ptr, line.end );
|
||||
ImGui::SameLine( 0, 0 );
|
||||
break;
|
||||
}
|
||||
if( ptr < it->begin )
|
||||
{
|
||||
ImGui::TextUnformatted( ptr, it->begin );
|
||||
ImGui::SameLine( 0, 0 );
|
||||
}
|
||||
auto color = SyntaxColors[(int)it->color];
|
||||
TextColoredUnformatted( color, it->begin, it->end );
|
||||
ImGui::SameLine( 0, 0 );
|
||||
ptr = it->end;
|
||||
++it;
|
||||
}
|
||||
ImGui::ItemSize( ImVec2( 0, 0 ), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,14 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
#include "../public/common/TracyForceInline.hpp"
|
||||
#include "IconsFontAwesome6.h"
|
||||
#include "TracySourceTokenizer.hpp"
|
||||
|
||||
#if !IMGUI_DEFINE_MATH_OPERATORS
|
||||
static inline ImVec2 operator+( const ImVec2& l, const ImVec2& r ) { return ImVec2( l.x + r.x, l.y + r.y ); }
|
||||
@ -29,6 +31,7 @@ bool WasActive();
|
||||
void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end, double h, uint32_t color );
|
||||
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<Tokenizer::Line>& lines );
|
||||
|
||||
|
||||
static constexpr const uint32_t SyntaxColors[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user