Permalink
Browse files

Minor key binding simplification

  • Loading branch information...
1 parent ed21b19 commit 0913362a7584af5730aa4668b33366dad0e571a8 @jskinner jskinner committed Feb 14, 2012
Showing with 10 additions and 58 deletions.
  1. +1 −21 Default (OSX).sublime-keymap
  2. +2 −36 Default.sublime-keymap
  3. +7 −1 vintage.py
@@ -22,27 +22,7 @@
"context":
[
{ "key": "setting.command_mode" },
- { "key": "vi_has_action" },
- { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
- { "key": "setting.vintage_ctrl_keys" }
- ]
- },
-
- { "keys": ["ctrl+c"], "command": "vi_cancel_current_action",
- "context":
- [
- { "key": "setting.command_mode" },
- { "key": "vi_has_repeat_digit" },
- { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
- { "key": "setting.vintage_ctrl_keys" }
- ]
- },
-
- { "keys": ["ctrl+c"], "command": "vi_cancel_current_action",
- "context":
- [
- { "key": "setting.command_mode" },
- { "key": "vi_has_register" },
+ { "key": "vi_has_input_state" },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
{ "key": "setting.vintage_ctrl_keys" }
]
View
@@ -26,23 +26,7 @@
[
{ "key": "setting.command_mode" },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
- { "key": "vi_has_action" }
- ]
- },
-
- { "keys": ["escape"], "command": "vi_cancel_current_action", "context":
- [
- { "key": "setting.command_mode" },
- { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
- { "key": "vi_has_repeat_digit" }
- ]
- },
-
- { "keys": ["escape"], "command": "vi_cancel_current_action", "context":
- [
- { "key": "setting.command_mode" },
- { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
- { "key": "vi_has_register" }
+ { "key": "vi_has_input_state" }
]
},
@@ -68,25 +52,7 @@
{ "keys": ["ctrl+["], "command": "vi_cancel_current_action", "context":
[
{ "key": "setting.command_mode" },
- { "key": "vi_has_action" },
- { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
- { "key": "setting.vintage_ctrl_keys" }
- ]
- },
-
- { "keys": ["ctrl+["], "command": "vi_cancel_current_action", "context":
- [
- { "key": "setting.command_mode" },
- { "key": "vi_has_repeat_digit" },
- { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
- { "key": "setting.vintage_ctrl_keys" }
- ]
- },
-
- { "keys": ["ctrl+["], "command": "vi_cancel_current_action", "context":
- [
- { "key": "setting.command_mode" },
- { "key": "vi_has_register" },
+ { "key": "vi_has_input_state" },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": false },
{ "key": "setting.vintage_ctrl_keys" }
]
View
@@ -14,7 +14,6 @@
# * set_action
# * set_motion
# * push_repeat_digit
-
class InputState:
prefix_repeat_digits = []
action_command = None
@@ -176,6 +175,13 @@ def on_query_context(self, view, key, operator, operand, match_all):
v = len(g_input_state.prefix_repeat_digits) > 0
if operator == sublime.OP_EQUAL: return v == operand
if operator == sublime.OP_NOT_EQUAL: return v != operand
+ elif key == "vi_has_input_state":
+ v = (len(g_input_state.motion_repeat_digits) > 0 or
+ len(g_input_state.prefix_repeat_digits) > 0 or
+ g_input_state.action_command is not None or
+ g_input_state.register is not None)
+ if operator == sublime.OP_EQUAL: return v == operand
+ if operator == sublime.OP_NOT_EQUAL: return v != operand
elif key == "vi_can_enter_text_object":
v = (g_input_state.action_command is not None) or view.has_non_empty_selection_region()
if operator == sublime.OP_EQUAL: return v == operand

0 comments on commit 0913362

Please sign in to comment.