예제 #1
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)
예제 #2
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)
예제 #3
0
		def cb():
			aso = gs.aso()
			old_rev = aso.get('changelog.rev', '')
			new_rev = changes[0][0]
			if new_rev > old_rev:
				aso.set('changelog.rev', new_rev)
				gs.save_aso()

				new_changes = [
					'GoSublime: Recent Updates (you may need to restart Sublime Text for changes to take effect)',
					'------------------------------------------------------------------------------------------',
				]

				for change in changes:
					rev, msg = change
					if rev > old_rev:
						new_changes.append('\n%s\n\t%s' % (rev, msg))
					else:
						break

				new_changes.append('\nSee %s for the full CHANGELOG\n' % changelog_fn)
				new_changes = '\n'.join(new_changes)
				gs.show_output(DOMAIN, new_changes, print_output=False)
예제 #4
0
    def run(self, edit, save_hist=False):
        view = self.view
        pos = gs.sel(view).begin()
        line = view.line(pos)
        wd = view.settings().get('9o.wd')

        ln = view.substr(line).split('#', 1)
        if len(ln) == 2:
            cmd = ln[1].strip()
            if cmd:
                vs = view.settings()
                aso = gs.aso()
                hkey = '9o.hist.%s' % wd
                hist = gs.dval(aso.get(hkey), [])

                m = HIST_EXPAND_PAT.match(cmd)
                if m:
                    pfx = m.group(1)
                    hl = len(hist)
                    idx = hl - int(m.group(2))
                    cmd = ''
                    if idx >= 0 and idx < hl:
                        cmd = hist[idx]

                    if pfx == '^' or not cmd:
                        view.replace(edit, line, ('%s# %s' % (ln[0], cmd)))
                        return
                elif save_hist:
                    try:
                        hist.remove(cmd)
                    except ValueError:
                        pass
                    hist.append(cmd)
                    aso.set(hkey, hist)
                    gs.save_aso()

            if not cmd:
                view.run_command('gs9o_init')
                return

            view.replace(edit, line, (u'[ `%s` %s ]' % (cmd, HOURGLASS)))
            rkey = '9o.exec.%s' % uuid.uuid4()
            view.add_regions(rkey, [sublime.Region(line.begin(), view.size())],
                             '')
            view.run_command('gs9o_init')

            cli = cmd.split(' ', 1)

            # todo: move this into margo
            if cli[0] == 'sh':

                def on_done(c):
                    out = gs.ustr('\n'.join(c.consume_outq()))
                    sublime.set_timeout(lambda: push_output(view, rkey, out),
                                        0)

                c = gsshell.Command(cmd=cli[1], shell=True, cwd=wd)
                c.on_done = on_done
                c.start()
                return

            f = globals().get('cmd_%s' % cli[0])
            if f:
                args = shlex.split(gs.astr(cli[1])) if len(cli) == 2 else []
                f(view, edit, args, wd, rkey)
            else:
                push_output(view, rkey, 'Invalid command %s' % cli)
        else:
            view.insert(edit, gs.sel(view).begin(), '\n')
예제 #5
0
파일: mg9.py 프로젝트: timicx/GoSublime
			def f():
				gs.aso().set('mg9_install_tokens', _gen_tokens())
				gs.save_aso()
예제 #6
0
	def run(self, edit):
		view = self.view
		pos = gs.sel(view).begin()
		line = view.line(pos)
		wd = view.settings().get('9o.wd')

		ln = view.substr(line).split('#', 1)
		if len(ln) == 2:
			cmd = ln[1].strip()
			if cmd:
				vs = view.settings()
				aso = gs.aso()
				hkey = '9o.hist.%s' % wd
				hist = gs.dval(aso.get(hkey), [])

				m = HIST_EXPAND_PAT.match(cmd)
				if m:
					pfx = m.group(1)
					idx = int(m.group(2))-1
					cmd = hist[-idx] if idx < len(hist) else ''
					if pfx == '^' or not cmd:
						view.replace(edit, line, ('%s# %s' % (ln[0], cmd)))
						return
				else:
					try:
						hist.remove(cmd)
					except ValueError:
						pass
					hist.append(cmd)
					aso.set(hkey, hist)
					gs.save_aso()

			if not cmd:
				view.run_command('gs9o_init')
				return

			view.replace(edit, line, (u'[ `%s` %s ]' % (cmd, HOURGLASS)))
			rkey = '9o.exec.%s' % uuid.uuid4()
			view.add_regions(rkey, [sublime.Region(line.begin(), view.size())], '')
			view.run_command('gs9o_init')

			cli = cmd.split(' ', 1)

			# todo: move this into margo
			if cli[0] == 'sh':
				def on_done(c):
					out = gs.ustr('\n'.join(c.consume_outq()))
					sublime.set_timeout(lambda: push_output(view, rkey, out), 0)

				c = gsshell.Command(cmd=cli[1], shell=True, cwd=wd)
				c.on_done = on_done
				c.start()
				return

			f = globals().get('cmd_%s' % cli[0])
			if f:
				args = shlex.split(gs.astr(cli[1])) if len(cli) == 2 else []
				f(view, edit, args, wd, rkey)
			else:
				push_output(view, rkey, 'Invalid command %s' % cli)
		else:
			view.insert(edit, gs.sel(view).begin(), '\n')
예제 #7
0
 def f():
     gs.aso().set('mg9_install_tokens', _gen_tokens())
     gs.save_aso()