Python sublime 模块,CLASS_WORD_END 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用sublime.CLASS_WORD_END

项目:NeoVintageous    作者:NeoVintageous    | 项目源码 | 文件源码
def next_word_start(view, pt):
    if is_at_punctuation(view, pt):
        # Skip all punctuation surrounding the caret and any trailing spaces.
        end = get_punctuation_region(view, pt).b
        if view.substr(end) in (' ', '\n'):
            end = view.find_by_class(end, forward=True, classes=ANCHOR_NEXT_WORD_BOUNDARY)

            return end

    elif is_at_space(view, pt):
        # Skip all spaces surrounding the cursor and the text word.
        end = get_space_region(view, pt).b
        if is_at_word(view, end) or is_at_punctuation(view, end):
            end = view.find_by_class(
                end,
                forward=True,
                classes=CLASS_WORD_END | CLASS_PUNCTUATION_END | CLASS_LINE_END
            )

            return end

    # Skip the word under the caret and any trailing spaces.
    return view.find_by_class(pt, forward=True, classes=ANCHOR_NEXT_WORD_BOUNDARY)
项目:KodiDevKit    作者:phil65    | 项目源码 | 文件源码
def run(self, edit):
        flags = sublime.CLASS_WORD_START | sublime.CLASS_WORD_END
        path = utils.get_node_content(self.view, flags)
        imagepath = INFOS.addon.translate_path(path)
        if not os.path.exists(imagepath):
            return None
        if os.path.isdir(imagepath):
            self.files = []
            for (_dirpath, _dirnames, filenames) in os.walk(imagepath):
                self.files.extend(filenames)
                break
            self.files = [imagepath + s for s in self.files]
        else:
            self.files = [imagepath]
        sublime.active_window().show_quick_panel(items=self.files,
                                                 on_select=self.on_done,
                                                 selected_index=0,
                                                 on_highlight=self.show_preview)
项目:Assembly-RGBDS    作者:michalisb    | 项目源码 | 文件源码
def findLocalLabelInView(self, symbol_region):
        ''' Try to expand the region so that it includes a local label (including macro ones) '''

        # check if there is a punctuation at the start
        if self.view.classify(symbol_region.begin()) & sublime.CLASS_PUNCTUATION_END:
            # cool, there is a punctuation expand selection with custom logic
            new_region = self.view.expand_by_class(symbol_region, 
                sublime.CLASS_WORD_START | sublime.CLASS_WORD_END,
                "()[]:, ")
            region_word = self.view.substr(new_region).strip()

            # we could also use self.view.indexed_symbols() here instead of the scopes

            # get the global label point closest to this local one
            closest_global = 0
            for r in self.view.find_by_selector("rgbds.label.global"):
                if r.end() < symbol_region.begin():
                    closest_global = r.end()

            # now get all local labels and stop at the one after the global point
            for r in self.view.find_by_selector("rgbds.label.local"):
                if self.view.substr(r) == region_word and r.begin() > closest_global:
                    return (self.view.file_name(), r)
        return None
项目:SmartVHDL    作者:TheClams    | 项目源码 | 文件源码
def show(self,region,location):
        # If nothing is selected expand selection to word
        if region.empty() :
            region = self.view.word(region)
        # Make sure a whole word is selected
        elif (self.view.classify(region.a) & sublime.CLASS_WORD_START)==0 or (self.view.classify(region.b) & sublime.CLASS_WORD_END)==0:
            if (self.view.classify(region.a) & sublime.CLASS_WORD_START)==0:
                region.a = self.view.find_by_class(region.a,False,sublime.CLASS_WORD_START)
            if (self.view.classify(region.b) & sublime.CLASS_WORD_END)==0:
                region.b = self.view.find_by_class(region.b,True,sublime.CLASS_WORD_END)
        v = self.view.substr(region)
        # trigger on valid word only
        if not re.match(r'^[A-Za-z_]\w*$',v):
            return
        #
        s,ti = self.get_type(v,region)
        if not s:
            sublime.status_message('No definition found for ' + v)
        else :
            s = self.color_str(s,ti)
            s = '<style>{css}</style><div class="content">{txt}</div>'.format(css=tooltip_css, txt=s)
            self.view.show_popup(s,location=location, flags=tooltip_flag, max_width=500, on_navigate=self.on_navigate)
