[pypy-svn] r12422 - pypy/dist/pypy/translator/tool/pygame

pedronis at codespeak.net pedronis at codespeak.net
Tue May 17 23:44:04 CEST 2005


Author: pedronis
Date: Tue May 17 23:44:04 2005
New Revision: 12422

Modified:
   pypy/dist/pypy/translator/tool/pygame/drawgraph.py
   pypy/dist/pypy/translator/tool/pygame/graphdisplay.py
Log:
less work by sethighlight



Modified: pypy/dist/pypy/translator/tool/pygame/drawgraph.py
==============================================================================
--- pypy/dist/pypy/translator/tool/pygame/drawgraph.py	(original)
+++ pypy/dist/pypy/translator/tool/pygame/drawgraph.py	Tue May 17 23:44:04 2005
@@ -207,7 +207,14 @@
         self.setoffset(0, 0)
         self.screen = screen
         self.textzones = []
-        self.highlightwords = {}
+        self.highlightwords = graphlayout.links
+        self.highlight_word = None
+
+    def wordcolor(self, word):
+        if word == self.highlight_word:
+            return ((255,255,80), (128,0,0))
+        else:
+            return ((128,0,0), None)
 
     def setscale(self, scale):
         scale = max(min(scale, self.SCALEMAX), self.SCALEMIN)
@@ -507,7 +514,7 @@
             if not word:
                 continue
             if word in renderer.highlightwords:
-                fg, bg = renderer.highlightwords[word]
+                fg, bg = renderer.wordcolor(word)
                 bg = bg or bgcolor
             else:
                 fg, bg = fgcolor, bgcolor

Modified: pypy/dist/pypy/translator/tool/pygame/graphdisplay.py
==============================================================================
--- pypy/dist/pypy/translator/tool/pygame/graphdisplay.py	(original)
+++ pypy/dist/pypy/translator/tool/pygame/graphdisplay.py	Tue May 17 23:44:04 2005
@@ -481,17 +481,10 @@
                     self.look_at_node(edge.tail)
 
     def sethighlight(self, word=None, obj=None):
-        # The initialization of self.viewer.highlightwords should probably be
-        # moved to setlayout()
-        self.viewer.highlightwords = {}
-        for name in self.layout.links:
-            self.viewer.highlightwords[name] = ((128,0,0), None)
-        if word:
-            self.viewer.highlightwords[word] = ((255,255,80), (128,0,0))
-
-        if word == self.highlight_obj and obj is self.highlight_obj:
+        if word == self.highlight_word and obj is self.highlight_obj:
             return # Nothing has changed, so there's no need to redraw
 
+        self.viewer.highlight_word = word
         if self.highlight_obj is not None:
             self.highlight_obj.sethighlight(False)
         if obj is not None:



More information about the Pypy-commit mailing list