Little improvements to the hex editor goto widget.

Sat, 23 Jan 2016 16:59:18 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 23 Jan 2016 16:59:18 +0100
changeset 4687
f1d921533cc5
parent 4686
5f8a5c568230
child 4688
fe866d2674fc

Little improvements to the hex editor goto widget.

APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric6.HexEdit.HexEditGotoWidget.html file | annotate | diff | comparison | revisions
HexEdit/HexEditGotoWidget.py file | annotate | diff | comparison | revisions
HexEdit/HexEditMainWindow.py file | annotate | diff | comparison | revisions
HexEdit/HexEditSearchReplaceWidget.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric6.api	Sat Jan 23 16:21:23 2016 +0100
+++ b/APIs/Python3/eric6.api	Sat Jan 23 16:59:18 2016 +0100
@@ -3548,6 +3548,7 @@
 eric6.HexEdit.HexEditGotoWidget.HexEditGotoWidget.on_formatCombo_currentIndexChanged?4(idx)
 eric6.HexEdit.HexEditGotoWidget.HexEditGotoWidget.on_gotoButton_clicked?4()
 eric6.HexEdit.HexEditGotoWidget.HexEditGotoWidget.on_offsetEdit_textChanged?4(offset)
+eric6.HexEdit.HexEditGotoWidget.HexEditGotoWidget.reset?4()
 eric6.HexEdit.HexEditGotoWidget.HexEditGotoWidget.show?4()
 eric6.HexEdit.HexEditGotoWidget.HexEditGotoWidget?1(editor, parent=None)
 eric6.HexEdit.HexEditMainWindow.HexEditMainWindow.closeEvent?4(evt)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Sat Jan 23 16:21:23 2016 +0100
+++ b/Documentation/Help/source.qhp	Sat Jan 23 16:59:18 2016 +0100
@@ -5774,6 +5774,7 @@
       <keyword name="HexEditGotoWidget.on_formatCombo_currentIndexChanged" id="HexEditGotoWidget.on_formatCombo_currentIndexChanged" ref="eric6.HexEdit.HexEditGotoWidget.html#HexEditGotoWidget.on_formatCombo_currentIndexChanged" />
       <keyword name="HexEditGotoWidget.on_gotoButton_clicked" id="HexEditGotoWidget.on_gotoButton_clicked" ref="eric6.HexEdit.HexEditGotoWidget.html#HexEditGotoWidget.on_gotoButton_clicked" />
       <keyword name="HexEditGotoWidget.on_offsetEdit_textChanged" id="HexEditGotoWidget.on_offsetEdit_textChanged" ref="eric6.HexEdit.HexEditGotoWidget.html#HexEditGotoWidget.on_offsetEdit_textChanged" />
+      <keyword name="HexEditGotoWidget.reset" id="HexEditGotoWidget.reset" ref="eric6.HexEdit.HexEditGotoWidget.html#HexEditGotoWidget.reset" />
       <keyword name="HexEditGotoWidget.show" id="HexEditGotoWidget.show" ref="eric6.HexEdit.HexEditGotoWidget.html#HexEditGotoWidget.show" />
       <keyword name="HexEditMainWindow" id="HexEditMainWindow" ref="eric6.HexEdit.HexEditMainWindow.html#HexEditMainWindow" />
       <keyword name="HexEditMainWindow (Constructor)" id="HexEditMainWindow (Constructor)" ref="eric6.HexEdit.HexEditMainWindow.html#HexEditMainWindow.__init__" />
--- a/Documentation/Source/eric6.HexEdit.HexEditGotoWidget.html	Sat Jan 23 16:21:23 2016 +0100
+++ b/Documentation/Source/eric6.HexEdit.HexEditGotoWidget.html	Sat Jan 23 16:59:18 2016 +0100
@@ -78,6 +78,9 @@
 <td><a href="#HexEditGotoWidget.on_offsetEdit_textChanged">on_offsetEdit_textChanged</a></td>
 <td>Private slot handling a change of the entered offset.</td>
 </tr><tr>
+<td><a href="#HexEditGotoWidget.reset">reset</a></td>
+<td>Public slot to reset the input widgets.</td>
+</tr><tr>
 <td><a href="#HexEditGotoWidget.show">show</a></td>
 <td>Public slot to show the widget.</td>
 </tr>
@@ -165,7 +168,12 @@
 <dd>
 entered offset
 </dd>
