[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/master] Option for disabling ACS support



commit b96f129b9349ccfb53d5eeb9c54b4c063fce3804
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Nov 30 10:13:55 2011 -0800

    Option for disabling ACS support
    
    Some terminals have issues with alternate character support which is widely
    used by arm for borders. Unfortunatley this makes the interface look pretty
    crappy...
    http://www.atagar.com/arm/images/acs_display_failure.png
    
    Explaining the issue in the README and adding an option to manually remedy the
    most obvious broken bits. ACS is used throughout arm so it's gonna take a much
    more invasive change to allow the user to completely replace ACS usage (for
    instance, we can't use the curses box() function...).
    
    Thanks to Robert for explaining the issue!
---
 README              |   15 ++++++++++++++-
 armrc.sample        |    4 ++++
 src/util/panel.py   |   25 ++++++++++++++++++++-----
 src/util/uiTools.py |   14 ++++++++++----
 4 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/README b/README
index 87a6141..05f18cb 100644
--- a/README
+++ b/README
@@ -99,12 +99,25 @@ pid belongs to the open control port. If it's running as a different user (such
 as being in a chroot jail) then it's probably failing due to permission issues.
 Arm still runs, just no connection listing or ps stats.
 
-> The bandwidth graph showing up
+> The bandwidth graph isn't showing up
 
 Some terminals, most notably screen sessions on Gentoo, appear to have a bug
 where highlighted spaces aren't rendered. A reported workaround is to set:
   TERM="rxvt-unicode"
 
+> There's borders like 'mwqqqqqqqqj'
+
+If you're getting something that looks like...
+http://www.atagar.com/arm/images/acs_display_failure.png
+
+then you're encountering a bug between ncurses and your terminal where
+alternate character support (ACS) is unavailable. For more information see...
+http://invisible-island.net/ncurses/ncurses.faq.html#no_line_drawing
+
+Unfortunately there doesn't seem to be a way for arm to automatically detect
+and correct this. To work around some of the issues set this in your armrc...
+features.acsSupport false
+
 > When I press enter in the connection panel to get details some of the
 information is either missing or outdated. Why is this?
 
diff --git a/armrc.sample b/armrc.sample
index 7daba30..7a611c0 100644
--- a/armrc.sample
+++ b/armrc.sample
@@ -28,6 +28,10 @@ queries.useProc true
 # Renders the interface with color if set and the terminal supports it
 features.colorInterface true
 
+# Uses ACS (alternate character support) to display nice borders. This may not
+# work on all terminals.
+features.acsSupport true
+
 # Replaces all colored content (ie, anything that isn't white) with this
 # color. Valid options are:
 # none, red, green, yellow, blue, cyan, magenta, black, white
diff --git a/src/util/panel.py b/src/util/panel.py
index 50ae2c0..c0c13d8 100644
--- a/src/util/panel.py
+++ b/src/util/panel.py
@@ -23,7 +23,8 @@ FORMAT_TAGS = {"<b>": (_noOp, curses.A_BOLD),
                "<h>": (_noOp, curses.A_STANDOUT)}
 for colorLabel in uiTools.COLOR_LIST: FORMAT_TAGS["<%s>" % colorLabel] = (uiTools.getColor, colorLabel)
 
-CONFIG = {"log.panelRecreated": log.DEBUG}
+CONFIG = {"features.acsSupport": True,
+          "log.panelRecreated": log.DEBUG}
 
 # prevents curses redraws if set
 HALT_ACTIVITY = False
@@ -425,7 +426,11 @@ class Panel():
     if self.win and self.maxX > x and self.maxY > y:
       try:
         drawLength = min(length, self.maxX - x)
-        self.win.hline(y, x, curses.ACS_HLINE | attr, drawLength)
+        
+        if CONFIG["features.acsSupport"]:
+          self.win.hline(y, x, curses.ACS_HLINE | attr, drawLength)
+        else:
+          self.addstr(y, x, "-" * drawLength, attr)
       except:
         # in edge cases drawing could cause a _curses.error
         pass
@@ -445,7 +450,12 @@ class Panel():
     if self.win and self.maxX > x and self.maxY > y:
       try:
         drawLength = min(length, self.maxY - y)
-        self.win.vline(y, x, curses.ACS_VLINE | attr, drawLength)
+        
+        if CONFIG["features.acsSupport"]:
+          self.win.vline(y, x, curses.ACS_VLINE | attr, drawLength)
+        else:
+          for i in range(drawLength):
+            self.addch(y + i, x, "|", attr)
       except:
         # in edge cases drawing could cause a _curses.error
         pass
@@ -686,8 +696,13 @@ class Panel():
     
     # draws box around the scroll bar
     self.vline(drawTop, drawLeft + 1, drawBottom - 1)
-    self.addch(drawBottom, drawLeft + 1, curses.ACS_LRCORNER)
-    self.addch(drawBottom, drawLeft, curses.ACS_HLINE)
+    
+    if CONFIG["features.acsSupport"]:
+      self.addch(drawBottom, drawLeft + 1, curses.ACS_LRCORNER)
+      self.addch(drawBottom, drawLeft, curses.ACS_HLINE)
+    else:
+      self.addch(drawBottom, drawLeft + 1, "+")
+      self.addch(drawBottom, drawLeft, "-")
   
   def _resetSubwindow(self):
     """
diff --git a/src/util/uiTools.py b/src/util/uiTools.py
index 01d2ad1..51f5fee 100644
--- a/src/util/uiTools.py
+++ b/src/util/uiTools.py
@@ -39,6 +39,7 @@ TIME_UNITS = [(86400.0, "d", " day"), (3600.0, "h", " hour"),
 Ending = enum.Enum("ELLIPSE", "HYPHEN")
 SCROLL_KEYS = (curses.KEY_UP, curses.KEY_DOWN, curses.KEY_PPAGE, curses.KEY_NPAGE, curses.KEY_HOME, curses.KEY_END)
 CONFIG = {"features.colorInterface": True,
+          "features.acsSupport": True,
           "features.printUnicode": True,
           "log.cursesColorSupport": log.INFO,
           "log.configEntryTypeError": log.NOTICE}
@@ -337,10 +338,15 @@ def drawBox(panel, top, left, width, height, attr=curses.A_NORMAL):
   panel.vline(top + 1, left + width - 1, height - 2, attr)
   
   # draws the corners
-  panel.addch(top, left, curses.ACS_ULCORNER, attr)
-  panel.addch(top, left + width - 1, curses.ACS_URCORNER, attr)
-  panel.addch(top + height - 1, left, curses.ACS_LLCORNER, attr)
-  panel.addch(top + height - 1, left + width - 1, curses.ACS_LRCORNER, attr)
+  if CONFIG["features.acsSupport"]:
+    panel.addch(top, left, curses.ACS_ULCORNER, attr)
+    panel.addch(top, left + width - 1, curses.ACS_URCORNER, attr)
+    panel.addch(top + height - 1, left, curses.ACS_LLCORNER, attr)
+  else:
+    panel.addch(top, left, "+", attr)
+    panel.addch(top, left + width - 1, "+", attr)
+    panel.addch(top + height - 1, left, "+", attr)
+    panel.addch(top + height - 1, left + width - 1, "+", attr)
 
 def isSelectionKey(key):
   """

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits