Initial add of color syntax logic in Qt debugger.

This commit is contained in:
mjbudd77 2021-07-09 21:36:26 -04:00
parent ea7deb0fd0
commit 5c992a8610
4 changed files with 76 additions and 26 deletions

View File

@ -46,7 +46,7 @@ ColorMenuItem::ColorMenuItem( QString txt, QWidget *parent)
//----------------------------------------------------------------------------
ColorMenuItem::~ColorMenuItem(void)
{
printf("Destroy Color Menu Item\n");
//printf("Destroy Color Menu Item\n");
}
//----------------------------------------------------------------------------
void ColorMenuItem::connectColor( QColor *c )

View File

@ -3686,11 +3686,11 @@ QAsmView::QAsmView(QWidget *parent)
useDarkTheme = false;
opcodeColor.setRgb( 255, 0, 0 );
labelColor.setRgb( 255, 255, 0 );
commentColor.setRgb( 0, 255, 0 );
addressColor.setRgb( 0, 0, 255 );
immediateColor.setRgb( 255, 0, 255 );
opcodeColor.setRgb( 46, 139, 87 );
labelColor.setRgb( 165, 42, 42 );
commentColor.setRgb( 0, 0, 255 );
addressColor.setRgb( 106, 90, 205 );
immediateColor.setRgb( 255, 1, 255 );
g_config->getOption("SDL.DebuggerAsmFont", &fontString);
@ -4745,6 +4745,50 @@ void QAsmView::drawAsmLine( QPainter *painter, int x, int y, const char *txt )
}
}
//----------------------------------------------------------------------------
void QAsmView::drawLabelLine( QPainter *painter, int x, int y, const char *txt )
{
int i=0;
char c[2];
c[0] = 0; c[1] = 0;
// Label Text
painter->setPen( this->palette().color(QPalette::WindowText));
while ( (txt[i] != 0) )
{
if ( isalnum(txt[i]) || (txt[i] == '_') )
{
painter->setPen( labelColor );
}
else
{
painter->setPen( this->palette().color(QPalette::WindowText));
}
c[0] = txt[i];
painter->drawText( x, y, tr(c) );
i++; x += pxCharWidth;
}
}
//----------------------------------------------------------------------------
void QAsmView::drawCommentLine( QPainter *painter, int x, int y, const char *txt )
{
int i=0;
char c[2];
c[0] = 0; c[1] = 0;
// Comment Text
painter->setPen( commentColor );
while ( (txt[i] != 0) )
{
c[0] = txt[i];
painter->drawText( x, y, tr(c) );
i++; x += pxCharWidth;
}
}
//----------------------------------------------------------------------------
void QAsmView::paintEvent(QPaintEvent *event)
{
int x,y,l, row, nrow, selAddr;
@ -4819,11 +4863,11 @@ void QAsmView::paintEvent(QPaintEvent *event)
if ( l < asmEntry.size() )
{
if ( asmEntry[l]->type != dbg_asm_entry_t::ASM_TEXT )
{
painter.fillRect( cd_boundary, y - pxLineSpacing + pxLineLead, viewWidth, pxLineSpacing, QColor("light blue") );
forceDarkColor = true;
}
//if ( asmEntry[l]->type != dbg_asm_entry_t::ASM_TEXT )
//{
// painter.fillRect( cd_boundary, y - pxLineSpacing + pxLineLead, viewWidth, pxLineSpacing, QColor("light blue") );
// forceDarkColor = true;
//}
if ( forceDarkColor )
{
@ -4837,9 +4881,13 @@ void QAsmView::paintEvent(QPaintEvent *event)
{
drawAsmLine( &painter, x, y, asmEntry[l]->text.c_str() );
}
else if ( asmEntry[l]->type == dbg_asm_entry_t::SYMBOL_NAME )
{
drawLabelLine( &painter, x, y, asmEntry[l]->text.c_str() );
}
else
{
drawText( &painter, x, y, asmEntry[l]->text.c_str() );
drawCommentLine( &painter, x, y, asmEntry[l]->text.c_str() );
}
if ( (selAddrLine == l) )

View File

@ -151,6 +151,8 @@ class QAsmView : public QWidget
void loadClipboard( const char *txt );
void drawText( QPainter *painter, int x, int y, const char *txt );
void drawAsmLine( QPainter *painter, int x, int y, const char *txt );
void drawLabelLine( QPainter *painter, int x, int y, const char *txt );
void drawCommentLine( QPainter *painter, int x, int y, const char *txt );
private:
ConsoleDebugger *parent;

View File

@ -763,11 +763,11 @@ debugSymbol_t *replaceSymbols( int flags, int addr, char *str )
{
if ( flags & ASM_DEBUG_ADDR_02X )
{
sprintf( str, "%02X ", addr );
sprintf( str, "$%02X ", addr );
}
else
{
sprintf( str, "%04X ", addr );
sprintf( str, "$%04X ", addr );
}
strcat( str, sym->name.c_str() );
}
@ -776,11 +776,11 @@ debugSymbol_t *replaceSymbols( int flags, int addr, char *str )
{
if ( flags & ASM_DEBUG_ADDR_02X )
{
sprintf( str, "%02X", addr );
sprintf( str, "$%02X", addr );
}
else
{
sprintf( str, "%04X", addr );
sprintf( str, "$%04X", addr );
}
}
@ -874,7 +874,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
if ( flags )
{
sym = replaceSymbols( flags, tmp, stmp );
sprintf(str,"%s ($%02X,X) @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
sprintf(str,"%s ($%02X,X) @ %s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
}
else
{
@ -910,7 +910,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
if ( flags )
{
sym = replaceSymbols( flags | ASM_DEBUG_ADDR_02X, opcode[1], stmp );
sprintf(str,"%s $%s = #$%02X", chr,stmp,GetMem(opcode[1]));
sprintf(str,"%s %s = #$%02X", chr,stmp,GetMem(opcode[1]));
}
else
{
@ -964,7 +964,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
if ( flags )
{
sym = replaceSymbols( flags, tmp, stmp );
sprintf(str,"%s $%s = #$%02X", chr,stmp,GetMem(tmp));
sprintf(str,"%s %s = #$%02X", chr,stmp,GetMem(tmp));
}
else
{
@ -987,7 +987,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
if ( flags )
{
sym = replaceSymbols( flags, tmp, stmp );
sprintf(str,"%s $%s", chr,stmp);
sprintf(str,"%s %s", chr,stmp);
}
else
{
@ -1010,7 +1010,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
if ( flags )
{
sym = replaceSymbols( flags, tmp, stmp );
sprintf(str,"%s ($%02X),Y @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
sprintf(str,"%s ($%02X),Y @ %s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
}
else
{
@ -1042,7 +1042,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
if ( flags )
{
sym = replaceSymbols( flags, tmp, stmp );
sprintf(str,"%s $%02X,X @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
sprintf(str,"%s $%02X,X @ %s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
}
else
{
@ -1068,7 +1068,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
{
sym = replaceSymbols( flags, tmp , stmp );
sym2 = replaceSymbols( flags, tmp2, stmp2 );
sprintf(str,"%s $%s,Y @ $%s = #$%02X", chr,stmp,stmp2,GetMem(tmp2));
sprintf(str,"%s %s,Y @ %s = #$%02X", chr,stmp,stmp2,GetMem(tmp2));
}
else
{
@ -1099,7 +1099,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
{
sym = replaceSymbols( flags, tmp , stmp );
sym2 = replaceSymbols( flags, tmp2, stmp2 );
sprintf(str,"%s $%s,X @ $%s = #$%02X", chr,stmp,stmp2,GetMem(tmp2));
sprintf(str,"%s %s,X @ %s = #$%02X", chr,stmp,stmp2,GetMem(tmp2));
}
else
{
@ -1117,7 +1117,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
if ( flags )
{
sym = replaceSymbols( flags, tmp, stmp );
sprintf(str,"%s $%s", chr,stmp);
sprintf(str,"%s %s", chr,stmp);
}
else
{
@ -1135,7 +1135,7 @@ int DisassembleWithDebug(int addr, uint8_t *opcode, int flags, char *str, debugS
if ( flags )
{
sym = replaceSymbols( flags, tmp, stmp );
sprintf(str,"%s $%02X,Y @ $%s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
sprintf(str,"%s $%02X,Y @ %s = #$%02X", chr,opcode[1],stmp,GetMem(tmp));
}
else
{