diff --git a/haxor_news/haxor.py b/haxor_news/haxor.py index 34910ab..1356248 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=8, + reserve_space_for_menu=True, 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(reset_current_buffer=True) + document = self.cli.run() self.handle_exit(document) self.run_command(document) diff --git a/haxor_news/style.py b/haxor_news/style.py index 1ebb980..cadea91 100644 --- a/haxor_news/style.py +++ b/haxor_news/style.py @@ -14,8 +14,9 @@ # language governing permissions and limitations under the License. from pygments.token import Token +from pygments.style import Style from pygments.util import ClassNotFound -from prompt_toolkit.styles import default_style_extensions, style_from_dict +from prompt_toolkit.styles import default_style_extensions import pygments.styles @@ -45,27 +46,31 @@ def style_factory(self, name): except ClassNotFound: style = pygments.styles.get_style_by_name('native') - # 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' - }) + class CliStyle(Style): + """Provides styles for the autocomplete menu and the toolbar. - return style_from_dict(styles) + :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 diff --git a/setup.py b/setup.py index da5d73a..e5c54a3 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>=1.0.0,<1.1.0', + 'prompt-toolkit==0.52', 'six>=1.9.0,<2.0.0', ], extras_require={