Register line selection.

This commit is contained in:
Bartosz Taudul 2020-05-01 16:33:24 +02:00
parent 8b2b2f650f
commit f4b06ed1fc
2 changed files with 20 additions and 1 deletions

View File

@ -74,6 +74,7 @@ SourceView::SourceView( ImFont* font )
, m_dataSize( 0 )
, m_targetLine( 0 )
, m_selectedLine( 0 )
, m_asmSelected( -1 )
, m_hoveredLine( 0 )
, m_hoveredSource( 0 )
, m_codeLen( 0 )
@ -2084,11 +2085,20 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
}
}
const auto asmIdx = &line - m_asm.data();
const auto msz = line.mnemonic.size();
memcpy( buf, line.mnemonic.c_str(), msz );
memset( buf+msz, ' ', m_maxMnemonicLen-msz );
memcpy( buf+m_maxMnemonicLen, line.operands.c_str(), line.operands.size() + 1 );
ImGui::TextUnformatted( buf );
if( asmIdx == m_asmSelected )
{
TextColoredUnformatted( ImVec4( 1, 0.25f, 0.25f, 1 ), buf );
}
else
{
ImGui::TextUnformatted( buf );
}
if( ImGui::IsItemHovered() )
{
@ -2243,6 +2253,14 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
if( m_font ) ImGui::PushFont( m_font );
}
}
if( ImGui::IsMouseClicked( 0 ) )
{
m_asmSelected = asmIdx;
}
else if( ImGui::IsMouseClicked( 1 ) )
{
m_asmSelected = -1;
}
}
if( line.jumpAddr != 0 )

View File

@ -176,6 +176,7 @@ private:
size_t m_dataSize;
int m_targetLine;
int m_selectedLine;
int m_asmSelected;
DecayValue<int> m_hoveredLine;
DecayValue<uint32_t> m_hoveredSource;
int m_displayMode;