Пример #1
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
Пример #2
0
def _get_default_engine_if_not_valid(engine, default='DuckDuckGo'):
    if engine is None:
        engine = suricate.get_setting('default_search_engine', default)
    if engine not in ENGINES:
        suricate.log('ERROR: Search engine "%s" not implemented.', engine)
        engine = default
    return engine
Пример #3
0
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
def copy_build_variable_to_clipboard(key=None, window=None):
    """If key is None, show a quick panel with the currently available build
    variables."""
    append_suricate_variables = suricate.get_setting('dev_mode', False)
    variables = suricate.extract_variables(window, append_suricate_variables)
    on_done = lambda picked: sublime.set_clipboard(picked[1])
    if key is None:
        show_quick_panel(sorted([[k, i] for k, i in variables.items()]), on_done)
    else:
        on_done([None, variables[key]])
Пример #5
0
def switch_language(view):
    dicts = suricate.get_setting('quick_switch_dictionary_list', [])
    if not dicts:
        dicts = sublime.find_resources('*.dic')
        if not dicts:
            suricate.log('ERROR: no dictionary found')
            return
    current = view.settings().get('dictionary')
    next_item_index = dicts.index(current) + 1 if current in dicts else 0
    next_item = dicts[next_item_index % len(dicts)]
    if next_item in sublime.find_resources('*.dic'):
        view.settings().set('dictionary', next_item)
        sublime.status_message(
            'Dictionary changed to %s' %
            os.path.basename(next_item))
    else:
        sublime.error_message('Dictionary %r not available' % next_item)
Пример #6
0
def _datetime_formats():
    defaults = [
        '%d/%m/%Y',
        '%Y/%m/%d',
        '%d/%m/%Y',
        '%Y-%m-%d',
        '%d %B %Y',
        '%B %d, %Y',
        '%A, %B %d, %Y',
        '%B %Y',
        'Week %W, day %j',
        '%a%d',
        '%c',
        '%Y%m%d%H%M%S',
        '%Y%m%d',
        '%H:%M:%S',
        '%H:%M']
    return suricate.get_setting('time_formats', defaults)
Пример #7
0
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)
Пример #8
0
def _get_current_profile_set():
    return set(suricate.get_setting('profiles', []))