def setup():
    if int(sublime.version()) < 3000:
        # Sublime Text 2 & Python 2.6
        messagehook.setup(callback)
    else:
        # Sublime Text 3 & Python 3.3
        globalhook.setup(sublime.arch() == 'x64')
class ImeSupportGetMeasureCommand(sublime_plugin.WindowCommand):
    def run(self):
        self.test(self.window, self.window.active_view())

    @staticmethod
    def test(window, view):
        print('ImeSupportGetMeasureCommand:')
        for k, v in WindowLayout(window).get_status().items():
            print(k + ': ' + str(v))


if sublime.load_settings('IMESupport.sublime-settings').get('imesupport_debug'):
    class _WindowLayoutTestEventListener(sublime_plugin.EventListener):
        def __init__(self):
            window = sublime.active_window()
            if window is None:
                return
            view = window.active_view()
            if view is None:
                return
            ImeSupportGetMeasureCommand.test(window, view)


class ImeSupportSetImeStatusCommand(sublime_plugin.TextCommand):
    def run(self, edit, status):
        set_ime_status(self.view.window().hwnd(), status)


messagehook.setup(callback)
    def run(self):
        self.test(self.window, self.window.active_view())

    @staticmethod
    def test(window, view):
        print('ImeSupportGetMeasureCommand:')
        for k, v in WindowLayout(window).get_status().items():
            print(k + ': ' + str(v))


if sublime.load_settings('IMESupport.sublime-settings').get(
        'imesupport_debug'):

    class _WindowLayoutTestEventListener(sublime_plugin.EventListener):
        def __init__(self):
            window = sublime.active_window()
            if window is None:
                return
            view = window.active_view()
            if view is None:
                return
            ImeSupportGetMeasureCommand.test(window, view)


class ImeSupportSetImeStatusCommand(sublime_plugin.TextCommand):
    def run(self, edit, status):
        set_ime_status(self.view.window().hwnd(), status)


messagehook.setup(callback)