diff --git a/Changes.txt b/Changes.txt index 0ab5ba6db..21c354d1e 100644 --- a/Changes.txt +++ b/Changes.txt @@ -19,6 +19,10 @@ etc can be used to toggle each event. Thanks to Buzbard of AtariAge 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 'cursor'. The new argument allows to set mouse cursor visibility separately for both UI and emulation modes. diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index 2cb23326f..a3e9beab9 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -70,11 +70,16 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n xpos = x + lwidth + myPCGrid->getWidth() + 10; myCpuGridDecValue = 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; myCpuGridBinValue = 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) _w = lwidth + myPCGrid->getWidth() + myPCLabel->getWidth() + 20; @@ -137,6 +142,8 @@ void CpuWidget::setOpsWidget(DataGridOpsWidget* w) { myPCGrid->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(); value = myCpuGrid->getSelectedValue(); break; + + case kCpuRegDecID: + addr = myCpuGridDecValue->getSelectedAddr(); + value = myCpuGridDecValue->getSelectedValue(); + break; + + case kCpuRegBinID: + addr = myCpuGridBinValue->getSelectedAddr(); + value = myCpuGridBinValue->getSelectedValue(); + break; } switch(addr) @@ -175,26 +192,30 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case kSPRegAddr: dbg.setSP(value); - myCpuGridDecValue->setValue(0, value); - myCpuGridBinValue->setValue(0, value); + myCpuGrid->setValueInternal(0, value); + myCpuGridDecValue->setValueInternal(0, value); + myCpuGridBinValue->setValueInternal(0, value); break; case kARegAddr: dbg.setA(value); - myCpuGridDecValue->setValue(1, value); - myCpuGridBinValue->setValue(1, value); + myCpuGrid->setValueInternal(1, value); + myCpuGridDecValue->setValueInternal(1, value); + myCpuGridBinValue->setValueInternal(1, value); break; case kXRegAddr: dbg.setX(value); - myCpuGridDecValue->setValue(2, value); - myCpuGridBinValue->setValue(2, value); + myCpuGrid->setValueInternal(2, value); + myCpuGridDecValue->setValueInternal(2, value); + myCpuGridBinValue->setValueInternal(2, value); break; case kYRegAddr: dbg.setY(value); - myCpuGridDecValue->setValue(3, value); - myCpuGridBinValue->setValue(3, value); + myCpuGrid->setValueInternal(3, value); + myCpuGridDecValue->setValueInternal(3, value); + myCpuGridBinValue->setValueInternal(3, value); break; } break; diff --git a/src/debugger/gui/CpuWidget.hxx b/src/debugger/gui/CpuWidget.hxx index 0c66eb4ca..23412828c 100644 --- a/src/debugger/gui/CpuWidget.hxx +++ b/src/debugger/gui/CpuWidget.hxx @@ -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 enum { kPCRegID, - kCpuRegID + kCpuRegID, + kCpuRegDecID, + kCpuRegBinID }; enum { diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 7aab03b0b..0c9f26fad 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -84,22 +84,31 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font, } // Add filtering - EditableWidget::TextFilter f = [&](char c) { - bool isBin = c == '0' || c == '1', - isDec = c >= '0' && c <= '9', - isHex = isDec || (c >= 'a' && c <= 'f'), - isOp = c == '$' || c == '#' || c == '\\'; - - if(BSPF_startsWithIgnoreCase(editString(), "$")) - return isHex; - else if(BSPF_startsWithIgnoreCase(editString(), "#")) - return isDec; - else if(BSPF_startsWithIgnoreCase(editString(), "\\")) - return isBin; - else - return isHex || isDec || isBin || isOp; - }; - setTextFilter(f); + EditableWidget::TextFilter f; + switch(base) + { + case Common::Base::F_16: + case Common::Base::F_16_1: + case Common::Base::F_16_2: + case Common::Base::F_16_4: + case Common::Base::F_16_8: + setTextFilter([](char c) { + return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'); + }); + break; + case Common::Base::F_10: + setTextFilter([](char c) { + return (c >= '0' && c <= '9'); + }); + 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()) { @@ -217,7 +233,8 @@ void DataGridWidget::setValue(int position, int value, bool changed) _changedList[position] = changed; _valueList[position] = value; - sendCommand(DataGridWidget::kItemDataChangedCmd, position, _id); + if(emitSignal) + sendCommand(DataGridWidget::kItemDataChangedCmd, position, _id); setDirty(); } diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index e1392b5a0..5a8821037 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -63,15 +63,17 @@ class DataGridWidget : public EditableWidget void setSelectedValue(int value); /** Set value at given position */ 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 */ - 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 getSelectedValue() const { return _valueList[_selectedItem]; } 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 int getWidth() const override; diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index 9c8487843..faf8de812 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -46,24 +46,24 @@ class EditableWidget : public Widget, public CommandSender }; 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 = ""); virtual ~EditableWidget(); virtual void setText(const string& str, bool changed = false); const string& getText() const { return _editString; } - bool isEditable() const { return _editable; } + bool isEditable() const { return _editable; } void setEditable(bool editable); bool handleText(char text) override; bool handleKeyDown(StellaKey key, StellaMod mod) override; // 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 - void setTextFilter(TextFilter& filter) { _filter = filter; } + void setTextFilter(const TextFilter& filter) { _filter = filter; } protected: virtual void startEditMode() { setFlags(WIDGET_WANTS_RAWDATA); } diff --git a/src/gui/InputTextDialog.cxx b/src/gui/InputTextDialog.cxx index f079b8866..6dc129ebd 100644 --- a/src/gui/InputTextDialog.cxx +++ b/src/gui/InputTextDialog.cxx @@ -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()) myInput[idx]->setTextFilter(f); diff --git a/src/gui/InputTextDialog.hxx b/src/gui/InputTextDialog.hxx index 1343ef40b..84f9b015f 100644 --- a/src/gui/InputTextDialog.hxx +++ b/src/gui/InputTextDialog.hxx @@ -46,7 +46,7 @@ class InputTextDialog : public Dialog, public CommandSender const string& getResult(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 setTitle(const string& title);