项目:VintageousPlus    作者:trishume    | 项目源码 | 文件源码
def next_word_start(view, pt):
    if is_at_punctuation(view, pt):
        # Skip all punctuation surrounding the caret and any trailing spaces.
        end = get_punctuation_region(view, pt).b
        if view.substr(end) in (' ', '\n'):
            end = view.find_by_class(end, forward=True,
                                     classes=ANCHOR_NEXT_WORD_BOUNDARY)
            return end
    elif is_at_space(view, pt):
        # Skip all spaces surrounding the cursor and the text word.
        end = get_space_region(view, pt).b
        if is_at_word(view, end) or is_at_punctuation(view, end):
            end = view.find_by_class(end, forward=True,
                                     classes=CLASS_WORD_END |
                                             CLASS_PUNCTUATION_END |
                                             CLASS_LINE_END)
            return end

    # Skip the word under the caret and any trailing spaces.
    return view.find_by_class(pt, forward=True,
                              classes=ANCHOR_NEXT_WORD_BOUNDARY)
项目:NeoVintageous    作者:NeoVintageous    | 项目源码 | 文件源码
def at_word_end(view, pt):
    return (view.classify(pt) & CLASS_WORD_END) == CLASS_WORD_END
项目:NeoVintageous    作者:NeoVintageous    | 项目源码 | 文件源码
def skip_word(view, pt):
    while True:
        if at_punctuation(view, pt):
            pt = view.find_by_class(pt, forward=True, classes=CLASS_PUNCTUATION_END)
        elif at_word(view, pt):
            pt = view.find_by_class(pt, forward=True, classes=CLASS_WORD_END)
        else:
            break

    return pt
项目:KodiDevKit    作者:phil65    | 项目源码 | 文件源码
def run(self, pack_textures=True):
        path = utils.get_node_content(view=self.window.active_view(),
                                      flags=sublime.CLASS_WORD_START | sublime.CLASS_WORD_END)
        imagepath = INFOS.addon.translate_path(path)
        if not os.path.exists(imagepath):
            return None
        webbrowser.open(imagepath)
项目:KodiDevKit    作者:phil65    | 项目源码 | 文件源码
def is_visible(self):
        if not INFOS.addon or not INFOS.addon.media_path:
            return False
        flags = sublime.CLASS_WORD_START | sublime.CLASS_WORD_END
        content = utils.get_node_content(self.view, flags)
        return "/" in content or "\\" in content
项目:KodiDevKit    作者:phil65    | 项目源码 | 文件源码
def run(self):
        flags = sublime.CLASS_WORD_START | sublime.CLASS_WORD_END
        view = self.window.active_view()
        position = INFOS.go_to_tag(keyword=utils.get_node_content(view, flags),
                                   folder=view.file_name().split(os.sep)[-2])
        if position:
            self.window.open_file(position, sublime.ENCODED_POSITION)
项目:VintageousPlus    作者:trishume    | 项目源码 | 文件源码
def at_word_end(view, pt):
    return (view.classify(pt) & CLASS_WORD_END) == CLASS_WORD_END
项目:VintageousPlus    作者:trishume    | 项目源码 | 文件源码
def skip_word(view, pt):
    while True:
        if at_punctuation(view, pt):
            pt = view.find_by_class(pt, forward=True, classes=CLASS_PUNCTUATION_END)
        elif at_word(view, pt):
            pt = view.find_by_class(pt, forward=True, classes=CLASS_WORD_END)
        else:
            break
    return pt
项目: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