Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest prompt-toolkit v1.0.0 #59

Merged
merged 1 commit into from
May 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions haxor_news/haxor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -212,6 +212,6 @@ def run_cli(self):
click.echo('Version: ' + __version__)
click.echo('Syntax: hn <command> [params] [options]')
while True:
document = self.cli.run()
document = self.cli.run(reset_current_buffer=True)
self.handle_exit(document)
self.run_command(document)
52 changes: 24 additions & 28 deletions haxor_news/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down