commit
b1f923e148
|
@ -15,16 +15,30 @@ from mitmproxy.tools.console import grideditor
|
||||||
from mitmproxy.tools.console import eventlog
|
from mitmproxy.tools.console import eventlog
|
||||||
|
|
||||||
|
|
||||||
class Header(urwid.Frame):
|
class StackWidget(urwid.Frame):
|
||||||
def __init__(self, widget, title, focus):
|
def __init__(self, widget, title, focus):
|
||||||
super().__init__(
|
if title:
|
||||||
widget,
|
|
||||||
header = urwid.AttrWrap(
|
header = urwid.AttrWrap(
|
||||||
urwid.Text(title),
|
urwid.Text(title),
|
||||||
"heading" if focus else "heading_inactive"
|
"heading" if focus else "heading_inactive"
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
header = None
|
||||||
|
super().__init__(
|
||||||
|
widget,
|
||||||
|
header=header
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def keypress(self, size, key):
|
||||||
|
# Make sure that we don't propagate cursor events outside of the widget.
|
||||||
|
# Otherwise, in a horizontal layout, urwid's Pile would change the focused widget
|
||||||
|
# if we cannot scroll any further.
|
||||||
|
ret = super().keypress(size, key)
|
||||||
|
command = self._command_map[ret] # awkward as they don't implement a full dict api
|
||||||
|
if command and command.startswith("cursor"):
|
||||||
|
return None
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class WindowStack:
|
class WindowStack:
|
||||||
def __init__(self, master, base):
|
def __init__(self, master, base):
|
||||||
|
@ -142,12 +156,16 @@ class Window(urwid.Frame):
|
||||||
self.pane = 0
|
self.pane = 0
|
||||||
|
|
||||||
def wrapped(idx):
|
def wrapped(idx):
|
||||||
window = self.stacks[idx].top_window()
|
|
||||||
widget = self.stacks[idx].top_widget()
|
widget = self.stacks[idx].top_widget()
|
||||||
if self.master.options.console_layout_headers and window.title:
|
if self.master.options.console_layout_headers:
|
||||||
return Header(widget, window.title, self.pane == idx)
|
title = self.stacks[idx].top_window().title
|
||||||
else:
|
else:
|
||||||
return widget
|
title = None
|
||||||
|
return StackWidget(
|
||||||
|
widget,
|
||||||
|
title,
|
||||||
|
self.pane == idx
|
||||||
|
)
|
||||||
|
|
||||||
w = None
|
w = None
|
||||||
if c == "single":
|
if c == "single":
|
||||||
|
|
Loading…
Reference in New Issue