console: simplify view modes.

This commit is contained in:
Aldo Cortesi 2015-03-29 15:27:17 +13:00
parent bdc2fda7ef
commit 8f0e4a9bdd

View File

@ -154,13 +154,13 @@ class FlowView(urwid.WidgetWrap):
) )
return (description, text_objects) return (description, text_objects)
def viewmode_get(self, override): def viewmode_get(self):
override = self.state.get_flow_setting(
self.flow,
(self.state.view_flow_mode, "prettyview")
)
return self.state.default_body_view if override is None else override return self.state.default_body_view if override is None else override
def override_get(self):
return self.state.get_flow_setting(self.flow,
(self.state.view_flow_mode, "prettyview"))
def conn_text_raw(self, conn): def conn_text_raw(self, conn):
""" """
Based on a request/response, conn, returns the elements for Based on a request/response, conn, returns the elements for
@ -171,8 +171,7 @@ class FlowView(urwid.WidgetWrap):
key = "header", key = "header",
val = "text" val = "text"
) )
override = self.override_get() viewmode = self.viewmode_get()
viewmode = self.viewmode_get(override)
msg, body = self.content_view(viewmode, conn) msg, body = self.content_view(viewmode, conn)
return headers, msg, body return headers, msg, body
@ -181,26 +180,22 @@ class FlowView(urwid.WidgetWrap):
Grabs what is returned by conn_text_raw and merges them all Grabs what is returned by conn_text_raw and merges them all
toghether, mainly used by conn_text toghether, mainly used by conn_text
""" """
override = self.override_get() viewmode = self.viewmode_get()
viewmode = self.viewmode_get(override)
cols = [urwid.Text( cols = [urwid.Text(
[ [
("heading", msg), ("heading", msg),
] ]
) )
] ]
cols.append(urwid.Text([
if override is not None: " ",
cols.append(urwid.Text([ ('heading', "["),
" ", ('heading_key', "m"),
('heading', "["), ('heading', (":%s]"%viewmode.name)),
('heading_key', "m"), ],
('heading', (":%s]"%viewmode.name)), align="right"
],
align="right"
)
) )
)
title = urwid.AttrWrap(urwid.Columns(cols), "heading") title = urwid.AttrWrap(urwid.Columns(cols), "heading")
headers.append(title) headers.append(title)