Ticket #15160: 0002-Add-option-to-scroll-graphs-from-right-to-left.patch

File 0002-Add-option-to-scroll-graphs-from-right-to-left.patch, 3.0 KB (added by ifraser, 5 years ago)
  • armrc.sample

    From 15577ccc2f2ac44a0200118d1ce16822b86df617 Mon Sep 17 00:00:00 2001
    From: ifraser <ifraser@protonmail.ch>
    Date: Wed, 4 Mar 2015 21:29:22 +0000
    Subject: [PATCH 2/2] Add option to scroll graphs from right to left.
    
    ---
     armrc.sample                   |  1 +
     src/cli/graphing/graphPanel.py | 23 ++++++++++++++++++-----
     2 files changed, 19 insertions(+), 5 deletions(-)
    
    diff --git a/armrc.sample b/armrc.sample
    index c38bcfc..dd24d91 100644
    a b features.graph.interval 0 
    180180features.graph.bound 1
    181181features.graph.type 1
    182182features.graph.showIntermediateBounds true
     183features.graph.rightToLeft false
    183184
    184185# Parameters for graphing bandwidth stats
    185186# ---------------------------------------
  • src/cli/graphing/graphPanel.py

    diff --git a/src/cli/graphing/graphPanel.py b/src/cli/graphing/graphPanel.py
    index 76221ff..1c992ad 100644
    a b CONFIG = {"features.graph.height": 7, 
    4747          "features.graph.interval": 0,
    4848          "features.graph.bound": 1,
    4949          "features.graph.maxWidth": 150,
    50           "features.graph.showIntermediateBounds": True}
     50          "features.graph.showIntermediateBounds": True,
     51          "features.graph.rightToLeft": False}
    5152
    5253def loadConfig(config):
    5354  config.update(CONFIG, {
    5455    "features.graph.height": MIN_GRAPH_HEIGHT,
    5556    "features.graph.maxWidth": 1,
    5657    "features.graph.interval": (0, len(UPDATE_INTERVALS) - 1),
    57     "features.graph.bound": (0, 2)})
     58    "features.graph.bound": (0, 2),
     59    "features.graph.rightToLeft": False})
    5860
    5961class GraphStats(TorCtl.PostEventListener):
    6062  """
    class GraphPanel(panel.Panel): 
    443445      for col in range(graphCol):
    444446        colCount = int(param.primaryCounts[self.updateInterval][col + 1]) - primaryMinBound
    445447        colHeight = min(self.graphHeight, self.graphHeight * colCount / (max(1, primaryMaxBound) - primaryMinBound))
    446         for row in range(colHeight): self.addstr(self.graphHeight + 1 - row, col + 5, " ", curses.A_STANDOUT | primaryColor)
    447        
     448        for row in range(colHeight):
     449          if CONFIG["features.graph.rightToLeft"]:
     450            xValue = graphCol - col + 4
     451          else:
     452            xValue = col + 5
     453          self.addstr(self.graphHeight + 1 - row, xValue," ", curses.A_STANDOUT | primaryColor)
     454       
    448455        colCount = int(param.secondaryCounts[self.updateInterval][col + 1]) - secondaryMinBound
    449456        colHeight = min(self.graphHeight, self.graphHeight * colCount / (max(1, secondaryMaxBound) - secondaryMinBound))
    450         for row in range(colHeight): self.addstr(self.graphHeight + 1 - row, col + graphCol + 10, " ", curses.A_STANDOUT | secondaryColor)
     457        for row in range(colHeight):
     458          if CONFIG["features.graph.rightToLeft"]:
     459            xValue = (graphCol * 2) - col + 9
     460          else:
     461            xValue = col + graphCol + 10
     462          self.addstr(self.graphHeight + 1 - row, xValue, " ", curses.A_STANDOUT | secondaryColor)
     463       
    451464     
    452465      # bottom labeling of x-axis
    453466      intervalSec = 1 # seconds per labeling