diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 385b354c..aed2458e 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,99 +1,99 @@ set( cantor_LIB_SRCS session.cpp expression.cpp backend.cpp result.cpp textresult.cpp imageresult.cpp epsresult.cpp latexresult.cpp latexrenderer.cpp helpresult.cpp animationresult.cpp extension.cpp assistant.cpp completionobject.cpp syntaxhelpobject.cpp defaulthighlighter.cpp defaultvariablemodel.cpp panelplugin.cpp panelpluginhandler.cpp worksheetaccess.cpp directives/plotdirectives.cpp ) Set( cantor_LIB_HDRS cantor_macros.h #base classes backend.h session.h expression.h extension.h syntaxhelpobject.h completionobject.h #results animationresult.h epsresult.h helpresult.h imageresult.h latexresult.h result.h textresult.h #helper classes defaulthighlighter.h defaultvariablemodel.h worksheetaccess.h ) ki18n_wrap_ui(cantor_LIB_SRCS directives/axisrange.ui directives/plottitle.ui) kconfig_add_kcfg_files(cantor_LIB_SRCS settings.kcfgc) install(FILES cantor_libs.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) configure_file (config-cantorlib.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-cantorlib.h ) add_library( cantorlibs SHARED ${cantor_LIB_SRCS} ) generate_export_header(cantorlibs BASE_NAME cantor) kcoreaddons_desktop_to_json(cantorlibs cantor_assistant.desktop DEFAULT_SERVICE_TYPE) kcoreaddons_desktop_to_json(cantorlibs cantor_backend.desktop DEFAULT_SERVICE_TYPE) kcoreaddons_desktop_to_json(cantorlibs cantor_panelplugin.desktop DEFAULT_SERVICE_TYPE) target_link_libraries( cantorlibs KF5::Completion KF5::IconThemes KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::Archive KF5::ConfigCore KF5::ConfigGui KF5::I18n KF5::XmlGui ${QT5_LIBRARIES} Qt5::Xml ) -set (CANTORLIBS_SOVERSION 23) +set (CANTORLIBS_SOVERSION 24) set_target_properties( cantorlibs PROPERTIES VERSION ${KDE_APPLICATIONS_VERSION} SOVERSION ${CANTORLIBS_SOVERSION}) ecm_setup_version(${KDE_APPLICATIONS_VERSION} VARIABLE_PREFIX CANTOR SOVERSION ${CANTORLIBS_SOVERSION} VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/cantorlibs_version.h ) install( TARGETS cantorlibs EXPORT CantorTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install( FILES ${cantor_LIB_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/cantor_export.h ${CMAKE_CURRENT_BINARY_DIR}/cantorlibs_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/cantor COMPONENT Devel ) if(BUILD_TESTING) add_subdirectory(test) endif() diff --git a/src/lib/defaulthighlighter.h b/src/lib/defaulthighlighter.h index b5a9e565..23b1c538 100644 --- a/src/lib/defaulthighlighter.h +++ b/src/lib/defaulthighlighter.h @@ -1,187 +1,187 @@ /* 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) 2009 Alexander Rieder */ #ifndef DEFAULTHIGHLIGHTER_H #define DEFAULTHIGHLIGHTER_H #include "cantor_export.h" #include class QGraphicsTextItem; namespace Cantor { class DefaultHighlighterPrivate; class Session; /** * The DefaultHighlighter is an implementation QSyntaxHighlighter. * It covers most common cases of syntax highlighting for Cantor's command entries. * * When creating a custom highlighter, for example for a new backend, you should use * the provided functions addPairs(), addRule() and/or addRules(). * * If you need more specific functionality, subclass highlightBlock(). Usually it's a good idea to also call * DefaultHighlighter's implementation from it. * * @author Alexander Rieder */ class CANTOR_EXPORT DefaultHighlighter : public QSyntaxHighlighter { Q_OBJECT public: explicit DefaultHighlighter(QObject* parent); explicit DefaultHighlighter(QObject* parent, Session* session); - ~DefaultHighlighter() override; + virtual ~DefaultHighlighter() override; /** * Change the item being highlighted. */ void setTextItem(QGraphicsTextItem* item); public Q_SLOTS: /** * Called when the cursor moved. Rehighlights accordingly. */ void positionChanged(const QTextCursor&); protected Q_SLOTS: /** * Convenience method, equivalent to @code addRules(functions, functionFormat()) @endcode */ void addFunctions(const QStringList& functions); /** * Convenience method, equivalent to @code addRules(variables, variableFormat()) @endcode */ void addVariables(const QStringList& variables); /** * Removes any rules previously added for the word @p word */ void removeRule(const QString& word); /** * Convenience method, removes all rules with conditions from @p conditions * @sa removeRule, addRules */ void removeRules(const QStringList& conditions); protected: /** * This method is called by Cantor's KTextEdit and is where all the highlighting must take place. * The default implementation calls highlightPairs(), highlightWords() and highlightRegExps(). * */ void highlightBlock(const QString& text) override; bool skipHighlighting(const QString& text); QTextCharFormat functionFormat() const; QTextCharFormat variableFormat() const; QTextCharFormat objectFormat() const; QTextCharFormat keywordFormat() const; QTextCharFormat numberFormat() const; QTextCharFormat operatorFormat() const; QTextCharFormat errorFormat() const; QTextCharFormat commentFormat() const; QTextCharFormat stringFormat() const; QTextCharFormat matchingPairFormat() const; QTextCharFormat mismatchingPairFormat() const; /** * Call this to add a pair of symbols for highlighting. * The default implementation of the class already adds (), {} and [], so no need to add those. * For example, if you wanted to highlight angle-brackets, you would use: * @code * addPair('<', '>'); * @endcode * @param openSymbol the opening symbol of the pair * @param closeSymbol the closing symbol of the pair * @sa highlightPairs */ void addPair(QChar openSymbol, QChar closeSymbol); /** * Highlights all instances of the @p word in the text with the specified @p format * @param word the word to highlight * @param format the format to be used for displaying the word */ void addRule(const QString& word, const QTextCharFormat& format); /** * Highlights all parts of the text matched by the regular expression @p regexp in the text * with the specified @p format * @param regexp the regular expression used to look for matches * @param format the format used to display the matching parts of the text */ void addRule(const QRegExp& regexp, const QTextCharFormat& format); /** * Convenience method, highlights all items in @p conditions with the specified @p format * @code * QStringList greenWords; * greenWords << "tree" << "forest" << "grass"; * addRules(greenWords, greenWordFormat); * @endcode * @param conditions any Qt container of QRegExp or QString. * @param format the format used to display the matching parts of the text */ void addRules(const QStringList& conditions, const QTextCharFormat& format); /** * Convenience method, equivalent to @code addRules(keywords, keywordFormat()) @endcode */ void addKeywords(const QStringList& keywords); /** * Removes any rules previously added for the regular expression @p regexp */ void removeRule(const QRegExp& regexp); /** * Highlight pairs added with addPair() * @sa addPair */ void highlightPairs(const QString& text); /** * Highlights words added with addRule() * @sa addRule, addRules */ void highlightWords(const QString& text); /** * Highlights all matches from regular expressions added with addRule() * @sa addRule, addRules */ void highlightRegExps(const QString& text); /** * Returns a string that contains a regular expression that matches for characters thar are allowed inside * words for this backend. For example, maxima or scilab allow % at the beginning of variable names */ virtual QString nonSeparatingCharacters() const; private Q_SLOTS: void updateFormats(); Q_SIGNALS: void rulesChanged(); private: DefaultHighlighterPrivate* d; }; } #endif