コード例 #1
0
    def run(self, edit, mode=None, extend=False, exact_word=True):
        def f(view, s):

            if exact_word:
                pattern = r'\b{0}\b'.format(query)
            else:
                pattern = query

            flags = sublime.IGNORECASE

            if mode == _MODE_INTERNAL_NORMAL:
                match = reverse_search(view, pattern, 0, current_sel.a, flags)
            else:
                match = reverse_search(view, pattern, 0, current_sel.a, flags)

            if match:
                if mode == _MODE_INTERNAL_NORMAL:
                    return sublime.Region(s.b, match.begin())
                elif state.mode == MODE_VISUAL:
                    return sublime.Region(s.b, match.begin())
                elif state.mode == MODE_NORMAL:
                    return sublime.Region(match.begin(), match.begin())
            return s

        state = VintageState(self.view)
        # TODO: make sure we swallow any leading white space.
        query = self.view.substr(self.view.word(self.view.sel()[0].end()))
        if query:
            state.last_buffer_search = query

        current_sel = self.view.sel()[0]

        regions_transformer(self.view, f)
コード例 #2
0
ファイル: motion_cmds.py プロジェクト: Web5design/Vintageous
    def run(self, edit, mode=None, count=1, extend=False):
        def f(view, s):

            pattern = r'\b{0}\b'.format(query)
            flags = sublime.IGNORECASE

            if mode == _MODE_INTERNAL_NORMAL:
                match = view.find(pattern, view.word(s.end()).end(), flags)
            else:
                match = view.find(pattern, view.word(s).end(), flags)

            if match:
                if mode == _MODE_INTERNAL_NORMAL:
                    return sublime.Region(s.a, match.begin())
                elif state.mode == MODE_VISUAL:
                    return sublime.Region(s.a, match.begin())
                elif state.mode == MODE_NORMAL:
                    return sublime.Region(match.begin(), match.begin())
            return s

        state = VintageState(self.view)
        # TODO: make sure we swallow any leading white space.
        query = self.view.substr(self.view.word(self.view.sel()[0].end()))
        if query:
            state.last_buffer_search = query

        regions_transformer(self.view, f)
コード例 #3
0
ファイル: motion_cmds.py プロジェクト: structAnkit/Vintageous
    def run(self, edit, mode=None, extend=False, exact_word=True):
        def f(view, s):

            if exact_word:
                pattern = r'\b{0}\b'.format(query)
            else:
                pattern = query

            flags = sublime.IGNORECASE

            if mode == _MODE_INTERNAL_NORMAL:
                match = reverse_search(view, pattern, 0, current_sel.a, flags)
            else:
                match = reverse_search(view, pattern, 0, current_sel.a, flags)

            if match:
                if mode == _MODE_INTERNAL_NORMAL:
                    return sublime.Region(s.b, match.begin())
                elif state.mode == MODE_VISUAL:
                    return sublime.Region(s.b, match.begin())
                elif state.mode == MODE_NORMAL:
                    return sublime.Region(match.begin(), match.begin())
            return s

        state = VintageState(self.view)
        # TODO: make sure we swallow any leading white space.
        query = self.view.substr(self.view.word(self.view.sel()[0].end()))
        if query:
            state.last_buffer_search = query

        current_sel = self.view.sel()[0]

        regions_transformer(self.view, f)
コード例 #4
0
ファイル: motion_cmds.py プロジェクト: Web5design/Vintageous
 def on_done(self, s):
     # FIXME: Sublime Text seems to reset settings between the .run() call above and this
     # .on_done() method. An issue has been filed about this. Awaiting response.
     state = VintageState(self.view)
     state.motion = 'vi_forward_slash'
     state.user_input = s
     state.last_buffer_search = s
     state.run()
コード例 #5
0
ファイル: motion_cmds.py プロジェクト: structAnkit/Vintageous
    def on_done(self, s):
        state = VintageState(self.view)
        state.motion = 'vi_question_mark'

        state.user_input = s
        # Equivalent to ?<CR>, which must repeat the last search.
        if s == '':
            state.user_input = state.last_buffer_search

        if s != '':
            state.last_buffer_search = s
        state.eval()
