Merge pull request #48 from afh/pull/palette-option

Pull/palette option
This commit is contained in:
Aldo Cortesi 2012-07-01 14:04:43 -07:00
commit c664801d7d
3 changed files with 26 additions and 15 deletions

View File

@ -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(

View File

@ -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

View File

@ -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'),
]
],
}