示例#1
0
def _9_begin_call(name, view, edit, args, wd, rkey, cid):
	dmn = '%s: 9 %s' % (DOMAIN, name)
	msg = '[ %s ] # 9 %s' % (gs.simple_fn(wd), ' '.join(args))
	if not cid:
		cid = '9%s-%s' % (name, uuid.uuid4())
	tid = gs.begin(dmn, msg, set_status=False, cancel=lambda: mg9.acall('kill', {'cid': cid}, None))
	tid_alias['%s-%s' % (name, wd)] = tid

	def cb(res, err):
		out = '\n'.join(s for s in (res.get('out'), res.get('err'), err) if s)

		tmp_fn = res.get('tmpFn')
		fn = res.get('fn')
		if fn and tmp_fn:
			bfn = os.path.basename(tmp_fn)
			repls = [
				'./%s' % bfn,
				'.\\%s' % bfn,
				tmp_fn,
			]
			for s in repls:
				out = out.replace(s, fn)

		def f():
			gs.end(tid)
			push_output(view, rkey, out, hourglass_repl='| done: %s' % res.get('dur', ''))

		sublime.set_timeout(f, 0)

	return cid, cb
示例#2
0
def _9_begin_call(name, view, edit, args, wd, rkey, cid):
    dmn = "%s: 9 %s" % (DOMAIN, name)
    msg = "[ %s ] # 9 %s" % (gs.simple_fn(wd), " ".join(args))
    if not cid:
        cid = "9%s-%s" % (name, uuid.uuid4())
    tid = gs.begin(dmn, msg, set_status=False, cancel=lambda: mg9.acall("kill", {"cid": cid}, None))
    tid_alias["%s-%s" % (name, wd)] = tid

    def cb(res, err):
        out = "\n".join(s for s in (res.get("out"), res.get("err"), err) if s)

        tmp_fn = res.get("tmpFn")
        fn = res.get("fn")
        if fn and tmp_fn:
            bfn = os.path.basename(tmp_fn)
            repls = ["./%s" % bfn, ".\\%s" % bfn, tmp_fn]
            for s in repls:
                out = out.replace(s, fn)

        def f():
            gs.end(tid)
            push_output(view, rkey, out, hourglass_repl="| done: %s" % res.get("dur", ""))

        sublime.set_timeout(f, 0)

    return cid, cb
示例#3
0
    def run(self, edit, wd=None):
        v = self.view
        vs = v.settings()

        if not wd:
            wd = vs.get('9o.wd', active_wd(win=v.window()))

        was_empty = v.size() == 0
        s = '[ %s ] # \n' % gs.simple_fn(wd)

        if was_empty:
            v.insert(
                edit, 0,
                'GoSublime %s 9o: type `help` for help and command documentation\n\n'
                % about.VERSION)

        if was_empty or v.substr(v.size() - 1) == '\n':
            v.insert(edit, v.size(), s)
        else:
            v.insert(edit, v.size(), '\n' + s)

        v.sel().clear()
        n = v.size() - 1
        v.sel().add(sublime.Region(n, n))
        vs.set("9o.wd", wd)
        vs.set("rulers", [])
        vs.set("fold_buttons", True)
        vs.set("fade_fold_buttons", False)
        vs.set("gutter", True)
        vs.set("margin", 0)
        # pad mostly so the completion menu shows on the first line
        vs.set("line_padding_top", 1)
        vs.set("line_padding_bottom", 1)
        vs.set("tab_size", 2)
        vs.set("word_wrap", True)
        vs.set("indent_subsequent_lines", True)
        vs.set("line_numbers", False)
        vs.set("auto_complete", True)
        vs.set("auto_complete_selector", "text")
        vs.set("highlight_line", True)
        vs.set("draw_indent_guides", True)
        vs.set("scroll_past_end", True)
        vs.set("indent_guide_options", ["draw_normal", "draw_active"])
        vs.set("word_separators", "./\\()\"'-:,.;<>~!@#$%&*|+=[]{}`~?")

        color_scheme = gs.setting("9o_color_scheme", "")
        if color_scheme:
            if color_scheme == "default":
                vs.erase("color_scheme")
            else:
                vs.set("color_scheme", color_scheme)
        else:
            vs.set("color_scheme", "")

        v.set_syntax_file(gs.tm_path('9o'))

        if was_empty:
            v.show(0)
        else:
            v.show(v.size() - 1)
