Fix theme support

This commit is contained in:
Buck Ryan 2017-08-26 21:37:09 -04:00
parent 5d23890c81
commit fc2f059ed4
6 changed files with 17 additions and 6 deletions

View file

@ -6,7 +6,6 @@ import os
import sys
import importlib
import json
from .themes.default import DefaultColor
from .utils import warn, py3
@ -68,10 +67,10 @@ class Powerline(object):
'bare': '%s',
}
def __init__(self, args, config, theme=None):
def __init__(self, args, config, theme):
self.args = args
self.config = config
self.theme = theme or DefaultColor
self.theme = theme
self.cwd = get_valid_cwd()
mode = config.get("mode", "patched")
shell = config.get("shell", "bash")
@ -152,7 +151,11 @@ def main():
with open(config_path) as f:
config = json.loads(f.read())
powerline = Powerline(args, config)
theme_name = config.get("theme", "default")
mod = importlib.import_module("powerline_shell.themes." + theme_name)
theme = getattr(mod, "Color")
powerline = Powerline(args, config, theme)
segments = []
for seg_name in config["segments"]:
mod = importlib.import_module("powerline_shell.segments." + seg_name)

View file

@ -1,6 +1,8 @@
# Basic theme which only uses colors in 0-15 range
from .default import DefaultColor
class Color(DefaultColor):
"""Basic theme which only uses colors in 0-15 range"""
USERNAME_FG = 8
USERNAME_BG = 15
USERNAME_ROOT_BG = 1

View file

@ -1,4 +1,4 @@
class DefaultColor:
class DefaultColor(object):
"""
This class should have the default colors for every segment.
Please test every new segment with this theme first.

View file

@ -1,3 +1,6 @@
from .default import DefaultColor
class Color(DefaultColor):
USERNAME_FG = 15
USERNAME_BG = 4

View file

@ -1,3 +1,6 @@
from .default import DefaultColor
class Color(DefaultColor):
USERNAME_FG = 8
USERNAME_BG = 251