예제 #1
0
def get_tools(editor):
    global tools, tool
    tools_module.clear()

    if tools is None:
        tools = []
        added_tools = set()

        filenames = (join_to_settings_dir('snaked', editor.session, 'tools'),
            join_to_settings_dir('snaked', 'tools.conf'))

        for f in filenames:
            tool = ToolExtractor()

            try:
                execfile(f, tools_module.setdefault(f, {}), tools_module.setdefault(f, {}))
            except IOError:
                pass
            except:
                import traceback
                editor.message('Unable to load ' + f + '\n\n' + traceback.format_exc(3), 'error', 0)
            else:
                for t in tool._tools:
                    if t._title in added_tools: continue
                    tools.append(t)
                    added_tools.add(t._title)

    return tools
예제 #2
0
    def __init__(self, session):
        self.buffers = []
        self.windows = []

        self.session = session
        self.style_manager = gtksourceview2.style_scheme_manager_get_default()
        self.lang_manager = gtksourceview2.language_manager_get_default()
        self.modify_lang_search_path(self.lang_manager)

        self.activator = keymap.get_activator(config_section='editor_window')
        self.activator.add_context('manager', (), lambda: self)

        self.activator.bind_menu('_File#1')
        self.activator.bind_menu('_Edit#10')
        self.activator.bind_menu('_Prefs#15/_Global#90')
        self.activator.bind_menu('Prefs/_Session')
        self.activator.bind_menu('Prefs/_Project')
        self.activator.bind_menu('_View#20')
        self.activator.bind_menu('Too_ls#30')
        self.activator.bind_menu('_Run#40')
        self.activator.bind_menu('_Tab#90')
        self.activator.bind_menu('_Window#100')

        self.activator.bind('manager', 'quit', 'File/_Quit#100', EditorManager.quit).to('<ctrl>q')
        self.activator.bind('window', 'plugin-list', 'Prefs/Pl_ugins#10',
            snaked.core.plugins.show_plugins_prefs)

        self.activator.alias(('window', 'activator'), 'root-menu', 'Prefs/_Root menu#100')

        self.plugin_manager = PluginManager(self.activator)

        self.init_conf()

        self.default_ctx_processor = ContextProcessor(join_to_settings_dir('snaked', 'contexts.conf'))
        self.session_ctx_processor = ContextProcessor(
            join_to_settings_dir('snaked', self.session, 'contexts'))
        self.ctx_managers = {}

        self.escape_stack = []
        self.escape_map = {}
        self.on_quit = []

        # Init core plugins
        self.plugin_manager.add_plugin(prefs)
        self.plugin_manager.add_plugin(snaked.core.quick_open)
        self.plugin_manager.add_plugin(snaked.core.editor_list)
        self.plugin_manager.add_plugin(snaked.core.titler)
        self.plugin_manager.add_plugin(snaked.core.console)
        self.plugin_manager.add_plugin(snaked.core.spot)
        self.plugin_manager.add_plugin(snaked.core.monitor)
        self.plugin_manager.add_plugin(snaked.core.completer)

        self.spot_manager = snaked.core.spot.Manager()

        self.plugin_manager.ready('manager', self)

        self.plugin_manager.add_plugin(snaked.core.window)

        snaked.core.plugins.init_plugins(self.plugin_manager)
예제 #3
0
def edit_external_tools(editor, kind):
    if kind == 'global':
        filename = join_to_settings_dir('snaked', 'tools.conf')
    elif kind == 'session':
        filename = join_to_settings_dir('snaked', editor.session, 'tools')
    else:
        raise Exception('Unknown external tools type: ' + str(kind))

    if not exists(filename):
        make_missing_dirs(filename)
        shutil.copy(join(dirname(__file__), 'external.tools.template'), filename)

    e = editor.window.manager.open(filename, contexts='python')
    editor.window.attach_editor(e)
    e.connect('file-saved', on_external_tools_save)
예제 #4
0
    def edit_context(self, ctx):
        user_snippet_filename = join_to_settings_dir('snaked', 'snippets', ctx + '.snippets')
        if ctx in self.existing_snippets and \
                self.existing_snippets[ctx] != user_snippet_filename:

            import shutil
            make_missing_dirs(user_snippet_filename)
            shutil.copy(self.existing_snippets[ctx], user_snippet_filename)

        idle(self.hide)
        e = self.editor().open_file(user_snippet_filename)
        e.connect('file-saved', on_snippet_saved, ctx)
예제 #5
0
파일: prefs.py 프로젝트: pombredanne/snaked
def show_session_config(window):
    window.manager.session_config.save()
    uri = join_to_settings_dir("snaked", window.manager.session, "config")
    e = window.manager.open(uri, contexts="python")
    window.attach_editor(e)
    e.connect("file-saved", on_config_saved, window.manager.session_config, uri)
예제 #6
0
파일: prefs.py 프로젝트: pombredanne/snaked
def get_settings_path(*name):
    filename = join_to_settings_dir("snaked", *name)
    make_missing_dirs(filename)
    return filename
예제 #7
0
파일: app.py 프로젝트: baverman/fmd
import gtk

from uxie.utils import join_to_settings_dir
from uxie.actions import KeyMap
from uxie.floating import Manager as FeedbackManager
from uxie.plugins import Manager as PluginManager

import filelist
import clipboard
import fsutils

keymap = KeyMap(join_to_settings_dir('fmd', 'keys.conf'))
keymap.map_generic('root-menu', 'F1')
keymap.map_generic('copy', '<ctrl>c')
keymap.map_generic('copy', '<ctrl>Insert')
keymap.map_generic('cut', '<ctrl>x')
keymap.map_generic('cut', '<shift>Delete')
keymap.map_generic('paste', '<ctrl>v')
keymap.map_generic('paste', '<shift>Insert')
keymap.map_generic('delete', 'Delete')

class App(object):
    def __init__(self):
        self.wg = gtk.WindowGroup()
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_default_size(700, 415)
        self.window.connect('delete-event', self.quit)
        self.wg.add_window(self.window)

        self.clipboard = clipboard.Clipboard()
        self.window.feedback = self.feedback = FeedbackManager()