Commit c2295b3e authored by Christoph Cullmann's avatar Christoph Cullmann

Merge branch 'master' into frameworks

parents 12beef19 91c8d03d
REVIEWBOARD_URL = "https://git.reviewboard.kde.org"
REPOSITORY = "git://anongit.kde.org/kate"
TARGET_GROUPS = "kate"
BRANCH = "master"
......@@ -1011,7 +1011,7 @@ void KateBuildView::slotDeleteTargetClicked()
QString target = m_targetsUi->targetsList->item(row, COL_NAME)->text();
int result = KMessageBox::questionYesNo(0, QString(i18n("Really delete target %1 ?")).arg(target));
int result = KMessageBox::questionYesNo(0, QString(i18n("Really delete target %1?")).arg(target));
if (result == KMessageBox::No) {
return;
}
......
......@@ -55,5 +55,6 @@ install(
# Dive into plugins crowd
add_subdirectory(plugins)
add_subdirectory(test)
# kate: indent-width 4;
This diff is collapsed.
......@@ -21,6 +21,8 @@
#ifndef __PATE_ENGINE_H__
# define __PATE_ENGINE_H__
# include "version_checker.h"
# include <KService>
# include <KUrl>
# include <Python.h>
......@@ -64,6 +66,7 @@ public:
const QString& errorReason() const;
bool isEnabled() const;
bool isBroken() const;
bool isUnstable() const;
//@}
private:
......@@ -78,6 +81,7 @@ public:
QString m_errorReason;
bool m_enabled;
bool m_broken;
bool m_unstable;
bool m_isDir;
};
......@@ -130,6 +134,13 @@ private:
};
};
static bool isServiceUsable(const KService::Ptr&); ///< Make sure that service is usable
static bool setModuleProperties(PluginState&);
static void verifyDependenciesSetStatus(PluginState&);
static QPair<QString, version_checker> parseDependency(const QString&);
static version tryObtainVersionFromTuple(PyObject*);
static version tryObtainVersionFromString(PyObject*);
PyObject* m_configuration; ///< Application-wide configuration data
PyObject* m_sessionConfiguration; ///< Session-wide configuration data
QList<PluginState> m_plugins; ///< List of available plugins
......@@ -157,6 +168,10 @@ inline bool Engine::PluginState::isBroken() const
{
return m_broken;
}
inline bool Engine::PluginState::isUnstable() const
{
return m_unstable;
}
inline const QList<Engine::PluginState>& Engine::plugins() const
{
......
......@@ -28,7 +28,6 @@ from PyKate4.kate import Kate
import pate
class NoActiveView(Exception):
pass
application = Kate.application()
......@@ -59,6 +58,7 @@ def mainWindow():
the actual widget main window. If you need to access the
Kate.MainWindow for the methods it provides (e.g createToolView),
then use the mainInterfaceWindow function '''
assert('Sanity check' and application.activeMainWindow() is not None)
return application.activeMainWindow().window()
......@@ -66,6 +66,7 @@ def activeView():
''' The currently active view. Access its KTextEditor.Document
by calling document() on it (or by using kate.activeDocument()).
This is a shortcut for kate.application.activeMainWindow().activeView()'''
assert('Sanity check' and application.activeMainWindow() is not None)
return application.activeMainWindow().activeView()
......
......@@ -27,6 +27,7 @@ import xml.dom.minidom
from PyQt4 import QtCore, QtGui
from PyKDE4 import kdecore, kdeui
from PyKDE4.kdecore import i18nc
import pate
......@@ -221,6 +222,10 @@ class _catchAllHandler(object):
raise _HandledException(txt)
class InvalidAction(Exception):
pass
def action(func):
''' Decorator that adds an action to the menu bar. When the item is fired,
your function is called
......@@ -277,6 +282,8 @@ def action(func):
act.setWhatsThis(tag.attributes['whatsThis'].value)
# Connect it to the function
act.connect(act, QtCore.SIGNAL('triggered()'), func)
# Make an action accessible from the targeted function as its attribute
setattr(func, 'action', act)
# No need to scan anything else!!!
# ATTENTION It is why the very first action declaration
# MUST contain everything! While others, w/ same name,
......@@ -285,8 +292,14 @@ def action(func):
break
if not found:
# TODO Show some SPAM about inconsistent action
pass
raise InvalidAction(
i18nc(
'@info:tooltip'
, 'Invalid <filename>%1</filename> file: No action with name <icode>%2</icode> defined'
, ui_file
, func.__name__
)
)
if plugin not in _registered_xml_gui_clients:
_registered_xml_gui_clients[plugin] = clnt
......
......@@ -23,6 +23,7 @@ Comment[sv]=Kate Python-insticksprogram
Comment[tr]=Kate Python Eklentisi
Comment[uk]=Додаток Python для Kate
Comment[x-test]=xxKate Python Pluginxx
Comment[zh_TW]=Kate Python 外掛程式
[PropertyDef::X-Python-2-Compatible]
Type=bool
......
......@@ -61,10 +61,10 @@ const KAboutData& getAboutData()
{
static KAboutData about = KAboutData(
"katepateplugin"
, "katepateplugin"
, ki18n("Pate Plugin") // BUG "Pâté" in a title bar looks incorrectly
, "1.0"
, "pate"
, ki18n("Pâté host for Python plugins")
, "2.0"
, ki18n("Python interpreter settings")
, KAboutData::License_LGPL_V3
);
return about;
......@@ -142,11 +142,29 @@ bool Pate::Plugin::checkEngineShowPopup() const
KPassivePopup::message(
i18nc("@title:window", "Pate engine could not be initialised")
, m_engineFailureReason
//, KIcon("dialog-error").pixmap(16, 16)
, static_cast<QWidget*>(0)
);
return false;
}
else
{
// Check if some modules are not available and show warning
unsigned broken_modules_count = 0;
Q_FOREACH(const Engine::PluginState& plugin, m_engine.plugins())
broken_modules_count += unsigned(plugin.isEnabled() && plugin.isBroken());
if (broken_modules_count)
KPassivePopup::message(
i18nc("@title:window", "Warning")
, i18ncp(
"@info:tooltip %1 is a number of failed plugins"
, "%1 plugin module couldn't be loaded. Check the Python plugins config page for details."
, "%1 plugin modules couldn't be loaded. Check the Python plugins config page for details."
, broken_modules_count
)
, static_cast<QWidget*>(0)
);
}
return true;
}
......@@ -294,7 +312,7 @@ Pate::PluginView::PluginView(Kate::MainWindow* const window, Plugin* const plugi
, m_plugin(plugin)
{
KAction* about = actionCollection()->addAction("about_pate");
about->setText("About Pate");
about->setText(i18n("About Pate"));
about->setIcon(KIcon("python"));
connect(about, SIGNAL(triggered(bool)), this, SLOT(aboutPate()));
......@@ -311,8 +329,8 @@ Pate::PluginView::PluginView(Kate::MainWindow* const window, Plugin* const plugi
{
m_plugin->setFailureReason(i18nc("@info:tooltip ", "Cannot load <icode>kate</icode> module"));
m_plugin->engine().setBroken();
m_plugin->checkEngineShowPopup();
}
m_plugin->checkEngineShowPopup();
// Inject collected actions into GUI
mainWindow()->guiFactory()->addClient(this);
}
......@@ -328,32 +346,31 @@ void Pate::PluginView::aboutPate()
KAboutData about = getAboutData();
// Set other text to show some info about Python used
// NOTE Separate scope around Python() instance
QString pythonInfoText = QString(
"Embedded Python version %1<br/>"
"Python paths: <pre><code>"
).arg(PY_VERSION)
;
QStringList pythonPaths;
Python py = Python();
if (PyObject* sysPath = py.itemString("path", "sys"))
{
Python py = Python();
if (PyObject* sysPath = py.itemString("path", "sys"))
Py_ssize_t len = PyList_Size(sysPath);
for (Py_ssize_t i = 0; i < len; i++)
{
Py_ssize_t len = PyList_Size(sysPath);
for (Py_ssize_t i = 0; i < len; i++)
{
PyObject* path = PyList_GetItem(sysPath, i);
pythonInfoText += Python::unicode(path) + '\n';
}
PyObject* path = PyList_GetItem(sysPath, i);
pythonPaths += Python::unicode(path);
}
}
pythonInfoText += "</code></pre>";
/// \todo Show info about loaded modules? Problems?
/// \attention It seems about dialog is not customizable much...
/// Particularly it would be nice to add a custom tab...
/// So \b dirty hack is here...
about.setOtherText(ki18n(pythonInfoText.toUtf8().constData()));
about.setOtherText(ki18nc("Python variables, no translation needed",
"sys.version = %1<br/>sys.path = %2").
subs(PY_VERSION).subs(pythonPaths.join(",\n&nbsp;&nbsp;&nbsp;&nbsp;")));
/// \todo Add logo, authors and everything...
about.setProgramIconName("python");
about.addAuthor(ki18n("Paul Giannaros"), ki18n("Out-of-tree original"), "paul@giannaros.org");
about.addAuthor(ki18n("Shaheed Haque"), ki18n("Rewritten and brought in-tree, V1.0"), "srhaque@theiet.org");
about.addAuthor(ki18n("Alex Turbov"), ki18n("Streamlined and updated, V2.0"), "i.zaufi@gmail.com");
KAboutApplicationDialog ad(&about, KAboutApplicationDialog::HideKdeVersion);
ad.exec();
}
......
......@@ -11,6 +11,7 @@ install(
katepate_expand.desktop
katepate_format.desktop
katepate_python_autocomplete_jedi.desktop
katepate_try_open_file.desktop
katepate_xml_pretty.desktop
python_autocomplete/katepate_python_autocomplete.desktop
python_console_classic/katepate_python_console_classic.desktop
......@@ -30,6 +31,7 @@ install(
expand.py expand_ui.rc
format.py format_ui.rc
python_autocomplete_jedi.py
try_open_file.py try_open_file_ui.rc
xml_pretty.py xml_pretty.ui xml_pretty_ui.rc
DESTINATION ${DATA_INSTALL_DIR}/kate/pate
)
......
......@@ -22,6 +22,7 @@ Name[sv]=CMake-verktyg
Name[tr]=CMake Araçları
Name[uk]=Інструменти CMake
Name[x-test]=xxCMake Utilitiesxx
Name[zh_TW]=CMake 工具
Comment=Code completer, cache and help browser
Comment[de]=Quelltext-Vervollständigung, Zwischenspeicher und Hilfe-Browser
Comment[fi]=Koodintäydennys sekä välimuistin ja ohjeiden selain
......@@ -41,3 +42,4 @@ Comment[sv]=Kodkomplettering, cache och hjälpbläddrare
Comment[tr]=Kod tamamlayıcı, önbellek ve yardım tarayıcısı
Comment[uk]=Доповнювач коду, переглядач кешу та довідки
Comment[x-test]=xxCode completer, cache and help browserxx
Comment[zh_TW]=源碼補完器,快取及說明瀏覽器
......@@ -4,9 +4,10 @@
# document. To get help (via tooltip) for the selected expansion function use
# Ctrl+Shift+E shotcut.
#
# TODO Use jinja2 to handle templates
#
import kate
from libkatepate import ui
_BRIEF_DOC_TPL = '''/**
* \\brief Class \c {0}
......
......@@ -3,26 +3,37 @@ Type=Service
ServiceTypes=Kate/PythonPlugin
X-KDE-Library=gid
Name=GNU idutils plugin
Name[cs]=Modul GNU idutils
Name[de]=„GNU Idutils“-Modul
Name[gl]=Complemento das GNU idutils
Name[ia]=Plug-in de GNU idutils
Name[kk]=GNU idutils плагині
Name[nl]=Plug-in voor GNU idutils
Name[pt]='Plugin' do 'idutils' da GNU
Name[pt_BR]=Plugin do GNU idutils
Name[sk]=GNU idutils plugin
Name[sl]=Vstavek GNU idutils
Name[sr]=Прикључак за Гнуове ИД алатке
Name[sr@ijekavian]=Прикључак за Гнуове ИД алатке
Name[sr@ijekavianlatin]=Priključak za GNU‑ove ID alatke
Name[sr@latin]=Priključak za GNU‑ove ID alatke
Name[sv]=GNU idutils-insticksprogram
Name[uk]=Додаток GNU idutils
Name[x-test]=xxGNU idutils pluginxx
Comment=Browse the tokens in a GNU idutils ID file
Comment[de]=Durchsuchen Sie die Token in einer ID-Datei von „GNU-Idutils“
Comment[gl]=Examina os tokens dun ficheiro de identificadores de GNU idutils
Comment[ia]=Explora indicios in un file de GNU idutils ID
Comment[kk]=GNU idutils ID файлдағы өрнектерді шолу
Comment[nl]=Blader door de tokens in een GNU idutils ID-bestand
Comment[pt]=Navega pelos itens de um ficheiro ID do 'idutils' da GNU
Comment[pt_BR]=Navega pelos itens de um arquivo ID do GNU idutils
Comment[sk]=Prehliadať tokeny v ID súbore GNU idutils
Comment[sl]=Brskajte po žetonih v datoteki GNU idutils ID
Comment[sr]=Прегледајте токене у фајлу Гнуових ИД алатки
Comment[sr@ijekavian]=Прегледајте токене у фајлу Гнуових ИД алатки
Comment[sr@ijekavianlatin]=Pregledajte tokene u fajlu GNU‑ovih ID alatki
Comment[sr@latin]=Pregledajte tokene u fajlu GNU‑ovih ID alatki
Comment[sv]=Bläddra bland symbolerna i en GNU idutils id-fil
Comment[uk]=Перегляд ключів у файлі ідентифікаторів GNU idutils
Comment[x-test]=xxBrowse the tokens in a GNU idutils ID filexx
......
......@@ -22,6 +22,7 @@ Name[sv]=Javascript-verktyg
Name[tr]=JavaScript Araçları
Name[uk]=Інструменти JavaScript
Name[x-test]=xxJavaScript Utilitiesxx
Name[zh_TW]=JavaScript 工具
Comment=JS and jQuery autocompletion, a jQuery ready snippet, JSLint/JSHint
Comment[de]=Auto-Vervollständigung für JS und jQuery, jQuery-Textbaustein, jSLint/JSHint
Comment[gl]=Completador de código, caché e navegador de axuda
......@@ -40,4 +41,5 @@ Comment[sv]=JS och jQuery automatisk komplettering, jQuery klar kodsnutt, JSLint
Comment[tr]=JS ve jQuery otomatik tamamlama, bir jQuery hazır kodu, JSLint/JSHint
Comment[uk]=Автодоповнення JS і jQuery, фрагмент ready jQuery, JSLint/JSHint
Comment[x-test]=xxJS and jQuery autocompletion, a jQuery ready snippet, JSLint/JSHintxx
Comment[zh_TW]=JS 與 jQuery 自動補完,jQuery 就緒片段,JSLint/JSHint
X-Python-2-Compatible=true
......@@ -7,6 +7,7 @@ Name[de]=Block
Name[gl]=Bloque
Name[ia]=Bloco
Name[kk]=Блок
Name[nb]=Blokk
Name[nl]=Blok
Name[pt]=Bloco
Name[pt_BR]=Bloco
......@@ -20,6 +21,7 @@ Name[sv]=Rektangel
Name[tr]=Blok
Name[uk]=Блок
Name[x-test]=xxBlockxx
Name[zh_TW]=區塊
Comment=Various actions to help code editing
Comment[de]=Verschiedene Aktionen zur Hilfe bei dem Editieren von Quelltext
Comment[es]=Diversas acciones para ayudar en la edición de código
......@@ -39,4 +41,5 @@ Comment[sv]=Diverse åtgärder för att hjälpa till vid kodredigering
Comment[tr]=Kod düzenlemeye yardımcı olmak için çeşitli eylemler
Comment[uk]=Різноманітні засоби допомоги у редагуванні коду
Comment[x-test]=xxVarious actions to help code editingxx
Comment[zh_TW]=協助程式編輯的多個動作
X-Python-2-Compatible=true
......@@ -22,6 +22,7 @@ Name[sv]=Färgverktyg
Name[tr]=Renk Araçları
Name[uk]=Засоби роботи з кольорами
Name[x-test]=xxColor Toolsxx
Name[zh_TW]=色彩工具
Comment=Utilities to work with hexadecimal colors in documents
Comment[de]=Hilfsmittel zum Umgang mit Hexadezimalwerten für Farben in Dokumenten
Comment[es]=Utilidades para trabajar con colores en hexadecimal en los documentos
......@@ -42,4 +43,5 @@ Comment[sv]=Verktyg för att arbeta med hexadecimala färger i dokument
Comment[tr]=Belgelerde onaltılık renklerle çalışmak için yardımcılar
Comment[uk]=Засоби для роботи з шістнадцятковими кольорами у документах
Comment[x-test]=xxUtilities to work with hexadecimal colors in documentsxx
Comment[zh_TW]=在文件中編輯十六進制色彩碼的工具
X-Python-2-Compatible=true
......@@ -22,6 +22,7 @@ Name[sv]=Insticksprogram för att arbeta med kommentarer
Name[tr]=Yorumlarla çalışmak için eklentiler
Name[uk]=Додатки для роботи з коментарями
Name[x-test]=xxPlugins to work with commentsxx
Name[zh_TW]=處理註解的外掛程式
Comment=Supported languages are C++, JS, Python, CMake, Bash
Comment[de]=Unterstützte Sprachen sind C++, JS, Python, CMake, Bash
Comment[es]=Los lenguajes permitidos son C++, JS, Python, CMake y Bash
......@@ -42,4 +43,5 @@ Comment[sv]=Språk som stöds är C++, JS, Python, CMake, Bash
Comment[tr]=Desteklenen diller C++, JS, Python, CMake, Bash
Comment[uk]=Підтримуваними мовами є C++, JS, Python, CMake, Bash
Comment[x-test]=xxSupported languages are C++, JS, Python, CMake, Bashxx
Comment[zh_TW]=支援的語言包括 C++,JS,Python,CMake 與 Bash
X-Python-2-Compatible=true
......@@ -21,6 +21,7 @@ Name[sv]=Användardefinierad textexpansion
Name[tr]=Kullanıcı tanımlı metin açılımları
Name[uk]=Визначені користувачем засоби розгортання коду
Name[x-test]=xxUser defined text expansionsxx
Name[zh_TW]=使用預定義的文字擴展
Comment=Execute expansion function and insert output into a document
Comment[de]=Führt die Erweiterungsfunktion aus und fügt die Ausgabe in ein Dokument ein
Comment[es]=Ejecutar la función de expansión e insertar la salida en un documento
......@@ -40,4 +41,5 @@ Comment[sv]=Utför expansionsfunktion och infoga utdata i ett dokument
Comment[tr]=Genişleme fonksiyonu uygulayın ve çıktıyı bir belgeye ekleyin
Comment[uk]=Виконати функцію розширення і вставити виведені нею дані до документа
Comment[x-test]=xxExecute expansion function and insert output into a documentxx
Comment[zh_TW]=執行擴展函式並將輸出插入到文件中
X-Python-2-Compatible=true
......@@ -20,6 +20,7 @@ Name[sv]=Boost-liknande C++ kodformatering
Name[tr]=Boost benzeri C++ Kod Biçimlendirici
Name[uk]=Засіб форматування коду C++ у стилі Boost
Name[x-test]=xxBoost-like C++ Code Formatterxx
Name[zh_TW]=類似 Boost 的 C++ 程式碼編排器
Comment=Help to format calls/templates in boost style
Comment[de]=Hilfe zur Formatierung von Aufrufen / Vorlagen im Boost-Stil
Comment[gl]=Axuda a formatar as chamadas/modelos ao estilo de Boost
......@@ -38,4 +39,5 @@ Comment[sv]=Hjälp att formatera anrop och mallar med Boost-stil
Comment[tr]=Çağrı ve şablonları boost biçeminde biçimlendirmej için yardım
Comment[uk]=Допоміжний інструмент форматування викликів та шаблонів у стилі boost
Comment[x-test]=xxHelp to format calls/templates in boost stylexx
Comment[zh_TW]=協助以 boost 樣式編排呼叫/templates
X-Python-2-Compatible=true
......@@ -22,17 +22,23 @@ Name[sv]=Python automatisk komplettering
Name[tr]=Python Otomatik Tamamlama
Name[uk]=Автодоповнення Python
Name[x-test]=xxPython Autocompletionxx
Name[zh_TW]=Python 自動補完
Comment=Based on the Jedi library
Comment[de]=Entwickelt aus der Jedi-Bibliothek
Comment[gl]=Baseado na biblioteca Jedi
Comment[ia]=Basate sur le bibliotheca Jedi
Comment[kk]=Jedi жиын файлды негіздеген
Comment[nl]=Gebaseerd op de Jedi-bibliotheek
Comment[pt]=Baseado na biblioteca Jedi
Comment[pt_BR]=Baseado na biblioteca Jedi
Comment[sk]=Založené na knižnici Jedi
Comment[sl]=Temelji na knjižnici Jedi
Comment[sr]=Над библиотеком Џедај
Comment[sr@ijekavian]=Над библиотеком Џедај
Comment[sr@ijekavianlatin]=Nad bibliotekom Jedi
Comment[sr@latin]=Nad bibliotekom Jedi
Comment[sv]=Baserat på Jedi-biblioteket
Comment[uk]=Засновано на бібліотеці Jedi
Comment[x-test]=xxBased on the Jedi libraryxx
X-Python-2-Compatible=true
X-Python-Dependencies=jedi|jedi>=0.5b5
X-Python-Dependencies=jedi(>=0.7.0)
[Desktop Entry]
Type=Service
ServiceTypes=Kate/PythonPlugin
X-KDE-Library=try_open_file
Name=Easy file open/create
Name[de]=Einfacher Öffnen/Erstellen von Dateien
Name[gl]=Abrir/Crear ficheiro doadamente
Name[ia]=Aperir/crear file de modo facile
Name[nl]=Gemakkelijk openen/aanmaken van een bestand
Name[pt]=Abertura/criação simples de ficheiros
Name[pt_BR]=Abertura/criação simples de arquivos
Name[sk]=Ľahko otvoriť/vytvoriť súbor
Name[sl]=Enostavno odpri/ustvari datoteko
Name[sr]=Лако отварање и стварање фајлова
Name[sr@ijekavian]=Лако отварање и стварање фајлова
Name[sr@ijekavianlatin]=Lako otvaranje i stvaranje fajlova
Name[sr@latin]=Lako otvaranje i stvaranje fajlova
Name[sv]=Öppna/skapa fil enkelt
Name[uk]=Просте відкриття та створення файлів
Name[x-test]=xxEasy file open/createxx
Comment=Try to open selected text as URI to a document
Comment[de]=Öffnen des ausgewählten Textes als URI zu einem Dokument
Comment[gl]=Tenta abrir o texto escollido como se fose a URI dun documento
Comment[ia]=Essaya aperir texto seligite como URI pro un documento
Comment[nl]=Probeer de geselecteerde tekst als URI naar een document te openen
Comment[pt]=Tentar abrir o texto seleccionado como o URI de um documento
Comment[pt_BR]=Tenta abrir o texto selecionado como a URI de um documento
Comment[sk]=Skúsiť otvoriť vybraný text ako URI do dokumentu
Comment[sl]=Poskusi odpreti izbrano besedilo kot URI do dokumenta
Comment[sr]=Отворите изабрани текст као УРИ документа
Comment[sr@ijekavian]=Отворите изабрани текст као УРИ документа
Comment[sr@ijekavianlatin]=Otvorite izabrani tekst kao URI dokumenta
Comment[sr@latin]=Otvorite izabrani tekst kao URI dokumenta
Comment[sv]=Försök öppna markerad text som en dokumentwebbadress
Comment[uk]=Відкриття позначеного тексту як адреси документа
Comment[x-test]=xxTry to open selected text as URI to a documentxx
......@@ -3,26 +3,37 @@ Type=Service
ServiceTypes=Kate/PythonPlugin
X-KDE-Library=xml_pretty
Name=XML Tools
Name[cs]=Nástroje XML
Name[de]=XML-Werkzeuge
Name[gl]=Utilidades XML
Name[ia]=Instrumentos de XML
Name[kk]=XML құралдары
Name[nl]=XML-hulpmiddelen
Name[pt]=Ferramentas de XML
Name[pt_BR]=Ferramentas de XML
Name[sk]=XML nástroje
Name[sl]=Orodja za XML
Name[sr]=ИксМЛ алатке
Name[sr@ijekavian]=ИксМЛ алатке
Name[sr@ijekavianlatin]=XML alatke
Name[sr@latin]=XML alatke
Name[sv]=XML-verktyg
Name[uk]=Засоби XML
Name[x-test]=xxXML Toolsxx
Comment=XML Pretty print
Comment[de]=XML-Quelltextformatierung
Comment[gl]=Versión para ler XML
Comment[ia]=Imprime como XML pretty
Comment[kk]=XML безендіруі
Comment[nl]=XML mooie afdruk
Comment[pt]=Impressão bonita do XML
Comment[pt_BR]=Impressão bonita de XML
Comment[sk]=XML Pekná tlač
Comment[sl]=Lep tisk za XML
Comment[sr]=Улепшан испис ИксМЛ‑а
Comment[sr@ijekavian]=Улепшан испис ИксМЛ‑а
Comment[sr@ijekavianlatin]=Ulepšan ispis XML‑a
Comment[sr@latin]=Ulepšan ispis XML‑a
Comment[sv]=XML snygg utskrift
Comment[uk]=Форматування XML
Comment[x-test]=xxXML Pretty printxx
......
......@@ -22,6 +22,7 @@ Name[sv]=Python automatisk komplettering
Name[tr]=Python Otomatik Tamamlama
Name[uk]=Автодоповнення Python
Name[x-test]=xxPython Autocompletionxx
Name[zh_TW]=Python 自動補完
Comment=Beta, only for Python 2
Comment[de]=Beta, nur für Python 2
Comment[es]=Beta, solo para Python 2
......@@ -42,6 +43,7 @@ Comment[sv]=Beta, bara för Python 2
Comment[tr]=Beta, sadece Python 2 için
Comment[uk]=Тестова версія, лише для Python 2
Comment[x-test]=xxBeta, only for Python 2xx
Comment[zh_TW]=Beta 版,只適用 Python 2
X-Python-2-Compatible=true
X-Python-2-Only=true
X-Python-2-Dependencies=pysmell|>=0.7.3,pyplete|>=0.0.5
X-Python-2-Dependencies=pysmell(>=0.7.3),pyplete(>=0.0.5)
......@@ -10,23 +10,21 @@ Autocompletion in python you want? Become a [Jedi] you must!
[Worried]: https://github.com/davidhalter/jedi#a-little-history
"""
from collections import defaultdict
import kate
from PyQt4.QtCore import Qt, QModelIndex
from libkatepate.autocomplete import CodeCompletionBase
from PyKDE4.kdeui import i18nc, KIcon
from PyKDE4.kdecore import i18nc
from PyKDE4.kdeui import KIcon
from PyKDE4.ktexteditor import KTextEditor
CCM = KTextEditor.CodeCompletionModel # alias for easier typing
from jedi.api import Script
import kate
from libkatepate.autocomplete import CodeCompletionBase
#################
### constants ###
#################
# alias for easier typing
CCM = KTextEditor.CodeCompletionModel
TYPE2ICON = defaultdict(lambda: 'unknown') # Jedi completion types to KIcon converter
......@@ -40,12 +38,8 @@ TYPE2ICON.update({
})
#################
### main code ###
#################
def func_param_strings(call_def): # TODO: do kwargs instead; #TODO: support kwarg-only
def _func_param_strings(call_def): # TODO: do kwargs instead; #TODO: support kwarg-only
"""Create strings that form a parameter list
e.g. for fun(a, b, c); completing after “fun(a,” yields 'fun(a, ' and ', c)'
......@@ -84,6 +78,7 @@ class JediCompletionModel(CodeCompletionBase):
super(JediCompletionModel, self).__init__(parent)
self.script = None
def completionInvoked(self, view, range_, invocation_type):
"""For the lack of a better event, we create a script here and remember its completions"""
doc = view.document()
......@@ -95,6 +90,7 @@ class JediCompletionModel(CodeCompletionBase):
self.resultList = self.script.complete()
def data(self, index, role):
"""Basically a 2D-lookup-table for all the things a code completion model can do"""
if not index.parent().isValid():
......@@ -109,7 +105,7 @@ class JediCompletionModel(CodeCompletionBase):
if role == Qt.DisplayRole:
call_def = self.script.get_in_function_call()
if call_def:
before, after = func_param_strings(call_def)
before, after = _func_param_strings(call_def)
if col == CCM.Prefix:
return before if call_def else None
......@@ -123,28 +119,22 @@ class JediCompletionModel(CodeCompletionBase):
return self.roles.get(role)
#################
### init code ###
#################
ccm = JediCompletionModel(kate.application) # TODO: only for python files, then remove mime check
ccm = JediCompletionModel(kate.application)
@kate.init
@kate.viewCreated
def init(view=None):
def init(view):
if view is None:
view = kate.activeView()
return
cci = view.codeCompletionInterface()
cci.registerCompletionModel(ccm)
#################
### resources ###
#################
#
# Resources to read
#
#model: http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html
#index: http://qt-project.org/doc/qt-4.8/qmodelindex.html#details
......