Exemplo n.º 1
0
def createSignalAutocompleteDocument(view, *args, **kwargs):
    # https://launchpad.net/ubuntu/precise/+source/pykde4
    # https://launchpad.net/ubuntu/precise/+source/pykde4/4:4.7.97-0ubuntu1/+files/pykde4_4.7.97.orig.tar.bz2
    # http://doc.trolltech.com/4.6/qabstractitemmodel.html
    # http://gitorious.org/kate/kate/blobs/a17eb928f8133528a6194b7e788ab7a425ef5eea/ktexteditor/codecompletionmodel.cpp
    # http://code.google.com/p/lilykde/source/browse/trunk/frescobaldi/python/frescobaldi_app/mainapp.py#1391
    # http://api.kde.org/4.0-api/kdelibs-apidocs/kate/html/katecompletionmodel_8cpp_source.html
    # https://svn.reviewboard.kde.org/r/1640/diff/?expand=1
    global pyplete
    session = get_session()
    codecompletationmodel.setSession(session)
    cci = view.codeCompletionInterface()
    cci.registerCompletionModel(codecompletationmodel)
Exemplo n.º 2
0
def createSignalAutocompleteDocument(view=None, *args, **kwargs):
    # https://launchpad.net/ubuntu/precise/+source/pykde4
    # https://launchpad.net/ubuntu/precise/+source/pykde4/4:4.7.97-0ubuntu1/+files/pykde4_4.7.97.orig.tar.bz2
    # http://doc.trolltech.com/4.6/qabstractitemmodel.html
    # http://gitorious.org/kate/kate/blobs/a17eb928f8133528a6194b7e788ab7a425ef5eea/ktexteditor/codecompletionmodel.cpp
    # http://code.google.com/p/lilykde/source/browse/trunk/frescobaldi/python/frescobaldi_app/mainapp.py#1391
    # http://api.kde.org/4.0-api/kdelibs-apidocs/kate/html/katecompletionmodel_8cpp_source.html
    # https://svn.reviewboard.kde.org/r/1640/diff/?expand=1
    if not PYTHON_AUTOCOMPLETE_ENABLED:
        return
    view = view or kate.activeView()
    global pyplete
    session = get_session()
    codecompletationmodel.setSession(session)
    cci = view.codeCompletionInterface()
    cci.registerCompletionModel(codecompletationmodel)
Exemplo n.º 3
0
 def completionInvoked(self, view, word, invocationType):
     line = super(PythonCodeCompletionModel, self).completionInvoked(view,
                                                    word, invocationType)
     session = get_session()
     if self.session != session:
         self.setSession(session)
     if line is None:
         return
     is_auto = False
     line_rough = line
     if 'from' in line or 'import' in line:
         is_auto = self.autoCompleteImport(view, word, line)
     line = self.getLastExpression(line)
     if not is_auto and line:
         is_auto = self.autoCompleteLine(view, word, line)
     if not is_auto and line and line_rough and not self.SEPARATOR in line_rough:
         is_auto = self.autoCompleteFile(view, word, line)
Exemplo n.º 4
0
 def completionInvoked(self, view, word, invocationType):
     line = super(PythonCodeCompletionModel, self).completionInvoked(view,
                                                    word, invocationType)
     session = get_session()
     if self.session != session:
         self.setSession(session)
     if line is None:
         return
     is_auto = False
     line_rough = line
     if 'from' in line or 'import' in line:
         is_auto = self.autoCompleteImport(view, word, line)
     line = self.getLastExpression(line)
     if not is_auto and line:
         is_auto = self.autoCompleteLine(view, word, line)
     if not is_auto and line and line_rough and not self.SEPARATOR in line_rough:
         is_auto = self.autoCompleteFile(view, word, line)
Exemplo n.º 5
0
            text_list[raw] = ';'.join(text_list[raw].split(";")[:-1])
        else:
            del text_list[raw]
        text = '\n'.join(text_list)
        line = line.strip()
        return text


def createSignalAutocompleteDocument(view, *args, **kwargs):
    # https://launchpad.net/ubuntu/precise/+source/pykde4
    # https://launchpad.net/ubuntu/precise/+source/pykde4/4:4.7.97-0ubuntu1/+files/pykde4_4.7.97.orig.tar.bz2
    # http://doc.trolltech.com/4.6/qabstractitemmodel.html
    # http://gitorious.org/kate/kate/blobs/a17eb928f8133528a6194b7e788ab7a425ef5eea/ktexteditor/codecompletionmodel.cpp
    # http://code.google.com/p/lilykde/source/browse/trunk/frescobaldi/python/frescobaldi_app/mainapp.py#1391
    # http://api.kde.org/4.0-api/kdelibs-apidocs/kate/html/katecompletionmodel_8cpp_source.html
    # https://svn.reviewboard.kde.org/r/1640/diff/?expand=1
    global pyplete
    session = get_session()
    codecompletationmodel.setSession(session)
    cci = view.codeCompletionInterface()
    cci.registerCompletionModel(codecompletationmodel)


if PYTHON_AUTOCOMPLETE_ENABLED:
    windowInterface = kate.application.activeMainWindow()
    session = get_session()
    codecompletationmodel = PythonCodeCompletionModel(session, windowInterface)
    windowInterface.connect(windowInterface,
                    QtCore.SIGNAL('viewCreated(KTextEditor::View*)'),
                    createSignalAutocompleteDocument)