def home(self): """Navigate from home.""" home = qualify_settings(sublime.load_settings(FUZZY_SETTINGS), "home", "", expanduser) home = get_root_path( ) if not path.exists(home) or not path.isdir(home) else home self.window.run_command("fuzzy_file_nav", {"start": home})
def on_modified(self, view): """Monitor content change in the panel and take actions accordingly.""" if (FuzzyFileNavCommand.active and FuzzyFileNavCommand.view is not None and FuzzyFileNavCommand.view.id() == view.id()): sel = view.sel()[0] win = view.window() line_text = view.substr(view.line(sel)) FuzzyPathCompleteCommand.update_autocomplete(line_text) regex = CMD_WIN if PLATFORM == "windows" else CMD_NIX m = re.match(regex, line_text) if m: if m.group(1): # Go Home FuzzyFileNavCommand.fuzzy_reload = True home = qualify_settings( sublime.load_settings(FUZZY_SETTINGS), "home", "", expanduser) home = get_root_path() if not path.exists( home) or not path.isdir(home) else home win.run_command("hide_overlay") win.run_command("fuzzy_file_nav", {"start": home}) elif m.group(2): # Back a directory FuzzyFileNavCommand.fuzzy_reload = True win.run_command("hide_overlay") win.run_command( "fuzzy_file_nav", {"start": back_dir(FuzzyFileNavCommand.cwd)}) elif m.group(3): # Go to root of drive/computer if PLATFORM == "windows" and re.match( WIN_DRIVE, line_text): if path.exists(line_text): new_path = line_text.upper() else: new_path = back_to_root(FuzzyFileNavCommand.cwd) FuzzyFileNavCommand.fuzzy_reload = True win.run_command("hide_overlay") win.run_command("fuzzy_file_nav", {"start": new_path}) elif m.group(4): # Load folder new_path = path.join(FuzzyFileNavCommand.cwd, m.group(4)) if path.exists(new_path) and path.isdir(new_path): FuzzyFileNavCommand.fuzzy_reload = True win.run_command("hide_overlay") win.run_command("fuzzy_file_nav", {"start": new_path})
def run(self): if FuzzyFileNavCommand.active: self.window.run_command("hide_overlay") self.display = [] # Search through bookmarks bookmarks = sublime.load_settings(FUZZY_SETTINGS).get("bookmarks", []) for bm in bookmarks: # Only show bookmarks that are for this host and/or platform target = qualify_settings(bm, "path", None, expanduser) # Make sure bookmards point to valid locations if target is not None and ((path.exists(target) and path.isdir(target)) or (PLATFORM == "windows" and target == "")): self.display.append([bm.get("name", target), target]) if len(self.display) > 0: # Display bookmarks if valid ones were found self.window.run_command("hide_overlay") FuzzyFileNavCommand.reset() self.window.show_quick_panel(self.display, self.check_selection)
def on_modified(self, view): """Monitor content change in the panel and take actions accordingly.""" if ( FuzzyFileNavCommand.active and FuzzyFileNavCommand.view is not None and FuzzyFileNavCommand.view.id() == view.id() ): sel = view.sel()[0] win = view.window() line_text = view.substr(view.line(sel)) FuzzyPathCompleteCommand.update_autocomplete(line_text) regex = CMD_WIN if PLATFORM == "windows" else CMD_NIX m = re.match(regex, line_text) if m: if m.group(1): # Go Home FuzzyFileNavCommand.fuzzy_reload = True home = qualify_settings(sublime.load_settings(FUZZY_SETTINGS), "home", "", expanduser) home = get_root_path() if not path.exists(home) or not path.isdir(home) else home win.run_command("hide_overlay") win.run_command("fuzzy_file_nav", {"start": home}) elif m.group(2): # Back a directory FuzzyFileNavCommand.fuzzy_reload = True win.run_command("hide_overlay") win.run_command("fuzzy_file_nav", {"start": back_dir(FuzzyFileNavCommand.cwd)}) elif m.group(3): # Go to root of drive/computer if PLATFORM == "windows" and re.match(WIN_DRIVE, line_text): if path.exists(line_text): new_path = line_text.upper() else: new_path = back_to_root(FuzzyFileNavCommand.cwd) FuzzyFileNavCommand.fuzzy_reload = True win.run_command("hide_overlay") win.run_command("fuzzy_file_nav", {"start": new_path}) elif m.group(4): # Load folder new_path = path.join(FuzzyFileNavCommand.cwd, m.group(4)) if path.exists(new_path) and path.isdir(new_path): FuzzyFileNavCommand.fuzzy_reload = True win.run_command("hide_overlay") win.run_command("fuzzy_file_nav", {"start": new_path})
def run(self): """Run command.""" if FuzzyFileNavCommand.active: self.window.run_command("hide_overlay") self.display = [] # Search through bookmarks bookmarks = sublime.load_settings(FUZZY_SETTINGS).get("bookmarks", []) for bm in bookmarks: # Only show bookmarks that are for this host and/or platform target = qualify_settings(bm, "path", None, expanduser) # Make sure bookmards point to valid locations if (target is not None and ((path.exists(target) and path.isdir(target)) or (PLATFORM == "windows" and target == ""))): self.display.append([bm.get("name", target), target]) if len(self.display) > 0: # Display bookmarks if valid ones were found self.window.run_command("hide_overlay") FuzzyFileNavCommand.reset() self.window.show_quick_panel(self.display, self.check_selection)
def home(self): """Navigate from home.""" home = qualify_settings(sublime.load_settings(FUZZY_SETTINGS), "home", "", expanduser) home = get_root_path() if not path.exists(home) or not path.isdir(home) else home self.window.run_command("fuzzy_file_nav", {"start": home})