コード例 #6
0
    def on_done(self, s):
        self.view.erase_regions("vi_inc_search")
        state = VintageState(self.view)
        state.motion = "vi_question_mark"

        state.user_input = s
        # Equivalent to ?<CR>, which must repeat the last search.
        if s == "":
            state.user_input = state.last_buffer_search

        if s != "":
            state.last_buffer_search = s
        state.eval()
コード例 #7
0
ファイル: motion_cmds.py プロジェクト: typopl/Vintageous
    def on_done(self, s):
        self.view.erase_regions('vi_inc_search')
        state = VintageState(self.view)
        state.motion = 'vi_question_mark'

        state.user_input = s
        # Equivalent to ?<CR>, which must repeat the last search.
        if s == '':
            state.user_input = state.last_buffer_search

        if s != '':
            state.last_buffer_search = s
        state.eval()
コード例 #8
0
ファイル: motion_cmds.py プロジェクト: typopl/Vintageous
    def on_done(self, s):
        self.view.erase_regions('vi_inc_search')
        state = VintageState(self.view)
        state.motion = 'vi_forward_slash'

        state.user_input = s
        # Equivalent to /<CR>, which must repeat the last search.
        if s == '':
            state.user_input = state.last_buffer_search

        if s != '':
            state.last_buffer_search = s
        state.eval()
コード例 #9
0
ファイル: motion_cmds.py プロジェクト: typopl/Vintageous
    def run(self, edit, mode=None, extend=False, exact_word=True):
        def f(view, s):

            if exact_word:
                pattern = r'\b{0}\b'.format(query)
            else:
                pattern = query

            flags = sublime.IGNORECASE

            if mode == _MODE_INTERNAL_NORMAL:
                match = find_wrapping(view,
                                      term=pattern,
                                      start=view.word(s.end()).end(),
                                      end=view.size(),
                                      flags=0,
                                      times=1)
            else:
                match = find_wrapping(view,
                                      term=pattern,
                                      start=view.word(s.end()).end(),
                                      end=view.size(),
                                      flags=0,
                                      times=1)

            if match:
                if mode == _MODE_INTERNAL_NORMAL:
                    return sublime.Region(s.a, match.begin())
                elif state.mode == MODE_VISUAL:
                    return sublime.Region(s.a, match.begin())
                elif state.mode == MODE_NORMAL:
                    return sublime.Region(match.begin(), match.begin())
            return s

        state = VintageState(self.view)
        # TODO: make sure we swallow any leading white space.
        query = self.view.substr(self.view.word(self.view.sel()[0].end()))
        if query:
            state.last_buffer_search = query

        regions_transformer(self.view, f)
コード例 #10
0
ファイル: motion_cmds.py プロジェクト: typopl/Vintageous
    def run(self, edit, mode=None, extend=False, exact_word=True):
        def f(view, s):

            if exact_word:
                pattern = r'\b{0}\b'.format(query)
            else:
                pattern = query

            flags = sublime.IGNORECASE

            if mode == _MODE_INTERNAL_NORMAL:
                match = find_wrapping(view,
                                      term=pattern,
                                      start=view.word(s.end()).end(),
                                      end=view.size(),
                                      flags=0,
                                      times=1)
            else:
                match = find_wrapping(view,
                                      term=pattern,
                                      start=view.word(s.end()).end(),
                                      end=view.size(),
                                      flags=0,
                                      times=1)

            if match:
                if mode == _MODE_INTERNAL_NORMAL:
                    return sublime.Region(s.a, match.begin())
                elif state.mode == MODE_VISUAL:
                    return sublime.Region(s.a, match.begin())
                elif state.mode == MODE_NORMAL:
                    return sublime.Region(match.begin(), match.begin())
            return s

        state = VintageState(self.view)
        # TODO: make sure we swallow any leading white space.
        query = self.view.substr(self.view.word(self.view.sel()[0].end()))
        if query:
            state.last_buffer_search = query

        regions_transformer(self.view, f)