The debugger CPU area now has editable decimal and binary fields for the

registers.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3189 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2015-07-26 17:28:57 +00:00
parent 36ef5cd112
commit 237f0e5d35
8 changed files with 83 additions and 37 deletions

View File

@ -19,6 +19,10 @@
etc can be used to toggle each event. Thanks to Buzbard of AtariAge etc can be used to toggle each event. Thanks to Buzbard of AtariAge
for the suggestion. for the suggestion.
* Added ability to edit values in more widgets in the debugger. For
now, this applies mainly to the various decimal and binary fields.
More widgets will be made editable in future releases.
* Changed 'hidecursor' commandline argument (and associated UI item) to * Changed 'hidecursor' commandline argument (and associated UI item) to
'cursor'. The new argument allows to set mouse cursor visibility 'cursor'. The new argument allows to set mouse cursor visibility
separately for both UI and emulation modes. separately for both UI and emulation modes.

View File

@ -70,11 +70,16 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
xpos = x + lwidth + myPCGrid->getWidth() + 10; xpos = x + lwidth + myPCGrid->getWidth() + 10;
myCpuGridDecValue = myCpuGridDecValue =
new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 3, 8, Common::Base::F_10); new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 3, 8, Common::Base::F_10);
myCpuGridDecValue->setEditable(false); myCpuGridDecValue->setTarget(this);
myCpuGridDecValue->setID(kCpuRegDecID);
addFocusWidget(myCpuGridDecValue);
xpos += myCpuGridDecValue->getWidth() + 5; xpos += myCpuGridDecValue->getWidth() + 5;
myCpuGridBinValue = myCpuGridBinValue =
new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 8, 8, Common::Base::F_2); new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 8, 8, Common::Base::F_2);
myCpuGridBinValue->setEditable(false); myCpuGridBinValue->setTarget(this);
myCpuGridBinValue->setID(kCpuRegBinID);
addFocusWidget(myCpuGridBinValue);
// Calculate real dimensions (_y will be calculated at the end) // Calculate real dimensions (_y will be calculated at the end)
_w = lwidth + myPCGrid->getWidth() + myPCLabel->getWidth() + 20; _w = lwidth + myPCGrid->getWidth() + myPCLabel->getWidth() + 20;
@ -137,6 +142,8 @@ void CpuWidget::setOpsWidget(DataGridOpsWidget* w)
{ {
myPCGrid->setOpsWidget(w); myPCGrid->setOpsWidget(w);
myCpuGrid->setOpsWidget(w); myCpuGrid->setOpsWidget(w);
myCpuGridDecValue->setOpsWidget(w);
myCpuGridBinValue->setOpsWidget(w);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -159,6 +166,16 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
addr = myCpuGrid->getSelectedAddr(); addr = myCpuGrid->getSelectedAddr();
value = myCpuGrid->getSelectedValue(); value = myCpuGrid->getSelectedValue();
break; break;
case kCpuRegDecID:
addr = myCpuGridDecValue->getSelectedAddr();
value = myCpuGridDecValue->getSelectedValue();
break;
case kCpuRegBinID:
addr = myCpuGridBinValue->getSelectedAddr();
value = myCpuGridBinValue->getSelectedValue();
break;
} }
switch(addr) switch(addr)
@ -175,26 +192,30 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kSPRegAddr: case kSPRegAddr:
dbg.setSP(value); dbg.setSP(value);
myCpuGridDecValue->setValue(0, value); myCpuGrid->setValueInternal(0, value);
myCpuGridBinValue->setValue(0, value); myCpuGridDecValue->setValueInternal(0, value);
myCpuGridBinValue->setValueInternal(0, value);
break; break;
case kARegAddr: case kARegAddr:
dbg.setA(value); dbg.setA(value);
myCpuGridDecValue->setValue(1, value); myCpuGrid->setValueInternal(1, value);
myCpuGridBinValue->setValue(1, value); myCpuGridDecValue->setValueInternal(1, value);
myCpuGridBinValue->setValueInternal(1, value);
break; break;
case kXRegAddr: case kXRegAddr:
dbg.setX(value); dbg.setX(value);
myCpuGridDecValue->setValue(2, value); myCpuGrid->setValueInternal(2, value);
myCpuGridBinValue->setValue(2, value); myCpuGridDecValue->setValueInternal(2, value);
myCpuGridBinValue->setValueInternal(2, value);
break; break;
case kYRegAddr: case kYRegAddr:
dbg.setY(value); dbg.setY(value);
myCpuGridDecValue->setValue(3, value); myCpuGrid->setValueInternal(3, value);
myCpuGridBinValue->setValue(3, value); myCpuGridDecValue->setValueInternal(3, value);
myCpuGridBinValue->setValueInternal(3, value);
break; break;
} }
break; break;

View File

