Commit e0b7a815 authored by camilo higuita's avatar camilo higuita

fixes on statuc qmake scripts

parent 39502119
/*
Copyright (C) 2016 Volker Krause <vkrause@kde.org>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef KSYNTAXHIGHLIGHTING_ABSTRACTHIGHLIGHTERM_H
#define KSYNTAXHIGHLIGHTING_ABSTRACTHIGHLIGHTERM_H
#include "ksyntaxhighlighting_export.h"
#include <QObject>
#include <memory>
QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace KSyntaxHighlighting {
class AbstractHighlighterPrivate;
class Definition;
class FoldingRegion;
class Format;
class State;
class Theme;
/**
* Abstract base class for highlighters.
*
* @section abshl_intro Introduction
*
* The AbstractHighlighter provides an interface to highlight text.
*
* The SyntaxHighlighting framework already ships with one implementation,
* namely the SyntaxHighlighter, which also derives from QSyntaxHighlighter,
* meaning that it can be used to highlight a QTextDocument or a QML TextEdit.
* In order to use the SyntaxHighlighter, just call setDefinition() and
* setTheme(), and the associated documents will automatically be highlighted.
*
* However, if you want to use the SyntaxHighlighting framework to implement
* your own syntax highlighter, you need to sublcass from AbstractHighlighter.
*
* @section abshl_impl Implementing your own Syntax Highlighter
*
* In order to implement your own syntax highlighter, you need to inherit from
* AbstractHighlighter. Then, pass each text line that needs to be highlighted
* in order to highlightLine(). Internally, highlightLine() uses the Definition
* initially set through setDefinition() and the State of the previous text line
* to parse and highlight the given text line. For each visual highlighting
* change, highlightLine() will call applyFormat(). Therefore, reimplement
* applyFormat() to get notified of the Format that is valid in the range
* starting at the given offset with the specified length. Similarly, for each
* text part that starts or ends a code folding region, highlightLine() will
* call applyFolding(). Therefore, if you are interested in code folding,
* reimplement applyFolding() to get notified of the starting and ending code
* folding regions, again specified in the range starting at the given offset
* with the given length.
*
* The Format class itself depends on the current Theme. A theme must be
* initially set once such that the Format%s instances can be queried for
* concrete colors.
*
* Optionally, you can also reimplement setTheme() and setDefinition() to get
* notified whenever the Definition or the Theme changes.
*
* @see SyntaxHighlighter
* @since 5.28
*/
class KSYNTAXHIGHLIGHTING_EXPORT AbstractHighlighter
{
public:
virtual ~AbstractHighlighter();
/**
* Returns the syntax definition used for highlighting.
*
* @see setDefinition()
*/
Definition definition() const;
/**
* Sets the syntax definition used for highlighting.
*
* Subclasses can re-implement this method to e.g. trigger
* re-highlighting or clear internal data structures if needed.
*/
virtual void setDefinition(const Definition &def);
/**
* Returns the currently selected theme for highlighting.
*
* @note If no Theme was set through setTheme(), the returned Theme will be
* invalid, see Theme::isValid().
*/
Theme theme() const;
/**
* Sets the theme used for highlighting.
*
* Subclasses can re-implement this method to e.g. trigger
* re-highlighing or to do general palette color setup.
*/
virtual void setTheme(const Theme &theme);
protected:
AbstractHighlighter();
AbstractHighlighter(AbstractHighlighterPrivate *dd);
// TODO KF6: add an optional void* context argument that is passed through
// to the applyX() calls, so highlighters dealing with some form of line object
// (such as QSyntaxHighlighter or KTextEditor) can avoid some ugly hacks to have
// this context available in their applyX methods
/**
* Highlight the given line. Call this from your derived class
* where appropriate. This will result in any number of applyFormat()
* and applyFolding() calls as a result.
* @param text A string containing the text of the line to highlight.
* @param state The highlighting state handle returned by the call
* to highlightLine() for the previous line. For the very first line,
* just pass a default constructed State().
* @returns The state of the highlighing engine after processing the
* given line. This needs to passed into highlightLine() for the
* next line. You can store the state for efficient partial
* re-highlighting for example during editing.
*
* @see applyFormat(), applyFolding()
*/
State highlightLine(const QString &text, const State &state);
/**
* Reimplement this to apply formats to your output. The provided @p format
* is valid for the interval [@p offset, @p offset + @p length).
*
* @param offset The start column of the interval for which @p format matches
* @param length The length of the matching text
* @param format The Format that applies to the range [offset, offset + length)
*
* @note Make sure to set a valid Definition, otherwise the parameter
* @p format is invalid for the entire line passed to highlightLine()
* (cf. Format::isValid()).
*
* @see applyFolding(), highlightLine()
*/
virtual void applyFormat(int offset, int length, const Format &format) = 0;
/**
* Reimplement this to apply folding to your output. The provided
* FoldingRegion @p region either stars or ends a code folding region in the
* interval [@p offset, @p offset + @p length).
*
* @param offset The start column of the FoldingRegion
* @param length The length of the matching text that starts / ends a
* folding region
* @param region The FoldingRegion that applies to the range [offset, offset + length)
*
* @note The FoldingRegion @p region is @e always either of type
* FoldingRegion::Type::Begin or FoldingRegion::Type::End.
*
* @see applyFormat(), highlightLine(), FoldingRegion
*/
virtual void applyFolding(int offset, int length, FoldingRegion region);
protected:
AbstractHighlighterPrivate *d_ptr;
private:
Q_DECLARE_PRIVATE(AbstractHighlighter)
Q_DISABLE_COPY(AbstractHighlighter)
};
}
QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(KSyntaxHighlighting::AbstractHighlighter, "org.kde.SyntaxHighlighting.AbstractHighlighter")
QT_END_NAMESPACE
#endif // KSYNTAXHIGHLIGHTING_ABSTRACTHIGHLIGHTERM_H
/*
Copyright (C) 2016 Volker Krause <vkrause@kde.org>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef KSYNTAXHIGHLIGHTING_DEFINITIONDOWNLOADER_H
#define KSYNTAXHIGHLIGHTING_DEFINITIONDOWNLOADER_H
#include "ksyntaxhighlighting_export.h"
#include <QObject>
#include <memory>
namespace KSyntaxHighlighting {
class DefinitionDownloaderPrivate;
class Repository;
/**
* Helper class to download definition file updates.
*
* With the DefinitionDownloader you can download new and update existing
* syntax highlighting definition files (xml files).
*
* An example that updates the highlighting Definition%s and prints the current
* update progress to the console may look as follows:
*
* @code
* auto downloader = new DefinitionDownloader(repo); // repo is a pointer to a Repository
*
* // print update progress to console
* QObject::connect(downloader, &DefinitionDownloader::informationMessage, [](const QString &msg) {
* std::cout << qPrintable(msg) << std::endl;
* });
*
* // connect to signal done to delete the downloader later
* QObject::connect(downloader, &DefinitionDownloader::done,
* downloader, &DefinitionDownloader::deleteLater);
* downloader->start();
* @endcode
*
* @see Repository, Definition
* @since 5.28
*/
class KSYNTAXHIGHLIGHTING_EXPORT DefinitionDownloader : public QObject
{
Q_OBJECT
public:
/**
* Constructor.
* The Repository @p repo is used as reference to compare the versions of
* the existing Definition%s with the ones that are available online.
*
* Optionally, @p parent is a pointer to the owner of this instance.
*/
explicit DefinitionDownloader(Repository *repo, QObject *parent = nullptr);
/**
* Destructor.
*/
~DefinitionDownloader();
/**
* Starts the update procedure.
* Once no more updates are available (i.e. either the local definition files
* are up-to-date, or all updates have been downloaded), the signal done()
* is emitted.
*
* During the update process, the signal informationMessage() can be used
* to display the current update progress to the user.
*
* @see done(), informationMessage()
*/
void start();
Q_SIGNALS:
/**
* Prints the information about the current state of the definition files.
* If all files are up-to-date, this signal is emitted informing you that
* all highlighting files are up-to-date. If there are updates, this signal
* is emitted for each update being downloaded.
*/
void informationMessage(const QString &msg);
/**
* This signal is emitted when there are no pending downloads anymore.
*/
void done();
private:
std::unique_ptr<DefinitionDownloaderPrivate> d;
};
}
#endif // KSYNTAXHIGHLIGHTING_DEFINITIONDOWNLOADER_H
/*
Copyright (C) 2016 Volker Krause <vkrause@kde.org>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef KSYNTAXHIGHLIGHTING_FOLDINGREGION_H
#define KSYNTAXHIGHLIGHTING_FOLDINGREGION_H
#include "ksyntaxhighlighting_export.h"
#include <QTypeInfo>
namespace KSyntaxHighlighting {
/** Represents a begin or end of a folding region.
* @since 5.28 */
class KSYNTAXHIGHLIGHTING_EXPORT FoldingRegion
{
public:
/**
* Defines whether a FoldingRegion starts or ends a folding region.
*/
enum Type {
//! Used internally as indicator for invalid FoldingRegion%s.
None,
//! Indicates the start of a FoldingRegion.
Begin,
//! Indicates the end of a FoldingRegion.
End
};
/**
* Constructs an invalid folding region, meaning that isValid() returns @e false.
* To obtain valid instances, see AbstractHighlighter::applyFolding().
*/
FoldingRegion();
/** Compares two FoldingRegion instances for equality. */
bool operator==(const FoldingRegion &other) const;
/**
* Returns @c true if this is a valid folding region.
* A valid FoldingRegion is defined by a type() other than Type::None.
*
* @note The FoldingRegion%s passed in AbstractHighlighter::applyFolding()
* are always valid.
*/
bool isValid() const;
/**
* Returns a unique identifier for this folding region.
*
* As example, the C/C++ highlighter starts and ends a folding region for
* scopes, e.g.:
* \code
* void foo() { // '{' starts a folding region
* if (bar()) { // '{' starts a (nested) folding region
* } // '}' ends the (nested) folding region
* } // '}' ends the outer folding region
* \endcode
* In this example, all braces '{' and '}' have the same id(), meaning that
* if you want to find the matching closing region for the first opening
* brace, you need to do kind of a reference counting to find the correct
* closing brace.
*/
quint16 id() const;
/**
* Returns whether this is the begin or end of a region.
*
* @note The FoldingRegion%s passed in AbstractHighlighter::applyFolding()
* are always valid, i.e. either Type::Begin or Type::End.
*/
Type type() const;
private:
friend class Rule;
FoldingRegion(Type type, quint16 id);
quint16 m_type : 2;
quint16 m_id: 14;
};
}
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(KSyntaxHighlighting::FoldingRegion, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
#endif
/*
Copyright (C) 2016 Volker Krause <vkrause@kde.org>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef KSYNTAXHIGHLIGHTING_FORMAT_H
#define KSYNTAXHIGHLIGHTING_FORMAT_H
#include "ksyntaxhighlighting_export.h"
#include "theme.h"
#include <QExplicitlySharedDataPointer>
#include <QTypeInfo>
QT_BEGIN_NAMESPACE
class QColor;
class QString;
class QXmlStreamReader;
QT_END_NAMESPACE
namespace KSyntaxHighlighting {
class DefinitionRef;
class FormatPrivate;
/** Describes the format to be used for a specific text fragment.
* The actual format used for displaying is merged from the format information
* in the syntax definition file, and a theme.
*
* @see Theme
* @since 5.28
*/
class KSYNTAXHIGHLIGHTING_EXPORT Format
{
public:
/** Creates an empty/invalid format. */
Format();
Format(const Format &other);
~Format();
Format& operator=(const Format &other);
/** Returns @c true if this is a valid format, ie. one that
* was read from a syntax definition file.
*/
bool isValid() const;
/** The name of this format as used in the syntax definition file. */
QString name() const;
/** Returns a unique identifier of this format.
* This is useful for efficient storing of formats in a text line. The
* identifier is unique per Repository instance, but will change when
* the repository is reloaded (which also invalidatess the corresponding
* Definition anyway).
*/
quint16 id() const;
/** Returns the underlying TextStyle of this Format.
* Every Theme::TextStyle is visually defined by a Theme. A Format uses one
* of the Theme::TextStyle%s and on top allows modifications such as setting
* a different foreground color etc.
* @see Theme::TextStyle
* @since 5.49
*/
Theme::TextStyle textStyle() const;
/** Returns @c true if the combination of this format and the theme @p theme
* do not change the default text format in any way.
* This is useful for output formats where changing formatting implies cost,
* and thus benefit from optimizing the default case of not having any format
* applied. If you make use of this, make sure to set the default text style
* to what the corresponding theme sets for Theme::Normal.
*/
bool isDefaultTextStyle(const Theme &theme) const;
/** Returns @c true if the combination of this format and the theme @p theme
* change the foreground color compared to the default format.
*/
bool hasTextColor(const Theme &theme) const;
/** Returns the foreground color of the combination of this format and the
* given theme.
*/
QColor textColor(const Theme &theme) const;
/** Returns the foreground color for selected text of the combination of
* this format and the given theme.
*/
QColor selectedTextColor(const Theme &theme) const;
/** Returns @c true if the combination of this format and the theme @p theme
* change the background color compared to the default format.
*/
bool hasBackgroundColor(const Theme &theme) const;
/** Returns the background color of the combination of this format and the
* given theme.
*/
QColor backgroundColor(const Theme &theme) const;
/** Returns the background color of selected text of the combination of
* this format and the given theme.
*/
QColor selectedBackgroundColor(const Theme &theme) const;
/** Returns @c true if the combination of this format and the given theme
* results in bold text formatting.
*/
bool isBold(const Theme &theme) const;
/** Returns @c true if the combination of this format and the given theme
* results in italic text formatting.
*/
bool isItalic(const Theme &theme) const;
/** Returns @c true if the combination of this format and the given theme
* results in underlined text.
*/
bool isUnderline(const Theme &theme) const;
/** Returns @c true if the combination of this format and the given theme
* results in struck through text.
*/
bool isStrikeThrough(const Theme &theme) const;
/**
* Returns whether characters with this format should be spell checked.
*/
bool spellCheck() const;
private:
friend class FormatPrivate;
QExplicitlySharedDataPointer<FormatPrivate> d;
};
}
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(KSyntaxHighlighting::Format, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
#endif // KSYNTAXHIGHLIGHTING_FORMAT_H
#ifndef KSYNTAXHIGHLIGHTING_EXPORT_H
#define KSYNTAXHIGHLIGHTING_EXPORT_H
#ifdef KSYNTAXHIGHLIGHTING_STATIC_DEFINE
# define KSYNTAXHIGHLIGHTING_EXPORT
# define KSYNTAXHIGHLIGHTING_NO_EXPORT
#else
# ifndef KSYNTAXHIGHLIGHTING_EXPORT