Beispiel #1
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['src'] = av.substr(sublime.Region(0, av.size()))

    mg9.acall('play', a, cb)
Beispiel #2
0
def cmd_9(view, edit, args, wd, r):
	if len(args) == 1 and args[0] == "play":
		dmn = '%s: 9 play' % DOMAIN
		cid = '9play-%s' % uuid.uuid4()
		def cancel():
			mg9.acall('kill', {'cid': cid}, None)

		tid = gs.begin(dmn, "9 play", set_status=False, cancel=cancel)

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

			def f():
				gs.end(tid)
				view.insert(edit, r.end(), '\n%s' % out)
				view.run_command('gs_commander_init')
			sublime.set_timeout(f, 0)

		a = {
			'cid': cid,
			'env': gs.env(),
			'dir': wd,
		}
		av = sublime.active_window().active_view()
		if av and not av.file_name() and gs.is_go_source_view(av, False):
			a['src'] = av.substr(sublime.Region(0, av.size()))

		mg9.acall('play', a, cb)
	else:
		view.insert(edit, r.end(), ('Invalid args %s' % args))
		view.run_command('gs_commander_init')
def cmd_9(view, edit, args, wd, rkey):
	if len(args) == 0 or args[0] not in ('play', 'build'):
		push_output(view, rkey, ('9: invalid args %s' % args))
		return

	subcmd = args[0]
	cid, cb = _9_begin_call(subcmd, view, edit, args, wd, rkey)
	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:
				basedir = gs.basedir_or_cwd(fn)
				for v in win.views():
					try:
						fn = v.file_name()
						if fn and v.is_dirty() and fn.endswith('.go') and os.path.dirname(fn) == basedir:
							v.run_command('gs_fmt_save')
					except Exception:
						gs.println(gs.traceback())
			else:
				if gs.is_go_source_view(av, False):
					a['src'] = av.substr(sublime.Region(0, av.size()))

	mg9.acall('play', a, cb)
Beispiel #4
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['src'] = av.substr(sublime.Region(0, av.size()))

	mg9.acall('play', a, cb)
Beispiel #5
0
def cmd_go(view, edit, args, wd, rkey):
	cid, cb = _9_begin_call('go', view, edit, args, wd, rkey, '')
	a = {
		'cid': cid,
		'env': gs.env(),
		'cwd': wd,
		'cmd': {
			'name': 'go',
			'args': args,
		}
	}
	mg9.acall('sh', a, cb)
def cmd_go(view, edit, args, wd, rkey):
    cid, cb = _9_begin_call('go', view, edit, args, wd, rkey, '')
    a = {
        'cid': cid,
        'env': gs.env(),
        'cwd': wd,
        'cmd': {
            'name': 'go',
            'args': args,
        }
    }
    mg9.acall('sh', a, cb)
Beispiel #7
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,
        }
    }
    mg9.acall('sh', a, cb)
Beispiel #8
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,
		}
	}
	mg9.acall('sh', a, 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': 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:
                basedir = gs.basedir_or_cwd(fn)
                for v in win.views():
                    try:
                        fn = v.file_name()
                        if fn and v.is_dirty() and fn.endswith(
                                '.go') and os.path.dirname(fn) == basedir:
                            v.run_command('gs_fmt_save')
                    except Exception:
                        gs.println(gs.traceback())
            else:
                if gs.is_go_source_view(av, False):
                    a['src'] = av.substr(sublime.Region(0, av.size()))

    mg9.acall('play', a, cb)
def _9_begin_call(name, view, edit, args, wd, rkey):
	dmn = '%s: 9 %s' % (DOMAIN, name)
	msg = '[ %s ] # 9 %s' % (wd, ' '.join(args))
	cid = '9%s-%s' % (name, uuid.uuid4())
	tid = gs.begin(dmn, msg, set_status=False, cancel=lambda: mg9.acall('kill', {'cid': cid}, None))

	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 _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))

	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
Beispiel #12
0
		def cancel():
			mg9.acall('kill', {'cid': cid}, None)