[or-cvs] r22991: {arm} added: interface option for growing and shrinking the graph' (in arm/trunk: . interface interface/graphing)

Damian Johnson atagar1 at gmail.com
Thu Aug 19 16:00:28 UTC 2010


Author: atagar
Date: 2010-08-19 16:00:27 +0000 (Thu, 19 Aug 2010)
New Revision: 22991

Modified:
   arm/trunk/TODO
   arm/trunk/interface/controller.py
   arm/trunk/interface/graphing/graphPanel.py
Log:
added: interface option for growing and shrinking the graph's size



Modified: arm/trunk/TODO
===================================================================
--- arm/trunk/TODO	2010-08-19 00:15:23 UTC (rev 22990)
+++ arm/trunk/TODO	2010-08-19 16:00:27 UTC (rev 22991)
@@ -144,7 +144,6 @@
       circuits at the exit
     * look at vidalia for ideas
     * need to solicit for ideas on what would be most helpful to clients
-  * interface option to change graph height
   * check if batch getInfo/getOption calls provide much performance benefit
   * layout (css) bugs with site
       Revise to use 'em' for measurements and somehow stretch image's y-margin?

Modified: arm/trunk/interface/controller.py
===================================================================
--- arm/trunk/interface/controller.py	2010-08-19 00:15:23 UTC (rev 22990)
+++ arm/trunk/interface/controller.py	2010-08-19 16:00:27 UTC (rev 22991)
@@ -622,16 +622,20 @@
         if page == 0:
           graphedStats = panels["graph"].currentDisplay
           if not graphedStats: graphedStats = "none"
-          popup.addfstr(1, 2, "<b>s</b>: graphed stats (<b>%s</b>)" % graphedStats)
-          popup.addfstr(1, 41, "<b>i</b>: graph update interval (<b>%s</b>)" % graphing.graphPanel.UPDATE_INTERVALS[panels["graph"].updateInterval][0])
-          popup.addfstr(2, 2, "<b>b</b>: graph bounds (<b>%s</b>)" % graphing.graphPanel.BOUND_LABELS[panels["graph"].bounds])
-          popup.addfstr(2, 41, "<b>d</b>: file descriptors")
-          popup.addfstr(3, 2, "<b>e</b>: change logged events")
+          popup.addfstr(1, 2, "<b>up arrow</b>: scroll log up a line")
+          popup.addfstr(1, 41, "<b>down arrow</b>: scroll log down a line")
+          popup.addfstr(2, 2, "<b>m</b>: increase graph size")
+          popup.addfstr(2, 41, "<b>n</b>: decrease graph size")
+          popup.addfstr(3, 2, "<b>s</b>: graphed stats (<b>%s</b>)" % graphedStats)
+          popup.addfstr(3, 41, "<b>i</b>: graph update interval (<b>%s</b>)" % graphing.graphPanel.UPDATE_INTERVALS[panels["graph"].updateInterval][0])
+          popup.addfstr(4, 2, "<b>b</b>: graph bounds (<b>%s</b>)" % graphing.graphPanel.BOUND_LABELS[panels["graph"].bounds])
+          popup.addfstr(4, 41, "<b>d</b>: file descriptors")
+          popup.addfstr(5, 2, "<b>e</b>: change logged events")
           
           regexLabel = "enabled" if panels["log"].regexFilter else "disabled"
-          popup.addfstr(3, 41, "<b>f</b>: log regex filter (<b>%s</b>)" % regexLabel)
+          popup.addfstr(5, 41, "<b>f</b>: log regex filter (<b>%s</b>)" % regexLabel)
           
-          pageOverrideKeys = (ord('s'), ord('i'), ord('d'), ord('e'), ord('r'), ord('f'))
+          pageOverrideKeys = (ord('m'), ord('n'), ord('s'), ord('i'), ord('d'), ord('e'), ord('r'), ord('f'))
         if page == 1:
           popup.addfstr(1, 2, "<b>up arrow</b>: scroll up a line")
           popup.addfstr(1, 41, "<b>down arrow</b>: scroll down a line")
@@ -890,6 +894,21 @@
       # reverts changes made for popup
       panels["graph"].showLabel = True
       setPauseState(panels, isPaused, page)
+    elif page == 0 and key in (ord('n'), ord('N'), ord('m'), ord('M')):
+      # Unfortunately modifier keys don't work with the up/down arrows (sending
+      # multiple keycodes. The only exception to this is shift + left/right,
+      # but for now just gonna use standard characters.
+      
+      if key in (ord('n'), ord('N')):
+        panels["graph"].setGraphHeight(panels["graph"].graphHeight - 1)
+      else:
+        # don't grow the graph if it's already consuming the whole display
+        # (plus an extra line for the graph/log gap)
+        maxHeight = panels["graph"].parent.getmaxyx()[0] - panels["graph"].top
+        currentHeight = panels["graph"].getHeight()
+        
+        if currentHeight < maxHeight + 1:
+          panels["graph"].setGraphHeight(panels["graph"].graphHeight + 1)
     elif key == 27 and panels["conn"].listingType == connPanel.LIST_HOSTNAME and panels["control"].resolvingCounter != -1:
       # canceling hostname resolution (esc on any page)
       panels["conn"].listingType = connPanel.LIST_IP

Modified: arm/trunk/interface/graphing/graphPanel.py
===================================================================
--- arm/trunk/interface/graphing/graphPanel.py	2010-08-19 00:15:23 UTC (rev 22990)
+++ arm/trunk/interface/graphing/graphPanel.py	2010-08-19 16:00:27 UTC (rev 22991)
@@ -29,6 +29,7 @@
 
 DEFAULT_CONTENT_HEIGHT = 4 # space needed for labeling above and below the graph
 DEFAULT_COLOR_PRIMARY, DEFAULT_COLOR_SECONDARY = "green", "cyan"
+MIN_GRAPH_HEIGHT = 1
 
 # enums for graph bounds:
 #   BOUNDS_GLOBAL_MAX - global maximum (highest value ever seen)
@@ -44,7 +45,7 @@
 
 def loadConfig(config):
   config.update(CONFIG)
-  CONFIG["features.graph.height"] = max(3, CONFIG["features.graph.height"])
+  CONFIG["features.graph.height"] = max(MIN_GRAPH_HEIGHT, CONFIG["features.graph.height"])
   CONFIG["features.graph.maxWidth"] = max(1, CONFIG["features.graph.maxWidth"])
   CONFIG["features.graph.interval"] = min(len(UPDATE_INTERVALS) - 1, max(0, CONFIG["features.graph.interval"]))
   CONFIG["features.graph.bound"] = min(2, max(0, CONFIG["features.graph.bound"]))
@@ -254,6 +255,17 @@
       return self.stats[self.currentDisplay].getContentHeight() + self.graphHeight
     else: return 0
   
+  def setGraphHeight(self, newGraphHeight):
+    """
+    Sets the preferred height used for the graph (restricted to the
+    MIN_GRAPH_HEIGHT minimum).
+    
+    Arguments:
+      newGraphHeight - new height for the graph
+    """
+    
+    self.graphHeight = max(MIN_GRAPH_HEIGHT, newGraphHeight)
+  
   def draw(self, subwindow, width, height):
     """ Redraws graph panel """
     



More information about the tor-commits mailing list