1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Adding a copy button to the source view.

This commit is contained in:
Ben Vanik
2024-03-13 09:35:16 -07:00
parent f1998292a4
commit 605cdcb5d5
4 changed files with 16 additions and 1 deletions
+1
View File
@@ -33,6 +33,7 @@ void SourceContents::Parse( const char* fileName, const Worker& worker, const Vi
if( srcCache.data != nullptr )
{
m_data = srcCache.data;
m_dataSize = srcCache.len;
sz = srcCache.len;
}
else
+2
View File
@@ -27,6 +27,8 @@ public:
const char* filename() const { return m_file; }
uint32_t idx() const { return m_fileStringIdx; }
bool is_cached() const { return m_data != m_dataBuf; }
const char* data() const { return m_data; }
size_t data_size() const { return m_dataSize; }
private:
const char* m_file;
+12
View File
@@ -1,5 +1,6 @@
#include <ctype.h>
#include <inttypes.h>
#include <sstream>
#include <stdio.h>
#include <capstone.h>
@@ -1058,6 +1059,17 @@ void SourceView::Render( Worker& worker, View& view )
if( m_symAddr == 0 )
{
ImGui::PushFont( m_bigFont );
if( ClipboardButton() )
{
std::ostringstream stream;
stream.write( m_source.data(), m_source.data_size() );
ImGui::SetClipboardText( stream.str().c_str() );
}
ImGui::PopFont();
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
if( m_source.filename() )
{
ImGui::PushFont( m_bigFont );