aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy/console')
-rw-r--r--libmproxy/console/__init__.py25
-rw-r--r--libmproxy/console/flowlist.py3
-rw-r--r--libmproxy/console/flowview.py4
-rw-r--r--libmproxy/console/grideditor.py22
-rw-r--r--libmproxy/console/help.py7
5 files changed, 34 insertions, 27 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py
index 73912129..3ba555f5 100644
--- a/libmproxy/console/__init__.py
+++ b/libmproxy/console/__init__.py
@@ -16,7 +16,7 @@
import mailcap, mimetypes, tempfile, os, subprocess, glob, time, shlex
import os.path, sys
import urwid
-from .. import controller, utils, flow, version
+from .. import controller, utils, flow
import flowlist, flowview, help, common, grideditor, palettes
EVENTLOG_SIZE = 500
@@ -320,17 +320,6 @@ class Options(object):
class ConsoleMaster(flow.FlowMaster):
palette = []
- footer_text_default = [
- ('heading_key', "?"), ":help ",
- ]
- footer_text_help = [
- ("heading", 'mitmproxy v%s '%version.VERSION),
- ('heading_key', "q"), ":back ",
- ]
- footer_text_flowview = [
- ('heading_key', "?"), ":help ",
- ('heading_key', "q"), ":back ",
- ]
def __init__(self, server, options):
flow.FlowMaster.__init__(self, server, ConsoleState())
self.looptime = 0
@@ -542,7 +531,7 @@ 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.statusbar = StatusBar(self, help.footer)
self.body = h
self.header = None
self.make_view()
@@ -551,7 +540,7 @@ class ConsoleMaster(flow.FlowMaster):
self.body = ge
self.header = None
self.help_context = grideditor.help_context
- self.statusbar = StatusBar(self, self.footer_text_help)
+ self.statusbar = StatusBar(self, grideditor.footer)
self.make_view()
def view_flowlist(self):
@@ -562,7 +551,7 @@ class ConsoleMaster(flow.FlowMaster):
self.body = flowlist.BodyPile(self)
else:
self.body = flowlist.ConnectionListBox(self)
- self.statusbar = StatusBar(self, self.footer_text_default)
+ self.statusbar = StatusBar(self, flowlist.footer)
self.header = None
self.currentflow = None
@@ -572,7 +561,7 @@ class ConsoleMaster(flow.FlowMaster):
def view_flow(self, flow):
self.body = flowview.FlowView(self, self.state, flow)
self.header = flowview.FlowViewHeader(self, flow)
- self.statusbar = StatusBar(self, self.footer_text_flowview)
+ self.statusbar = StatusBar(self, flowview.footer)
self.currentflow = flow
self.make_view()
@@ -936,7 +925,3 @@ class ConsoleMaster(flow.FlowMaster):
if f:
self.process_flow(f, r)
return f
-
-
-
-
diff --git a/libmproxy/console/flowlist.py b/libmproxy/console/flowlist.py
index a4784fa4..412a4ec2 100644
--- a/libmproxy/console/flowlist.py
+++ b/libmproxy/console/flowlist.py
@@ -40,6 +40,9 @@ def _mkhelp():
return text
help_context = _mkhelp()
+footer = [
+ ('heading_key', "?"), ":help ",
+]
class EventListBox(urwid.ListBox):
def __init__(self, master):
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py
index 112548e9..2f85c756 100644
--- a/libmproxy/console/flowview.py
+++ b/libmproxy/console/flowview.py
@@ -72,6 +72,10 @@ def _mkhelp():
return text
help_context = _mkhelp()
+footer = [
+ ('heading_key', "?"), ":help ",
+ ('heading_key', "q"), ":back ",
+]
VIEW_CUTOFF = 1024*100
diff --git a/libmproxy/console/grideditor.py b/libmproxy/console/grideditor.py
index 28d2cc1d..12315ddd 100644
--- a/libmproxy/console/grideditor.py
+++ b/libmproxy/console/grideditor.py
@@ -35,6 +35,14 @@ def _mkhelp():
return text
help_context = _mkhelp()
+footer = [
+ ('heading_key', "enter"), ":edit ",
+ ('heading_key', "q"), ":back ",
+]
+footer_editing = [
+ ('heading_key', "esc"), ":stop editing ",
+]
+
class SText(common.WWrap):
def __init__(self, txt, focused):
@@ -66,7 +74,7 @@ class SEdit(common.WWrap):
return True
-class GridItem(common.WWrap):
+class GridRow(common.WWrap):
def __init__(self, focused, editing, first_width, values):
self.focused, self.editing, self.first_width = focused, editing, first_width
@@ -143,11 +151,13 @@ class GridWalker(urwid.ListWalker):
def start_edit(self):
if self.lst:
- self.editing = GridItem(self.focus_col, True, self.editor.first_width, self.lst[self.focus])
+ self.editing = GridRow(self.focus_col, True, self.editor.first_width, self.lst[self.focus])
+ self.editor.master.statusbar.update(footer_editing)
self._modified()
def stop_edit(self):
if self.editing:
+ self.editor.master.statusbar.update(footer)
self.lst[self.focus] = self.editing.get_value()
self.editing = False
self._modified()
@@ -173,7 +183,7 @@ class GridWalker(urwid.ListWalker):
if self.editing:
return self.editing, self.focus
elif self.lst:
- return GridItem(self.focus_col, False, self.editor.first_width, self.lst[self.focus]), self.focus
+ return GridRow(self.focus_col, False, self.editor.first_width, self.lst[self.focus]), self.focus
else:
return None, None
@@ -184,12 +194,12 @@ class GridWalker(urwid.ListWalker):
def get_next(self, pos):
if pos+1 >= len(self.lst):
return None, None
- return GridItem(None, False, self.editor.first_width, self.lst[pos+1]), pos+1
+ return GridRow(None, False, self.editor.first_width, self.lst[pos+1]), pos+1
def get_prev(self, pos):
if pos-1 < 0:
return None, None
- return GridItem(None, False, self.editor.first_width, self.lst[pos-1]), pos-1
+ return GridRow(None, False, self.editor.first_width, self.lst[pos-1]), pos-1
class GridListBox(urwid.ListBox):
@@ -232,7 +242,7 @@ class GridEditor(common.WWrap):
self.walker = GridWalker(self.value, self)
self.lb = GridListBox(self.walker)
self.w = urwid.Frame(
- self.lb,
+ self.lb,
header = urwid.Pile([title, h])
)
self.master.statusbar.update("")
diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py
index 8db3efd0..97118aee 100644
--- a/libmproxy/console/help.py
+++ b/libmproxy/console/help.py
@@ -15,7 +15,12 @@
import urwid
import common
-from .. import filt
+from .. import filt, version
+
+footer = [
+ ("heading", 'mitmproxy v%s '%version.VERSION),
+ ('heading_key', "q"), ":back ",
+]
class HelpView(urwid.ListBox):
def __init__(self, master, help_context, state):