def run(self, edit): if gs.setting("comp_lint_enabled") is not True: return fn = self.view.file_name() fn = os.path.abspath(fn) if fn: file_refs[fn] = FileRef(self.view) mg9.acall("comp_lint", {"filename": fn}, do_comp_lint_callback)
def cmd_cancel_replay(view, edit, args, wd, rkey): cid = '' av = None win = view.window() if win is not None: av = win.active_view() if av is not None and not av.file_name(): cid = '9replayv-%s' % av.id() if not cid: cid = '9replay-%s' % wd mg9.acall('kill', {'cid': cid}, None) push_output(view, rkey, '')
def cmd_cancel_replay(view, edit, args, wd, rkey): cid = "" av = None win = view.window() if win is not None: av = win.active_view() if av is not None and not av.file_name(): cid = "9replayv-%s" % av.id() if not cid: cid = "9replay-%s" % wd mg9.acall("kill", {"cid": cid}, None) push_output(view, rkey, "")
def cmd_9(view, edit, args, wd, rkey): if len(args) == 0 or args[0] not in ("run", "replay", "build"): push_output(view, rkey, ("9: invalid args %s" % args)) return subcmd = args[0] cid = "" if subcmd == "replay": cid = "9replay-%s" % wd cid, cb = _9_begin_call(subcmd, view, edit, args, wd, rkey, cid) a = {"cid": cid, "env": sh.env(), "dir": wd, "args": args[1:], "build_only": (subcmd == "build")} win = view.window() if win is not None: av = win.active_view() if av is not None: fn = av.file_name() if fn: _save_all(win, wd) else: if gs.is_go_source_view(av, False): a["fn"] = gs.view_fn(av) a["src"] = av.substr(sublime.Region(0, av.size())) sublime.set_timeout(lambda: mg9.acall("play", a, cb), 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
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
def cmd_9(view, edit, args, wd, rkey): if len(args) == 0 or args[0] not in ('run', 'replay', 'build'): push_output(view, rkey, ('9: invalid args %s' % args)) return subcmd = args[0] cid = '' if subcmd == 'replay': cid = '9replay-%s' % wd cid, cb = _9_begin_call(subcmd, view, edit, args, wd, rkey, cid) a = { 'cid': cid, 'env': sh.env(), 'dir': wd, 'args': args[1:], 'build_only': (subcmd == 'build'), } win = view.window() if win is not None: av = win.active_view() if av is not None: fn = av.file_name() if fn: _save_all(win, wd) else: if gs.is_go_source_view(av, False): a['fn'] = gs.view_fn(av) a['src'] = av.substr(sublime.Region(0, av.size())) sublime.set_timeout(lambda: mg9.acall('play', a, cb), 0)
def cmd_9(view, edit, args, wd, rkey): if len(args) == 0 or args[0] not in ('run', 'replay', 'build'): push_output(view, rkey, ('9: invalid args %s' % args)) return subcmd = args[0] cid = '' if subcmd == 'replay': cid = '9replay-%s' % wd cid, cb = _9_begin_call(subcmd, view, edit, args, wd, rkey, cid) a = { 'cid': cid, 'env': gs.env(), 'dir': wd, 'args': args[1:], 'build_only': (subcmd == 'build'), } win = view.window() if win is not None: av = win.active_view() if av is not None: fn = av.file_name() if fn: _save_all(win, wd) else: if gs.is_go_source_view(av, False): a['fn'] = gs.view_fn(av) a['src'] = av.substr(sublime.Region(0, av.size())) sublime.set_timeout(lambda: mg9.acall('play', a, cb), 0)
def cmd_sh(view, edit, args, wd, rkey): cid, cb = _9_begin_call("sh", view, edit, args, wd, rkey, "") a = { "cid": cid, "env": sh.env(), "cwd": wd, "cmd": {"name": args[0], "args": args[1:]}, } sublime.set_timeout(lambda: mg9.acall("sh", a, cb), 0)
def cmd_sh(view, edit, args, wd, rkey): cid, cb = _9_begin_call('sh', view, edit, args, wd, rkey, '') a = { 'cid': cid, 'env': sh.env(), 'cwd': wd, 'cmd': { 'name': args[0], 'args': args[1:], } } sublime.set_timeout(lambda: mg9.acall('sh', a, cb), 0)
def cmd_go(view, edit, args, wd, rkey): _save_all(view.window(), wd) cid, cb = _9_begin_call('go', view, edit, args, wd, rkey, '9go-%s' % wd) a = { 'cid': cid, 'env': sh.env(), 'cwd': wd, 'cmd': { 'name': 'go', 'args': args, } } sublime.set_timeout(lambda: mg9.acall('sh', a, cb), 0)
def cmd_go(view, edit, args, wd, rkey): _save_all(view.window(), wd) cid, cb = _9_begin_call('go', view, edit, args, wd, rkey, '9go-%s' % wd) a = { 'cid': cid, 'env': gs.env(), 'cwd': wd, 'cmd': { 'name': 'go', 'args': args, } } sublime.set_timeout(lambda: mg9.acall('sh', a, cb), 0)
def _9_begin_call(name, view, edit, args, wd, rkey, cid): dmn = '%s: 9 %s' % (DOMAIN, name) msg = '[ %s ] # 9 %s' % (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) 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
def cmd_go(view, edit, args, wd, rkey): _save_all(view.window(), wd) cid, cb = _9_begin_call("go", view, edit, args, wd, rkey, "9go-%s" % wd) a = {"cid": cid, "env": sh.env(), "cwd": wd, "cmd": {"name": "go", "args": args}} sublime.set_timeout(lambda: mg9.acall("sh", a, cb), 0)