Skip to content

Commit

Permalink
Set fallback command of some keys
Browse files Browse the repository at this point in the history
If keys are ignored by ibus, those fall back to nomal command.
  • Loading branch information
shirosaki committed Apr 20, 2013
1 parent 629ad7b commit 9d7dee2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions SublimeIBusFallBackCommand.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"backspace": { "command": "left_delete" },
"left": { "command": "move", "args": {"by": "characters", "forward": false} },
"right": { "command": "move", "args": {"by": "characters", "forward": true} },
"up": { "command": "move", "args": {"by": "lines", "forward": false} },
"down": { "command": "move", "args": {"by": "lines", "forward": true} },
"enter": { "command": "insert", "args": {"characters": "\n"} },
"pageup": { "command": "move", "args": {"by": "pages", "forward": false} },
"pagedown": { "command": "move", "args": {"by": "pages", "forward": true} },
"home": { "command": "move_to", "args": {"to": "bol", "extend": false} },
"end": { "command": "move_to", "args": {"to": "eol", "extend": false} }
}
8 changes: 7 additions & 1 deletion sublimeibusplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ def ibus_hide_preedit_text_cb(self, id_no):
pass

def ibus_process_key_event_cb(self, id_no, handled):
pass
if handled == 0:
settings = sublime.load_settings('SublimeIBusFallBackCommand.sublime-settings')
cmd = settings.get(status.key)
if cmd is not None:
status.view.run_command(cmd.get('command', None),
cmd.get('args', None))


class IbusToggleCommand(sublime_plugin.TextCommand):
Expand All @@ -159,6 +164,7 @@ def run(self, edit, key, alt=False, ctrl=False, shift=False, super=False):

keysym = self.table.get(key, None)
if keysym is not None:
status.key = key
command.process_key(keysym)


Expand Down

0 comments on commit 9d7dee2

Please sign in to comment.