def run(self, edit):
        v = self.view
        pos = v.sel()[0].begin()
        inscope = lambda p: v.score_selector(p, 'path.gscommander') > 0
        if not inscope(pos):
            pos -= 1
            if not inscope(pos):
                return

        path = v.substr(v.extract_scope(pos))
        if URL_PATH_PAT.match(path):
            try:
                if not URL_SCHEME_PAT.match(path):
                    path = 'http://%s' % path
                gs.notice(DOMAIN, 'open url: %s' % path)
                webbrowser.open_new_tab(path)
            except Exception:
                gs.notice(DOMAIN, gs.traceback())
        else:
            wd = v.settings().get('gscommander.wd') or active_wd()
            m = SPLIT_FN_POS_PAT.match(path)
            path = gs.apath((m.group(1) if m else path), wd)
            row = max(0, int(m.group(2)) - 1 if (m and m.group(2)) else 0)
            col = max(0, int(m.group(3)) - 1 if (m and m.group(3)) else 0)

            if os.path.exists(path):
                gs.focus(path, row, col, win=self.view.window())
            else:
                gs.notice(DOMAIN, "Invalid path `%s'" % path)
Beispiel #2
0
    def run(self, edit):
        v = self.view
        pos = gs.sel(v).begin()
        inscope = lambda p: v.score_selector(p, 'path.9o') > 0
        if not inscope(pos):
            pos -= 1
            if not inscope(pos):
                return

        path = v.substr(v.extract_scope(pos))
        if URL_PATH_PAT.match(path):
            if path.lower().startswith('gs.packages://'):
                path = os.path.join(sublime.packages_path(), path[14:])
            else:
                try:
                    if not URL_SCHEME_PAT.match(path):
                        path = 'http://%s' % path
                    gs.notify(DOMAIN, 'open url: %s' % path)
                    webbrowser.open_new_tab(path)
                except Exception:
                    gs.error_traceback(DOMAIN)

                return

        wd = v.settings().get('9o.wd') or active_wd()
        m = SPLIT_FN_POS_PAT.match(path)
        path = gs.apath((m.group(1) if m else path), wd)
        row = max(0, int(m.group(2)) - 1 if (m and m.group(2)) else 0)
        col = max(0, int(m.group(3)) - 1 if (m and m.group(3)) else 0)

        if os.path.exists(path):
            gs.focus(path, row, col, win=self.view.window())
        else:
            gs.notify(DOMAIN, "Invalid path `%s'" % path)
Beispiel #3
0
	def run(self, edit):
		v = self.view
		pos = gs.sel(v).begin()
		inscope = lambda p: v.score_selector(p, 'path.9o') > 0
		if not inscope(pos):
			pos -= 1
			if not inscope(pos):
				return

		path = v.substr(v.extract_scope(pos))
		if URL_PATH_PAT.match(path):
			try:
				if not URL_SCHEME_PAT.match(path):
					path = 'http://%s' % path
				gs.notice(DOMAIN, 'open url: %s' % path)
				webbrowser.open_new_tab(path)
			except Exception:
				gs.notice(DOMAIN, gs.traceback())
		else:
			wd = v.settings().get('9o.wd') or active_wd()
			m = SPLIT_FN_POS_PAT.match(path)
			path = gs.apath((m.group(1) if m else path), wd)
			row = max(0, int(m.group(2))-1 if (m and m.group(2)) else 0)
			col = max(0, int(m.group(3))-1 if (m and m.group(3)) else 0)

			if os.path.exists(path):
				gs.focus(path, row, col, win=self.view.window())
			else:
				gs.notice(DOMAIN, "Invalid path `%s'" % path)
Beispiel #4
0
	def cb():
		aso = gs.aso()
		old_rev = aso.get('changelog.rev', '')
		if REV > old_rev:
			aso.set('changelog.rev', REV)
			gs.save_aso()
			gs.focus(CHANGELOG_FN)
		def f(docs, err):
			doc = ''
			if err:
				self.show_output('// Error: %s' % err)
			elif docs:
				if mode == "goto":
					fn = ''
					flags = 0
					if len(docs) > 0:
						d = docs[0]
						fn = d.get('fn', '')
						row = d.get('row', 0)
						col = d.get('col', 0)
						if fn:
							gs.println('opening %s:%s:%s' % (fn, row, col))
							gs.focus(fn, row, col)
							return
					self.show_output("%s: cannot find definition" % DOMAIN)
				elif mode == "hint":
					s = []
					for d in docs:
						name = d.get('name', '')
						if name:
							kind = d.get('kind', '')
							pkg = d.get('pkg', '')
							if pkg:
								name = '%s.%s' % (pkg, name)
							src = d.get('src', '')
							if src:
								src = '\n//\n%s' % src
							doc = '// %s %s%s' % (name, kind, src)

						s.append(doc)
					doc = '\n\n\n'.join(s).strip()
			self.show_output(doc or "// %s: no docs found" % DOMAIN)
		def cb(i, win):
			if i >= 0:
				fn = m[ents[i]]
				if os.path.isdir(fn):
					win.run_command("gs_browse_files", {"dir": fn})
				else:
					gs.focus(fn, 0, 0, win)
Beispiel #7
0
        def f(docs, err):
            doc = ""
            if err:
                self.show_output("// Error: %s" % err)
            elif docs:
                if mode == "goto":
                    fn = ""
                    flags = 0
                    if len(docs) > 0:
                        d = docs[0]
                        fn = d.get("fn", "")
                        row = d.get("row", 0)
                        col = d.get("col", 0)
                        if fn:
                            gs.println("opening %s:%s:%s" % (fn, row, col))
                            gs.focus(fn, row, col)
                            return
                    self.show_output("%s: cannot find definition" % DOMAIN)
                elif mode == "hint":
                    s = []
                    for d in docs:
                        name = d.get("name", "")
                        if name:
                            kind = d.get("kind", "")
                            pkg = d.get("pkg", "")
                            if pkg:
                                name = "%s.%s" % (pkg, name)
                            src = d.get("src", "")
                            if src:
                                src = "\n//\n%s" % src
                            doc = "// %s %s%s" % (name, kind, src)

                        s.append(doc)
                    doc = "\n\n\n".join(s).strip()
            self.show_output(doc or "// %s: no docs found" % DOMAIN)
Beispiel #8
0
 def cb():
     aso = gs.aso()
     old_rev = aso.get('changelog.rev', '')
     if REV > old_rev:
         aso.set('changelog.rev', REV)
         gs.save_aso()
         gs.focus(CHANGELOG_FN)
Beispiel #9
0
def cmd_help(view, edit, args, wd, rkey):
    gs.focus(gs.dist_path('9o.md'))
    push_output(view, rkey, '')
Beispiel #10
0
def cmd_help(view, edit, args, wd, rkey):
	gs.focus(gs.dist_path('9o.md'))
	push_output(view, rkey, '')
Beispiel #11
0
	def goto(self, loc):
		gs.focus(loc.fn, loc.row, loc.col)
Beispiel #12
0
 def goto(self, loc):
     gs.focus(loc.fn, loc.row, loc.col)
			def cb(i, win):
				if i >= 0:
					d = decls[i]
					gs.focus(d['fn'], d['row'], d['col'], win)
Beispiel #14
0
 def cb(i):
     if i >= 0:
         d = decls[i]
         gs.focus(d["fn"], d["row"], d["col"], win)