mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 23:09:44 +00:00
Added a 'keep terminal background' option (-t), so that you can use it with your own background color. (Foreground color following.)
This commit is contained in:
parent
fc6f170731
commit
0e76f0f341
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user