summaryrefslogtreecommitdiffstats
path: root/pgcli/pgtoolbar.py
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2015-05-02 17:01:57 +0200
committerAmjith Ramanujam <amjith.r@gmail.com>2015-05-11 13:29:45 -0700
commit5f8126c1799974f0bebad9390c025329c2343b36 (patch)
treefc18250b161fb552d27bad65b73cbaef44dbbefd /pgcli/pgtoolbar.py
parente4f571970c8da2c4ac68f8b5fb751ff13cd3b154 (diff)
Upgrade to prompt-toolkit 0.34
Diffstat (limited to 'pgcli/pgtoolbar.py')
-rw-r--r--pgcli/pgtoolbar.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/pgcli/pgtoolbar.py b/pgcli/pgtoolbar.py
index 3a35be4d..0b8846e1 100644
--- a/pgcli/pgtoolbar.py
+++ b/pgcli/pgtoolbar.py
@@ -1,34 +1,33 @@
-from prompt_toolkit.layout.toolbars import Toolbar
-from prompt_toolkit.layout.utils import TokenList
from pygments.token import Token
-class PGToolbar(Toolbar):
- def __init__(self, key_binding_manager, token=None):
- self.key_binding_manager = key_binding_manager
- token = token or Token.Toolbar.Status
- super(PGToolbar, self).__init__(token=token)
+def create_toolbar_tokens_func(key_binding_manager, token=None):
+ """
+ Return a function that generates the toolbar tokens.
+ """
+ token = token or Token.Toolbar
- def get_tokens(self, cli, width):
- result = TokenList()
- result.append((self.token, ' '))
+ def get_toolbar_tokens(cli):
+ result = []
+ result.append((token, ' '))
if cli.buffers['default'].completer.smart_completion:
- result.append((self.token.On, '[F2] Smart Completion: ON '))
+ result.append((token.On, '[F2] Smart Completion: ON '))
else:
- result.append((self.token.Off, '[F2] Smart Completion: OFF '))
+ result.append((token.Off, '[F2] Smart Completion: OFF '))
if cli.buffers['default'].always_multiline:
- result.append((self.token.On, '[F3] Multiline: ON '))
+ result.append((token.On, '[F3] Multiline: ON '))
else:
- result.append((self.token.Off, '[F3] Multiline: OFF '))
+ result.append((token.Off, '[F3] Multiline: OFF '))
if cli.buffers['default'].always_multiline:
- result.append((self.token,
+ result.append((token,
' (Semi-colon [;] will end the line)'))
- if self.key_binding_manager.enable_vi_mode:
- result.append((self.token.On, '[F4] Vi-mode'))
+ if key_binding_manager.enable_vi_mode:
+ result.append((token.On, '[F4] Vi-mode'))
else:
- result.append((self.token.On, '[F4] Emacs-mode'))
+ result.append((token.On, '[F4] Emacs-mode'))
return result
+ return get_toolbar_tokens