示例#1
0
def init(injector):
    injector.add_context('search', 'ctx_getter', search_context)
    injector.add_context('replace', 'ctx_getter', replace_context)
    injector.add_context('replace-all', 'replace',
        lambda view: None if view_has_multiline_selection(view) else view)
    injector.add_context('replace-in-selection', 'replace',
        lambda view: view if view_has_multiline_selection(view) else None)

    injector.bind('textview-active', 'search',  'Edit/_Search#30/_Find', search).to('<ctrl>f')
    injector.bind('textview-active', 'mark-selection', 'Edit/Search/_Mark', mark_selection).to('<ctrl>h')
    injector.bind('search', 'replace',  'Edit/Search/_Replace', replace).to('<ctrl>r')
    injector.bind('replace', 'replace-next', 'Edit/Search/Replace and goto ne_xt',
        replace_next).to('<ctrl>Return', 10)
    injector.bind('replace-all', 'replace-all', 'Edit/Search/Replace _all',
        replace_all, False).to('<ctrl><shift>Return', 10)
    injector.bind('replace-in-selection', 'replace-in-selection',
        'Edit/Search/Replace in _selection', replace_all, True).to('<ctrl><shift>Return', 10)

    injector.bind_check('search', 'search-ignore-case', 'Edit/Search/_Ignore case',
        ignore_case).to('<alt>i')

    injector.bind_check('search', 'search-use-regex', 'Edit/Search/Use _RegEx',
        use_regex).to('<alt>r')

    injector.bind('search', 'next', 'Edit/Search/Find _next', find_next)
    injector.bind('search', 'prev', 'Edit/Search/Find _prev', find_prev)

    from snaked.core.prefs import add_internal_option
    add_internal_option('SEARCH_IGNORE_CASE', False)
    add_internal_option('SEARCH_REGEX', False)
    add_internal_option('LAST_SEARCHES', list)
    add_internal_option('LAST_REPLACES', list)
示例#2
0
def init(injector):
    injector.add_context('python-editor', 'editor-active',
        lambda e: e if is_python_editor(e) else None)

    injector.bind('python-editor', 'goto-definition', '_Python#70/Goto _defenition', goto_definition)
    injector.bind('python-editor', 'show-outline', 'Python/Show _outline', open_outline)

    injector.bind('python-editor', 'show-calltip', 'Python/Show _calltip', show_calltips)

    injector.bind_dynamic('python-editor', 'select-interpreter', 'Python/_Executable/executables',
        generate_python_executable_menu, resolve_python_executable_menu_entry, True)

    injector.bind('editor', 'run-test', 'Python/_Tests/_Run test in cursor scope', run_test)
    injector.bind('editor', 'run-all-tests', 'Python/Tests/Run _all tests', run_all_tests)
    injector.bind('editor', 'rerun-test', 'Python/Tests/Rerun last test', rerun_test)
    injector.bind('editor', 'toggle-test-panel', 'View/Toggle _test panel', toggle_test_panel)

    from snaked.core.prefs import add_option, add_internal_option

    add_internal_option('PYTHON_EXECUTABLE', 'default')
    add_option('PYTHON_EXECUTABLES', dict,
        'Path to python executables. Used by test runner and completion framework')
    add_option('PYTHON_EXECUTABLE_ENV', dict,
        'Python interpreter environment. Used by test runner and completion framework')
    add_option('PYTHON_SUPP_CONFIG', dict, 'Config for supplement')

    add_option('PYTHON_SPYPKG_HANDLER_MAX_CHARS', 25, 'Maximum allowed python package title length')

    add_option('PYTHON_LINT_ON_FILE_LOAD', False, 'Run lint check on file load')

    from snaked.core.titler import add_title_handler
    add_title_handler('pypkg', pypkg_handler)
    add_title_handler('spypkg', spypkg_handler)

    injector.on_ready('editor-with-new-buffer-created', editor_created)
    injector.on_ready('editor-with-new-buffer', editor_opened)
    injector.on_ready('manager', start_supplement)
    injector.on_done('last-buffer-editor', editor_closed)
    injector.on_done('manager', quit)