Skip to content

Commit e7ac3d3

Browse files
jonathanslendersjamesls
authored andcommitted
Upgrade to prompt-toolkit 1.0.0
1 parent 8bfd6a9 commit e7ac3d3

File tree

3 files changed

+26
-33
lines changed

3 files changed

+26
-33
lines changed

awsshell/app.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from prompt_toolkit.filters import Always
1616
from prompt_toolkit.interface import CommandLineInterface, Application
1717
from prompt_toolkit.interface import AbortAction, AcceptAction
18-
from prompt_toolkit.utils import Callback
1918
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
2019
from prompt_toolkit.history import InMemoryHistory, FileHistory
2120

@@ -279,7 +278,7 @@ def cli(self):
279278
def run(self):
280279
while True:
281280
try:
282-
document = self.cli.run()
281+
document = self.cli.run(reset_current_buffer=True)
283282
text = document.text
284283
except InputInterrupt:
285284
pass
@@ -423,7 +422,7 @@ def create_application(self, completer, history,
423422
buffer=self.create_buffer(completer, history),
424423
on_abort=AbortAction.RETRY,
425424
on_exit=AbortAction.RAISE_EXCEPTION,
426-
on_input_timeout=Callback(self.on_input_timeout),
425+
on_input_timeout=self.on_input_timeout,
427426
key_bindings_registry=self.key_manager.manager.registry,
428427
)
429428

awsshell/style.py

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pygments.style import Style
1515
from pygments.util import ClassNotFound
1616
from pygments.styles import get_style_by_name
17-
from prompt_toolkit.styles import default_style_extensions
17+
from prompt_toolkit.styles import default_style_extensions, style_from_dict
1818

1919

2020
class StyleFactory(object):
@@ -43,32 +43,26 @@ def style_factory(self, style_name):
4343
except ClassNotFound:
4444
style = get_style_by_name('vim')
4545

46-
class CliStyle(Style):
47-
"""Provides styles for the autocomplete menu and the toolbar.
46+
# Create a style dictionary.
47+
styles = {}
48+
styles.update(style.styles)
49+
styles.update(default_style_extensions)
50+
t = Token
51+
styles.update({
52+
t.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000',
53+
t.Menu.Completions.Completion: 'bg:#008888 #ffffff',
54+
t.Menu.Completions.Meta.Current: 'bg:#00aaaa #000000',
55+
t.Menu.Completions.Meta: 'bg:#00aaaa #ffffff',
56+
t.Scrollbar.Button: 'bg:#003333',
57+
t.Scrollbar: 'bg:#00aaaa',
58+
t.Toolbar: 'bg:#222222 #cccccc',
59+
t.Toolbar.Off: 'bg:#222222 #696969',
60+
t.Toolbar.On: 'bg:#222222 #ffffff',
61+
t.Toolbar.Search: 'noinherit bold',
62+
t.Toolbar.Search.Text: 'nobold',
63+
t.Toolbar.System: 'noinherit bold',
64+
t.Toolbar.Arg: 'noinherit bold',
65+
t.Toolbar.Arg.Text: 'nobold'
66+
})
4867

49-
:type styles: dict
50-
:param styles: Contains pygments style info.
51-
"""
52-
53-
styles = {}
54-
styles.update(style.styles)
55-
styles.update(default_style_extensions)
56-
t = Token
57-
styles.update({
58-
t.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000',
59-
t.Menu.Completions.Completion: 'bg:#008888 #ffffff',
60-
t.Menu.Completions.Meta.Current: 'bg:#00aaaa #000000',
61-
t.Menu.Completions.Meta: 'bg:#00aaaa #ffffff',
62-
t.Menu.Completions.ProgressButton: 'bg:#003333',
63-
t.Menu.Completions.ProgressBar: 'bg:#00aaaa',
64-
t.Toolbar: 'bg:#222222 #cccccc',
65-
t.Toolbar.Off: 'bg:#222222 #696969',
66-
t.Toolbar.On: 'bg:#222222 #ffffff',
67-
t.Toolbar.Search: 'noinherit bold',
68-
t.Toolbar.Search.Text: 'nobold',
69-
t.Toolbar.System: 'noinherit bold',
70-
t.Toolbar.Arg: 'noinherit bold',
71-
t.Toolbar.Arg.Text: 'nobold'
72-
})
73-
74-
return CliStyle
68+
return style_from_dict(styles)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
requires = [
99
'awscli>=1.8.9,<2.0.0',
10-
'prompt-toolkit==0.52',
10+
'prompt-toolkit>=1.0.0,<1.1.0',
1111
'boto3>=1.2.1,<2.0.0',
1212
'configobj>=5.0.6,<6.0.0',
1313
'Pygments>=2.1.3,<3.0.0',

0 commit comments

Comments
 (0)