aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-02-18 18:48:08 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-02-18 18:48:08 +1300
commit71ad7140be5a114bf80306bb8eb6a11d25316c16 (patch)
tree125d5047d2398d6fba8b9327e148cea27eaeec47
parent7aa79b89e89385a234741589bef730cc0085662a (diff)
downloadmitmproxy-71ad7140be5a114bf80306bb8eb6a11d25316c16.tar.gz
mitmproxy-71ad7140be5a114bf80306bb8eb6a11d25316c16.tar.bz2
mitmproxy-71ad7140be5a114bf80306bb8eb6a11d25316c16.zip
Consolidate palettes somewhat.
-rw-r--r--libmproxy/console/__init__.py34
-rw-r--r--libmproxy/console/connlist.py2
-rw-r--r--libmproxy/console/connview.py26
-rw-r--r--libmproxy/console/palettes.py16
-rw-r--r--libmproxy/proxy.py2
5 files changed, 33 insertions, 47 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py
index da110cdb..6fc37a47 100644
--- a/libmproxy/console/__init__.py
+++ b/libmproxy/console/__init__.py
@@ -122,31 +122,31 @@ class StatusBar(common.WWrap):
if self.master.client_playback:
r.append("[")
- r.append(("key", "cplayback"))
+ r.append(("heading_key", "cplayback"))
r.append(":%s to go]"%self.master.client_playback.count())
if self.master.server_playback:
r.append("[")
- r.append(("key", "splayback"))
+ r.append(("heading_key", "splayback"))
r.append(":%s to go]"%self.master.server_playback.count())
if self.master.state.intercept_txt:
r.append("[")
- r.append(("key", "i"))
+ r.append(("heading_key", "i"))
r.append(":%s]"%self.master.state.intercept_txt)
if self.master.state.limit_txt:
r.append("[")
- r.append(("key", "l"))
+ r.append(("heading_key", "l"))
r.append(":%s]"%self.master.state.limit_txt)
if self.master.stickycookie_txt:
r.append("[")
- r.append(("key", "t"))
+ r.append(("heading_key", "t"))
r.append(":%s]"%self.master.stickycookie_txt)
if self.master.stickyauth_txt:
r.append("[")
- r.append(("key", "u"))
+ r.append(("heading_key", "u"))
r.append(":%s]"%self.master.stickyauth_txt)
if self.master.server.config.reverse_proxy:
r.append("[")
- r.append(("key", "R"))
+ r.append(("heading_key", "R"))
r.append(":%s]"%utils.unparse_url(*self.master.server.config.reverse_proxy))
opts = []
@@ -175,7 +175,7 @@ class StatusBar(common.WWrap):
self.message("")
t = [
- ('statusbar_text', ("[%s]"%self.master.state.flow_count()).ljust(7)),
+ ('heading', ("[%s]"%self.master.state.flow_count()).ljust(7)),
]
t.extend(self.get_status())
@@ -192,7 +192,7 @@ class StatusBar(common.WWrap):
],
align="right"
),
- ]), "statusbar")
+ ]), "heading")
self.ib.set_w(status)
def update(self, text):
@@ -314,15 +314,15 @@ class Options(object):
class ConsoleMaster(flow.FlowMaster):
palette = []
footer_text_default = [
- ('statusbar_key', "?"), ":help ",
+ ('heading_key', "?"), ":help ",
]
footer_text_help = [
- ('statusbar_key', "q"), ":back",
+ ('heading_key', "q"), ":back",
]
footer_text_connview = [
- ('statusbar_key', "tab"), ":toggle view ",
- ('statusbar_key', "?"), ":help ",
- ('statusbar_key', "q"), ":back ",
+ ('heading_key', "tab"), ":toggle view ",
+ ('heading_key', "?"), ":help ",
+ ('heading_key', "q"), ":back ",
]
def __init__(self, server, options):
flow.FlowMaster.__init__(self, server, ConsoleState())
@@ -532,18 +532,16 @@ class ConsoleMaster(flow.FlowMaster):
def view_help(self):
h = help.HelpView(self, self.help_context, (self.statusbar, self.body, self.header))
-
self.statusbar = StatusBar(self, self.footer_text_help)
self.body = h
self.header = None
self.make_view()
def view_kveditor(self, title, value, callback, *args, **kwargs):
- self.statusbar = StatusBar(self, "foo")
self.body = kveditor.KVEditor(self, title, value, callback, *args, **kwargs)
self.header = None
-
self.help_context = kveditor.help_context
+ self.statusbar = StatusBar(self, self.footer_text_help)
self.make_view()
def view_connlist(self):
@@ -562,9 +560,9 @@ class ConsoleMaster(flow.FlowMaster):
self.help_context = connlist.help_context
def view_flow(self, flow):
- self.statusbar = StatusBar(self, self.footer_text_connview)
self.body = connview.ConnectionView(self, self.state, flow)
self.header = connview.ConnectionViewHeader(self, flow)
+ self.statusbar = StatusBar(self, self.footer_text_connview)
self.currentflow = flow
self.make_view()
diff --git a/libmproxy/console/connlist.py b/libmproxy/console/connlist.py
index 8fbe3609..957e797b 100644
--- a/libmproxy/console/connlist.py
+++ b/libmproxy/console/connlist.py
@@ -43,7 +43,7 @@ class BodyPile(urwid.Pile):
h = urwid.Text("Event log")
h = urwid.Padding(h, align="left", width=("relative", 100))
- self.inactive_header = urwid.AttrWrap(h, "inactive_heading")
+ self.inactive_header = urwid.AttrWrap(h, "heading_inactive")
self.active_header = urwid.AttrWrap(h, "heading")
urwid.Pile.__init__(
diff --git a/libmproxy/console/connview.py b/libmproxy/console/connview.py
index 7f0b0541..704fe3e7 100644
--- a/libmproxy/console/connview.py
+++ b/libmproxy/console/connview.py
@@ -233,11 +233,7 @@ class ConnectionView(common.WWrap):
txt.extend(body)
return urwid.ListBox(txt)
- def _tab(self, content, active):
- if active:
- attr = "heading"
- else:
- attr = "inactive"
+ def _tab(self, content, attr):
p = urwid.Text(content)
p = urwid.Padding(p, align="left", width=("relative", 100))
p = urwid.AttrWrap(p, attr)
@@ -247,24 +243,24 @@ class ConnectionView(common.WWrap):
parts = []
if self.flow.intercepting and not self.flow.request.acked:
- qt = "Request (intercepted)"
+ qt = "Request intercepted"
else:
qt = "Request"
if active == common.VIEW_FLOW_REQUEST:
- parts.append(self._tab(qt, True))
+ parts.append(self._tab(qt, "heading"))
else:
- parts.append(self._tab(qt, False))
+ parts.append(self._tab(qt, "heading_inactive"))
if self.flow.intercepting and self.flow.response and not self.flow.response.acked:
- st = "Response (intercepted)"
+ st = "Response intercepted"
else:
st = "Response"
if active == common.VIEW_FLOW_RESPONSE:
- parts.append(self._tab(st, True))
+ parts.append(self._tab(st, "heading"))
else:
- parts.append(self._tab(st, False))
+ parts.append(self._tab(st, "heading_inactive"))
- h = urwid.Columns(parts, dividechars=1)
+ h = urwid.Columns(parts)
f = urwid.Frame(
body,
header=h
@@ -284,17 +280,15 @@ class ConnectionView(common.WWrap):
def view_request(self):
self.state.view_flow_mode = common.VIEW_FLOW_REQUEST
- self.master.statusbar.update("Calculating view...")
body = self._conn_text(
self.flow.request,
self.state.view_body_mode
)
self.w = self.wrap_body(common.VIEW_FLOW_REQUEST, body)
- self.master.statusbar.update("")
+ self.master.statusbar.redraw()
def view_response(self):
self.state.view_flow_mode = common.VIEW_FLOW_RESPONSE
- self.master.statusbar.update("Calculating view...")
if self.flow.response:
body = self._conn_text(
self.flow.response,
@@ -314,7 +308,7 @@ class ConnectionView(common.WWrap):
]
)
self.w = self.wrap_body(common.VIEW_FLOW_RESPONSE, body)
- self.master.statusbar.update("")
+ self.master.statusbar.redraw()
def refresh_connection(self, c=None):
if c == self.flow:
diff --git a/libmproxy/console/palettes.py b/libmproxy/console/palettes.py
index cb620b90..1710786f 100644
--- a/libmproxy/console/palettes.py
+++ b/libmproxy/console/palettes.py
@@ -1,18 +1,17 @@
dark = [
- ('body', 'black', 'dark cyan', 'standout'),
+ ('body', 'black', 'dark cyan'),
('foot', 'light gray', 'default'),
('title', 'white,bold', 'default',),
('editline', 'white', 'default',),
- # Status bar
- ('statusbar', 'light gray', "dark blue"),
- ('statusbar_key', 'light cyan', "dark blue"),
- ('statusbar_text', 'light gray', "dark blue"),
- ('statusbar_highlight', 'white', "dark blue"),
+ # Status bar & heading
+ ('heading', 'light gray', "dark blue", None, "g85", "dark blue"),
+ ('heading_key', 'light cyan', "dark blue", None, "light cyan", "dark blue"),
+ ('heading_inactive', 'white', 'dark gray', None, "g58", "g11"),
# Help
- ('key', 'light cyan', 'default', 'underline'),
+ ('key', 'light cyan', 'default'),
('head', 'white,bold', 'default'),
('text', 'light gray', 'default'),
@@ -22,10 +21,7 @@ dark = [
('goodcode', 'light green', 'default'),
('error', 'light red', 'default'),
('header', 'dark cyan', 'default'),
- ('heading', 'white,bold', 'dark blue'),
- ('inactive_heading', 'white', 'dark gray'),
('highlight', 'white,bold', 'default'),
- ('inactive', 'dark gray', 'default'),
('intercept', 'brown', 'default', None, "#f60", "default"),
('replay', 'light green', 'default', None, "#0f0", "default"),
('ack', 'light red', 'default'),
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index 7012ea9b..43277a6c 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -503,5 +503,3 @@ def process_proxy_options(parser, options):
body_size_limit = body_size_limit,
reverse_proxy = rp
)
-
-