Permalink
Browse files

Fix #62: Revert to prompt-toolkit v0.52

  • Loading branch information...
1 parent c45583a commit 9764bf38ae14ca95bc188b21495d82510f66c30a @donnemartin committed May 30, 2016
Showing with 32 additions and 27 deletions.
  1. +2 −2 haxor_news/haxor.py
  2. +29 −24 haxor_news/style.py
  3. +1 −1 setup.py
View
@@ -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 <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)
View
@@ -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
View
@@ -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={

0 comments on commit 9764bf3

Please sign in to comment.