1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Make source location display a bit shorter in asm line.

This commit is contained in:
Bartosz Taudul 2022-09-24 00:36:59 +02:00
parent 55e78ba4f7
commit da58c1f55e
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -3666,6 +3666,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
bool lineHovered = false;
if( m_asmShowSourceLocation && !m_sourceFiles.empty() )
{
constexpr size_t MaxSourceLength = 26;
ImGui::SameLine( 0, stw );
ImVec2 startPos;
uint32_t srcline;
@ -3681,13 +3682,13 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
startPos = ImGui::GetCursorScreenPos();
char buf[64];
const auto fnsz = strlen( fileName );
if( fnsz < 30 - m_maxLine )
if( fnsz < MaxSourceLength - m_maxLine )
{
sprintf( buf, "%s:%i", fileName, srcline );
}
else
{
sprintf( buf, "\xe2\x80\xa6%s:%i", fileName+fnsz-(30-1-1-m_maxLine), srcline );
sprintf( buf, "\xe2\x80\xa6%s:%i", fileName+fnsz-(MaxSourceLength-1-1-m_maxLine), srcline );
}
TextDisabledUnformatted( buf );
if( ImGui::IsItemHovered() )
@ -3772,7 +3773,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
ImGui::SameLine( 0, 0 );
const auto endPos = ImGui::GetCursorScreenPos();
const auto itemsWidth = ( endPos - startPos ).x;
const auto fixedWidth = 32 * ts.x;
const auto fixedWidth = ( MaxSourceLength + 2 ) * ts.x;
ImGui::ItemSize( ImVec2( fixedWidth - itemsWidth, 0 ) );
}