]> git.saurik.com Git - wxWidgets.git/commitdiff
PyCrust update
authorRobin Dunn <robin@alldunn.com>
Fri, 14 Jun 2002 23:28:54 +0000 (23:28 +0000)
committerRobin Dunn <robin@alldunn.com>
Fri, 14 Jun 2002 23:28:54 +0000 (23:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/wxPython/lib/PyCrust/filling.py
wxPython/wxPython/lib/PyCrust/introspect.py
wxPython/wxPython/lib/PyCrust/shell.py

index 15c627ce6072e8ac7242cfa4150e57b958d95d08..b2ce11ced3e2ff64c43d036804ea5e098fa9c54c 100644 (file)
@@ -104,14 +104,18 @@ class FillingTree(wxTreeCtrl):
             self.setText('')
             return
         object = self.GetPyData(item)
+        otype = type(object)
         text = ''
         text += self.getFullName(item)
-        text += '\n\nType: ' + str(type(object))
-        value = str(object)
-        if type(object) is types.StringType:
-            value = repr(value)
+        text += '\n\nType: ' + str(otype)
+        try:
+            value = str(object)
+        except:
+            value = ''
+        if otype is types.StringType or otype is types.UnicodeType:
+            value = repr(object)
         text += '\n\nValue: ' + value
-        if type(object) is types.InstanceType:
+        if otype is types.InstanceType:
             try:
                 text += '\n\nClass Definition:\n\n' + \
                         inspect.getsource(object.__class__)
index bcb4fa31a1e644ade4dfa8af15535d97a5e27d91..d568dc6c6fe3ff1a901a092acac1289d65626106 100644 (file)
@@ -74,8 +74,13 @@ def getAllAttributeNames(object):
     # !!! Do Not use hasattr() as a test anywhere in this function,
     # !!! because it is unreliable with remote objects - xmlrpc, soap, etc.
     # !!! They always return true for hasattr().
-    # !!! 
-    key = str(object)
+    # !!!
+    try:
+        # Yes, this can fail if object is an instance of a class with 
+        # __str__ (or __repr__) having a bug or raising an exception. :-(
+        key = str(object)
+    except:
+        key = 'anonymous'
     # Wake up sleepy objects - a hack for ZODB objects in "ghost" state.
     wakeupcall = dir(object)
     del wakeupcall
index 65d7c00aef3403d4706a77e4061853359e04df78..e5105389d8abcec5f674894f3dfb5075a8acb91d 100644 (file)
@@ -176,6 +176,8 @@ class Shell(wxStyledTextCtrl):
         # Assign handlers for keyboard events.
         EVT_KEY_DOWN(self, self.OnKeyDown)
         EVT_CHAR(self, self.OnChar)
+        # Assign handlers for wxSTC events.
+        EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
         # Configure various defaults and user preferences.
         self.config()
         # Display the introductory banner information.
@@ -291,6 +293,37 @@ class Shell(wxStyledTextCtrl):
         self.StyleSetSpec(wxSTC_P_COMMENTBLOCK, "fore:#7F7F7F")
         self.StyleSetSpec(wxSTC_P_STRINGEOL, "fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces)
 
+    def OnUpdateUI(self, evt):
+        """Check for matching braces."""
+        braceAtCaret = -1
+        braceOpposite = -1
+        charBefore = None
+        caretPos = self.GetCurrentPos()
+        if caretPos > 0:
+            charBefore = self.GetCharAt(caretPos - 1)
+            styleBefore = self.GetStyleAt(caretPos - 1)
+
+        # Check before.
+        if charBefore and chr(charBefore) in '[]{}()' \
+        and styleBefore == wxSTC_P_OPERATOR:
+            braceAtCaret = caretPos - 1
+
+        # Check after.
+        if braceAtCaret < 0:
+            charAfter = self.GetCharAt(caretPos)
+            styleAfter = self.GetStyleAt(caretPos)
+            if charAfter and chr(charAfter) in '[]{}()' \
+            and styleAfter == wxSTC_P_OPERATOR:
+                braceAtCaret = caretPos
+
+        if braceAtCaret >= 0:
+            braceOpposite = self.BraceMatch(braceAtCaret)
+
+        if braceAtCaret != -1  and braceOpposite == -1:
+            self.BraceBadLight(braceAtCaret)
+        else:
+            self.BraceHighlight(braceAtCaret, braceOpposite)
+
     def OnChar(self, event):
         """Keypress event handler.