示例#4
0
def _9_begin_call(name, view, edit, args, wd, rkey, cid):
	dmn = '%s: 9 %s' % (DOMAIN, name)
	msg = '[ %s ] # 9 %s' % (gs.simple_fn(wd), ' '.join(args))
	if not cid:
		cid = '9%s-%s' % (name, uuid.uuid4())
	tid = gs.begin(dmn, msg, set_status=False, cancel=lambda: mg9.acall('kill', {'cid': cid}, None))
	tid_alias['%s-%s' % (name, wd)] = tid

	def cb(res, err):
		out = '\n'.join(s for s in (res.get('out'), res.get('err'), err) if s)

		tmp_fn = res.get('tmpFn')
		fn = res.get('fn')
		if fn and tmp_fn:
			bfn = os.path.basename(tmp_fn)
			repls = [
				'./%s' % bfn,
				'.\\%s' % bfn,
				tmp_fn,
			]
			for s in repls:
				out = out.replace(s, fn)

		def f():
			gs.end(tid)
			push_output(view, rkey, out, hourglass_repl='| done: %s' % res.get('dur', ''))

		sublime.set_timeout(f, 0)

	return cid, cb
示例#5
0
文件: gs9o.py 项目: slene/GoSublime
	def run(self, edit, wd=None):
		v = self.view
		vs = v.settings()

		if not wd:
			wd = vs.get('9o.wd', active_wd(win=v.window()))

		was_empty = v.size() == 0
		s = '[ %s ] # \n' % gs.simple_fn(wd)

		if was_empty:
			v.insert(edit, 0, 'GoSublime %s 9o: type `help` for help and command documentation\n\n' % about.VERSION)

		if was_empty or v.substr(v.size()-1) == '\n':
			v.insert(edit, v.size(), s)
		else:
			v.insert(edit, v.size(), '\n'+s)

		v.sel().clear()
		n = v.size()-1
		v.sel().add(sublime.Region(n, n))
		vs.set("9o.wd", wd)
		vs.set("rulers", [])
		vs.set("fold_buttons", True)
		vs.set("fade_fold_buttons", False)
		vs.set("gutter", True)
		vs.set("margin", 0)
		# pad mostly so the completion menu shows on the first line
		vs.set("line_padding_top", 1)
		vs.set("line_padding_bottom", 1)
		vs.set("tab_size", 2)
		vs.set("word_wrap", True)
		vs.set("indent_subsequent_lines", True)
		vs.set("line_numbers", False)
		vs.set("auto_complete", True)
		vs.set("auto_complete_selector", "text")
		vs.set("highlight_line", True)
		vs.set("draw_indent_guides", True)
		vs.set("scroll_past_end", True)
		vs.set("indent_guide_options", ["draw_normal", "draw_active"])
		vs.set("word_separators", "./\\()\"'-:,.;<>~!@#$%&*|+=[]{}`~?")

		color_scheme = gs.setting("9o_color_scheme", "")
		if color_scheme:
			if color_scheme == "default":
				vs.erase("color_scheme")
			else:
				vs.set("color_scheme", color_scheme)
		else:
			vs.set("color_scheme", "")

		v.set_syntax_file(gs.tm_path('9o'))

		if was_empty:
			v.show(0)
		else:
			v.show(v.size()-1)

		os.chdir(wd)
示例#6
0
	def run(self, edit, wd=None):
		v = self.view
		vs = v.settings()

		if not wd:
			wd = vs.get('9o.wd', active_wd(win=v.window()))

		wd = gs.abspath(wd)
		was_empty = v.size() == 0
		s = '[ %s ] # \n' % gs.simple_fn(wd).replace('#', '~')

		if was_empty:
			v.insert(edit, 0, 'GoSublime %s 9o: type `help` for help and command documentation\n\n%s' % (about.VERSION, s))
		else:
			v.insert(edit, v.size(), '\n'+s)

		v.sel().clear()
		n = v.size()-1
		v.sel().add(sublime.Region(n, n))

		opts = {
			"rulers": [],
			"fold_buttons": True,
			"fade_fold_buttons": False,
			"gutter": True,
			"margin": 0,
			# pad mostly so the completion menu shows on the first line
			"line_padding_top": 1,
			"line_padding_bottom": 1,
			"tab_size": 2,
			"word_wrap": True,
			"indent_subsequent_lines": True,
			"line_numbers": False,
			"auto_complete": True,
			"auto_complete_selector": "text",
			"highlight_line": True,
			"draw_indent_guides": True,
			"scroll_past_end": True,
			"indent_guide_options": ["draw_normal", "draw_active"],
			"word_separators": WORD_SEPARATORS,
		}
		opts.update(cfg.nineo_settings)

		for opt in opts:
			vs.set(opt, opts[opt])

		vs.set("9o", True)
		vs.set("9o.wd", wd)

		color_scheme = cfg.nineo_color_scheme
		if color_scheme:
			if color_scheme == "default":
				vs.erase("color_scheme")
			else:
				vs.set("color_scheme", color_scheme)
		else:
			vs.set("color_scheme", "")

		v.set_syntax_file(gs.tm_path('9o'))

		if was_empty:
			v.show(0)
		else:
			v.show(v.size()-1)

		os.chdir(wd)
