Python sublime.CLASS_WORD_END Examples

The following are 6 code examples of sublime.CLASS_WORD_END(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sublime , or try the search function .
Example #1
Source File: insert_import_command.py    From sublime-import-helper with MIT License 6 votes vote down vote up
def get_name_candidate(view, point):
    point_region = view.sel()[0]
    if point is not None:
        point_region = sublime.Region(point, point)
    name = view.substr(point_region).strip()
    if not name:
        cursor_region = view.expand_by_class(
            point_region,
            sublime.CLASS_WORD_START
            | sublime.CLASS_LINE_START
            | sublime.CLASS_PUNCTUATION_START
            | sublime.CLASS_WORD_END
            | sublime.CLASS_PUNCTUATION_END
            | sublime.CLASS_LINE_END,
        )
        name = view.substr(cursor_region)
    return name 
Example #2
Source File: selection_utility.py    From network_tech with Apache License 2.0 5 votes vote down vote up
def left_word(cls, view, region, repeat=1):
        return cls._expand_words(
            view,
            region,
            classes=sublime.CLASS_WORD_END,
            repeat=repeat,
            forward=False,
        ) 
Example #3
Source File: php.py    From sublime_debugger with MIT License 5 votes vote down vote up
def on_hover_provider(self, view, point):
		seperators = "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?."
		word = view.expand_by_class(point, sublime.CLASS_WORD_START | sublime.CLASS_WORD_END, separators=seperators)
		word_string = word and view.substr(word)
		if not word_string:
			return None

		match = re.search("\\$[a-zA-Z0-9_]*", word_string)
		if not match:
			return None

		word_string = match.group()
		return (match.group(), word) 
Example #4
Source File: utils.py    From sublimetext-cfml with MIT License 5 votes vote down vote up
def get_previous_character(view, position):
    if view.substr(position - 1) in [" ", "\t", "\n"]:
        position = view.find_by_class(
            position, False, sublime.CLASS_WORD_END | sublime.CLASS_PUNCTUATION_END
        )
    return position - 1 
Example #5
Source File: utils.py    From sublimetext-cfml with MIT License 5 votes vote down vote up
def get_dot_context(view, dot_position):
    context = []

    if view.substr(dot_position) != ".":
        return context

    if view.substr(dot_position - 1) in [" ", "\t", "\n"]:
        dot_position = view.find_by_class(
            dot_position, False, sublime.CLASS_WORD_END | sublime.CLASS_PUNCTUATION_END
        )

    base_scope_count = view.scope_name(dot_position).count("meta.function-call")
    scope_to_find = " ".join(["meta.function-call"] * (base_scope_count + 1))
    if view.match_selector(dot_position - 1, scope_to_find):
        function_name, name_region, function_args_region = get_function_call(
            view, dot_position - 1
        )
        context.append(
            Symbol(function_name, True, name_region, function_args_region, name_region)
        )
    elif view.match_selector(
        dot_position - 1, "variable, meta.property, meta.instance.constructor"
    ):
        name_region = view.word(dot_position)
        context.append(
            Symbol(view.substr(name_region).lower(), False, None, None, name_region)
        )

    if len(context) > 0:
        context.extend(get_dot_context(view, name_region.begin() - 1))

    return context 
Example #6
Source File: elixir_sublime.py    From ElixirSublime with MIT License 5 votes vote down vote up
def expand_selection(view, point_or_region, aliases={}):
    region = view.expand_by_class(point_or_region, 
        sublime.CLASS_WORD_START | 
        sublime.CLASS_WORD_END, ' (){},[]%&')
    selection = view.substr(region).strip()
    if aliases:
        parts = selection.split('.')
        for alias, canonical in aliases.items():
            if alias == parts[0]:
                parts[0] = canonical
                return '.'.join(parts)
    return selection