From 0e76f0f341f367abd3e317f48612071843977f3f Mon Sep 17 00:00:00 2001 From: Thomas Roth Date: Fri, 26 Feb 2010 00:20:49 +0100 Subject: Added a 'keep terminal background' option (-t), so that you can use it with your own background color. (Foreground color following.) --- libmproxy/console.py | 59 ++++++++++++++++++++++++++++++---------------------- mitmproxy | 6 +++++- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/libmproxy/console.py b/libmproxy/console.py index f666f71a..3cbc6173 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -714,30 +714,7 @@ class State: #begin nocover class ConsoleMaster(controller.Master): - palette = [ - ('body', 'black', 'dark cyan', 'standout'), - ('foot', 'light gray', 'black'), - ('title', 'white', 'black',), - ('editline', 'white', 'black',), - - # Help - ('key', 'light cyan', 'black', 'underline'), - ('head', 'white', 'black'), - ('text', 'light gray', 'black'), - - # List and Connections - ('method', 'dark cyan', 'black'), - ('focus', 'yellow', 'black'), - ('goodcode', 'light green', 'black'), - ('error', 'light red', 'black'), - ('header', 'dark cyan', 'black'), - ('heading', 'white', 'dark blue'), - ('inactive', 'dark gray', 'black'), - ('ack', 'light red', 'black'), - - # Hex view - ('offset', 'dark cyan', 'black'), - ] + palette = [] footer_text_default = [ ('key', "?"), ":help ", ('key', "q"), ":exit ", @@ -747,7 +724,8 @@ class ConsoleMaster(controller.Master): ('key', "?"), ":help ", ('key', "q"), ":back ", ] - def __init__(self, server, config): + def __init__(self, server, config, terminal_background): + self.set_palette(terminal_background) controller.Master.__init__(self, server) self.config = config self.state = State() @@ -755,6 +733,37 @@ class ConsoleMaster(controller.Master): self.stickycookie = None self.stickyhosts = {} + def set_palette(self, terminal_background): + if terminal_background: + background_color = 'default' + else: + background_color = 'black' + + self.palette = [ + ('body', 'black', 'dark cyan', 'standout'), + ('foot', 'light gray', background_color), + ('title', 'white', background_color,), + ('editline', 'white', background_color,), + + # Help + ('key', 'light cyan', background_color, 'underline'), + ('head', 'white', background_color), + ('text', 'light gray', background_color), + + # List and Connections + ('method', 'dark cyan', background_color), + ('focus', 'yellow', background_color), + ('goodcode', 'light green', background_color), + ('error', 'light red', background_color), + ('header', 'dark cyan', background_color), + ('heading', 'white', 'dark blue'), + ('inactive', 'dark gray', background_color), + ('ack', 'light red', background_color), + + # Hex view + ('offset', 'dark cyan', background_color), + ] + def run(self): self.ui = urwid.curses_display.Screen() self.ui.register_palette(self.palette) diff --git a/mitmproxy b/mitmproxy index 692d7bc6..6b1f0ae0 100755 --- a/mitmproxy +++ b/mitmproxy @@ -43,6 +43,10 @@ if __name__ == '__main__': parser.add_option("-q", "--quiet", action="store_true", dest="quiet", help="Quiet.") + parser.add_option( + "-t", "--terminal-backround", action="store_true", dest="terminal_background", + default=False, help="Uses the standard terminal background instead of setting an own. (Useful for transparent terminals etc.)") + parser.add_option("-v", "--verbose", action="count", dest="verbose", default=1, help="Increase verbosity. Can be passed multiple times.") @@ -64,7 +68,7 @@ if __name__ == '__main__': if options.dump: m = controller.DumpMaster(server, options.verbose) else: - m = console.ConsoleMaster(server, options.verbose) + m = console.ConsoleMaster(server, options.verbose, options.terminal_background) if options.verbose > 0: print >> sys.stderr, "Running on port %s"%options.port m.run() -- cgit v1.2.3