summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2015-02-12 18:26:43 -0800
committerAmjith Ramanujam <amjith.r@gmail.com>2015-02-12 18:26:43 -0800
commitd06e9d2c1b010b4c628e97a376dbab698cd65e40 (patch)
treef61a8257b6ee256b7143622d75dd89e1fa143bd8
parentb05a83cce2d7f401ae5f4efad47a63c465e0603f (diff)
parentedfd68382a36ac76ab8152691e750457e1ad8cd9 (diff)
Merge pull request #154 from jayzeng/prototype_vimode
Get vi mode working
-rw-r--r--pgcli/key_bindings.py4
-rwxr-xr-xpgcli/main.py3
-rw-r--r--pgcli/pgclirc9
3 files changed, 10 insertions, 6 deletions
diff --git a/pgcli/key_bindings.py b/pgcli/key_bindings.py
index ce93124c..463ccf54 100644
--- a/pgcli/key_bindings.py
+++ b/pgcli/key_bindings.py
@@ -4,11 +4,11 @@ from prompt_toolkit.key_binding.manager import KeyBindingManager
_logger = logging.getLogger(__name__)
-def pgcli_bindings():
+def pgcli_bindings(vi_mode = False):
"""
Custom key bindings for pgcli.
"""
- key_binding_manager = KeyBindingManager()
+ key_binding_manager = KeyBindingManager(enable_vi_mode=vi_mode)
@key_binding_manager.registry.add_binding(Keys.F2)
def _(event):
diff --git a/pgcli/main.py b/pgcli/main.py
index c9e7c6ab..c6ea0d95 100755
--- a/pgcli/main.py
+++ b/pgcli/main.py
@@ -61,6 +61,7 @@ class PGCli(object):
# Load config.
c = self.config = load_config('~/.pgclirc', default_config)
self.multi_line = c.getboolean('main', 'multi_line')
+ self.vi_mode = c.getboolean('main', 'vi')
pgspecial.TIMING_ENABLED = c.getboolean('main', 'timing')
self.table_format = c.get('main', 'table_format')
self.syntax_style = c.get('main', 'syntax_style')
@@ -174,7 +175,7 @@ class PGCli(object):
history=FileHistory(os.path.expanduser('~/.pgcli-history')))
cli = CommandLineInterface(style=style_factory(self.syntax_style),
layout=layout, buffer=buf,
- key_bindings_registry=pgcli_bindings())
+ key_bindings_registry=pgcli_bindings(self.vi_mode))
try:
while True:
diff --git a/pgcli/pgclirc b/pgcli/pgclirc
index 417ec05e..c6e15cc0 100644
--- a/pgcli/pgclirc
+++ b/pgcli/pgclirc
@@ -18,7 +18,7 @@ log_file = ~/.pgcli.log
# and "DEBUG".
log_level = INFO
-# Timing of sql statments and table rendering.
+# Timing of sql statments and table rendering.
timing = True
# Table format. Possible values: psql, plain, simple, grid, fancy_grid, pipe,
@@ -26,7 +26,10 @@ timing = True
# Recommended: psql, fancy_grid and grid.
table_format = psql
-# Syntax Style. Possible values: manni, igor, xcode, vim, autumn, vs, rrt,
-# native, perldoc, borland, tango, emacs, friendly, monokai, paraiso-dark,
+# Syntax Style. Possible values: manni, igor, xcode, vim, autumn, vs, rrt,
+# native, perldoc, borland, tango, emacs, friendly, monokai, paraiso-dark,
# colorful, murphy, bw, pastie, paraiso-light, trac, default, fruity
syntax_style = native
+
+# Enables vi-mode
+vi = False