commit bafcb04a9843443290dbfe697f5467f441941806 Author: Damian Johnson atagar@torproject.org Date: Thu May 12 19:00:21 2011 -0700
Moving log panel clearing handler to the log panel --- src/cli/controller.py | 20 -------------------- src/cli/logPanel.py | 4 ++++ src/cli/popups.py | 6 ++++-- 3 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/src/cli/controller.py b/src/cli/controller.py index 20a4e7e..dc82d65 100644 --- a/src/cli/controller.py +++ b/src/cli/controller.py @@ -934,26 +934,6 @@ def drawTorMonitor(stdscr, startTime, loggedEvents, isBlindMode):
if currentHeight < maxHeight + 1: panels["graph"].setGraphHeight(panels["graph"].graphHeight + 1) - elif page == 0 and (key == ord('c') or key == ord('C')): - # provides prompt to confirm that arm should clear the log - panel.CURSES_LOCK.acquire() - try: - setPauseState(panels, isPaused, page, True) - - # provides prompt - panels["control"].setMsg("This will clear the log. Are you sure (c again to confirm)?", curses.A_BOLD) - panels["control"].redraw(True) - - curses.cbreak() - confirmationKey = stdscr.getch() - if confirmationKey in (ord('c'), ord('C')): panels["log"].clear() - - # reverts display settings - curses.halfdelay(REFRESH_RATE * 10) - panels["control"].setMsg(CTL_PAUSED if isPaused else CTL_HELP) - setPauseState(panels, isPaused, page) - finally: - panel.CURSES_LOCK.release() else: for pagePanel in getPanels(page + 1): isKeystrokeConsumed = pagePanel.handleKey(key) diff --git a/src/cli/logPanel.py b/src/cli/logPanel.py index d34b640..745cb57 100644 --- a/src/cli/logPanel.py +++ b/src/cli/logPanel.py @@ -767,6 +767,10 @@ class LogPanel(panel.Panel, threading.Thread): self.showDuplicates = not self.showDuplicates self.redraw(True) self.valsLock.release() + elif key == ord('c') or key == ord('C'): + msg = "This will clear the log. Are you sure (c again to confirm)?" + keyPress = popups.showMsg(msg, attr = curses.A_BOLD) + if keyPress in (ord('c'), ord('C')): self.clear() elif key == ord('f') or key == ord('F'): # Provides menu to pick regular expression filters or adding new ones: # for syntax see: http://docs.python.org/library/re.html#regular-expression-syntax diff --git a/src/cli/popups.py b/src/cli/popups.py index de4bad6..b957186 100644 --- a/src/cli/popups.py +++ b/src/cli/popups.py @@ -66,7 +66,7 @@ def inputPrompt(msg, initialValue = ""): def showMsg(msg, maxWait = -1, attr = curses.A_STANDOUT): """ Displays a single line message on the control line for a set time. Pressing - any key will end the message. + any key will end the message. This returns the key pressed.
Arguments: msg - message to be displayed to the user @@ -81,10 +81,12 @@ def showMsg(msg, maxWait = -1, attr = curses.A_STANDOUT):
if maxWait == -1: curses.cbreak() else: curses.halfdelay(maxWait * 10) - controller.getScreen().getch() + keyPress = controller.getScreen().getch() controlPanel.revertMsg() curses.halfdelay(controller.REFRESH_RATE * 10) panel.CURSES_LOCK.release() + + return keyPress
def showHelpPopup(): """
tor-commits@lists.torproject.org