diff --git a/pgcli/main.py b/pgcli/main.py index 4645fef5..f0b43b92 100755 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -71,6 +71,7 @@ class PGCli(object): self.pgspecial.timing_enabled = c['main'].as_bool('timing') self.table_format = c['main']['table_format'] self.syntax_style = c['main']['syntax_style'] + self.cli_style = c['colors'] self.wider_completion_menu = c['main'].as_bool('wider_completion_menu') self.logger = logging.getLogger(__name__) @@ -254,7 +255,7 @@ class PGCli(object): history=FileHistory(os.path.expanduser(history_file)), complete_while_typing=Always()) - application = Application(style=style_factory(self.syntax_style), + application = Application(style=style_factory(self.syntax_style, self.cli_style), layout=layout, buffer=buf, key_bindings_registry=key_binding_manager.registry, on_exit=AbortAction.RAISE_EXCEPTION) diff --git a/pgcli/pgclirc b/pgcli/pgclirc index d6685f82..6e823f1a 100644 --- a/pgcli/pgclirc +++ b/pgcli/pgclirc @@ -44,6 +44,22 @@ syntax_style = default # for end are available in the REPL. vi = False -# Named queries are queries you can rexecute by name + +# Custom colors for the completion menu, toolbar, etc. +[colors] +Token.Menu.Completions.Completion.Current = 'bg:#ffffff #000000' +Token.Menu.Completions.Completion = 'bg:#008888 #ffffff' +Token.Menu.Completions.Meta.Current = 'bg:#44aaaa #000000' +Token.Menu.Completions.Meta = 'bg:#448888 #ffffff' +Token.Menu.Completions.ProgressButton = 'bg:#003333' +Token.Menu.Completions.ProgressBar = 'bg:#00aaaa' +Token.SelectedText = '#ffffff bg:#6666aa' +Token.IncrementalSearchMatch = '#ffffff bg:#4444aa' +Token.IncrementalSearchMatch.Current = '#ffffff bg:#44aa44' +Token.Toolbar = 'bg:#222222 #aaaaaa' +Token.Toolbar.Off = 'bg:#222222 #888888' +Token.Toolbar.On = 'bg:#222222 #ffffff' + +# Named queries are queries you can execute by name. [named queries] diff --git a/pgcli/pgstyle.py b/pgcli/pgstyle.py index af344aa9..dbb37706 100644 --- a/pgcli/pgstyle.py +++ b/pgcli/pgstyle.py @@ -5,7 +5,7 @@ from prompt_toolkit.styles import default_style_extensions import pygments.styles -def style_factory(name): +def style_factory(name, cli_style): try: style = pygments.styles.get_style_by_name(name) except ClassNotFound: @@ -16,20 +16,6 @@ def style_factory(name): styles.update(style.styles) styles.update(default_style_extensions) - styles.update({ - Token.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000', - Token.Menu.Completions.Completion: 'bg:#008888 #ffffff', - Token.Menu.Completions.Meta.Current: 'bg:#44aaaa #000000', - Token.Menu.Completions.Meta: 'bg:#448888 #ffffff', - Token.Menu.Completions.ProgressButton: 'bg:#003333', - Token.Menu.Completions.ProgressBar: 'bg:#00aaaa', - Token.SelectedText: '#ffffff bg:#6666aa', - Token.IncrementalSearchMatch: '#ffffff bg:#4444aa', - Token.IncrementalSearchMatch.Current: '#ffffff bg:#44aa44', - Token.Toolbar: 'bg:#440044 #ffffff', - Token.Toolbar: 'bg:#222222 #aaaaaa', - Token.Toolbar.Off: 'bg:#222222 #888888', - Token.Toolbar.On: 'bg:#222222 #ffffff', - }) - + custom_styles = dict([(eval(x), y) for x, y in cli_style.items()]) + styles.update(custom_styles) return PGStyle