console: overlays shouldn't clear window titles

This commit is contained in:
Aldo Cortesi 2017-06-11 11:17:19 +12:00
parent 8427c2c4c7
commit f804495fd8
2 changed files with 11 additions and 7 deletions

View File

@ -5,6 +5,8 @@ class LayoutWidget:
All top-level layout widgets and all widgets that may be set in an All top-level layout widgets and all widgets that may be set in an
overlay must comply with this API. overlay must comply with this API.
""" """
# Title is only required for windows, not overlay components
title = None
keyctx = "" keyctx = ""
def key_responder(self): def key_responder(self):

View File

@ -135,24 +135,26 @@ class Window(urwid.Frame):
if c == "single": if c == "single":
self.pane = 0 self.pane = 0
def wrap(w, idx): def wrapped(idx):
if self.master.options.console_layout_headers and hasattr(w, "title"): window = self.stacks[idx].top_window()
return Header(w, w.title, self.pane == idx) widget = self.stacks[idx].top_widget()
if self.master.options.console_layout_headers and window.title:
return Header(widget, window.title, self.pane == idx)
else: else:
return w return widget
w = None w = None
if c == "single": if c == "single":
w = wrap(self.stacks[0].top_widget(), 0) w = wrapped(0)
elif c == "vertical": elif c == "vertical":
w = urwid.Pile( w = urwid.Pile(
[ [
wrap(s.top_widget(), i) for i, s in enumerate(self.stacks) wrapped(i) for i, s in enumerate(self.stacks)
] ]
) )
else: else:
w = urwid.Columns( w = urwid.Columns(
[wrap(s.top_widget(), i) for i, s in enumerate(self.stacks)], [wrapped(i) for i, s in enumerate(self.stacks)],
dividechars=1 dividechars=1
) )