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

[tor-commits] [nyx/master] Fix log's date dividers



commit f974afccdde9216aedb649899da7932d11626fa4
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Aug 15 09:21:37 2017 -0700

    Fix log's date dividers
    
    Our date bounding box was placed in the completely wrong spot (inverted x/y
    coordinates), and the side border vanished in the top wasn't visible.
---
 nyx/curses.py     |  4 ++--
 nyx/panel/log.py  | 10 +++++-----
 test/panel/log.py | 48 +++++++++++++++++++++++++-----------------------
 3 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/nyx/curses.py b/nyx/curses.py
index 2cb1b42..3670629 100644
--- a/nyx/curses.py
+++ b/nyx/curses.py
@@ -905,14 +905,14 @@ class _Subwindow(object):
   def hline(self, x, y, length, *attr):
     if self.width > x and self.height > y:
       try:
-        self._curses_subwindow.hline(y, x, curses.ACS_HLINE | curses_attr(*attr), min(length, self.width - x))
+        self._curses_subwindow.hline(max(0, y), max(0, x), curses.ACS_HLINE | curses_attr(*attr), min(length, self.width - x))
       except:
         pass
 
   def vline(self, x, y, length, *attr):
     if self.width > x and self.height > y:
       try:
-        self._curses_subwindow.vline(y, x, curses.ACS_VLINE | curses_attr(*attr), min(length, self.height - y))
+        self._curses_subwindow.vline(max(0, y), max(0, x), curses.ACS_VLINE | curses_attr(*attr), min(length, self.height - y))
       except:
         pass
 
diff --git a/nyx/panel/log.py b/nyx/panel/log.py
index 2c93226..be3b8c0 100644
--- a/nyx/panel/log.py
+++ b/nyx/panel/log.py
@@ -276,7 +276,7 @@ class LogPanel(nyx.panel.DaemonPanel):
     if is_scrollbar_visible:
       subwindow.scrollbar(1, scroll, last_content_height)
 
-    x, y = 3 if is_scrollbar_visible else 1, 1 - scroll
+    x, y = 2 if is_scrollbar_visible else 0, 1 - scroll
     y = _draw_entries(subwindow, x, y, event_log, show_duplicates)
 
     # drawing the title after the content, so we'll clear content from the top line
@@ -378,16 +378,16 @@ def _draw_entries(subwindow, x, y, event_log, show_duplicates):
   for day in sorted(day_to_entries.keys(), reverse = True):
     if day == today:
       for entry in day_to_entries[day]:
-        y = _draw_entry(subwindow, x, y, subwindow.width, entry, show_duplicates)
+        y = _draw_entry(subwindow, x + 1, y, subwindow.width, entry, show_duplicates)
     else:
       original_y, y = y, y + 1
 
       for entry in day_to_entries[day]:
-        y = _draw_entry(subwindow, x, y, subwindow.width - 1, entry, show_duplicates)
+        y = _draw_entry(subwindow, x + 1, y, subwindow.width - 1, entry, show_duplicates)
 
-      subwindow.box(original_y, x - 1, subwindow.width - x + 1, y - original_y + 1, YELLOW, BOLD)
+      subwindow.box(x, original_y, subwindow.width - x + 2, y - original_y + 1, YELLOW, BOLD)
       time_label = time.strftime(' %B %d, %Y ', time.localtime(day_to_entries[day][0].timestamp))
-      subwindow.addstr(x + 1, original_y, time_label, YELLOW, BOLD)
+      subwindow.addstr(x + 2, original_y, time_label, YELLOW, BOLD)
 
       y += 1
 