-</dl><a NAME="HexEditGotoWidget.show" ID="HexEditGotoWidget.show"></a>
+</dl><a NAME="HexEditGotoWidget.reset" ID="HexEditGotoWidget.reset"></a>
+<h4>HexEditGotoWidget.reset</h4>
+<b>reset</b>(<i></i>)
+<p>
+        Public slot to reset the input widgets.
+</p><a NAME="HexEditGotoWidget.show" ID="HexEditGotoWidget.show"></a>
 <h4>HexEditGotoWidget.show</h4>
 <b>show</b>(<i></i>)
 <p>
--- a/HexEdit/HexEditGotoWidget.py	Sat Jan 23 16:21:23 2016 +0100
+++ b/HexEdit/HexEditGotoWidget.py	Sat Jan 23 16:59:18 2016 +0100
@@ -16,6 +16,7 @@
 from .Ui_HexEditGotoWidget import Ui_HexEditGotoWidget
 
 import UI.PixmapCache
+import Globals
 
 
 class HexEditGotoWidget(QWidget, Ui_HexEditGotoWidget):
@@ -36,9 +37,9 @@
         
         self.__editor = editor
         
-        # keep this in sync with the logic in __getContent()
+        # keep this in sync with the logic in on_gotoButton_clicked()
         self.__formatAndValidators = {
-            "hex": (self.tr("Hex"), QRegExpValidator((QRegExp("[0-9a-f]*")))),
+            "hex": (self.tr("Hex"), QRegExpValidator((QRegExp("[0-9a-f:]*")))),
             "dec": (self.tr("Dec"), QRegExpValidator((QRegExp("[0-9]*")))),
         }
         formatOrder = ["hex", "dec"]
@@ -100,7 +101,9 @@
         """
         format = self.formatCombo.itemData(self.formatCombo.currentIndex())
         if format == "hex":
-            offset = int(self.offsetEdit.text(), 16)
+            offset = self.offsetEdit.text().replace(":", "")
+            # get rid of ':' address separators
+            offset = int(offset, 16)
         else:
             offset = int(self.offsetEdit.text(), 10)
         
@@ -115,8 +118,19 @@
         """
         Public slot to show the widget.
         """
+        self.offsetEdit.selectAll()
         self.offsetEdit.setFocus()
         super(HexEditGotoWidget, self).show()
+    
+    def reset(self):
+        """
+        Public slot to reset the input widgets.
+        """
+        self.offsetEdit.clear()
+        self.formatCombo.setCurrentIndex(0)
+        self.cursorCheckBox.setChecked(False)
+        self.backCheckBox.setChecked(False)
+        self.selectionCheckBox.setChecked(False)
 
     def keyPressEvent(self, event):
         """
@@ -141,9 +155,10 @@
         @return converted text
         @rtype str
         """
-        if oldFormat and newFormat:
+        if txt and oldFormat and newFormat and oldFormat != newFormat:
             # step 1: convert the text to an integer using the old format
             if oldFormat == "hex":
+                txt = txt.replace(":", "")  # get rid of ':' address separators
                 index = int(txt, 16)
             else:
                 index = int(txt, 10)
@@ -151,6 +166,7 @@
             # step 2: convert the integer to text using the new format
             if newFormat == "hex":
                 txt = "{0:x}".format(index)
+                txt = Globals.strGroup(txt, ":", 4)
             else:
                 txt = "{0:d}".format(index)
         
--- a/HexEdit/HexEditMainWindow.py	Sat Jan 23 16:21:23 2016 +0100
+++ b/HexEdit/HexEditMainWindow.py	Sat Jan 23 16:59:18 2016 +0100
@@ -987,6 +987,8 @@
         self.__setCurrentFile(fileName)
         
         self.__editor.setReadOnly(Preferences.getHexEditor("OpenReadOnly"))
+        
+        self.__gotoWidget.reset()
     
     def __openHexFile(self):
         """
--- a/HexEdit/HexEditSearchReplaceWidget.py	Sat Jan 23 16:21:23 2016 +0100
+++ b/HexEdit/HexEditSearchReplaceWidget.py	Sat Jan 23 16:59:18 2016 +0100
@@ -491,7 +491,7 @@
         @return converted text
         @rtype str
         """
-        if oldFormat and newFormat:
+        if txt and oldFormat and newFormat and oldFormat != newFormat:
             # step 1: convert the text to a byte array using the old format
             byteArray = self.__text2bytearray(txt, oldFormat)
             

eric ide

mercurial