[tor-commits] [nyx/master] Move ACS support into curses.start()

atagar at torproject.org atagar at torproject.org
Fri Sep 16 06:18:14 UTC 2016


commit 9264b37174c80ee2c8bd3bd412ea290cef45e91b
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Sep 15 20:45:34 2016 -0700

    Move ACS support into curses.start()
    
    Our start method accepts flags for other curses features. ACS would be a
    perfect fit, and lets us make one of our functions private.
---
 nyx/controller.py | 4 ----
 nyx/curses.py     | 9 ++++++---
 nyx/starter.py    | 2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/nyx/controller.py b/nyx/controller.py
index d304527..76fa549 100644
--- a/nyx/controller.py
+++ b/nyx/controller.py
@@ -28,7 +28,6 @@ def conf_handler(key, value):
 
 
 CONFIG = conf.config_dict('nyx', {
-  'features.acsSupport': True,
   'features.redrawRate': 5,
   'features.confirmQuit': True,
   'start_time': 0,
@@ -40,9 +39,6 @@ def start_nyx():
   Main draw loop context.
   """
 
-  if not CONFIG['features.acsSupport']:
-    nyx.curses.disable_acs()
-
   # provides notice about any unused config keys
 
   for key in sorted(conf.get_config('nyx').unused_keys()):
diff --git a/nyx/curses.py b/nyx/curses.py
index d6176f9..1717067 100644
--- a/nyx/curses.py
+++ b/nyx/curses.py
@@ -25,7 +25,6 @@ if we want Windows support in the future too.
   get_color_override - provides color we override requests with
   set_color_override - sets color we override requests with
 
-  disable_acs - renders replacements for ACS characters
   is_wide_characters_supported - checks if curses supports wide character
 
   draw - renders subwindow that can be drawn into
@@ -181,11 +180,12 @@ CONFIG = stem.util.conf.config_dict('nyx', {
 }, conf_handler)
 
 
-def start(function, transparent_background = False, cursor = True):
+def start(function, acs_support = True, transparent_background = False, cursor = True):
   """
   Starts a curses interface, delegating to the given function.
 
   :param funtion: function to invoke when curses starts
+  :param bool acs_support: uses wide characters for pipes
   :param bool transparent_background: allows background transparency
   :param bool cursor: makes cursor visible
   """
@@ -195,6 +195,9 @@ def start(function, transparent_background = False, cursor = True):
 
     CURSES_SCREEN = stdscr
 
+    if not acs_support:
+      _disable_acs()
+
     if transparent_background:
       try:
         curses.use_default_colors()
@@ -608,7 +611,7 @@ def _color_attr():
   return COLOR_ATTR
 
 
-def disable_acs():
+def _disable_acs():
   """
   Replaces ACS characters used for showing borders. This can be preferable if
   curses is `unable to render them
diff --git a/nyx/starter.py b/nyx/starter.py
index 0126c3c..7ff37b2 100644
--- a/nyx/starter.py
+++ b/nyx/starter.py
@@ -85,7 +85,7 @@ def main(config):
   _set_process_name()
 
   try:
-    nyx.curses.start(nyx.controller.start_nyx, transparent_background = True, cursor = False)
+    nyx.curses.start(nyx.controller.start_nyx, acs_support = config.get('features.acsSupport', True), transparent_background = True, cursor = False)
   except UnboundLocalError as exc:
     if os.environ['TERM'] != 'xterm':
       print(msg('setup.unknown_term', term = os.environ['TERM']))





More information about the tor-commits mailing list