示例#7
0
    def run(self, edit, wd=None):
        v = self.view
        vs = v.settings()

        if not wd:
            wd = vs.get('9o.wd', active_wd(win=v.window()))

        wd = gs.abspath(wd)
        was_empty = v.size() == 0
        s = '[ %s ] # \n' % gs.simple_fn(wd).replace('#', '~')

        if was_empty:
            v.insert(
                edit, 0,
                'GoSublime %s 9o: type `help` for help and command documentation\n\n%s'
                % (about.VERSION, s))
        else:
            v.insert(edit, v.size(), '\n' + s)

        v.sel().clear()
        n = v.size() - 1
        v.sel().add(sublime.Region(n, n))

        opts = {
            "rulers": [],
            "fold_buttons": True,
            "fade_fold_buttons": False,
            "gutter": True,
            "margin": 0,
            # pad mostly so the completion menu shows on the first line
            "line_padding_top": 1,
            "line_padding_bottom": 1,
            "tab_size": 2,
            "word_wrap": True,
            "indent_subsequent_lines": True,
            "line_numbers": False,
            "auto_complete": True,
            "auto_complete_selector": "text",
            "highlight_line": True,
            "draw_indent_guides": True,
            "scroll_past_end": True,
            "indent_guide_options": ["draw_normal", "draw_active"],
            "word_separators": WORD_SEPARATORS,
        }
        opts.update(cfg.nineo_settings)

        for opt in opts:
            vs.set(opt, opts[opt])

        vs.set("9o", True)
        vs.set("9o.wd", wd)

        color_scheme = cfg.nineo_color_scheme
        if color_scheme:
            if color_scheme == "default":
                vs.erase("color_scheme")
            else:
                vs.set("color_scheme", color_scheme)
        else:
            vs.set("color_scheme", "")

        v.set_syntax_file(gs.tm_path('9o'))

        if was_empty:
            v.show(0)
        else:
            v.show(v.size() - 1)

        os.chdir(wd)
示例#8
0
    def run(self, edit, wd=None):
        v = self.view
        vs = v.settings()

        if not wd:
            wd = vs.get("9o.wd", active_wd(win=v.window()))

        was_empty = v.size() == 0
        s = "[ %s ] # \n" % gs.simple_fn(wd).replace("#", "~")

        if was_empty:
            v.insert(
                edit,
                0,
                "GoSublime %s 9o: type `help` for help and command documentation\n\n"
                % about.VERSION,
            )

        if was_empty or v.substr(v.size() - 1) == "\n":
            v.insert(edit, v.size(), s)
        else:
            v.insert(edit, v.size(), "\n" + s)

        v.sel().clear()
        n = v.size() - 1
        v.sel().add(sublime.Region(n, n))

        opts = {
            "rulers": [],
            "fold_buttons": True,
            "fade_fold_buttons": False,
            "gutter": True,
            "margin": 0,
            # pad mostly so the completion menu shows on the first line
            "line_padding_top": 1,
            "line_padding_bottom": 1,
            "tab_size": 2,
            "word_wrap": True,
            "indent_subsequent_lines": True,
            "line_numbers": False,
            "auto_complete": True,
            "auto_complete_selector": "text",
            "highlight_line": True,
            "draw_indent_guides": True,
            "scroll_past_end": True,
            "indent_guide_options": ["draw_normal", "draw_active"],
            "word_separators": "./\\()\"'-:,.;<>~!@#$%&*|+=[]{}`~?",
        }
        opts.update(gs.setting("9o_settings"))

        for opt in opts:
            vs.set(opt, opts[opt])

        vs.set("9o", True)
        vs.set("9o.wd", wd)

        color_scheme = gs.setting("9o_color_scheme", "")
        if color_scheme:
            if color_scheme == "default":
                vs.erase("color_scheme")
            else:
                vs.set("color_scheme", color_scheme)
        else:
            vs.set("color_scheme", "")

        v.set_syntax_file(gs.tm_path("9o"))

        if was_empty:
            v.show(0)
        else:
            v.show(v.size() - 1)

        os.chdir(wd)