def ask_daemon(view, callback, ask_type, ask_kwargs=None, location=None): """Jedi async request shortcut. Parameters ---------- view : sublime.View A Sublime Text view. callback : TYPE Description ask_type : str Description ask_kwargs : dict, None, optional Description location : int, int, None, optional Description """ window_id = view.window().id() def _async_summon(): answer = ask_daemon_sync(view, ask_type, ask_kwargs, location) run_in_active_view(window_id)(callback)(answer) if callback: queue.debounce(partial(sublime.set_timeout_async, _async_summon, 0), delay=settings.get("completion_timeout", 10), key=_plugin_id.format("debounce"))
def on_text_command(self, view, command_name, args): double_click = command_name == "drag_select" and "by" in args and args["by"] == "words" and \ view and len(view.sel()) if double_click: queue.debounce(partial(view.run_command, "odyseus_dn_show_numbers_popup"), delay=100, key=_plugin_id.format("debounce"))
def run(self, edit): """Action to perform when this Sublime Text command is executed. Parameters ---------- edit : object A Sublime Text edit. Returns ------- None Halt execution. """ queue.debounce(partial(match_trailing_spaces, self.view), delay=get_settings("highlight_delay", 0), key=_plugin_id.format("debounce"))
def on_selection_modified_async(self, view): if view and len(view.sel()) and get_settings( "live_highlight") and not view.settings().get("is_widget"): queue.debounce(partial(highlight_occurences, view), delay=get_settings("highlight_delay", 0), key=_plugin_id.format("debounce"))
def highlight_occurences(view): if not get_settings("highlight_when_selection_is_empty", False) and not view.has_non_empty_selection_region(): view.erase_status(_plugin_id.format("status")) view.erase_regions(_plugin_id.format("regions")) Storage.prev_regions = None Storage.prev_selections = None return # todo: The list cast below can go away when Sublime 3's Selection class implements __str__ prev_selections = str(list(view.sel())) if Storage.prev_selections == prev_selections: return else: Storage.prev_selections = prev_selections if view.size() <= get_settings("file_size_limit", 4194304): limited_size = False else: limited_size = True # print "running"+ str(time.time()) regions = [] processed_words = [] occurrences_message = [] occurrences_count = 0 word_separators = view.settings().get("word_separators", "") for sel in view.sel(): if get_settings("highlight_when_selection_is_empty", False) and sel.empty(): string = view.substr(view.word(sel)).strip() if string not in processed_words: processed_words.append(string) if string and all([c not in word_separators for c in string]): regions = find_regions(view, regions, string, limited_size) if not get_settings( "highlight_word_under_cursor_when_selection_is_empty", False): for s in view.sel(): regions = [r for r in regions if not r.contains(s)] elif not sel.empty() and get_settings("highlight_non_word_characters", False): string = view.substr(sel) if string and string not in processed_words: processed_words.append(string) regions = find_regions(view, regions, string, limited_size) elif not sel.empty(): word = view.word(sel) if word.end() == sel.end() and word.begin() == sel.begin(): string = view.substr(word).strip() if string not in processed_words: processed_words.append(string) if string and all( [c not in word_separators for c in string]): regions = find_regions(view, regions, string, limited_size) occurrences = len(regions) - occurrences_count if occurrences > 0: occurrences_message.append('"' + string + '" ' + str(occurrences) + " ") occurrences_count = occurrences_count + occurrences if Storage.prev_regions != regions: view.erase_regions(_plugin_id.format("regions")) if regions: queue.debounce(partial(delayed_highlight, view, regions, occurrences_message, limited_size), delay=get_settings("highlight_delay", 0), key=_plugin_id.format("debounce")) else: view.erase_status(_plugin_id.format("status")) Storage.prev_regions = regions
def _ody_match(self, view): if get_settings("live_highlight", True): queue.debounce(partial(match_trailing_spaces, view), delay=get_settings("highlight_delay", 0), key=_plugin_id.format("debounce"))