diff --git a/test/panel/log.py b/test/panel/log.py
index 4610bff..95d7e9d 100644
--- a/test/panel/log.py
+++ b/test/panel/log.py
@@ -19,32 +19,34 @@ EXPECTED_WRAPPED_MSG = """\
 """.rstrip()
 
 EXPECTED_ENTRIES = """\
-16:41:37 [NYX_WARNING] Tor's geoip database is unavailable.
-16:41:37 [NYX_NOTICE] No nyxrc loaded, using defaults. You can customize nyx by
-  placing a configuration file at /home/atagar/.nyx/nyxrc (see the nyxrc.sample
-  for its options).
-16:41:37 [NOTICE] New control connection opened from 127.0.0.1.
-16:41:37 [NOTICE] Opening OR listener on 0.0.0.0:7000
-16:41:37 [NOTICE] Opening Control listener on 127.0.0.1:9051
-16:41:37 [NOTICE] Opening Socks listener on 127.0.0.1:9050
-16:41:37 [NOTICE] Tor v0.2.9.0-alpha-dev (git-44ea3dc3311564a9) running on Linux
-  with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4.
-16:41:37 [NOTICE] Tor 0.2.9.0-alpha-dev (git-44ea3dc3311564a9) opening log file.
+ 16:41:37 [NYX_WARNING] Tor's geoip database is unavailable.
+ 16:41:37 [NYX_NOTICE] No nyxrc loaded, using defaults. You can customize nyx by
+   placing a configuration file at /home/atagar/.nyx/nyxrc (see the nyxrc.sample
+   for its options).
+ 16:41:37 [NOTICE] New control connection opened from 127.0.0.1.
+ 16:41:37 [NOTICE] Opening OR listener on 0.0.0.0:7000
+ 16:41:37 [NOTICE] Opening Control listener on 127.0.0.1:9051
+ 16:41:37 [NOTICE] Opening Socks listener on 127.0.0.1:9050
+ 16:41:37 [NOTICE] Tor v0.2.9.0-alpha-dev (git-44ea3dc3311564a9) running on
+   Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4.
+ 16:41:37 [NOTICE] Tor 0.2.9.0-alpha-dev (git-44ea3dc3311564a9) opening log
+   file.
 """.rstrip()
 
 EXPECTED_ENTRIES_WITH_BORDER = """\
-|October 26, 2011                                                              |
-|6:41:37 [NYX_WARNING] Tor's geoip database is unavailable.                    |
-|6:41:37 [NYX_NOTICE] No nyxrc loaded, using defaults. You can customize nyx by|
-| placing a configuration file at /home/atagar/.nyx/nyxrc (see the nyxrc.sample|
-| for its options).                                                            |
-|6:41:37 [NOTICE] New control connection opened from 127.0.0.1.                |
-|6:41:37 [NOTICE] Opening OR listener on 0.0.0.0:7000                          |
-|6:41:37 [NOTICE] Opening Control listener on 127.0.0.1:9051                   |
-|6:41:37 [NOTICE] Opening Socks listener on 127.0.0.1:9050                     |
-|6:41:37 [NOTICE] Tor v0.2.9.0-alpha-dev (git-44ea3dc3311564a9) running on     |
-| Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4.           |
-|6:41:37 [NOTICE] Tor 0.2.9.0-alpha-dev (git-44ea3dc3311564a9) opening log     |
++-October 26, 2011-------------------------------------------------------------+
+|16:41:37 [NYX_WARNING] Tor's geoip database is unavailable.                   |
+|16:41:37 [NYX_NOTICE] No nyxrc loaded, using defaults. You can customize nyx  |
+|  by placing a configuration file at /home/atagar/.nyx/nyxrc (see the         |
+|  nyxrc.sample for its options).                                              |
+|16:41:37 [NOTICE] New control connection opened from 127.0.0.1.               |
+|16:41:37 [NOTICE] Opening OR listener on 0.0.0.0:7000                         |
+|16:41:37 [NOTICE] Opening Control listener on 127.0.0.1:9051                  |
+|16:41:37 [NOTICE] Opening Socks listener on 127.0.0.1:9050                    |
+|16:41:37 [NOTICE] Tor v0.2.9.0-alpha-dev (git-44ea3dc3311564a9) running on    |
+|  Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4.          |
+|16:41:37 [NOTICE] Tor 0.2.9.0-alpha-dev (git-44ea3dc3311564a9) opening log    |
+|  file.                                                                       |
 +------------------------------------------------------------------------------+
 """.rstrip()
 

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