SublimeHelper.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:enjoy-sublime 作者: colacao 项目源码 文件源码
def get_region(self, view=None, can_select_entire_buffer=False):
        '''Get the value under the cursor, or cursors.'''

        value = ''

        view, window = self.get_view_and_window(view)

        # If there is no view then all bets are off:
        #
        if view is not None:

            # Get the selection:
            #
            selection = view.sel()

            # If there is no selection then optionally use the entire buffer:
            #
            if can_select_entire_buffer is True:
                if len(selection) == 1 and selection[0].empty():
                    selection = [sublime.Region(0, view.size())]

            if selection is not None:

                # For each region in the selection, either use it directly,
                # or expand it to take in the 'word' that the cursor is on:
                #
                for region in selection:
                    if region.empty():
                        region = view.expand_by_class(
                            region,
                            sublime.CLASS_WORD_START | sublime.CLASS_WORD_END,
                            ' ():'
                        )
                    value = value + ' ' + view.substr(region)

        return value
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号