aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2012-07-01 14:04:43 -0700
committerAldo Cortesi <aldo@corte.si>2012-07-01 14:04:43 -0700
commitc664801d7dc9a402453e1ad772783da29f3d65ea (patch)
treec04925eeadf3dc1be39e9f1cc2a75208fc3fa805 /libmproxy
parent90365e270e3e10779f6401e8f2ab48f243479ab2 (diff)
parenta695cf177dcb3f70cca673f1db7d0c424dcdd61c (diff)
downloadmitmproxy-c664801d7dc9a402453e1ad772783da29f3d65ea.tar.gz
mitmproxy-c664801d7dc9a402453e1ad772783da29f3d65ea.tar.bz2
mitmproxy-c664801d7dc9a402453e1ad772783da29f3d65ea.zip
Merge pull request #48 from afh/pull/palette-option
Pull/palette option
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/cmdline.py7
-rw-r--r--libmproxy/console/__init__.py7
-rw-r--r--libmproxy/console/palettes.py27
3 files changed, 26 insertions, 15 deletions
diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py
index 822bebec..93d99779 100644
--- a/libmproxy/cmdline.py
+++ b/libmproxy/cmdline.py
@@ -15,6 +15,7 @@
import proxy
import optparse, re, filt
+from console import palettes
class ParseReplaceException(Exception): pass
@@ -115,6 +116,7 @@ def get_common_options(options):
wfile = options.wfile,
verbosity = options.verbose,
nopop = options.nopop,
+ palette = options.palette,
)
@@ -216,6 +218,11 @@ def common_options(parser):
action="store_true", dest="upstream_cert",
help="Connect to upstream server to look up certificate details."
)
+ parser.add_option(
+ "--palette", type="str", default="dark",
+ action="store", dest="palette",
+ help="Select color palette: " + ", ".join(palettes.palettes.keys())
+ )
group = optparse.OptionGroup(parser, "Client Replay")
group.add_option(
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py
index 8686c974..054cc66e 100644
--- a/libmproxy/console/__init__.py
+++ b/libmproxy/console/__init__.py
@@ -335,6 +335,7 @@ class Options(object):
"verbosity",
"wfile",
"nopop",
+ "palette",
]
def __init__(self, **kwargs):
for k, v in kwargs.items():
@@ -358,7 +359,7 @@ class ConsoleMaster(flow.FlowMaster):
self.replacehooks.add(*i)
self.flow_list_walker = None
- self.set_palette()
+ self.set_palette(options.palette)
r = self.set_intercept(options.intercept)
if r:
@@ -504,8 +505,8 @@ class ConsoleMaster(flow.FlowMaster):
self.ui.start()
os.unlink(name)
- def set_palette(self):
- self.palette = palettes.dark
+ def set_palette(self, name):
+ self.palette = palettes.palettes[name]
def run(self):
self.currentflow = None
diff --git a/libmproxy/console/palettes.py b/libmproxy/console/palettes.py
index 39d49dd4..c4e92d99 100644
--- a/libmproxy/console/palettes.py
+++ b/libmproxy/console/palettes.py
@@ -13,9 +13,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+palettes = {
# Default palette for dark background
-dark = [
+ 'dark': [
# name, foreground, background, mono, foreground_high, background_high
# For details on the meaning of the elements refer to
# http://excess.org/urwid/reference.html#Screen-register_palette
@@ -61,10 +62,10 @@ dark = [
('focusfield_error', 'dark red', 'light gray'),
('field_error', 'dark red', 'black'),
('editfield', 'black', 'light cyan'),
-]
+ ],
# Palette for light background
-light = [
+ 'light': [
('body', 'black', 'dark cyan'),
('foot', 'dark gray', 'default'),
('title', 'white,bold', 'light blue',),
@@ -73,7 +74,7 @@ light = [
# Status bar & heading
('heading', 'white', 'light gray', None, 'g85', 'dark blue'),
('heading_key', 'dark blue', 'light gray', None, 'light cyan', 'dark blue'),
- ('heading_inactive', 'light gray', 'dark gray', None, 'g58', 'g11'),
+ ('heading_inactive', 'light gray', 'dark gray', None, 'dark gray', 'dark blue'),
# Help
('key', 'dark blue,bold', 'default'),
@@ -106,13 +107,13 @@ light = [
('focusfield_error', 'dark red', 'light gray'),
('field_error', 'dark red', 'black'),
('editfield', 'black', 'light cyan'),
-]
+ ],
# Palettes for terminals that use the Solarized precision colors
# (http://ethanschoonover.com/solarized#the-values)
# For dark backgrounds
-solarized_dark = [
+ 'solarized_dark': [
('body', 'dark cyan', 'default'),
('foot', 'dark gray', 'default'),
('title', 'white,bold', 'default',),
@@ -121,7 +122,7 @@ solarized_dark = [
# Status bar & heading
('heading', 'light gray', 'light cyan',),
('heading_key', 'dark blue', 'white',),
- ('heading_inactive', 'light cyan', 'default',),
+ ('heading_inactive', 'light cyan', 'light gray',),
# Help
('key', 'dark blue', 'default',),
@@ -155,19 +156,19 @@ solarized_dark = [
('focusfield_error', 'dark red', 'light gray'),
('field_error', 'dark red', 'black'),
('editfield', 'black', 'light gray'),
-]
+ ],
# For light backgrounds
-solarized_light = [
+ 'solarized_light': [
('body', 'dark cyan', 'default'),
('foot', 'dark gray', 'default'),
('title', 'white,bold', 'light cyan',),
('editline', 'white', 'default',),
# Status bar & heading
- ('heading', 'white,standout', 'light cyan',),
+ ('heading', 'light cyan', 'light gray',),
('heading_key', 'dark blue', 'white',),
- ('heading_inactive', 'light gray', 'default',),
+ ('heading_inactive', 'white', 'light gray',),
# Help
('key', 'dark blue', 'default',),
@@ -201,4 +202,6 @@ solarized_light = [
('focusfield_error', 'dark red', 'light gray'),
('field_error', 'dark red', 'black'),
('editfield', 'white', 'light cyan'),
-]
+ ],
+
+}