commit 702d8d329b8c305b0dc7207e550b6d89b98aab25
Author: Damian Johnson <atagar(a)torproject.org>
Date: Sat Jul 23 11:41:58 2016 -0700
Occasional stacktraces when starting up
When starting up we occasionally flashed a stacktrace such as...
File "/home/atagar/Desktop/nyx/nyx/panel/graph.py", line 596, in _update_accounting
if not nyx_controller.is_paused():
AttributeError 'NoneType' object has no attribute 'is_paused'
The issue is that our …
[View More]Controller's constructor creates panels which in turn
have threads that use the still-incomplete controller. As such breaking the
constructor into two parts. The first creates a blank instance and the second
adds the panels.
Don't really like this but fixes the issue. I'll revisit this when it's the
controller's turn to be rewitten.
---
nyx/controller.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/nyx/controller.py b/nyx/controller.py
index d02dbeb..8040e7e 100644
--- a/nyx/controller.py
+++ b/nyx/controller.py
@@ -98,9 +98,18 @@ class Controller(object):
top to bottom on the page.
"""
- self._header_panel = nyx.panel.header.HeaderPanel()
+ self._page_panels = []
+ self._header_panel = None
+ self.quit_signal = False
+ self._page = 0
+ self._paused = False
+ self._pause_time = -1
+ self._force_redraw = False
+ self._last_drawn = 0
- self._page_panels, first_page_panels = [], []
+ def init(self):
+ self._header_panel = nyx.panel.header.HeaderPanel()
+ first_page_panels = []
if CONFIG['features.panels.show.graph']:
first_page_panels.append(nyx.panel.graph.GraphPanel())
@@ -330,6 +339,7 @@ def start_nyx():
global NYX_CONTROLLER
NYX_CONTROLLER = Controller()
+ NYX_CONTROLLER.init()
control = get_controller()
if not CONFIG['features.acsSupport']:
[View Less]
commit 2b17ec2b8c287a1268790da54e5f5ba32281a315
Author: Damian Johnson <atagar(a)torproject.org>
Date: Sat Jul 23 09:36:13 2016 -0700
Tab completion always moved cursor to end
Curses' gather() method moves the cursor to the end of the message. As such
whenever we call gather() we need to revert the cursor position afterward.
Here's the repro steps for the issue...
* in the interpreter panel type 'hello'
* moved the cursor to the middle of the word
…
[View More] * press tab, the cursor will move to the end of the line
This was a bug copied from the arm 1.4.5 release (it was there too).
---
nyx/curses.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/nyx/curses.py b/nyx/curses.py
index 0cf9527..ecc2644 100644
--- a/nyx/curses.py
+++ b/nyx/curses.py
@@ -303,7 +303,7 @@ def str_input(x, y, initial_text = '', backlog = None, tab_completion = None):
def _handle_key(textbox, key):
"""
- Handles esc, home, end, right arrow, and resizing. We don't need ot handle
+ Handles esc, home, end, right arrow, and resizing. We don't need to handle
the left arrow key because curses has reasonable behavior for that one.
:param Textbox textbox: current textbox context
@@ -322,7 +322,7 @@ def _handle_key(textbox, key):
msg_length = len(textbox.gather())
textbox.win.move(y, x) # reverts cursor movement during gather call
- if key == curses.KEY_END and msg_length > 0 and x < msg_length - 1:
+ if key == curses.KEY_END and x < msg_length - 1:
textbox.win.move(y, msg_length - 1) # if we're in the content then move to the end
elif key == curses.KEY_RIGHT and x < msg_length - 1:
textbox.win.move(y, x + 1) # only move cursor if there's content after it
@@ -393,9 +393,12 @@ def _handle_tab_completion(next_handler, tab_completion, textbox, key):
"""
if key == 9:
+ y, x = textbox.win.getyx()
current_contents = textbox.gather().strip()
- matches = tab_completion(current_contents)
+ textbox.win.move(y, x) # reverts cursor movement during gather call
+
new_input = None
+ matches = tab_completion(current_contents)
if len(matches) == 1:
new_input = matches[0]
@@ -406,7 +409,6 @@ def _handle_tab_completion(next_handler, tab_completion, textbox, key):
new_input = common_prefix
if new_input:
- y, _ = textbox.win.getyx()
_, max_x = textbox.win.getmaxyx()
textbox.win.clear()
textbox.win.addstr(y, 0, new_input[:max_x - 1])
[View Less]