@ -48,7 +48,9 @@ class CpuWidget : public Widget, public CommandSender
// We need ID's, since there are more than one of several types of widgets // We need ID's, since there are more than one of several types of widgets
enum { enum {
kPCRegID, kPCRegID,
kCpuRegID kCpuRegID,
kCpuRegDecID,
kCpuRegBinID
}; };
enum { enum {

View File

@ -84,22 +84,31 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font,
} }
// Add filtering // Add filtering
EditableWidget::TextFilter f = [&](char c) { EditableWidget::TextFilter f;
bool isBin = c == '0' || c == '1', switch(base)
isDec = c >= '0' && c <= '9', {
isHex = isDec || (c >= 'a' && c <= 'f'), case Common::Base::F_16:
isOp = c == '$' || c == '#' || c == '\\'; case Common::Base::F_16_1:
case Common::Base::F_16_2:
if(BSPF_startsWithIgnoreCase(editString(), "$")) case Common::Base::F_16_4:
return isHex; case Common::Base::F_16_8:
else if(BSPF_startsWithIgnoreCase(editString(), "#")) setTextFilter([](char c) {
return isDec; return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
else if(BSPF_startsWithIgnoreCase(editString(), "\\")) });
return isBin; break;
else case Common::Base::F_10:
return isHex || isDec || isBin || isOp; setTextFilter([](char c) {
}; return (c >= '0' && c <= '9');
setTextFilter(f); });
break;
case Common::Base::F_2:
case Common::Base::F_2_8:
case Common::Base::F_2_16:
setTextFilter([](char c) { return (c >= '0' && c <= '1'); });
break;
default:
break; // no filtering for now
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -206,7 +215,14 @@ void DataGridWidget::setValue(int position, int value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::setValue(int position, int value, bool changed) void DataGridWidget::setValueInternal(int position, int value)
{
setValue(position, value, true, false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::setValue(int position, int value, bool changed,
bool emitSignal)
{ {
if(position >= 0 && uInt32(position) < _valueList.size()) if(position >= 0 && uInt32(position) < _valueList.size())
{ {
@ -217,6 +233,7 @@ void DataGridWidget::setValue(int position, int value, bool changed)
_changedList[position] = changed; _changedList[position] = changed;
_valueList[position] = value; _valueList[position] = value;
if(emitSignal)
sendCommand(DataGridWidget::kItemDataChangedCmd, position, _id); sendCommand(DataGridWidget::kItemDataChangedCmd, position, _id);
setDirty(); setDirty();

View File

@ -63,15 +63,17 @@ class DataGridWidget : public EditableWidget
void setSelectedValue(int value); void setSelectedValue(int value);
/** Set value at given position */ /** Set value at given position */
void setValue(int position, int value); void setValue(int position, int value);
/** Set value at given position, do not emit any signals */
void setValueInternal(int position, int value);
/** Set value at given position, manually specifying if the value changed */ /** Set value at given position, manually specifying if the value changed */
void setValue(int position, int value, bool changed); void setValue(int position, int value, bool changed, bool emitSignal = true);
int getSelectedAddr() const { return _addrList[_selectedItem]; } int getSelectedAddr() const { return _addrList[_selectedItem]; }
int getSelectedValue() const { return _valueList[_selectedItem]; } int getSelectedValue() const { return _valueList[_selectedItem]; }
void setRange(int lower, int upper); void setRange(int lower, int upper);
bool wantsFocus() override { return true; } bool wantsFocus() const override { return true; }
// Account for the extra width of embedded scrollbar // Account for the extra width of embedded scrollbar
int getWidth() const override; int getWidth() const override;

View File

@ -46,7 +46,7 @@ class EditableWidget : public Widget, public CommandSender
}; };
public: public:
EditableWidget(GuiObject *boss, const GUI::Font& font, EditableWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, const string& str = ""); int x, int y, int w, int h, const string& str = "");
virtual ~EditableWidget(); virtual ~EditableWidget();
@ -60,10 +60,10 @@ class EditableWidget : public Widget, public CommandSender
bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;
// We only want to focus this widget when we can edit its contents // We only want to focus this widget when we can edit its contents
virtual bool wantsFocus() { return _editable; } virtual bool wantsFocus() const { return _editable; }
// Set filter used to test whether a character can be inserted // Set filter used to test whether a character can be inserted
void setTextFilter(TextFilter& filter) { _filter = filter; } void setTextFilter(const TextFilter& filter) { _filter = filter; }
protected: protected:
virtual void startEditMode() { setFlags(WIDGET_WANTS_RAWDATA); } virtual void startEditMode() { setFlags(WIDGET_WANTS_RAWDATA); }

View File

@ -177,7 +177,7 @@ void InputTextDialog::setText(const string& str, int idx)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputTextDialog::setTextFilter(EditableWidget::TextFilter& f, int idx) void InputTextDialog::setTextFilter(const EditableWidget::TextFilter& f, int idx)
{ {
if((uInt32)idx < myInput.size()) if((uInt32)idx < myInput.size())
myInput[idx]->setTextFilter(f); myInput[idx]->setTextFilter(f);

View File

@ -46,7 +46,7 @@ class InputTextDialog : public Dialog, public CommandSender
const string& getResult(int idx = 0); const string& getResult(int idx = 0);
void setText(const string& str, int idx = 0); void setText(const string& str, int idx = 0);
void setTextFilter(EditableWidget::TextFilter& f, int idx = 0); void setTextFilter(const EditableWidget::TextFilter& f, int idx = 0);
void setEmitSignal(int cmd) { myCmd = cmd; } void setEmitSignal(int cmd) { myCmd = cmd; }
void setTitle(const string& title); void setTitle(const string& title);