Python prompt_toolkit.styles.style_from_dict() Examples

The following are 4 code examples of prompt_toolkit.styles.style_from_dict(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module prompt_toolkit.styles , or try the search function .
Example #1
Source File: color_styles.py    From azure-cli-shell with MIT License 6 votes vote down vote up
def color_mapping(curr_completion, completion, prompt, command, subcommand,
                  param, text, line, example, toolbar):

    return style_from_dict({
        # Completion colors
        Token.Menu.Completions.Completion.Current: curr_completion,
        Token.Menu.Completions.Completion: completion,
        Token.Menu.Completions.ProgressButton: 'bg:#b78991',
        Token.Menu.Completions.ProgressBar: 'bg:#ffc0cb',

        Token.Az: prompt,
        Token.Prompt.Arg: prompt,

        # Pretty Words
        Token.Keyword: command,
        Token.Keyword.Declaration: subcommand,
        Token.Name.Class: param,
        Token.Text: text,

        Token.Line: line,
        Token.Number: example,
        # toolbar
        Token.Operator: toolbar,
        Token.Toolbar: toolbar
    }) 
Example #2
Source File: style.py    From contrail-api-cli with MIT License 5 votes vote down vote up
def style_from_dict(d):
        styles = default_style_extensions.copy()
        styles.update(DefaultStyle.styles)
        styles.update(d)
        PromptStyle = type('PromptStyle', (Style,), {'styles': styles})
        return PromptStyle 
Example #3
Source File: style.py    From kube-shell with Apache License 2.0 5 votes vote down vote up
def style_factory(self, style_name):
        """Retrieve the specified pygments style.

        If the specified style is not found, the vim style is returned.

        :type style_name: str
        :param style_name: The pygments style name.

        :rtype: :class:`pygments.style.StyleMeta`
        :return: Pygments style info.
        """
        try:
            style = get_style_by_name(style_name)
        except ClassNotFound:
            style = get_style_by_name('vim')

        # Create a style dictionary.
        styles = {}
        styles.update(style.styles)
        styles.update(default_style_extensions)
        t = Token
        styles.update({
            t.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000',
            t.Menu.Completions.Completion: 'bg:#008888 #ffffff',
            t.Menu.Completions.Meta.Current: 'bg:#00aaaa #000000',
            t.Menu.Completions.Meta: 'bg:#00aaaa #ffffff',
            t.Scrollbar.Button: 'bg:#003333',
            t.Scrollbar: 'bg:#00aaaa',
            t.Toolbar: 'bg:#222222 #cccccc',
            t.Toolbar.Off: 'bg:#222222 #696969',
            t.Toolbar.On: 'bg:#222222 #ffffff',
            t.Toolbar.Search: 'noinherit bold',
            t.Toolbar.Search.Text: 'nobold',
            t.Toolbar.System: 'noinherit bold',
            t.Toolbar.Arg: 'noinherit bold',
            t.Toolbar.Arg.Text: 'nobold'
        })

        return style_from_dict(styles) 
Example #4
Source File: style.py    From aws-shell with Apache License 2.0 5 votes vote down vote up
def style_factory(self, style_name):
        """Retrieve the specified pygments style.

        If the specified style is not found, the vim style is returned.

        :type style_name: str
        :param style_name: The pygments style name.

        :rtype: :class:`pygments.style.StyleMeta`
        :return: Pygments style info.
        """
        try:
            style = get_style_by_name(style_name)
        except ClassNotFound:
            style = get_style_by_name('vim')

        # Create a style dictionary.
        styles = {}
        styles.update(style.styles)
        styles.update(default_style_extensions)
        t = Token
        styles.update({
            t.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000',
            t.Menu.Completions.Completion: 'bg:#008888 #ffffff',
            t.Menu.Completions.Meta.Current: 'bg:#00aaaa #000000',
            t.Menu.Completions.Meta: 'bg:#00aaaa #ffffff',
            t.Scrollbar.Button: 'bg:#003333',
            t.Scrollbar: 'bg:#00aaaa',
            t.Toolbar: 'bg:#222222 #cccccc',
            t.Toolbar.Off: 'bg:#222222 #696969',
            t.Toolbar.On: 'bg:#222222 #ffffff',
            t.Toolbar.Search: 'noinherit bold',
            t.Toolbar.Search.Text: 'nobold',
            t.Toolbar.System: 'noinherit bold',
            t.Toolbar.Arg: 'noinherit bold',
            t.Toolbar.Arg.Text: 'nobold'
        })

        return style_from_dict(styles)