Skip to content

Commit

Permalink
Minor key binding simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
jskinner committed Feb 14, 2012
1 parent ed21b19 commit 0913362
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 58 deletions.
22 changes: 1 addition & 21 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
]
Expand Down
38 changes: 2 additions & 36 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
]
},

Expand All @@ -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" }
]
Expand Down
8 changes: 7 additions & 1 deletion vintage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# * set_action
# * set_motion
# * push_repeat_digit

class InputState:
prefix_repeat_digits = []
action_command = None
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0913362

Please sign in to comment.