diff --git a/haxor_news/haxor.py b/haxor_news/haxor.py index 1356248..34910ab 100644 --- a/haxor_news/haxor.py +++ b/haxor_news/haxor.py @@ -139,7 +139,7 @@ def _create_cli(self): toolbar = Toolbar(lambda: self.paginate_comments) layout = create_default_layout( message=u'haxor> ', - reserve_space_for_menu=True, + reserve_space_for_menu=8, get_bottom_toolbar_tokens=toolbar.handler, ) cli_buffer = Buffer( @@ -212,6 +212,6 @@ def run_cli(self): click.echo('Version: ' + __version__) click.echo('Syntax: hn [params] [options]') while True: - document = self.cli.run() + document = self.cli.run(reset_current_buffer=True) self.handle_exit(document) self.run_command(document) diff --git a/haxor_news/style.py b/haxor_news/style.py index cadea91..3135470 100644 --- a/haxor_news/style.py +++ b/haxor_news/style.py @@ -16,7 +16,7 @@ from pygments.token import Token from pygments.style import Style from pygments.util import ClassNotFound -from prompt_toolkit.styles import default_style_extensions +from prompt_toolkit.styles import default_style_extensions, style_from_dict import pygments.styles @@ -46,31 +46,27 @@ def style_factory(self, name): except ClassNotFound: style = pygments.styles.get_style_by_name('native') - class CliStyle(Style): - """Provides styles for the autocomplete menu and the toolbar. + # Create styles dictionary. + styles = {} + 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:#00aaaa #000000', + Token.Menu.Completions.Meta: 'bg:#00aaaa #ffffff', + Token.Menu.Completions.ProgressButton: 'bg:#003333', + Token.Menu.Completions.ProgressBar: 'bg:#00aaaa', + Token.Scrollbar: 'bg:#00aaaa', + Token.Scrollbar.Button: 'bg:#003333', + Token.Toolbar: 'bg:#222222 #cccccc', + Token.Toolbar.Off: 'bg:#222222 #696969', + Token.Toolbar.On: 'bg:#222222 #ffffff', + Token.Toolbar.Search: 'noinherit bold', + Token.Toolbar.Search.Text: 'nobold', + Token.Toolbar.System: 'noinherit bold', + Token.Toolbar.Arg: 'noinherit bold', + Token.Toolbar.Arg.Text: 'nobold' + }) - :type styles: dict - :param styles: Contains pygments style info. - """ - - styles = {} - 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:#00aaaa #000000', - Token.Menu.Completions.Meta: 'bg:#00aaaa #ffffff', - Token.Menu.Completions.ProgressButton: 'bg:#003333', - Token.Menu.Completions.ProgressBar: 'bg:#00aaaa', - Token.Toolbar: 'bg:#222222 #cccccc', - Token.Toolbar.Off: 'bg:#222222 #696969', - Token.Toolbar.On: 'bg:#222222 #ffffff', - Token.Toolbar.Search: 'noinherit bold', - Token.Toolbar.Search.Text: 'nobold', - Token.Toolbar.System: 'noinherit bold', - Token.Toolbar.Arg: 'noinherit bold', - Token.Toolbar.Arg.Text: 'nobold' - }) - - return CliStyle + return style_from_dict(styles) diff --git a/setup.py b/setup.py index e5c54a3..da5d73a 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ 'colorama>=0.3.3,<1.0.0', 'requests>=2.4.3,<3.0.0', 'pygments>=2.0.2,<3.0.0', - 'prompt-toolkit==0.52', + 'prompt-toolkit>=1.0.0,<1.1.0', 'six>=1.9.0,<2.0.0', ], extras_require={