Python sublime.LITERAL Examples
The following are 7
code examples of sublime.LITERAL().
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: JsonTree.py From JsonTree with MIT License | 6 votes |
def goto(self, arrpos): # The position gives us the line number strgo = self.trimkeys[arrpos] # Check for matches in the array before 48 found = 0 for index, item in enumerate(self.trimkeys): if index >= arrpos: break if item == strgo: found += 1 # Now we need to find that string N times in # the text, and go to its line number # and highlight it, why not? regions = self.view.find_all(strgo, sublime.LITERAL) region = regions[found] self.view.sel().clear() self.view.sel().add(region) self.view.show(region)
Example #2
Source File: diff.py From GitSavvy with MIT License | 6 votes |
def find_hunk_in_view(view, patch): # type: (sublime.View, str) -> Optional[sublime.Region] """Given a patch, search for its first hunk in the view Returns the region of the first line of the hunk (the one starting with '@@ ...'), if any. """ diff = SplittedDiff.from_string(patch) try: hunk = diff.hunks[0] except IndexError: return None return ( view.find(hunk.header().text, 0, sublime.LITERAL) or fuzzy_search_hunk_content_in_view(view, hunk.content().text.splitlines()) )
Example #3
Source File: diff.py From GitSavvy with MIT License | 6 votes |
def fuzzy_search_hunk_content_in_view(view, lines): # type: (sublime.View, List[str]) -> Optional[sublime.Region] """Fuzzy search the hunk content in the view Note that hunk content does not include the starting line, the one starting with '@@ ...', anymore. The fuzzy strategy here is to search for the hunk or parts of it by reducing the contextual lines symmetrically. Returns the region of the starting line of the found hunk, if any. """ for hunk_content in shrink_list_sym(lines): region = view.find('\n'.join(hunk_content), 0, sublime.LITERAL) if region: diff = SplittedDiff.from_view(view) head_and_hunk = diff.head_and_hunk_for_pt(region.a) if head_and_hunk: _, hunk = head_and_hunk hunk_header = hunk.header() return sublime.Region(hunk_header.a, hunk_header.b) break return None
Example #4
Source File: dired.py From dired with MIT License | 5 votes |
def run(self, view): path = self.path window = self.view.window() names = os.listdir(path) f = [] for name in names: if isdir(join(path, name)): name += os.sep f.append(name) def on_done(select): if not select == -1 : line_str = f[select] r_list = self.view.find_all(line_str, sublime.LITERAL) # Make match whole word. if len(r_list) > 1 : for r in r_list : find_str = self.view.substr(self.view.line(r)) if find_str == line_str : break else : r = r_list[0] if self.p_key : window.run_command('dired_preview_refresh', {'path':path + line_str}) self.view.sel().clear() self.view.sel().add(r.a) self.view.show(r.a) if self.p_key : self.view.settings().set('preview_key', True) self.p_key = self.view.settings().get('preview_key') self.view.settings().set('preview_key', False) window.show_quick_panel(f, on_done)
Example #5
Source File: semilive.py From semilive with MIT License | 5 votes |
def run(self, edit, line='~~~'): region = self.view.find(line, 0, sublime.LITERAL) self.view.sel().add(region)
Example #6
Source File: status.py From GitSavvy with MIT License | 5 votes |
def get_available_regions(self): return ( self.view.find_by_selector("gitsavvy.gotosymbol") + self.view.find_all("Your working directory is clean", sublime.LITERAL) )
Example #7
Source File: MultiEditUtils.py From Sublime-MultiEditUtils with MIT License | 4 votes |
def run(self, edit, case=True, word=False, ignore_comments=False, expand=True): view = self.view newRegions = [] # filter selections in order to exclude duplicates since it can hang # Sublime if search is performed on dozens of selections, this doesn't # happen with built-in command because it works on a single selection initial = [sel for sel in view.sel()] regions, substrings = [], [] for region in view.sel(): if expand and region.empty(): # if expanding substring will be the word region = view.word(region.a) # add the region since nothing is selected yet view.sel().add(region) # filter by substring (word or not) substr = view.substr(region) if substr and substr not in substrings: regions.append(region) substrings.append(substr) view.sel().clear() if regions: for region in regions: view.sel().add(region) else: view.window().status_message("Multi Find All: nothing selected") for sel in initial: view.sel().add(sel) return selected_words = [view.substr(view.word(sel)).lower() for sel in view.sel()] for region in view.sel(): substr = view.substr(region) if case: for region in view.find_all(substr, sublime.LITERAL): newRegions.append(region) else: for region in view.find_all(substr, sublime.LITERAL | sublime.IGNORECASE): newRegions.append(region) if word: deleted = [region for region in newRegions if view.substr(view.word(region)).lower() not in selected_words] newRegions = [region for region in newRegions if region not in deleted] if ignore_comments: deleted = [region for region in newRegions if re.search(r'\bcomment\b', view.scope_name(region.a))] newRegions = [region for region in newRegions if region not in deleted] for region in newRegions: view.sel().add(region)