add_subdirectory(exporter)
add_subdirectory(autobrace)
add_subdirectory(kte_iconinserter)
-add_subdirectory(lumen)
+++ /dev/null
-project(ktexteditor_lumen)
-
-########### next target ###############
-
-set(ktexteditor_lumen_SRCS
- lumen.cpp
- dcd.cpp
- completion.cpp
-)
-
-kde4_add_plugin(ktexteditor_lumen ${ktexteditor_lumen_SRCS})
-
-target_link_libraries(ktexteditor_lumen
- ${KDE4_KDECORE_LIBS}
- ${KDE4_KTEXTEDITOR_LIBS}
-)
-
-install(
- TARGETS ktexteditor_lumen
- DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
-)
-
-########### install files ###############
-
-install(
- FILES ktexteditor_lumen.desktop
- DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
-)
+++ /dev/null
-/*
- * Copyright 2014 David Herberth kde@dav1d.de
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) version 3, or any
- * later version accepted by the membership of KDE e.V. (or its
- * successor approved by the membership of KDE e.V.), which shall
- * act as a proxy defined in Section 6 of version 3 of the license.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
-**/
-
-#include "completion.h"
-#include <ktexteditor/view.h>
-#include <ktexteditor/document.h>
-#include <ktexteditor/codecompletioninterface.h>
-#include <ktexteditor/codecompletionmodelcontrollerinterface.h>
-#include <klocalizedstring.h>
-
-
-LumenCompletionModel::LumenCompletionModel(QObject* parent, DCD* dcd): KTextEditor::CodeCompletionModel2(parent)
-{
- m_dcd = dcd;
-}
-
-LumenCompletionModel::~LumenCompletionModel()
-{
-
-}
-
-bool LumenCompletionModel::shouldStartCompletion(KTextEditor::View* view, const QString& insertedText, bool userInsertion, const KTextEditor::Cursor& position)
-{
- bool complete = KTextEditor::CodeCompletionModelControllerInterface::shouldStartCompletion(
- view, insertedText, userInsertion, position
- );
-
- complete = complete || insertedText.endsWith("("); // calltip
- complete = complete || insertedText.endsWith("import "); // import
-
- return complete;
-}
-
-void LumenCompletionModel::completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, CodeCompletionModel::InvocationType invocationType)
-{
- Q_UNUSED(invocationType);
- KTextEditor::Document* document = view->document();
-
- KTextEditor::Cursor cursor = range.end();
- KTextEditor::Cursor cursorEnd = document->documentEnd();
- KTextEditor::Range range0c = KTextEditor::Range(0, 0, cursor.line(), cursor.column());
- KTextEditor::Range rangece = KTextEditor::Range(cursor.line(), cursor.column(),
- cursorEnd.line(), cursorEnd.column());
- QString text0c = document->text(range0c, false);
- QByteArray utf8 = text0c.toUtf8();
- int offset = utf8.length();
- utf8.append(document->text(rangece, false).toUtf8());
-
- m_data = m_dcd->complete(utf8, offset);
- setRowCount(m_data.completions.length());
-
- setHasGroups(false);
-}
-
-void LumenCompletionModel::executeCompletionItem2(KTextEditor::Document* document, const KTextEditor::Range& word, const QModelIndex& index) const
-{
- QModelIndex sibling = index.sibling(index.row(), Name);
- KTextEditor::View* view = document->activeView();
-
- document->replaceText(word, data(sibling).toString());
-
- int crole = data(sibling, CompletionRole).toInt();
- if (crole & Function) {
- KTextEditor::Cursor cursor = document->activeView()->cursorPosition();
- document->insertText(cursor, QString("()"));
- view->setCursorPosition(KTextEditor::Cursor(cursor.line(), cursor.column()+1));
- }
-}
-
-QVariant LumenCompletionModel::data(const QModelIndex& index, int role) const
-{
- DCDCompletionItem item = m_data.completions[index.row()];
-
- switch (role)
- {
- case Qt::DecorationRole:
- {
- if(index.column() == Icon) {
- return item.icon();
- }
- break;
- }
- case Qt::DisplayRole:
- {
- if(item.type == DCDCompletionItemType::Calltip) {
- QRegExp funcRE("^\\s*(\\w+)\\s+(\\w+\\s*\\(.*\\))\\s*$");
- funcRE.indexIn(item.name);
- QStringList matches = funcRE.capturedTexts();
-
- switch(index.column()) {
- case Prefix: return matches[1];
- case Name: return matches[2];
- }
- } else {
- if(index.column() == Name) {
- return item.name;
- }
- }
- break;
- }
- case CompletionRole:
- {
- int p = NoProperty;
- switch (item.type) {
- case DCDCompletionItemType::FunctionName: p |= Function; break;
- case DCDCompletionItemType::VariableName: p |= Variable; break;
- default: break;
- }
- return p;
- }
- case BestMatchesCount:
- {
- return 5;
- }
- case ArgumentHintDepth:
- {
- if(item.type == DCDCompletionItemType::Calltip) {
- return 1;
- }
- break;
- }
- case GroupRole:
- {
- break;
- }
- case IsExpandable:
- {
- // I like the green arrow
- return true;
- }
- case ExpandingWidget:
- {
- // TODO well implementation in DCD is missing
- return QVariant();
- }
- }
-
- return QVariant();
-}
-
-#include "moc_completion.cpp"
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2014 David Herberth kde@dav1d.de
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) version 3, or any
- * later version accepted by the membership of KDE e.V. (or its
- * successor approved by the membership of KDE e.V.), which shall
- * act as a proxy defined in Section 6 of version 3 of the license.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
-**/
-
-#ifndef LUMEN_COMPLETION_H
-#define LUMEN_COMPLETION_H
-#include <ktexteditor/codecompletionmodel.h>
-#include <ktexteditor/codecompletionmodelcontrollerinterface.h>
-#include "dcd.h"
-
-class LumenCompletionModel: public KTextEditor::CodeCompletionModel2,
- public KTextEditor::CodeCompletionModelControllerInterface
-{
- Q_OBJECT
- Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface)
-public:
- LumenCompletionModel(QObject* parent, DCD* dcd);
- virtual ~LumenCompletionModel();
-
- virtual bool shouldStartCompletion(KTextEditor::View* view, const QString& insertedText, bool userInsertion, const KTextEditor::Cursor& position);
- virtual void completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType invocationType);
- virtual void executeCompletionItem2(KTextEditor::Document* document, const KTextEditor::Range& word, const QModelIndex& index) const;
- virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
-private:
- DCD* m_dcd;
- DCDCompletion m_data;
-};
-
-
-
-#endif
+++ /dev/null
-/*
- * Copyright 2014 David Herberth kde@dav1d.de
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) version 3, or any
- * later version accepted by the membership of KDE e.V. (or its
- * successor approved by the membership of KDE e.V.), which shall
- * act as a proxy defined in Section 6 of version 3 of the license.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
-**/
-
-#include "dcd.h"
-#include <kdebug.h>
-#include <QtCore/QFile>
-
-
-char DCDCompletionItemType::toChar(DCDCompletionItemType e)
-{
- switch (e) {
- case Invalid: return 0;
- case Calltip: return 1;
- case ClassName: return 'c';
- case InterfaceName: return 'i';
- case StructName: return 's';
- case UnionName: return 'u';
- case VariableName: return 'v';
- case MemberVariableName: return 'm';
- case Keyword: return 'k';
- case FunctionName: return 'f';
- case EnumName: return 'g';
- case EnumMember: return 'e';
- case PackageName: return 'p';
- case ModuleName: return 'M';
- }
-
- return 0;
-}
-
-DCDCompletionItemType::DCDCompletionItemType DCDCompletionItemType::fromChar(char c)
-{
- switch (c) {
- case 0: return Invalid;
- case 1: return Calltip;
- case 'c': return ClassName;
- case 'i': return InterfaceName;
- case 's': return StructName;
- case 'u': return UnionName;
- case 'v': return VariableName;
- case 'm': return MemberVariableName;
- case 'k': return Keyword;
- case 'f': return FunctionName;
- case 'g': return EnumName;
- case 'e': return EnumMember;
- case 'p': return PackageName;
- case 'M': return ModuleName;
- }
-
- return Invalid;
-}
-
-
-
-DCDCompletionItem::DCDCompletionItem(DCDCompletionItemType::DCDCompletionItemType t, QString s): type(t), name(s)
-{
-
-}
-
-#define RETURN_CACHED_ICON(name) {static QIcon icon(KIcon(name).pixmap(QSize(16, 16))); return icon;}
-QIcon DCDCompletionItem::icon() const
-{
- using namespace DCDCompletionItemType;
- switch (type)
- {
- case Invalid: break;
- case Calltip: RETURN_CACHED_ICON("code-function")
- case ClassName: RETURN_CACHED_ICON("code-class")
- case InterfaceName: RETURN_CACHED_ICON("code-class")
- case StructName: RETURN_CACHED_ICON("struct")
- case UnionName: RETURN_CACHED_ICON("union")
- case VariableName: RETURN_CACHED_ICON("code-variable")
- case MemberVariableName: RETURN_CACHED_ICON("field")
- case Keyword: RETURN_CACHED_ICON("field")
- case FunctionName: RETURN_CACHED_ICON("code-function")
- case EnumName: RETURN_CACHED_ICON("enum")
- case EnumMember: RETURN_CACHED_ICON("enum")
- case PackageName: RETURN_CACHED_ICON("field")
- case ModuleName: RETURN_CACHED_ICON("field")
- }
-
- return KIcon();
-}
-
-QString DCDCompletionItem::typeLong() const
-{
- using namespace DCDCompletionItemType;
- switch (type)
- {
- case Invalid: return "invalid";
- case Calltip: return "calltip";
- case ClassName: return "class";
- case InterfaceName: return "interface";
- case StructName: return "struct";
- case UnionName: return "union";
- case VariableName: return "variable";
- case MemberVariableName: return "member";
- case Keyword: return "keyword";
- case FunctionName: return "function";
- case EnumName: return "enum";
- case EnumMember: return "enum member";
- case PackageName: return "package";
- case ModuleName: return "module";
- }
-
- return "completion";
-}
-
-
-static const int TIMEOUT_START_SERVER = 200;
-static const int TIMEOUT_COMPLETE = 200;
-static const int TIMEOUT_IMPORTPATH = 200;
-static const int TIMEOUT_SHUTDOWN = 350;
-static const int TIMEOUT_SHUTDOWN_SERVER = 200;
-
-
-DCD::DCD(int port, const QString& server, const QString& client)
-{
- m_port = port;
- m_server = server;
- m_client = client;
-}
-
-int DCD::port()
-{
- return m_port;
-}
-
-bool DCD::running()
-{
- return m_sproc.state() == QProcess::Running;
-}
-
-
-bool DCD::startServer()
-{
- m_sproc.setProcessChannelMode(QProcess::MergedChannels);
- m_sproc.start(m_server, QStringList(QString("-p%1").arg(m_port)));
- bool started = m_sproc.waitForStarted(TIMEOUT_START_SERVER);
- bool finished = m_sproc.waitForFinished(TIMEOUT_START_SERVER);
-
- if (!started || finished || m_sproc.state() == QProcess::NotRunning) {
- kWarning() << "unable to start completion-server:" << m_sproc.exitCode();
- kWarning() << m_sproc.readAll();
- return false;
- }
- kDebug() << "started completion-server";
- return true;
-}
-
-
-DCDCompletion DCD::complete(QString file, int offset)
-{
- QProcess proc;
- proc.setProcessChannelMode(QProcess::MergedChannels);
- proc.start(m_client,
- QStringList()
- << QString("-p%1").arg(m_port)
- << QString("-c%1").arg(offset)
- << file
- );
-
- if (!proc.waitForFinished(TIMEOUT_COMPLETE)) {
- kWarning() << "unable to complete:" << proc.exitCode();
- kWarning() << proc.readAll();
- return DCDCompletion();
- }
-
- return processCompletion(proc.readAllStandardOutput());
-}
-
-DCDCompletion DCD::complete(QByteArray data, int offset)
-{
- QProcess proc;
- proc.setProcessChannelMode(QProcess::MergedChannels);
- proc.start(m_client,
- QStringList()
- << QString("-p%1").arg(m_port)
- << QString("-c%1").arg(offset)
- );
-
- proc.write(data);
- proc.closeWriteChannel();
- if (!proc.waitForFinished(TIMEOUT_COMPLETE)) {
- kWarning() << "unable to complete: client didn't finish in time";
- proc.close();
- } else if (proc.exitCode() != 0) {
- kWarning() << "unable to complete:" << proc.exitCode();
- kWarning() << proc.readAll();
- } else {
- // everything Ok
- return processCompletion(proc.readAllStandardOutput());
- }
-
- return DCDCompletion();
-}
-
-QString DCD::doc(QByteArray data, int offset)
-{
- QProcess proc;
- proc.setProcessChannelMode(QProcess::MergedChannels);
- proc.start(m_client,
- QStringList()
- << QString("-p%1").arg(m_port)
- << QString("-c%1").arg(offset)
- << QString("--doc")
- );
-
- proc.write(data);
- proc.closeWriteChannel();
- if (!proc.waitForFinished(TIMEOUT_COMPLETE)) {
- kWarning() << "unable to lookup documentation: client didn't finish in time";
- proc.close();
- } else if (proc.exitCode() != 0) {
- kWarning() << "unable to lookup documentation:" << proc.exitCode();
- kWarning() << proc.readAll();
- } else {
- return proc.readAllStandardOutput();
- }
-
- return QString("");
-}
-
-
-DCDCompletion DCD::processCompletion(QString data)
-{
- DCDCompletion completion;
-
- QStringList lines = data.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
- if (lines.length() == 0) {
- return completion;
- }
-
- QString type = lines.front();
- if (type == "identifiers") { completion.type = DCDCompletionType::Identifiers; }
- else if (type == "calltips") { completion.type = DCDCompletionType::Calltips; }
- else {
- kWarning() << "Invalid type:" << type;
- return completion;
- }
- lines.pop_front();
-
- foreach(QString line, lines) {
- if (line.trimmed().length() == 0) {
- continue;
- }
-
- QStringList kv = line.split(QRegExp("\\s+"), QString::SkipEmptyParts);
- if (kv.length() != 2 && completion.type != DCDCompletionType::Calltips) {
- kWarning() << "invalid completion data:" << kv.length() << completion.type;
- continue;
- }
-
- if (completion.type == DCDCompletionType::Identifiers) {
- completion.completions.append(DCDCompletionItem(
- DCDCompletionItemType::fromChar(kv[1].at(0).toAscii()), kv[0]
- ));
- } else {
- completion.completions.append(DCDCompletionItem(
- DCDCompletionItemType::Calltip, line
- ));
- }
- }
-
- return completion;
-}
-
-
-void DCD::addImportPath(QString path)
-{
- addImportPath(QStringList(path));
-}
-
-void DCD::addImportPath(QStringList paths)
-{
- if (paths.isEmpty()) {
- return;
- }
-
- QStringList arguments = QStringList(QString("-p%1").arg(m_port));
- foreach(QString path, paths) {
- if (QFile::exists(path))
- arguments << QString("-I%1").arg(path);
- }
-
- kDebug() << "ARGUMENTS:" << arguments;
-
- QProcess proc;
- proc.setProcessChannelMode(QProcess::MergedChannels);
- proc.start(m_client, arguments);
-
- if (!proc.waitForFinished(TIMEOUT_IMPORTPATH)) {
- kWarning() << "unable to add importpath(s)" << paths << ":" << proc.exitCode();
- kWarning() << proc.readAll();
- }
-}
-
-void DCD::shutdown()
-{
- QProcess proc;
- proc.setProcessChannelMode(QProcess::MergedChannels);
- proc.start(m_client,
- QStringList()
- << QString("-p%1").arg(m_port)
- << QString("--shutdown")
- );
-
- if (!proc.waitForFinished(TIMEOUT_SHUTDOWN)) {
- kWarning() << "unable to shutdown dcd:" << proc.exitCode();
- kWarning() << proc.readAll();
- }
-}
-
-
-bool DCD::stopServer()
-{
- if (m_sproc.state() == QProcess::Running) {
- kDebug() << "shutting down dcd";
- shutdown();
- if(!m_sproc.waitForFinished(TIMEOUT_SHUTDOWN_SERVER))
- m_sproc.terminate();
- if(!m_sproc.waitForFinished(TIMEOUT_SHUTDOWN_SERVER))
- m_sproc.kill();
-
- return true;
- }
- return false;
-}
-
-DCD::~DCD()
-{
- if (running()) {
- stopServer();
- }
-}
+++ /dev/null
-/*
- * Copyright 2014 David Herberth kde@dav1d.de
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) version 3, or any
- * later version accepted by the membership of KDE e.V. (or its
- * successor approved by the membership of KDE e.V.), which shall
- * act as a proxy defined in Section 6 of version 3 of the license.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
-**/
-
-#ifndef LUMEN_DCD_H
-#define LUMEN_DCD_H
-
-#include <qobject.h>
-#include <qmap.h>
-#include <qprocess.h>
-#include <kicon.h>
-
-namespace DCDCompletionType { enum DCDCompletionType { Identifiers, Calltips }; };
-namespace DCDCompletionItemType {
- enum DCDCompletionItemType {
- Invalid,
-
- Calltip,
-
- ClassName,
- InterfaceName,
- StructName,
- UnionName,
- VariableName,
- MemberVariableName,
- Keyword,
- FunctionName,
- EnumName,
- EnumMember,
- PackageName,
- ModuleName,
- };
-
- char toChar(DCDCompletionItemType e);
- DCDCompletionItemType fromChar(char c);
-};
-
-struct DCDCompletionItem {
- DCDCompletionItem(DCDCompletionItemType::DCDCompletionItemType, QString);
-
- DCDCompletionItemType::DCDCompletionItemType type;
- QString name;
-
- QIcon icon() const;
- QString typeLong() const;
-};
-
-struct DCDCompletion {
- DCDCompletionType::DCDCompletionType type;
- QList<DCDCompletionItem> completions;
-};
-
-class DCD
-{
- public:
- DCD(int, const QString&, const QString&);
- virtual ~DCD();
- int port();
- bool running();
- bool startServer();
- bool stopServer();
- DCDCompletion complete(QString, int);
- DCDCompletion complete(QByteArray, int);
- QString doc(QByteArray, int);
- void shutdown();
- void addImportPath(QString);
- void addImportPath(QStringList);
- private:
- DCDCompletion processCompletion(QString);
- int m_port;
- QString m_server;
- QString m_client;
- QProcess m_sproc;
-};
-
-#endif
+++ /dev/null
-[Desktop Entry]
-X-KDE-Library=ktexteditor_lumen
-X-KDE-PluginKeyword=ktexteditor_lumen
-X-KDE-PluginInfo-Author=David Herberth
-X-KDE-PluginInfo-Email=kde@dav1d.de
-X-KDE-PluginInfo-Name=ktexteditorlumen
-X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=http://kate.kde.org
-X-KDE-PluginInfo-Category=Editor
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=LGPLv2
-X-KDE-PluginInfo-EnabledByDefault=false
-X-KDE-ParentApp=kate
-X-KDE-Version=4.0
-X-KDE-ServiceTypes=KTextEditor/Plugin
-Type=Service
-Icon=task-delegate
-Name=Lumen
-Name[ca]=Lumen
-Name[ca@valencia]=Lumen
-Name[cs]=Lumen
-Name[da]=Lumen
-Name[de]=Lumen
-Name[el]=Lumen
-Name[en_GB]=Lumen
-Name[es]=Lumen
-Name[et]=Lumen
-Name[fi]=Lumen
-Name[fr]=Lumen
-Name[gl]=Lumen
-Name[he]=Lumen
-Name[hu]=Lumen
-Name[ia]=Lumen
-Name[ko]=Lumen
-Name[nb]=Lumen
-Name[nds]=Lumen
-Name[nl]=Lumen
-Name[pl]=Lumen
-Name[pt]=Lumen
-Name[pt_BR]=Lumen
-Name[ro]=Lumen
-Name[ru]=Lumen
-Name[sk]=Lumen
-Name[sl]=Lumen
-Name[sr]=Лумен
-Name[sr@ijekavian]=Лумен
-Name[sr@ijekavianlatin]=Lumen
-Name[sr@latin]=Lumen
-Name[sv]=Lumen
-Name[tr]=Lumen
-Name[uk]=Lumen
-Name[x-test]=xxLumenxx
-Name[zh_CN]=Lumen
-Name[zh_TW]=Lumen
-Comment=Lumen is a Autocompletion Plugin for D, using the DCD autocompletion server
-Comment[ca]=El Lumen és un connector de compleció automàtica pel D, que utilitza el servidor de compleció automàtica DCD
-Comment[ca@valencia]=El Lumen és un connector de compleció automàtica pel D, que utilitza el servidor de compleció automàtica DCD
-Comment[cs]=Lumen modul pro automatické doplňování D využívající server pro automatické doplňování DCD
-Comment[da]=Lumen er et autofuldførelse-plugin til D, som bruger autofuldførelse-serveren DCD
-Comment[de]=Lumen ist ein Modul zur automatischen Vervollständigung für D und benutzt den DCD-Auto-Vervollständigungs-Server
-Comment[el]=Το Lumen είναι ένα πρόσθετο αυτόματης συμπλήρωσης για την D, με τη χρήση του εξυπηρετητή αυτόματης συμπλήρωσης DCD
-Comment[en_GB]=Lumen is a Autocompletion Plugin for D, using the DCD autocompletion server
-Comment[es]=Lumen es un complemento de completado automático para D que utiliza el servidor de completado automático DCD.
-Comment[et]=Lumen on D keele automaatse koodilõpetamise plugin, mis kasutab välist koodilõpetamisserverit
-Comment[fi]=Lumen on D-kielen automaattitäydennysliitännäinen, joka käyttää DCD-automaattitäydennyspalvelinta
-Comment[fr]=Lumen est un composant externe d'auto-complètement pour le langage D qui utilise le serveur d'auto-complètement DCD
-Comment[gl]=Lumen é un complemento de completado automático para D que emprega o servidor de completado automático DCD
-Comment[he]=התוסף Lumen הוא תוסף השלמה אוטומית עבור שפת D, המשתמש בשרת השלמה DCD.
-Comment[hu]=A Lumen egy automatikus kiegészítő bővítmény a D-hez a DCD automatikus kiegészítő kiszolgáló használatával
-Comment[ia]=Lumen es un plugin de autocompletion pro D, usante le servitor de autocompletion DCD
-Comment[ko]=Lumen은 DCD를 자동 완성 서버로 사용하는 D 자동 완성 플러그인
-Comment[nb]=Lumen er et tillegg for autofullføring for D, som bruker DCD som tjener for autofullføring
-Comment[nds]=Lumen is en D-Kompletteermoduul, bruukt den DCD as Kompletteerserver
-Comment[nl]=Lumen is een plug-in voor automatisch aanvullen voor D, met gebruikmaking van de DCD-server voor automatisch aanvullen
-Comment[pl]=Lumen jest wtyczką samoczynnego uzupełniania dla D. Wykorzystuje serwer samoczynnego uzupełniania DCD.
-Comment[pt]=O Lumen é um 'plugin' de completação automática para o D, usando o servidor de completação automática DCD
-Comment[pt_BR]=Lumen é um plugin de autocompletar palavras para o D, usando o servidor de completação automática DCD
-Comment[ru]=Lumen — модуль автодополнения для языка D, использующий сервер автодополнения DCD
-Comment[sk]=Lumen je plugin pre automatické dokončovanie pre D, pomocou servera automatického dokončovania DCD
-Comment[sl]=Lumen je vstavek za samodejno dopolnjevanje za D, ki uporablja strežnik DCD
-Comment[sr]=Лумен је прикључак за самодопуну за Д, преко ДЦД‑овог сервера
-Comment[sr@ijekavian]=Лумен је прикључак за самодопуну за Д, преко ДЦД‑овог сервера
-Comment[sr@ijekavianlatin]=Lumen je priključak za samodopunu za D, preko DCD‑ovog servera
-Comment[sr@latin]=Lumen je priključak za samodopunu za D, preko DCD‑ovog servera
-Comment[sv]=Lumen insticksprogram för automatisk komplettering av D, som använder DCD-servern för automatisk komplettering
-Comment[tr]=Lumen D için DCD otomatik tamamlama sunucusu kullanan Otomatik Tamamlama Eklentisi'dir.
-Comment[uk]=Lumen — додаток автоматичного доповнення коду мовою D, якому використано сервер доповнення DCD
-Comment[x-test]=xxLumen is a Autocompletion Plugin for D, using the DCD autocompletion serverxx
-Comment[zh_CN]=Lumen 是 D 语言自动补全插件,使用的是 DCD 自动补全服务器
-Comment[zh_TW]=Lumen 是 D 的自動補完外掛程式,使用 DCD 自動補完伺服器
+++ /dev/null
-/*
- * Copyright 2014 David Herberth kde@dav1d.de
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) version 3, or any
- * later version accepted by the membership of KDE e.V. (or its
- * successor approved by the membership of KDE e.V.), which shall
- * act as a proxy defined in Section 6 of version 3 of the license.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
-**/
-
-#include "lumen.h"
-
-#include <kpluginfactory.h>
-#include <kaboutdata.h>
-#include <ktexteditor/document.h>
-#include <ktexteditor/range.h>
-#include <ktexteditor/view.h>
-#include <ktexteditor/codecompletioninterface.h>
-#include <ktexteditor/codecompletionmodel.h>
-#include <ktexteditor/texthintinterface.h>
-#include <kactioncollection.h>
-#include <QtCore/QFile>
-#include <QtCore/QDir>
-
-
-K_PLUGIN_FACTORY_DEFINITION(
- LumenPluginFactory, registerPlugin<LumenPlugin>("ktexteditor_lumen");
-)
-
-K_EXPORT_PLUGIN(
- LumenPluginFactory(
- KAboutData(
- "ktexteditor_lumen",
- "ktexteditor_plugins",
- ki18n("Lumen"),
- "0.1",
- ki18n("Lumen"),
- KAboutData::License_LGPL_V2,
- ki18n("© David Herberth"),
- ki18n("D Autocompletion plugin using DCD as completion server.")
- )
- )
-)
-
-
-LumenPluginView::LumenPluginView(LumenPlugin *plugin, KTextEditor::View *view): QObject(plugin),KXMLGUIClient(view),m_view(view),m_registered(false)
-{
- m_plugin = plugin;
- m_model = new LumenCompletionModel((QObject*)m_view, m_plugin->dcd());
-
- KTextEditor::Document* document = view->document();
-
- connect(document, SIGNAL(documentUrlChanged(KTextEditor::Document*)),
- this, SLOT(urlChanged(KTextEditor::Document*)));
-
- registerCompletion();
- registerTextHints();
-}
-
-void LumenPluginView::registerCompletion()
-{
- KTextEditor::CodeCompletionInterface *completion =
- qobject_cast<KTextEditor::CodeCompletionInterface*>(m_view);
-
- bool isD = m_view->document()->url().path().endsWith(".d") ||
- m_view->document()->highlightingMode() == "D";
-
- if (isD && !m_registered) {
- completion->registerCompletionModel(m_model);
- m_registered = true;
- } else if(!isD && m_registered) {
- completion->unregisterCompletionModel(m_model);
- m_registered = false;
- }
-}
-
-void LumenPluginView::registerTextHints()
-{
- KTextEditor::TextHintInterface *th =
- qobject_cast<KTextEditor::TextHintInterface*>(m_view);
- th->enableTextHints(500);
-
- connect(m_view, SIGNAL(needTextHint(const KTextEditor::Cursor&, QString &)),
- this, SLOT(getTextHint(const KTextEditor::Cursor&, QString &)));
-}
-
-void LumenPluginView::getTextHint(const KTextEditor::Cursor& cursor, QString& text)
-{
- KTextEditor::Document* document = m_view->document();
-
- KTextEditor::Cursor cursorEnd = document->documentEnd();
- KTextEditor::Range range0c = KTextEditor::Range(0, 0, cursor.line(), cursor.column());
- KTextEditor::Range rangece = KTextEditor::Range(cursor.line(), cursor.column(),
- cursorEnd.line(), cursorEnd.column());
- QString text0c = document->text(range0c, false);
- QByteArray utf8 = text0c.toUtf8();
- int offset = utf8.length();
- utf8.append(document->text(rangece, false).toUtf8());
-
- text = m_plugin->dcd()->doc(utf8, offset).trimmed().replace("\\n", "\n");
-}
-
-LumenPluginView::~LumenPluginView()
-{
-}
-
-void LumenPluginView::urlChanged(KTextEditor::Document* document)
-{
- registerCompletion();
-
- QStringList paths;
- for (KUrl url = document->url(); !url.equals(KUrl("/")); url = url.upUrl()) {
- url = url.directory();
- url.addPath(".lumenconfig");
-
- QFile file(url.path());
- if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- while (!file.atEnd()) {
- QString path = file.readLine().trimmed();
- // KUrl doesn really provide this functionallity
- if (QDir::isRelativePath(path)){
- path = QDir::cleanPath(
- url.directory() + QDir::separator() + path
- );
- }
-
- paths.append(path);
- }
- }
- }
-
- if (!paths.isEmpty()) {
- m_plugin->dcd()->addImportPath(paths);
- }
-}
-
-
-LumenPlugin::LumenPlugin(QObject *parent, const QVariantList &): Plugin(parent)
-{
- m_dcd = new DCD(9166, "dcd-server", "dcd-client");
- m_dcd->startServer();
-}
-
-LumenPlugin::~LumenPlugin()
-{
- m_dcd->stopServer();
- delete m_dcd;
-}
-
-DCD* LumenPlugin::dcd()
-{
- return m_dcd;
-}
-
-
-void LumenPlugin::addView(KTextEditor::View *view)
-{
- m_views.insert(view, new LumenPluginView(this, view));
-}
-
-void LumenPlugin::removeView(KTextEditor::View *view)
-{
- delete m_views.take(view);
-}
-
-#include "moc_lumen.cpp"
+++ /dev/null
-/*
- * Copyright 2014 David Herberth kde@dav1d.de
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) version 3, or any
- * later version accepted by the membership of KDE e.V. (or its
- * successor approved by the membership of KDE e.V.), which shall
- * act as a proxy defined in Section 6 of version 3 of the license.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
-**/
-
-#ifndef LUMEN_H
-#define LUMEN_H
-
-#include <ktexteditor/plugin.h>
-#include <ktexteditor/range.h>
-
-#include <kpluginfactory.h>
-
-#include <QtCore/qvariant.h>
-
-#include <kaction.h>
-#include <kxmlguiclient.h>
-#include "dcd.h"
-#include "completion.h"
-
-class LumenPlugin;
-
-class LumenPluginView: public QObject, public KXMLGUIClient
-{
- Q_OBJECT
- public:
- LumenPluginView(LumenPlugin *plugin, KTextEditor::View *view);
- virtual ~LumenPluginView();
- void registerCompletion();
- void registerTextHints();
- private slots:
- void urlChanged(KTextEditor::Document*);
- void getTextHint(const KTextEditor::Cursor&, QString&);
- private:
- LumenPlugin *m_plugin;
- QPointer<KTextEditor::View> m_view;
- LumenCompletionModel *m_model;
- bool m_registered;
-};
-
-class LumenPlugin: public KTextEditor::Plugin
-{
- Q_OBJECT
- public:
- LumenPlugin(QObject *parent, const QVariantList & = QVariantList());
- ~LumenPlugin();
- DCD* dcd();
- void addView(KTextEditor::View *view);
- void removeView(KTextEditor::View *view);
- virtual void readConfig(KConfig*) {}
- virtual void writeConfig(KConfig*) {}
- private:
- QMap<KTextEditor::View*,LumenPluginView*> m_views;
- DCD* m_dcd;
-};
-
-K_PLUGIN_FACTORY_DECLARATION(LumenPluginFactory)
-
-#endif