diff --git a/src/backends/sage/CMakeLists.txt b/src/backends/sage/CMakeLists.txt index 6be4fe0a..2742709d 100644 --- a/src/backends/sage/CMakeLists.txt +++ b/src/backends/sage/CMakeLists.txt @@ -1,32 +1,31 @@ set( SageBackend_SRCS sagebackend.cpp sagesession.cpp sageexpression.cpp sageextensions.cpp sagekeywords.cpp sagehighlighter.cpp sagecompletionobject.cpp ) kconfig_add_kcfg_files(SageBackend_SRCS settings.kcfgc) install(FILES sagebackend.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) ki18n_wrap_ui(SageBackend_SRCS settings.ui) add_backend(sagebackend ${SageBackend_SRCS}) target_link_libraries( cantor_sagebackend KF5::Pty) if(BUILD_TESTING) add_executable( testsage testsage.cpp) target_link_libraries( testsage ${QT_QTTEST_LIBRARY} cantorlibs cantortest ) add_test(NAME testsage COMMAND testsage) endif() -install( FILES cantor_sage.knsrc DESTINATION ${KDE_INSTALL_CONFDIR} ) -install( FILES keywords.xml DESTINATION ${KDE_INSTALL_DATADIR}/cantor/sagebackend) +install(FILES cantor_sage.knsrc DESTINATION ${KDE_INSTALL_CONFDIR}) diff --git a/src/backends/sage/keywords.xml b/src/backends/sage/keywords.xml deleted file mode 100644 index 04725e3f..00000000 --- a/src/backends/sage/keywords.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - and - del - from - not - while - as - elif - global - or - with - assert - else - if - pass - yield - break - except - import - print - class - exec - in - raise - continue - finally - is - return - def - for - lambda - try - - diff --git a/src/backends/sage/sagekeywords.cpp b/src/backends/sage/sagekeywords.cpp index 1b3fc723..2765a736 100644 --- a/src/backends/sage/sagekeywords.cpp +++ b/src/backends/sage/sagekeywords.cpp @@ -1,98 +1,62 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2012 Martin Kuettler */ #include "sagekeywords.h" -#include -#include -#include -#include - #include SageKeywords::SageKeywords() { } SageKeywords::~SageKeywords() { } SageKeywords* SageKeywords::instance() { static SageKeywords* inst=0; if(inst==0) { - inst=new SageKeywords(); - inst->loadFromFile(); - qSort(inst->m_keywords); + inst = new SageKeywords(); + inst->loadKeywords(); } return inst; } -void SageKeywords::loadFromFile() +void SageKeywords::loadKeywords() { - //load the known keywords from an xml file - QFile file(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("cantor/sagebackend/keywords.xml"))); - - if(!file.open(QIODevice::ReadOnly)) - { - qDebug()<<"error opening keywords.xml file. highlighting and completion won't work"; - return; - } - - QXmlStreamReader xml(&file); - - xml.readNextStartElement(); - while(xml.readNextStartElement()) - { - const QStringRef name=xml.name(); - - if(name==QLatin1String("keywords")) - { - while(xml.readNextStartElement()) - { - Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("word")); - - const QString text=xml.readElementText(); - - m_keywords< This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 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 14 of version 3 of the license. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _SAGEKEYWORDS_H #define _SAGEKEYWORDS_H #include /** Class to store all Sage keywords (i.e. Python keywords) It is similar to MaximaKeywords or ScilabKeywords, but for Sage we only need to store actual keywords, as variables and functions can be fetched from the backend. */ class SageKeywords { private: SageKeywords(); ~SageKeywords(); + public: static SageKeywords* instance(); const QStringList& keywords() const; //const QStringList& functions() const; //const QStringList& variables() const; private: - void loadFromFile(); + void loadKeywords(); QStringList m_keywords; }; #endif /* _SAGEKEYWORDS_H */