Skip to content

Commit

Permalink
Merge pull request chikatoike#4 from lewtds/engine-cycling
Browse files Browse the repository at this point in the history
Implement engine cycling
  • Loading branch information
chikatoike committed May 21, 2013
2 parents c37ae57 + 568bab7 commit 867228d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
3 changes: 2 additions & 1 deletion Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

]
10 changes: 10 additions & 0 deletions sublimeibus/sublime-ibus-agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
########################################################################
Expand Down
9 changes: 9 additions & 0 deletions sublimeibusplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 867228d

Please sign in to comment.