Merge pull request #750 from benvanik/benvanik-source-copy

Adding a copy button to the source view.
This commit is contained in:
Bartosz Taudul 2024-03-13 18:13:11 +01:00 committed by GitHub
commit 14206b5b4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 1 deletions

View File

@ -3681,7 +3681,7 @@ This window can operate in one of the two modes. The first one is quite simple,
\subsubsection{Source file view}
In source view mode, you can view the source code of the profiled application to take a quick glance at the context of the function behavior you are analyzing. The profiler will highlight the selected line (for example, a location of a profiling zone) both in the source code listing and on the scroll bar.
In source view mode, you can view the source code of the profiled application to take a quick glance at the context of the function behavior you are analyzing. The profiler will highlight the selected line (for example, a location of a profiling zone) both in the source code listing and on the scroll bar. The contents of the file displayed in the source view can be copied to the clipboard using the button adjacent to the file name.
\begin{bclogo}[
noborder=true,

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

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;

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 );