Give a visual indication that the eventlog has focus.

This commit is contained in:
Aldo Cortesi 2011-08-02 11:02:23 +12:00
parent 759f5d71a6
commit 73a7d893e3

View File

@ -859,8 +859,20 @@ class Options(object):
class BodyPile(urwid.Pile): class BodyPile(urwid.Pile):
def __init__(self, master, lst): def __init__(self, master):
urwid.Pile.__init__(self, lst) h = urwid.Text("Event log")
h = urwid.Padding(h, align="left", width=("relative", 100))
self.inactive_header = urwid.AttrWrap(h, "inactive_heading")
self.active_header = urwid.AttrWrap(h, "heading")
urwid.Pile.__init__(
self,
[
urwid.ListBox(master.conn_list_view),
urwid.Frame(urwid.ListBox(master.eventlist), header = self.inactive_header)
]
)
self.master = master self.master = master
self.focus = 0 self.focus = 0
@ -868,6 +880,10 @@ class BodyPile(urwid.Pile):
if key == "tab": if key == "tab":
self.focus = (self.focus + 1)%len(self.widget_list) self.focus = (self.focus + 1)%len(self.widget_list)
self.set_focus(self.focus) self.set_focus(self.focus)
if self.focus == 1:
self.widget_list[1].header = self.active_header
else:
self.widget_list[1].header = self.inactive_header
key = None key = None
elif key == "v": elif key == "v":
self.master.toggle_eventlog() self.master.toggle_eventlog()
@ -1170,6 +1186,7 @@ class ConsoleMaster(flow.FlowMaster):
('error', 'light red', 'default'), ('error', 'light red', 'default'),
('header', 'dark cyan', 'default'), ('header', 'dark cyan', 'default'),
('heading', 'white,bold', 'dark blue'), ('heading', 'white,bold', 'dark blue'),
('inactive_heading', 'white', 'dark gray'),
('highlight', 'white,bold', 'default'), ('highlight', 'white,bold', 'default'),
('inactive', 'dark gray', 'default'), ('inactive', 'dark gray', 'default'),
('ack', 'light red', 'default'), ('ack', 'light red', 'default'),
@ -1245,19 +1262,7 @@ class ConsoleMaster(flow.FlowMaster):
self.ui.clear() self.ui.clear()
self.focus_current() self.focus_current()
if self.eventlog: if self.eventlog:
h = urwid.Text("Event log") self.body = BodyPile(self)
h = urwid.Padding(h, align="left", width=("relative", 100))
h = urwid.AttrWrap(h, "heading")
self.body = BodyPile(
self,
[
urwid.ListBox(self.conn_list_view),
urwid.Frame(
urwid.ListBox(self.eventlist),
header = h
)
]
)
else: else:
self.body = urwid.ListBox(self.conn_list_view) self.body = urwid.ListBox(self.conn_list_view)
self.statusbar = StatusBar(self, self.footer_text_default) self.statusbar = StatusBar(self, self.footer_text_default)