From 5433918ba717004a50ca6d41dcd50b86d5f5b1ff Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 20 Jun 2005 21:01:37 +0000 Subject: [PATCH] Cleaned up the 'string to value' and 'value to string' methods. Added PC, SP, A, X, Y registers to the CpuWidget. These registers can now be changed and viewed while stepping/tracing. Still TODO is add a ToggleBitWidget to enable toggling of the individual bits in the Processor Flag register. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@534 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/Debugger.cxx | 35 +++++++++- stella/src/debugger/Debugger.hxx | 17 ++--- stella/src/debugger/DebuggerParser.cxx | 56 +--------------- stella/src/debugger/DebuggerParser.hxx | 11 ++-- stella/src/gui/AddrValueWidget.cxx | 35 ++++++---- stella/src/gui/AddrValueWidget.hxx | 18 ++---- stella/src/gui/CheatWidget.cxx | 11 ++-- stella/src/gui/CpuWidget.cxx | 89 +++++++++++++++++--------- stella/src/gui/CpuWidget.hxx | 3 +- stella/src/gui/DataGridWidget.cxx | 20 ++---- stella/src/gui/EditNumWidget.cxx | 11 ++-- 11 files changed, 153 insertions(+), 153 deletions(-) diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index 23f7311c1..b16cf7a4a 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.cxx,v 1.20 2005-06-20 18:32:11 stephena Exp $ +// $Id: Debugger.cxx,v 1.21 2005-06-20 21:01:37 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -130,6 +130,39 @@ const string Debugger::run(const string& command) return myParser->run(command); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const string Debugger::valueToString(int value, BaseFormat outputBase) +{ + char rendered[32]; + + if(outputBase == kBASE_DEFAULT) + outputBase = myParser->base(); + + switch(outputBase) + { + case kBASE_2: + if(value < 0x100) + sprintf(rendered, Debugger::to_bin_8(value)); + else + sprintf(rendered, Debugger::to_bin_16(value)); + break; + + case kBASE_10: + sprintf(rendered, "%d", value); + break; + + case kBASE_16: + default: + if(value < 0x100) + sprintf(rendered, Debugger::to_hex_8(value)); + else + sprintf(rendered, Debugger::to_hex_16(value)); + break; + } + + return string(rendered); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const string Debugger::state() { diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index 5c29c06ac..aee03174c 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.hxx,v 1.18 2005-06-20 18:32:11 stephena Exp $ +// $Id: Debugger.hxx,v 1.19 2005-06-20 21:01:37 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -50,7 +50,7 @@ enum { for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.18 2005-06-20 18:32:11 stephena Exp $ + @version $Id: Debugger.hxx,v 1.19 2005-06-20 21:01:37 stephena Exp $ */ class Debugger : public DialogContainer { @@ -124,16 +124,9 @@ class Debugger : public DialogContainer return to_bin(dec, 16, buf); } - bool parseArgument(string& arg, int *value, string& rendered, - BaseFormat outputBase) - { - return myParser->parseArgument(arg, value, rendered, outputBase); - } - - string parseValue(int value, BaseFormat outputBase) - { - return myParser->parseValue(value, outputBase); - } + int stringToValue(const string& stringval) + { return myParser->decipher_arg(stringval); } + const string valueToString(int value, BaseFormat outputBase); void toggleBreakPoint(int bp); bool breakPoint(int bp); diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 11f52b3b3..abc226d69 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.cxx,v 1.19 2005-06-20 18:32:11 stephena Exp $ +// $Id: DebuggerParser.cxx,v 1.20 2005-06-20 21:01:37 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -50,14 +50,11 @@ int DebuggerParser::conv_hex_digit(char d) { else return -1; } -void DebuggerParser::setBase(BaseFormat base) { - defaultBase = base; -} - // Evaluate expression. -int DebuggerParser::decipher_arg(string &arg) { +int DebuggerParser::decipher_arg(const string &str) { bool derefByte=false, derefWord=false, lobyte=false, hibyte=false, bin=false, dec=false; int result; + string arg = str; if(defaultBase == kBASE_2) { bin=true; dec=false; @@ -160,53 +157,6 @@ int DebuggerParser::decipher_arg(string &arg) { return result; } -// The GUI uses this: -bool DebuggerParser::parseArgument( - string& arg, int *value, string& rendered, BaseFormat outputBase) -{ - *value = decipher_arg(arg); - - if(*value == -1 || *value > 0xffff) { - rendered = "error"; - return false; - } - - rendered = parseValue(*value, outputBase); - return true; -} - -string DebuggerParser::parseValue(int value, BaseFormat outputBase) -{ - char rendered[32]; - - if(outputBase == kBASE_DEFAULT) - outputBase = defaultBase; - - switch(outputBase) - { - case kBASE_2: - if(value < 0x100) - sprintf(rendered, Debugger::to_bin_8(value)); - else - sprintf(rendered, Debugger::to_bin_16(value)); - break; - - case kBASE_10: - sprintf(rendered, "%d", value); - break; - - case kBASE_16: - default: - if(value < 0x100) - sprintf(rendered, Debugger::to_hex_8(value)); - else - sprintf(rendered, Debugger::to_hex_16(value)); - break; - } - - return string(rendered); -} - bool DebuggerParser::getArgs(const string& command) { int state = kIN_COMMAND; string curArg = ""; diff --git a/stella/src/debugger/DebuggerParser.hxx b/stella/src/debugger/DebuggerParser.hxx index cdcc78e91..5c52b57b1 100644 --- a/stella/src/debugger/DebuggerParser.hxx +++ b/stella/src/debugger/DebuggerParser.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.hxx,v 1.11 2005-06-20 18:32:11 stephena Exp $ +// $Id: DebuggerParser.hxx,v 1.12 2005-06-20 21:01:37 stephena Exp $ //============================================================================ #ifndef DEBUGGER_PARSER_HXX @@ -40,16 +40,15 @@ class DebuggerParser ~DebuggerParser(); string run(const string& command); - bool parseArgument(string& arg, int *value, string& rendered, - BaseFormat outputBase = kBASE_DEFAULT); - string parseValue(int value, BaseFormat outputBase); - void setBase(BaseFormat base); + int decipher_arg(const string &str); + + void setBase(BaseFormat base) { defaultBase = base; } + BaseFormat base() { return defaultBase; } private: bool getArgs(const string& command); int conv_hex_digit(char d); bool subStringMatch(const string& needle, const string& haystack); - int decipher_arg(string &arg); string disasm(); string listBreaks(); string eval(); diff --git a/stella/src/gui/AddrValueWidget.cxx b/stella/src/gui/AddrValueWidget.cxx index 4061f084b..4c7bb7ff0 100644 --- a/stella/src/gui/AddrValueWidget.cxx +++ b/stella/src/gui/AddrValueWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: AddrValueWidget.cxx,v 1.4 2005-06-16 00:55:59 stephena Exp $ +// $Id: AddrValueWidget.cxx,v 1.5 2005-06-20 21:01:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -30,9 +30,12 @@ #include "AddrValueWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AddrValueWidget::AddrValueWidget(GuiObject* boss, int x, int y, int w, int h) +AddrValueWidget::AddrValueWidget(GuiObject* boss, int x, int y, int w, int h, + int range, BaseFormat base) : EditableWidget(boss, x, y, w, h), - CommandSender(boss) + CommandSender(boss), + _range(range), + _base(base) { _w = w - kScrollBarWidth; @@ -40,7 +43,7 @@ AddrValueWidget::AddrValueWidget(GuiObject* boss, int x, int y, int w, int h) WIDGET_TAB_NAVIGATE; _type = kListWidget; // we're just a slightly modified listwidget _editMode = false; - _numberingMode = kHexNumbering; + _entriesPerPage = (_h - 2) / kLineHeight; _currentPos = 0; _selectedItem = -1; @@ -78,12 +81,13 @@ void AddrValueWidget::setList(const AddrList& alist, const ValueList& vlist) // An efficiency thing char temp[10]; + string str; for(unsigned int i = 0; i < (unsigned int)size; ++i) { sprintf(temp, "%.4x:", _addrList[i]); _addrStringList.push_back(temp); - sprintf(temp, "%3d", _valueList[i]); - _valueStringList.push_back(temp); + str = instance()->debugger().valueToString(_valueList[i], _base); + _valueStringList.push_back(str); } if (_currentPos >= size) @@ -410,16 +414,17 @@ void AddrValueWidget::endEditMode() _editMode = false; // Update the both the string representation and the real data - int value = atoi(_editString.c_str()); - if(_editString.length() == 0 || value < 0 || value > 255) + int value = instance()->debugger().stringToValue(_editString); + if(value < 0 || value > _range) { abortEditMode(); return; } - char temp[10]; - sprintf(temp, "%3d", value); - _valueStringList[_selectedItem] = temp; + // Correctly format the data for viewing + _editString = instance()->debugger().valueToString(value, _base); + + _valueStringList[_selectedItem] = _editString; _valueList[_selectedItem] = value; sendCommand(kAVItemDataChangedCmd, _selectedItem); @@ -436,10 +441,14 @@ void AddrValueWidget::abortEditMode() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool AddrValueWidget::tryInsertChar(char c, int pos) { - if (c >= '0' && c <= '9') + // Not sure how efficient this is, or should we even care? + c = tolower(c); + if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || + c == '%' || c == '#' || c == '$') { _editString.insert(pos, 1, c); return true; } - return false; + else + return false; } diff --git a/stella/src/gui/AddrValueWidget.hxx b/stella/src/gui/AddrValueWidget.hxx index d9859510c..7b0645288 100644 --- a/stella/src/gui/AddrValueWidget.hxx +++ b/stella/src/gui/AddrValueWidget.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: AddrValueWidget.hxx,v 1.3 2005-06-16 00:55:59 stephena Exp $ +// $Id: AddrValueWidget.hxx,v 1.4 2005-06-20 21:01:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -25,6 +25,7 @@ #include "GuiObject.hxx" #include "Widget.hxx" #include "Command.hxx" +#include "Debugger.hxx" #include "StringList.hxx" #include "EditableWidget.hxx" #include "Array.hxx" @@ -35,13 +36,6 @@ class ScrollBarWidget; typedef GUI::Array AddrList; typedef GUI::Array ValueList; -enum NumberingMode { - kHexNumbering, - kDecimalNumbering, - kBinaryNumbering -}; - -// Some special commands enum { kAVItemDoubleClickedCmd = 'AVdb', kAVItemActivatedCmd = 'AVac', @@ -53,7 +47,8 @@ enum { class AddrValueWidget : public EditableWidget, public CommandSender { public: - AddrValueWidget(GuiObject* boss, int x, int y, int w, int h); + AddrValueWidget(GuiObject* boss, int x, int y, int w, int h, + int range, BaseFormat base = kBASE_DEFAULT); virtual ~AddrValueWidget(); void setList(const StringList& list); @@ -64,7 +59,6 @@ class AddrValueWidget : public EditableWidget, public CommandSender bool isEditable() const { return _editable; } void setEditable(bool editable) { _editable = editable; } - void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; } void scrollTo(int item); virtual void handleMouseDown(int x, int y, int button, int clickCount); @@ -100,9 +94,11 @@ class AddrValueWidget : public EditableWidget, public CommandSender StringList _addrStringList; StringList _valueStringList; + int _range; + BaseFormat _base; + bool _editable; bool _editMode; - NumberingMode _numberingMode; int _currentPos; int _entriesPerPage; int _selectedItem; diff --git a/stella/src/gui/CheatWidget.cxx b/stella/src/gui/CheatWidget.cxx index a7e0ee885..a36788a1a 100644 --- a/stella/src/gui/CheatWidget.cxx +++ b/stella/src/gui/CheatWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CheatWidget.cxx,v 1.9 2005-06-17 17:34:01 stephena Exp $ +// $Id: CheatWidget.cxx,v 1.10 2005-06-20 21:01:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -88,8 +88,7 @@ CheatWidget::CheatWidget(GuiObject* boss, int x, int y, int w, int h) "Address Value", kTextAlignLeft); ypos += kLineHeight; - myResultsList = new AddrValueWidget(boss, xpos, ypos, 100, 75); - myResultsList->setNumberingMode(kHexNumbering); + myResultsList = new AddrValueWidget(boss, xpos, ypos, 100, 75, 0xff); myResultsList->setFont(instance()->consoleFont()); myResultsList->setTarget(this); @@ -147,7 +146,7 @@ void CheatWidget::doSearch() return; } - int searchVal = atoi(str.c_str()); + int searchVal = instance()->debugger().stringToValue(str); // Clear the search array of previous items mySearchArray.clear(); @@ -225,14 +224,14 @@ void CheatWidget::doCompare() negative = true; str.erase(0, 1); // remove the operator - searchVal = atoi(str.c_str()); + searchVal = instance()->debugger().stringToValue(str); if(negative) searchVal = -searchVal; comparitiveSearch = true; } else - searchVal = atoi(str.c_str()); + searchVal = instance()->debugger().stringToValue(str); AddrValueList tempList; diff --git a/stella/src/gui/CpuWidget.cxx b/stella/src/gui/CpuWidget.cxx index 6eca52395..5c6ee5ff5 100644 --- a/stella/src/gui/CpuWidget.cxx +++ b/stella/src/gui/CpuWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CpuWidget.cxx,v 1.1 2005-06-20 18:32:12 stephena Exp $ +// $Id: CpuWidget.cxx,v 1.2 2005-06-20 21:01:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -45,34 +45,30 @@ CpuWidget::CpuWidget(GuiObject* boss, int x, int y, int w, int h) CommandSender(boss) { int xpos = 10; - int ypos = 20; - int lwidth = 30; + int ypos = 10; + int lwidth = 20; const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; -/* - // Create a 16x8 grid (16 x 8 = 128 RAM bytes) with labels - for(int row = 0; row < 8; ++row) + // Create a 1x5 grid with labels for the CPU registers + myCpuGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 1, 5, 8, 0xffff); + myCpuGrid->setTarget(this); + myActiveWidget = myCpuGrid; + + string labels[5] = { "PC", "SP", "A", "X", "Y" }; + for(int row = 0; row < 5; ++row) { StaticTextWidget* t = new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2, lwidth, kLineHeight, - Debugger::to_hex_16(row*16 + kRamStart) + string(":"), + labels[row] + string(":"), kTextAlignLeft); t->setFont(instance()->consoleFont()); } - for(int col = 0; col < 16; ++col) - { - StaticTextWidget* t = new StaticTextWidget(boss, xpos + col*kColWidth + lwidth + 12, - ypos - kLineHeight, - lwidth, kLineHeight, - Debugger::to_hex_4(col), - kTextAlignLeft); - t->setFont(instance()->consoleFont()); - } -*/ - myCpuGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 1, 5, 8, - 0xffff); - myCpuGrid->setTarget(this); - myActiveWidget = myCpuGrid; + + // Create a read-only textbox containing the current PC label + ypos = 10; + myPCLabel = new StaticTextWidget(boss, xpos + lwidth + myCpuGrid->colWidth() + 10, + ypos, 100, kLineHeight, "FIXME!", + kTextAlignLeft); /* // Add some buttons for common actions @@ -128,12 +124,31 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data) switch(cmd) { case kDGItemDataChangedCmd: -cerr << "info changed\n"; -/* - addr = myRamGrid->getSelectedAddr() - kRamStart; - value = myRamGrid->getSelectedValue(); - instance()->debugger().writeRAM(addr, value); -*/ + addr = myCpuGrid->getSelectedAddr(); + value = myCpuGrid->getSelectedValue(); + + switch(addr) + { + case kPCRegAddr: + instance()->debugger().setPC(value); + break; + + case kSPRegAddr: + instance()->debugger().setS(value); + break; + + case kARegAddr: + instance()->debugger().setA(value); + break; + + case kXRegAddr: + instance()->debugger().setX(value); + break; + + case kYRegAddr: + instance()->debugger().setY(value); + break; + } break; /* @@ -194,11 +209,21 @@ void CpuWidget::fillGrid() AddrList alist; ValueList vlist; - for(unsigned int i = 0; i < kNumRegs; i++) - { - alist.push_back(i*16); - vlist.push_back(i*16);//instance()->debugger().readRAM(i)); - } + // We push the enumerated items as addresses, and deal with the real + // address in the callback (handleCommand) + alist.push_back(kPCRegAddr); + alist.push_back(kSPRegAddr); + alist.push_back(kARegAddr); + alist.push_back(kXRegAddr); + alist.push_back(kYRegAddr); + + // And now fill the values + Debugger& dbg = instance()->debugger(); + vlist.push_back(dbg.getPC()); + vlist.push_back(dbg.getS()); + vlist.push_back(dbg.getA()); + vlist.push_back(dbg.getX()); + vlist.push_back(dbg.getY()); myCpuGrid->setList(alist, vlist); } diff --git a/stella/src/gui/CpuWidget.hxx b/stella/src/gui/CpuWidget.hxx index 077947fc5..7473b909d 100644 --- a/stella/src/gui/CpuWidget.hxx +++ b/stella/src/gui/CpuWidget.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CpuWidget.hxx,v 1.1 2005-06-20 18:32:12 stephena Exp $ +// $Id: CpuWidget.hxx,v 1.2 2005-06-20 21:01:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -51,6 +51,7 @@ class CpuWidget : public Widget, public CommandSender DataGridWidget* myCpuGrid; // FIXME - add a ToggleBitWidget for processor status (ps) register + StaticTextWidget* myPCLabel; }; #endif diff --git a/stella/src/gui/DataGridWidget.cxx b/stella/src/gui/DataGridWidget.cxx index aaf62c1c6..878c7194b 100644 --- a/stella/src/gui/DataGridWidget.cxx +++ b/stella/src/gui/DataGridWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DataGridWidget.cxx,v 1.1 2005-06-20 18:32:12 stephena Exp $ +// $Id: DataGridWidget.cxx,v 1.2 2005-06-20 21:01:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -84,7 +84,7 @@ void DataGridWidget::setList(const AddrList& alist, const ValueList& vlist) string temp; for(unsigned int i = 0; i < (unsigned int)size; ++i) { - temp = instance()->debugger().parseValue(_valueList[i], _base); + temp = instance()->debugger().valueToString(_valueList[i], _base); _valueStringList.push_back(temp); } @@ -95,7 +95,7 @@ void DataGridWidget::setList(const AddrList& alist, const ValueList& vlist) void DataGridWidget::setSelectedValue(int value) { // Correctly format the data for viewing - _editString = instance()->debugger().parseValue(value, _base); + _editString = instance()->debugger().valueToString(value, _base); _valueStringList[_selectedItem] = _editString; _valueList[_selectedItem] = value; @@ -397,22 +397,14 @@ void DataGridWidget::endEditMode() _editMode = false; // Update the both the string representation and the real data - int value; string result; - bool converted = instance()->debugger().parseArgument(_editString, &value, - result, _base); - if(!converted || value < 0 || value > _range) + int value = instance()->debugger().stringToValue(_editString); + if(value < 0 || value > _range) { abortEditMode(); return; } - // Correctly format the data for viewing - _editString = result; - - _valueStringList[_selectedItem] = _editString; - _valueList[_selectedItem] = value; - - sendCommand(kDGItemDataChangedCmd, _selectedItem); + setSelectedValue(value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/EditNumWidget.cxx b/stella/src/gui/EditNumWidget.cxx index 2797e17e2..c1cd05ea2 100644 --- a/stella/src/gui/EditNumWidget.cxx +++ b/stella/src/gui/EditNumWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EditNumWidget.cxx,v 1.3 2005-06-17 17:34:01 stephena Exp $ +// $Id: EditNumWidget.cxx,v 1.4 2005-06-20 21:01:37 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -45,13 +45,16 @@ void EditNumWidget::setEditString(const string& str) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool EditNumWidget::tryInsertChar(char c, int pos) { - // Only allow numbers (FIXME - maybe allow A .. F for hex?) - if(isprint(c) && ((c >= '0' && c <= '9') || c == '+' || c == '-')) + // Not sure how efficient this is, or should we even care? + c = tolower(c); + if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || + c == '%' || c == '#' || c == '$' || c == '+' || c == '-') { _editString.insert(pos, 1, c); return true; } - return false; + else + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -