commit c32b0e121be823fd186fae37c2819f873421317f
Author: patacca <patacca(a)autistici.org>
Date: Thu Mar 10 19:58:21 2016 +0100
Implemented right to left scrolling (ticket #15160)
---
nyx/panel/graph.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/nyx/panel/graph.py b/nyx/panel/graph.py
index ecf7c1e..7df5929 100644
--- a/nyx/panel/graph.py
+++ b/nyx/panel/graph.py
@@ -28,7 +28,7 @@ GraphStat = enum.Enum(('BANDWIDTH', 'bandwidth'), ('CONNECTIONS', 'connections')
Interval = enum.Enum(('EACH_SECOND', 'each second'), ('FIVE_SECONDS', '5 seconds'), ('THIRTY_SECONDS', '30 seconds'), ('MINUTELY', 'minutely'), ('FIFTEEN_MINUTE', '15 minute'), ('THIRTY_MINUTE', '30 minute'), ('HOURLY', 'hourly'), ('DAILY', 'daily'))
Bounds = enum.Enum(('GLOBAL_MAX', 'global_max'), ('LOCAL_MAX', 'local_max'), ('TIGHT', 'tight'))
-DrawAttributes = collections.namedtuple('DrawAttributes', ('stat', 'subgraph_height', 'subgraph_width', 'interval', 'bounds_type', 'accounting'))
+DrawAttributes = collections.namedtuple('DrawAttributes', ('stat', 'subgraph_height', 'subgraph_width', 'interval', 'bounds_type', 'accounting', 'right_to_left'))
INTERVAL_SECONDS = {
Interval.EACH_SECOND: 1,
@@ -78,6 +78,7 @@ CONFIG = conf.config_dict('nyx', {
'features.graph.interval': Interval.EACH_SECOND,
'features.graph.bound': Bounds.LOCAL_MAX,
'features.graph.max_width': 300, # we need some sort of max size so we know how much graph data to retain
+ 'features.graph.right_to_left': False,
'features.panels.show.connection': True,
'features.graph.bw.transferInBytes': False,
'features.graph.bw.accounting.show': True,
@@ -554,6 +555,7 @@ class GraphPanel(panel.Panel):
interval = self.update_interval,
bounds_type = self.bounds_type,
accounting = self.get_attr('_accounting_stats'),
+ right_to_left = CONFIG['features.graph.right_to_left'],
)
if self.is_title_visible():
@@ -586,7 +588,10 @@ class GraphPanel(panel.Panel):
self.addstr(1, x, data.header(attr.subgraph_width), curses.A_BOLD, color)
for x_offset, label in x_axis_labels.items():
- self.addstr(attr.subgraph_height, x + x_offset + axis_offset, label, color)
+ if attr.right_to_left:
+ self.addstr(attr.subgraph_height, x + attr.subgraph_width - x_offset, label, color)
+ else:
+ self.addstr(attr.subgraph_height, x + x_offset + axis_offset, label, color)
for y, label in y_axis_labels.items():
self.addstr(y, x, label, color)
@@ -596,7 +601,10 @@ class GraphPanel(panel.Panel):
column_height = int(min(attr.subgraph_height - 2, (attr.subgraph_height - 2) * column_count / (max(1, max_bound) - min_bound)))
for row in range(column_height):
- self.addstr(attr.subgraph_height - 1 - row, x + col + axis_offset + 1, ' ', curses.A_STANDOUT, color)
+ if attr.right_to_left:
+ self.addstr(attr.subgraph_height - 1 - row, x + attr.subgraph_width - col - 1, ' ', curses.A_STANDOUT, color)
+ else:
+ self.addstr(attr.subgraph_height - 1 - row, x + col + axis_offset + 1, ' ', curses.A_STANDOUT, color)
def _get_graph_bounds(self, attr, data, subgraph_columns):
"""