mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +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 proxy
|
||||||
import optparse, re, filt
|
import optparse, re, filt
|
||||||
|
from console import palettes
|
||||||
|
|
||||||
|
|
||||||
class ParseReplaceException(Exception): pass
|
class ParseReplaceException(Exception): pass
|
||||||
@ -115,6 +116,7 @@ def get_common_options(options):
|
|||||||
wfile = options.wfile,
|
wfile = options.wfile,
|
||||||
verbosity = options.verbose,
|
verbosity = options.verbose,
|
||||||
nopop = options.nopop,
|
nopop = options.nopop,
|
||||||
|
palette = options.palette,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -216,6 +218,11 @@ def common_options(parser):
|
|||||||
action="store_true", dest="upstream_cert",
|
action="store_true", dest="upstream_cert",
|
||||||
help="Connect to upstream server to look up certificate details."
|
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 = optparse.OptionGroup(parser, "Client Replay")
|
||||||
group.add_option(
|
group.add_option(
|
||||||
|
@ -335,6 +335,7 @@ class Options(object):
|
|||||||
"verbosity",
|
"verbosity",
|
||||||
"wfile",
|
"wfile",
|
||||||
"nopop",
|
"nopop",
|
||||||
|
"palette",
|
||||||
]
|
]
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
for k, v in kwargs.items():
|
for k, v in kwargs.items():
|
||||||
@ -358,7 +359,7 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.replacehooks.add(*i)
|
self.replacehooks.add(*i)
|
||||||
|
|
||||||
self.flow_list_walker = None
|
self.flow_list_walker = None
|
||||||
self.set_palette()
|
self.set_palette(options.palette)
|
||||||
|
|
||||||
r = self.set_intercept(options.intercept)
|
r = self.set_intercept(options.intercept)
|
||||||
if r:
|
if r:
|
||||||
@ -504,8 +505,8 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.ui.start()
|
self.ui.start()
|
||||||
os.unlink(name)
|
os.unlink(name)
|
||||||
|
|
||||||
def set_palette(self):
|
def set_palette(self, name):
|
||||||
self.palette = palettes.dark
|
self.palette = palettes.palettes[name]
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.currentflow = None
|
self.currentflow = None
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
palettes = {
|
||||||
|
|
||||||
# Default palette for dark background
|
# Default palette for dark background
|
||||||
dark = [
|
'dark': [
|
||||||
# name, foreground, background, mono, foreground_high, background_high
|
# name, foreground, background, mono, foreground_high, background_high
|
||||||
# For details on the meaning of the elements refer to
|
# For details on the meaning of the elements refer to
|
||||||
# http://excess.org/urwid/reference.html#Screen-register_palette
|
# http://excess.org/urwid/reference.html#Screen-register_palette
|
||||||
@ -61,10 +62,10 @@ dark = [
|
|||||||
('focusfield_error', 'dark red', 'light gray'),
|
('focusfield_error', 'dark red', 'light gray'),
|
||||||
('field_error', 'dark red', 'black'),
|
('field_error', 'dark red', 'black'),
|
||||||
('editfield', 'black', 'light cyan'),
|
('editfield', 'black', 'light cyan'),
|
||||||
]
|
],
|
||||||
|
|
||||||
# Palette for light background
|
# Palette for light background
|
||||||
light = [
|
'light': [
|
||||||
('body', 'black', 'dark cyan'),
|
('body', 'black', 'dark cyan'),
|
||||||
('foot', 'dark gray', 'default'),
|
('foot', 'dark gray', 'default'),
|
||||||
('title', 'white,bold', 'light blue',),
|
('title', 'white,bold', 'light blue',),
|
||||||
@ -73,7 +74,7 @@ light = [
|
|||||||
# Status bar & heading
|
# Status bar & heading
|
||||||
('heading', 'white', 'light gray', None, 'g85', 'dark blue'),
|
('heading', 'white', 'light gray', None, 'g85', 'dark blue'),
|
||||||
('heading_key', 'dark blue', 'light gray', None, 'light cyan', '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
|
# Help
|
||||||
('key', 'dark blue,bold', 'default'),
|
('key', 'dark blue,bold', 'default'),
|
||||||
@ -106,13 +107,13 @@ light = [
|
|||||||
('focusfield_error', 'dark red', 'light gray'),
|
('focusfield_error', 'dark red', 'light gray'),
|
||||||
('field_error', 'dark red', 'black'),
|
('field_error', 'dark red', 'black'),
|
||||||
('editfield', 'black', 'light cyan'),
|
('editfield', 'black', 'light cyan'),
|
||||||
]
|
],
|
||||||
|
|
||||||
# Palettes for terminals that use the Solarized precision colors
|
# Palettes for terminals that use the Solarized precision colors
|
||||||
# (http://ethanschoonover.com/solarized#the-values)
|
# (http://ethanschoonover.com/solarized#the-values)
|
||||||
|
|
||||||
# For dark backgrounds
|
# For dark backgrounds
|
||||||
solarized_dark = [
|
'solarized_dark': [
|
||||||
('body', 'dark cyan', 'default'),
|
('body', 'dark cyan', 'default'),
|
||||||
('foot', 'dark gray', 'default'),
|
('foot', 'dark gray', 'default'),
|
||||||
('title', 'white,bold', 'default',),
|
('title', 'white,bold', 'default',),
|
||||||
@ -121,7 +122,7 @@ solarized_dark = [
|
|||||||
# Status bar & heading
|
# Status bar & heading
|
||||||
('heading', 'light gray', 'light cyan',),
|
('heading', 'light gray', 'light cyan',),
|
||||||
('heading_key', 'dark blue', 'white',),
|
('heading_key', 'dark blue', 'white',),
|
||||||
('heading_inactive', 'light cyan', 'default',),
|
('heading_inactive', 'light cyan', 'light gray',),
|
||||||
|
|
||||||
# Help
|
# Help
|
||||||
('key', 'dark blue', 'default',),
|
('key', 'dark blue', 'default',),
|
||||||
@ -155,19 +156,19 @@ solarized_dark = [
|
|||||||
('focusfield_error', 'dark red', 'light gray'),
|
('focusfield_error', 'dark red', 'light gray'),
|
||||||
('field_error', 'dark red', 'black'),
|
('field_error', 'dark red', 'black'),
|
||||||
('editfield', 'black', 'light gray'),
|
('editfield', 'black', 'light gray'),
|
||||||
]
|
],
|
||||||
|
|
||||||
# For light backgrounds
|
# For light backgrounds
|
||||||
solarized_light = [
|
'solarized_light': [
|
||||||
('body', 'dark cyan', 'default'),
|
('body', 'dark cyan', 'default'),
|
||||||
('foot', 'dark gray', 'default'),
|
('foot', 'dark gray', 'default'),
|
||||||
('title', 'white,bold', 'light cyan',),
|
('title', 'white,bold', 'light cyan',),
|
||||||
('editline', 'white', 'default',),
|
('editline', 'white', 'default',),
|
||||||
|
|
||||||
# Status bar & heading
|
# Status bar & heading
|
||||||
('heading', 'white,standout', 'light cyan',),
|
('heading', 'light cyan', 'light gray',),
|
||||||
('heading_key', 'dark blue', 'white',),
|
('heading_key', 'dark blue', 'white',),
|
||||||
('heading_inactive', 'light gray', 'default',),
|
('heading_inactive', 'white', 'light gray',),
|
||||||
|
|
||||||
# Help
|
# Help
|
||||||
('key', 'dark blue', 'default',),
|
('key', 'dark blue', 'default',),
|
||||||
@ -201,4 +202,6 @@ solarized_light = [
|
|||||||
('focusfield_error', 'dark red', 'light gray'),
|
('focusfield_error', 'dark red', 'light gray'),
|
||||||
('field_error', 'dark red', 'black'),
|
('field_error', 'dark red', 'black'),
|
||||||
('editfield', 'white', 'light cyan'),
|
('editfield', 'white', 'light cyan'),
|
||||||
]
|
],
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user