def run(self, view, args): if len(args) == 0: sublime.messageBox("You didn't select anything.") else: name = args[0] url = packagedownloader.packageRoot() + name + ".sublime-package" answer = sublime.questionBox("Download '%s'?" % url) if answer: localPackageRoot = packagedownloader.packageDir() if localPackageRoot == None: sublime.messageBox("Could not find package folder. Sorry.") return destination = "c:/downloaded-by-sublime-text-package-downloader.sublime-package" packagedownloader.downloadSinglePackage(url, destination) packageFolder = os.path.join(localPackageRoot, name) existsAlready = "" if os.path.exists(packageFolder): existsAlready = " This folder already exists and will be replaced." unpackAnswer = sublime.questionBox( "Download succeeded. Do you wish to install in '%s'?%s " % (packageFolder, existsAlready) ) if not unpackAnswer: os.remove(destination) return self.expandPackage(destination, packageFolder) os.remove(destination) sublime.messageBox("Unpacked to %s" % packageFolder)
def run(self, view, args): # get the wikiname under the cursor. for s in view.sel(): # try to find a phrase in square brackets name = self.phraseInSquareBrackets(view, s) if name == None: # nothing in square brackets -- try a word name = self.wordUnderCursor(view, s) if name == None: # total failure! sublime.statusMessage("No suitable hyperlink found. Try square brackets around the text.") return candidateFileName = os.path.split(view.fileName())[0] + "\\" + name + "." + self.wikiFileExtension print candidateFileName if os.access(candidateFileName, os.R_OK): sublime.statusMessage("Opening page: %s" % candidateFileName) view.window().openFile(candidateFileName) else: if sublime.questionBox("Do you want to create %s" % candidateFileName): self.ensureFile(candidateFileName) sublime.statusMessage("No page at %s: starting new file" % candidateFileName) view.window().openFile(candidateFileName)