From 120c3cfeb69d62bc8fe45e4dd4ad9e05180211e9 Mon Sep 17 00:00:00 2001 From: Trung Ngo Date: Sun, 5 May 2013 18:40:16 +0700 Subject: [PATCH 1/4] Add engine cycling keymap --- Default.sublime-keymap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Default.sublime-keymap b/Default.sublime-keymap index 586c6a9..a93be6f 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -159,6 +159,7 @@ {"keys": ["~"], "command": "ibus_key", "args": {"key": "~", "alt": false, "ctrl": false, "shift": false, "super": false}, "context": [{"key": "setting.ibus_mode"}, {"key": "setting.command_mode", "operand": false}]}, {"keys": ["ctrl+m"], "command": "ibus_key", "args": {"key": "henkan", "alt": false, "ctrl": false, "shift": false, "super": false}, "context": [{"key": "setting.ibus_mode"}, {"key": "setting.command_mode", "operand": false}]}, - { "keys": ["ctrl+\\"], "command": "ibus_toggle" } + { "keys": ["ctrl+\\"], "command": "ibus_toggle" }, + { "keys": ["alt+z"], "command": "ibus_cycle" } ] From 2e75a9e39517356a06f6e59d4d50d1e3ef11d75f Mon Sep 17 00:00:00 2001 From: Trung Ngo Date: Sun, 5 May 2013 18:40:36 +0700 Subject: [PATCH 2/4] Implement next_engine() in ibus-agent --- sublimeibus/sublime-ibus-agent.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sublimeibus/sublime-ibus-agent.py b/sublimeibus/sublime-ibus-agent.py index 31f4b19..a5dbec1 100644 --- a/sublimeibus/sublime-ibus-agent.py +++ b/sublimeibus/sublime-ibus-agent.py @@ -538,6 +538,16 @@ def stop_focus_observation(): def list_active_engines(): print_command('ibus_list_active_engines_cb', [i.name for i in bus.list_active_engines()]) +def next_engine(id_no): + current_engine_name = imcontexts[id_no].get_engine().name + all_engine_names = [i.name for i in bus.list_active_engines()] + current_engine_index = all_engine_names.index(current_engine_name) + try: + next_engine_name = all_engine_names[current_engine_index + 1] + except IndexError: + next_engine_name = all_engine_names[0] + set_engine(id_no, next_engine_name) + ######################################################################## # Main loop ######################################################################## From 2a77d98a6c0163040eb376a3994353551a98868e Mon Sep 17 00:00:00 2001 From: Trung Ngo Date: Sun, 5 May 2013 18:41:18 +0700 Subject: [PATCH 3/4] Implement ibus_cycle SublimeText command --- sublimeibusplugin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sublimeibusplugin.py b/sublimeibusplugin.py index 6f0fbef..cab9fb3 100644 --- a/sublimeibusplugin.py +++ b/sublimeibusplugin.py @@ -101,6 +101,9 @@ def set_cursor_location(self): self.push('set_cursor_location(%d, %d, %d, 0, %d)' % (status.id_no, left, top, height)) + def next_engine(self): + self.push('next_engine(%d)' % (status.id_no)) + class WindowLayout: def __init__(self): @@ -351,6 +354,12 @@ def run(self, edit): # logger.debug('enable = ' + str(enable)) +class IbusCycleCommand(sublime_plugin.TextCommand): + def run(self, edit): + logger.debug("next_engine()") + command.next_engine() + + class IbusKeyCommand(sublime_plugin.TextCommand): def __init__(self, view): super(IbusKeyCommand, self).__init__(view) From 568bab79b0cf06cfc07da403124d89e6186ef1ab Mon Sep 17 00:00:00 2001 From: Trung Ngo Date: Sun, 5 May 2013 18:41:41 +0700 Subject: [PATCH 4/4] Ignore *.pyc files --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc