コード例 #1
0
ファイル: vcs.py プロジェクト: nsubiron/SublimeSuricate
def _do(cmd, caption, path, out=None, ask=None, **kwargs):
    working_dir, base_name = os.path.split(
        path) if os.path.isfile(path) else (path, '.')
    cmd = suricate.expand_variables(cmd, {'path': base_name})
    suricate.debuglog('vcs do: %s', ' '.join(cmd))
    if ask and not sublime.ok_cancel_dialog(
        suricate.expand_variables(
            ask, {
            'path': base_name}), caption):
        return
    if out == 'gui':
        process.spawn(cmd, working_dir)
    elif out == 'buffer':
        text, err = process.popen(cmd, working_dir)
        name = ' '.join(cmd[:2])
        sublime_wrapper.flush_to_buffer(
            text,
            name=name,
            scratch=True,
            syntax='Diff')
    elif out is not None and out.endswith('_list'):
        cout, err = process.popen(cmd, working_dir)
        vcsname = suricate.flags.to_string(suricate.flags.get_vcs(path))
        lst = vcs_parser.parse(cout, out.replace('_list', ''), vcsname)
        window = sublime.active_window()
        getpath = lambda picked: os.path.abspath(os.path.join(path, picked[0]))
        on_done = lambda picked: window.open_file(getpath(picked))
        sublime_wrapper.show_quick_panel(lst, on_done, window)
    else:
        sublime_wrapper.execute(cmd=cmd, working_dir=working_dir)
コード例 #2
0
def get_css(view):
    style_file = suricate.get_setting('popup_style_file')
    if style_file is None or style_file == 'auto':
        css_path = 'Packages/${suricate_package_name}/css'
        css_path = suricate.expand_variables(css_path, window=view.window())
        default_css = css_path + '/default.css'
        default = suricate.get_setting('popup_style_file_fallback', default_css)
        default = suricate.expand_variables(default, window=view.window())
        return _find_best_css(view, css_path, default)
    return style_file
コード例 #3
0
ファイル: navigator.py プロジェクト: nsubiron/SublimeSuricate
def launch(mode=OPEN_MODE, view=None):
    """Open navigator quick panel.

      * `mode=='open'` Open selected file with Sublime Text
      * `mode=='launch'` Try to externally launch selected file"""
    if mode != OPEN_MODE and mode != LAUNCH_MODE:
        raise Exception('Unknown mode!')
    window = sublime.active_window()
    paths = suricate.get_setting('quick_%s_path_list' % mode)
    paths = suricate.expand_variables(paths, window=window)
    factory = _ItemFactory(mode, window)
    items = []
    if view is not None:
        current_file = view.file_name()
        if current_file is not None:
            if mode == LAUNCH_MODE:
                items.append(factory.create(current_file, 'Current file'))
            items.append(
                factory.create(
                    os.path.dirname(current_file),
                    'Current folder'))
    pathitems = [
        factory.create(
            path,
            os.path.basename(path)) for path in paths]
    items += sorted(x for x in pathitems if x is not None)
    _show_quick_panel(items)
コード例 #4
0
ファイル: vcs.py プロジェクト: nsubiron/SublimeSuricate
def _get_list(path):
    if path is None:
        repos = {'Current File': '${file}'}
        repos.update(suricate.get_setting('vcs_working_dirs', {}))
        repos = suricate.expand_variables(repos)

        def parse_settings(repositories):
            for name, path in repositories.items():
                path = os.path.abspath(path)
                if os.path.exists(path):
                    f = suricate.flags.get_vcs(path)
                    if f != suricate.flags.Flags.EMPTY:
                        yield PathProxy(name, suricate.flags.to_string(f), path)
        return sorted([x for x in parse_settings(repos)])
    elif os.path.isfile(path) or os.path.isdir(path):
        return get_commands(suricate.flags.parse(path), path)
    else:
        sublime.error_message('File path "%s" not found!' % path)
コード例 #5
0
def execute(window=None, **kwargs):
    """Runs an external process asynchronously. On Windows, GUIs are suppressed.
    ``exec`` is the default command used by build systems, thus it provides
    similar functionality. However, a few options in build systems are taken
    care of by Sublime Text internally so they list below only contains
    parameters accepted by this command.

      * cmd ``[String]``
      * file_regex ``String``
      * line_regex ``String``
      * working_dir ``String``
      * encoding ``String``
      * env ``{String: String}``
      * path ``String``
      * shell ``Bool``
      * kill ``Bool``: If True will simply terminate the current build process.
      This is invoked via Build: Cancel command from the Command Palette.
      * quiet ``Bool``: If True prints less information about running the
      command."""
    if window is None:
        window = sublime.active_window()
    kwargs = suricate.expand_variables(kwargs, window=window)
    window.run_command('exec', kwargs)