예제 #1
0
def getProjectAuxiDirectory(window, fileDirectoryName, *, makeIfNotExist=False):
    project = WView.getProjectPath(window)
    if project is None:
        return None

    workDir, prjFileName = os.path.split(project)
    prjName, _ = os.path.splitext(prjFileName)
    auxiPath = os.path.join(workDir, fileDirectoryName, prjName)
    if makeIfNotExist and not os.path.exists(auxiPath):
        Os.promiseDirectory(auxiPath)

    return auxiPath
예제 #2
0
        def promiseViewCondition():
            window.focus_view(self.view)

            if any(Os.isSameFile(filePath, v.file_name()) for v in window.views_in_group(self.group)):
                return

            for grp in [grp for grp in range(0, window.num_groups()) if grp != self.group]:
                for v in window.views_in_group(grp):
                    if Os.isSameFile(filePath, v.file_name()):
                        window.set_view_index(v, self.group, 0)
                        window.focus_view(self.view)
                        return
    def doWork(commands, run_mode, win_mode, run_opts, dyn_report_mul, **kwds):
        withErr, infos = False, []
        isMulCmd = len(commands) > 1
        for cmd in commands:
            rc, encoding, stdout, stderr = Os.runShellCmd(
                cmd,
                run_mode=run_mode, win_mode=win_mode,
                **run_opts)

            if not rc:
                withErr = False

            if encoding is None:
                secs = [("command", cmd, False)]
            else:
                secs = [("command", "encoding:{0}\n\n{1}".format(encoding, cmd), False)]
            if stderr:
                secs.append(("error/notify", stderr, True))
            secs.append(("output", stdout, True))

            info = StormOutputView.Info("success" if rc == 0 else "error", *secs)
            infos.append(info)
            if isMulCmd and dyn_report_mul and run_mode != "run":
                StormOutputView.DynamicUpdate([info], **kwds)

        return (withErr, infos, kwds) if run_mode != "run" else None
예제 #4
0
def expandVariables(window, *strs, forSublime=True, forEnv=True):
    view = window.active_view()
    sublimeVariables = window.extract_variables()

    extendVariables = {k: kFn(view) for k, kFn in _extendVariableKeys.items()}

    for cmd, cmdFn in _extendVariableCmds.items():
        extendVariables.update(
            {k + cmd: cmdFn(v)
             for k, v in sublimeVariables.items()})

    sublimeVariables.update(extendVariables)

    retStrs = [sublime.expand_variables(s, sublimeVariables)
               for s in strs] if forSublime else strs
    retStrs = Os.expandVariables(*retStrs) if forEnv else retStrs

    return retStrs
예제 #5
0
def expandVariables(window, *strs, forSublime=True, forEnv=True):
    view = window.active_view()
    sublimeVariables = window.extract_variables()

    extendVariables = {k: kFn(view) for k, kFn in _extendVariableKeys.items()}

    for cmd, cmdFn in _extendVariableCmds.items():
        extendVariables.update({
            k+cmd: cmdFn(v) for k, v in sublimeVariables.items()
        })

    sublimeVariables.update(extendVariables)

    retStrs = [sublime.expand_variables(s, sublimeVariables)
               for s in strs] if forSublime else strs
    retStrs = Os.expandVariables(*retStrs) if forEnv else retStrs

    return retStrs
            self.window.open_file(content)
        else:
            raise ValueError("assetType: {} is not support!".format(assetType))

    def vOnQuickPanelCancel(self):
        quickPanelView.endPane()


class ClipboardPaletteRecordCommand(ProjectWiseJsonAssetRecordBaseCommand):
    def __init__(self, *args):
        super().__init__(*args)

    @staticmethod
    def vProjectWiseAssetManager():
        return pwa

    def vPreTransContent(self, _, val):
        if val["content"] == "$<<clipboard>>":
            val["content"] = sublime.get_clipboard()


pwa = Project.ProjectWiseAsset(srcExt=SRC_FILE_EXT)
pwa.am = ClipboardAssetManager(srcExt=SRC_FILE_EXT,
                               assetKey="assets",
                               key="key")
pwa.ps = Setting.PluginSetting(SKEY)
pwa.prjInfo = Project.ProjectInfo(SKEY)

tmpShowFile = Os.TmpFile()
quickPanelView = WView.NewGroupPane("right")