Make "C" clear eventlog when it has focus.

This commit is contained in:
Aldo Cortesi 2011-08-03 17:41:13 +12:00
parent e337682d8e
commit 028d5bacc5
1 changed files with 17 additions and 2 deletions

View File

@ -247,6 +247,18 @@ class ConnectionListBox(urwid.ListBox):
return urwid.ListBox.keypress(self, size, key) return urwid.ListBox.keypress(self, size, key)
class EventListBox(urwid.ListBox):
def __init__(self, master):
self.master = master
urwid.ListBox.__init__(self, master.eventlist)
def keypress(self, size, key):
if key == "C":
self.master.clear_events()
key = None
return urwid.ListBox.keypress(self, size, key)
class ConnectionViewHeader(WWrap): class ConnectionViewHeader(WWrap):
def __init__(self, master, f): def __init__(self, master, f):
self.master, self.flow = master, f self.master, self.flow = master, f
@ -885,7 +897,7 @@ class BodyPile(urwid.Pile):
self, self,
[ [
ConnectionListBox(master), ConnectionListBox(master),
urwid.Frame(urwid.ListBox(master.eventlist), header = self.inactive_header) urwid.Frame(EventListBox(master), header = self.inactive_header)
] ]
) )
self.master = master self.master = master
@ -1424,7 +1436,7 @@ class ConsoleMaster(flow.FlowMaster):
text.extend([("head", "\n\nConnection list keys:\n")]) text.extend([("head", "\n\nConnection list keys:\n")])
keys = [ keys = [
("C", "clear connection list"), ("C", "clear connection list or eventlog"),
("d", "delete connection from view"), ("d", "delete connection from view"),
("v", "toggle eventlog"), ("v", "toggle eventlog"),
("X", "kill and delete connection, even if it's mid-intercept"), ("X", "kill and delete connection, even if it's mid-intercept"),
@ -1789,6 +1801,9 @@ class ConsoleMaster(flow.FlowMaster):
self.sync_list_view() self.sync_list_view()
self.refresh_connection(f) self.refresh_connection(f)
def clear_events(self):
self.eventlist[:] = []
def add_event(self, e, level="info"): def add_event(self, e, level="info"):
if level == "info": if level == "info":
e = urwid.Text(e) e = urwid.Text(e)