mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Open file preview in text editor.
This commit is contained in:
parent
9dbc56beb6
commit
5bd35eb34e
@ -15,6 +15,7 @@
|
|||||||
#include "TracyBadVersion.hpp"
|
#include "TracyBadVersion.hpp"
|
||||||
#include "TracyFileRead.hpp"
|
#include "TracyFileRead.hpp"
|
||||||
#include "TracyFileWrite.hpp"
|
#include "TracyFileWrite.hpp"
|
||||||
|
#include "TracyFilesystem.hpp"
|
||||||
#include "TracyImGui.hpp"
|
#include "TracyImGui.hpp"
|
||||||
#include "TracyPopcnt.hpp"
|
#include "TracyPopcnt.hpp"
|
||||||
#include "TracyView.hpp"
|
#include "TracyView.hpp"
|
||||||
@ -396,6 +397,25 @@ void View::InitTextEditor()
|
|||||||
m_textEditor = std::make_unique<TextEditor>();
|
m_textEditor = std::make_unique<TextEditor>();
|
||||||
m_textEditor->SetReadOnly( true );
|
m_textEditor->SetReadOnly( true );
|
||||||
m_textEditor->SetLanguageDefinition( TextEditor::LanguageDefinition::CPlusPlus() );
|
m_textEditor->SetLanguageDefinition( TextEditor::LanguageDefinition::CPlusPlus() );
|
||||||
|
|
||||||
|
m_textEditorFile = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::SetTextEditorFile( const char* fileName, int line )
|
||||||
|
{
|
||||||
|
FILE* f = fopen( fileName, "rb" );
|
||||||
|
fseek( f, 0, SEEK_END );
|
||||||
|
const auto sz = ftell( f );
|
||||||
|
fseek( f, 0, SEEK_SET );
|
||||||
|
std::string data;
|
||||||
|
data.resize( sz );
|
||||||
|
fread( data.data(), 1, sz, f );
|
||||||
|
fclose( f );
|
||||||
|
|
||||||
|
m_textEditor->SetText( data );
|
||||||
|
m_textEditor->SetCursorPosition( TextEditor::Coordinates( line, 0 ) );
|
||||||
|
|
||||||
|
m_textEditorFile = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* View::ShortenNamespace( const char* name ) const
|
const char* View::ShortenNamespace( const char* name ) const
|
||||||
@ -3371,6 +3391,14 @@ void View::DrawZoneInfoWindow()
|
|||||||
ImGui::PopStyleColor( 3 );
|
ImGui::PopStyleColor( 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( FileExists( m_worker.GetString( srcloc.file ) ) )
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
if( ImGui::Button( "Source" ) )
|
||||||
|
{
|
||||||
|
SetTextEditorFile( m_worker.GetString( srcloc.file ), srcloc.line );
|
||||||
|
}
|
||||||
|
}
|
||||||
if( !m_zoneInfoStack.empty() )
|
if( !m_zoneInfoStack.empty() )
|
||||||
{
|
{
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -3635,6 +3663,7 @@ void View::DrawZoneInfoWindow()
|
|||||||
void View::DrawGpuInfoWindow()
|
void View::DrawGpuInfoWindow()
|
||||||
{
|
{
|
||||||
auto& ev = *m_gpuInfoWindow;
|
auto& ev = *m_gpuInfoWindow;
|
||||||
|
const auto& srcloc = m_worker.GetSourceLocation( ev.srcloc );
|
||||||
|
|
||||||
bool show = true;
|
bool show = true;
|
||||||
ImGui::Begin( "Zone info", &show );
|
ImGui::Begin( "Zone info", &show );
|
||||||
@ -3671,6 +3700,14 @@ void View::DrawGpuInfoWindow()
|
|||||||
ImGui::PopStyleColor( 3 );
|
ImGui::PopStyleColor( 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( FileExists( m_worker.GetString( srcloc.file ) ) )
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
if( ImGui::Button( "Source" ) )
|
||||||
|
{
|
||||||
|
SetTextEditorFile( m_worker.GetString( srcloc.file ), srcloc.line );
|
||||||
|
}
|
||||||
|
}
|
||||||
if( !m_gpuInfoStack.empty() )
|
if( !m_gpuInfoStack.empty() )
|
||||||
{
|
{
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -3683,7 +3720,6 @@ void View::DrawGpuInfoWindow()
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
const auto tid = GetZoneThread( ev );
|
const auto tid = GetZoneThread( ev );
|
||||||
const auto& srcloc = m_worker.GetSourceLocation( ev.srcloc );
|
|
||||||
TextFocused( "Zone name:", m_worker.GetString( srcloc.name ) );
|
TextFocused( "Zone name:", m_worker.GetString( srcloc.name ) );
|
||||||
TextFocused( "Function:", m_worker.GetString( srcloc.function ) );
|
TextFocused( "Function:", m_worker.GetString( srcloc.function ) );
|
||||||
ImGui::TextDisabled( "Location:" );
|
ImGui::TextDisabled( "Location:" );
|
||||||
|
|||||||
@ -58,6 +58,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void InitTextEditor();
|
void InitTextEditor();
|
||||||
|
void SetTextEditorFile( const char* fileName, int line );
|
||||||
|
|
||||||
const char* ShortenNamespace( const char* name ) const;
|
const char* ShortenNamespace( const char* name ) const;
|
||||||
|
|
||||||
@ -234,6 +235,7 @@ private:
|
|||||||
Vector<const GpuEvent*> m_gpuInfoStack;
|
Vector<const GpuEvent*> m_gpuInfoStack;
|
||||||
|
|
||||||
std::unique_ptr<TextEditor> m_textEditor;
|
std::unique_ptr<TextEditor> m_textEditor;
|
||||||
|
const char* m_textEditorFile;
|
||||||
|
|
||||||
struct FindZone {
|
struct FindZone {
|
||||||
enum : uint64_t { Unselected = std::numeric_limits<uint64_t>::max() - 1 };
|
enum : uint64_t { Unselected = std::numeric_limits<uint64_t>::max() - 1 };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user