Skip to content

Commit

Permalink
Merge pull request #63 from donnemartin/develop
Browse files Browse the repository at this point in the history
Fix #62: Revert to prompt-toolkit v0.52
  • Loading branch information
donnemartin committed May 30, 2016
2 parents c45583a + 9764bf3 commit 0599373
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
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=8,
reserve_space_for_menu=True,
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(reset_current_buffer=True)
document = self.cli.run()
self.handle_exit(document)
self.run_command(document)
53 changes: 29 additions & 24 deletions haxor_news/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
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>=1.0.0,<1.1.0',
'prompt-toolkit==0.52',
'six>=1.9.0,<2.0.0',
],
extras_require={
Expand Down

0 comments on commit 0599373

Please sign in to comment.