mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Merge pull request #48 from afh/pull/palette-option
Pull/palette option
This commit is contained in:
commit
c664801d7d
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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'),
|
||||
]
|
||||
],
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user