|
11 | 11 | # ANY KIND, either express or implied. See the License for the specific |
12 | 12 | # language governing permissions and limitations under the License. |
13 | 13 | from pygments.token import Token |
14 | | -from pygments.style import Style |
15 | 14 | from pygments.util import ClassNotFound |
16 | 15 | from pygments.styles import get_style_by_name |
17 | | -from prompt_toolkit.styles import default_style_extensions |
| 16 | +from prompt_toolkit.styles import default_style_extensions, style_from_dict |
18 | 17 |
|
19 | 18 |
|
20 | 19 | class StyleFactory(object): |
@@ -43,32 +42,26 @@ def style_factory(self, style_name): |
43 | 42 | except ClassNotFound: |
44 | 43 | style = get_style_by_name('vim') |
45 | 44 |
|
46 | | - class CliStyle(Style): |
47 | | - """Provides styles for the autocomplete menu and the toolbar. |
| 45 | + # Create a style dictionary. |
| 46 | + styles = {} |
| 47 | + styles.update(style.styles) |
| 48 | + styles.update(default_style_extensions) |
| 49 | + t = Token |
| 50 | + styles.update({ |
| 51 | + t.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000', |
| 52 | + t.Menu.Completions.Completion: 'bg:#008888 #ffffff', |
| 53 | + t.Menu.Completions.Meta.Current: 'bg:#00aaaa #000000', |
| 54 | + t.Menu.Completions.Meta: 'bg:#00aaaa #ffffff', |
| 55 | + t.Scrollbar.Button: 'bg:#003333', |
| 56 | + t.Scrollbar: 'bg:#00aaaa', |
| 57 | + t.Toolbar: 'bg:#222222 #cccccc', |
| 58 | + t.Toolbar.Off: 'bg:#222222 #696969', |
| 59 | + t.Toolbar.On: 'bg:#222222 #ffffff', |
| 60 | + t.Toolbar.Search: 'noinherit bold', |
| 61 | + t.Toolbar.Search.Text: 'nobold', |
| 62 | + t.Toolbar.System: 'noinherit bold', |
| 63 | + t.Toolbar.Arg: 'noinherit bold', |
| 64 | + t.Toolbar.Arg.Text: 'nobold' |
| 65 | + }) |
48 | 66 |
|
49 | | - :type styles: dict |
50 | | - :param styles: Contains pygments style info. |
51 | | - """ |
52 | | - |
53 | | - styles = {} |
54 | | - styles.update(style.styles) |
55 | | - styles.update(default_style_extensions) |
56 | | - t = Token |
57 | | - styles.update({ |
58 | | - t.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000', |
59 | | - t.Menu.Completions.Completion: 'bg:#008888 #ffffff', |
60 | | - t.Menu.Completions.Meta.Current: 'bg:#00aaaa #000000', |
61 | | - t.Menu.Completions.Meta: 'bg:#00aaaa #ffffff', |
62 | | - t.Menu.Completions.ProgressButton: 'bg:#003333', |
63 | | - t.Menu.Completions.ProgressBar: 'bg:#00aaaa', |
64 | | - t.Toolbar: 'bg:#222222 #cccccc', |
65 | | - t.Toolbar.Off: 'bg:#222222 #696969', |
66 | | - t.Toolbar.On: 'bg:#222222 #ffffff', |
67 | | - t.Toolbar.Search: 'noinherit bold', |
68 | | - t.Toolbar.Search.Text: 'nobold', |
69 | | - t.Toolbar.System: 'noinherit bold', |
70 | | - t.Toolbar.Arg: 'noinherit bold', |
71 | | - t.Toolbar.Arg.Text: 'nobold' |
72 | | - }) |
73 | | - |
74 | | - return CliStyle |
| 67 | + return style_from_dict(styles) |
0 commit comments