rope_py3k / ropeide / editingtools.py

import rope.refactor.sourceutils
import ropeide.highlighter
import ropeide.indenter


def get_editingtools_for_context(editing_context, project, prefs):
    if editing_context.name == 'python':
        return PythonEditingTools(project, prefs)
    if editing_context.name == 'rst':
        return ReSTEditingTools()
    return NormalEditingTools()


class EditingTools(object):

    def create_indenter(self, editor):
        pass

    def create_highlighting(self):
        pass


class PythonEditingTools(EditingTools):

    def __init__(self, project, prefs):
        self.project = project
        self.prefs = prefs

    def create_indenter(self, editor):
        indents = rope.refactor.sourceutils.get_indent(self.project.get_pycore())
        return ropeide.indenter.PythonCodeIndenter(editor, indents=indents)

    def create_highlighting(self):
        return ropeide.highlighter.PythonHighlighting()


class ReSTEditingTools(EditingTools):

    def create_indenter(self, editor):
        return ropeide.indenter.NormalIndenter(editor)

    def create_highlighting(self):
        return ropeide.highlighter.ReSTHighlighting()


class NormalEditingTools(EditingTools):

    def create_indenter(self, editor):
        return ropeide.indenter.NormalIndenter(editor)

    def create_highlighting(self):
        return ropeide.highlighter.NoHighlighting()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.