Merge pull request #1275 from sqlitebrowser/xml_cell_edit

XML mode for the cell editor
This commit is contained in:
Manuel
2018-01-27 20:09:36 +01:00
committed by GitHub
26 changed files with 6987 additions and 338 deletions

View File

@@ -71,6 +71,7 @@ find_package(Qt5Widgets REQUIRED)
find_package(Qt5LinguistTools REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Concurrent REQUIRED)
find_package(Qt5Xml REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -106,7 +107,7 @@ set(SQLB_MOC_HDR
src/VacuumDialog.h
src/sqlitetablemodel.h
src/sqltextedit.h
src/jsontextedit.h
src/docktextedit.h
src/DbStructureModel.h
src/Application.h
src/CipherDialog.h
@@ -144,7 +145,7 @@ set(SQLB_SRC
src/sqlitetablemodel.cpp
src/sqlitetypes.cpp
src/sqltextedit.cpp
src/jsontextedit.cpp
src/docktextedit.cpp
src/csvparser.cpp
src/DbStructureModel.cpp
src/grammar/Sqlite3Lexer.cpp
@@ -334,7 +335,7 @@ add_executable(${PROJECT_NAME}
${SQLB_RESOURCES_RCC}
${SQLB_MISC})
qt5_use_modules(${PROJECT_NAME} Gui Widgets Network Test PrintSupport Concurrent)
qt5_use_modules(${PROJECT_NAME} Gui Widgets Network Test PrintSupport Concurrent Xml)
set(QT_LIBRARIES "")
add_dependencies(${PROJECT_NAME} qhexedit qcustomplot)

View File

@@ -23,6 +23,11 @@ set(QSCINTILLA_SRC
qscilexercustom.cpp
qscilexersql.cpp
qscilexerjson.cpp
qscilexerhtml.cpp
qscilexerxml.cpp
qscilexerjavascript.cpp
qscilexercpp.cpp
qscilexerpython.cpp
qscimacro.cpp
qsciprinter.cpp
qscistyle.cpp
@@ -35,6 +40,7 @@ set(QSCINTILLA_SRC
ScintillaQt.cpp
../lexers/LexSQL.cpp
../lexers/LexJSON.cpp
../lexers/LexHTML.cpp
../lexlib/Accessor.cpp
../lexlib/CharacterCategory.cpp
../lexlib/CharacterSet.cpp
@@ -146,6 +152,11 @@ set(QSCINTILLA_MOC_HDR
./Qsci/qscilexercustom.h
./Qsci/qscilexersql.h
./Qsci/qscilexerjson.h
./Qsci/qscilexerhtml.h
./Qsci/qscilexerxml.h
./Qsci/qscilexerjavascript.h
./Qsci/qscilexercpp.h
./Qsci/qscilexerpython.h
./Qsci/qscimacro.h
SciClasses.h
ScintillaQt.h

View File

@@ -0,0 +1,398 @@
// This defines the interface to the QsciLexerCPP class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#ifndef QSCILEXERCPP_H
#define QSCILEXERCPP_H
#include <QObject>
#include <Qsci/qsciglobal.h>
#include <Qsci/qscilexer.h>
//! \brief The QsciLexerCPP class encapsulates the Scintilla C++
//! lexer.
class QSCINTILLA_EXPORT QsciLexerCPP : public QsciLexer
{
Q_OBJECT
public:
//! This enum defines the meanings of the different styles used by the
//! C++ lexer.
enum {
//! The default.
Default = 0,
InactiveDefault = Default + 64,
//! A C comment.
Comment = 1,
InactiveComment = Comment + 64,
//! A C++ comment line.
CommentLine = 2,
InactiveCommentLine = CommentLine + 64,
//! A JavaDoc/Doxygen style C comment.
CommentDoc = 3,
InactiveCommentDoc = CommentDoc + 64,
//! A number.
Number = 4,
InactiveNumber = Number + 64,
//! A keyword.
Keyword = 5,
InactiveKeyword = Keyword + 64,
//! A double-quoted string.
DoubleQuotedString = 6,
InactiveDoubleQuotedString = DoubleQuotedString + 64,
//! A single-quoted string.
SingleQuotedString = 7,
InactiveSingleQuotedString = SingleQuotedString + 64,
//! An IDL UUID.
UUID = 8,
InactiveUUID = UUID + 64,
//! A pre-processor block.
PreProcessor = 9,
InactivePreProcessor = PreProcessor + 64,
//! An operator.
Operator = 10,
InactiveOperator = Operator + 64,
//! An identifier
Identifier = 11,
InactiveIdentifier = Identifier + 64,
//! The end of a line where a string is not closed.
UnclosedString = 12,
InactiveUnclosedString = UnclosedString + 64,
//! A C# verbatim string.
VerbatimString = 13,
InactiveVerbatimString = VerbatimString + 64,
//! A JavaScript regular expression.
Regex = 14,
InactiveRegex = Regex + 64,
//! A JavaDoc/Doxygen style C++ comment line.
CommentLineDoc = 15,
InactiveCommentLineDoc = CommentLineDoc + 64,
//! A keyword defined in keyword set number 2. The class must be
//! sub-classed and re-implement keywords() to make use of this style.
KeywordSet2 = 16,
InactiveKeywordSet2 = KeywordSet2 + 64,
//! A JavaDoc/Doxygen keyword.
CommentDocKeyword = 17,
InactiveCommentDocKeyword = CommentDocKeyword + 64,
//! A JavaDoc/Doxygen keyword error.
CommentDocKeywordError = 18,
InactiveCommentDocKeywordError = CommentDocKeywordError + 64,
//! A global class or typedef defined in keyword set number 5. The
//! class must be sub-classed and re-implement keywords() to make use
//! of this style.
GlobalClass = 19,
InactiveGlobalClass = GlobalClass + 64,
//! A C++ raw string.
RawString = 20,
InactiveRawString = RawString + 64,
//! A Vala triple-quoted verbatim string.
TripleQuotedVerbatimString = 21,
InactiveTripleQuotedVerbatimString = TripleQuotedVerbatimString + 64,
//! A Pike hash-quoted string.
HashQuotedString = 22,
InactiveHashQuotedString = HashQuotedString + 64,
//! A pre-processor stream comment.
PreProcessorComment = 23,
InactivePreProcessorComment = PreProcessorComment + 64,
//! A JavaDoc/Doxygen style pre-processor comment.
PreProcessorCommentLineDoc = 24,
InactivePreProcessorCommentLineDoc = PreProcessorCommentLineDoc + 64,
//! A user-defined literal.
UserLiteral = 25,
InactiveUserLiteral = UserLiteral + 64,
//! A task marker.
TaskMarker = 26,
InactiveTaskMarker = TaskMarker + 64,
//! An escape sequence.
EscapeSequence = 27,
InactiveEscapeSequence = EscapeSequence + 64,
};
//! Construct a QsciLexerCPP with parent \a parent. \a parent is typically
//! the QsciScintilla instance. \a caseInsensitiveKeywords is true if the
//! lexer ignores the case of keywords.
QsciLexerCPP(QObject *parent = 0, bool caseInsensitiveKeywords = false);
//! Destroys the QsciLexerCPP instance.
virtual ~QsciLexerCPP();
//! Returns the name of the language.
const char *language() const;
//! Returns the name of the lexer. Some lexers support a number of
//! languages.
const char *lexer() const;
//! \internal Returns the character sequences that can separate
//! auto-completion words.
QStringList autoCompletionWordSeparators() const;
//! \internal Returns a space separated list of words or characters in
//! a particular style that define the end of a block for
//! auto-indentation. The styles is returned via \a style.
const char *blockEnd(int *style = 0) const;
//! \internal Returns a space separated list of words or characters in
//! a particular style that define the start of a block for
//! auto-indentation. The styles is returned via \a style.
const char *blockStart(int *style = 0) const;
//! \internal Returns a space separated list of keywords in a
//! particular style that define the start of a block for
//! auto-indentation. The styles is returned via \a style.
const char *blockStartKeyword(int *style = 0) const;
//! \internal Returns the style used for braces for brace matching.
int braceStyle() const;
//! Returns the string of characters that comprise a word.
const char *wordCharacters() const;
//! Returns the foreground colour of the text for style number \a style.
//!
//! \sa defaultPaper()
QColor defaultColor(int style) const;
//! Returns the end-of-line fill for style number \a style.
bool defaultEolFill(int style) const;
//! Returns the font for style number \a style.
QFont defaultFont(int style) const;
//! Returns the background colour of the text for style number \a style.
//!
//! \sa defaultColor()
QColor defaultPaper(int style) const;
//! Returns the set of keywords for the keyword set \a set recognised
//! by the lexer as a space separated string. Set 1 is normally used for
//! primary keywords and identifiers. Set 2 is normally used for secondary
//! keywords and identifiers. Set 3 is normally used for documentation
//! comment keywords. Set 4 is normally used for global classes and
//! typedefs.
const char *keywords(int set) const;
//! Returns the descriptive name for style number \a style. If the
//! style is invalid for this language then an empty QString is returned.
//! This is intended to be used in user preference dialogs.
QString description(int style) const;
//! Causes all properties to be refreshed by emitting the
//! propertyChanged() signal as required.
void refreshProperties();
//! Returns true if "} else {" lines can be folded.
//!
//! \sa setFoldAtElse()
bool foldAtElse() const {return fold_atelse;}
//! Returns true if multi-line comment blocks can be folded.
//!
//! \sa setFoldComments()
bool foldComments() const {return fold_comments;}
//! Returns true if trailing blank lines are included in a fold block.
//!
//! \sa setFoldCompact()
bool foldCompact() const {return fold_compact;}
//! Returns true if preprocessor blocks can be folded.
//!
//! \sa setFoldPreprocessor()
bool foldPreprocessor() const {return fold_preproc;}
//! Returns true if preprocessor lines (after the preprocessor
//! directive) are styled.
//!
//! \sa setStylePreprocessor()
bool stylePreprocessor() const {return style_preproc;}
//! If \a allowed is true then '$' characters are allowed in identifier
//! names. The default is true.
//!
//! \sa dollarsAllowed()
void setDollarsAllowed(bool allowed);
//! Returns true if '$' characters are allowed in identifier names.
//!
//! \sa setDollarsAllowed()
bool dollarsAllowed() const {return dollars;}
//! If \a enabled is true then triple quoted strings are highlighted. The
//! default is false.
//!
//! \sa highlightTripleQuotedStrings()
void setHighlightTripleQuotedStrings(bool enabled);
//! Returns true if triple quoted strings should be highlighted.
//!
//! \sa setHighlightTripleQuotedStrings()
bool highlightTripleQuotedStrings() const {return highlight_triple;}
//! If \a enabled is true then hash quoted strings are highlighted. The
//! default is false.
//!
//! \sa highlightHashQuotedStrings()
void setHighlightHashQuotedStrings(bool enabled);
//! Returns true if hash quoted strings should be highlighted.
//!
//! \sa setHighlightHashQuotedStrings()
bool highlightHashQuotedStrings() const {return highlight_hash;}
//! If \a enabled is true then back-quoted raw strings are highlighted.
//! The default is false.
//!
//! \sa highlightBackQuotedStrings()
void setHighlightBackQuotedStrings(bool enabled);
//! Returns true if back-quoted raw strings should be highlighted.
//!
//! \sa setHighlightBackQuotedStrings()
bool highlightBackQuotedStrings() const {return highlight_back;}
//! If \a enabled is true then escape sequences in strings are highlighted.
//! The default is false.
//!
//! \sa highlightEscapeSequences()
void setHighlightEscapeSequences(bool enabled);
//! Returns true if escape sequences in strings should be highlighted.
//!
//! \sa setHighlightEscapeSequences()
bool highlightEscapeSequences() const {return highlight_escape;}
//! If \a allowed is true then escape sequences are allowed in verbatim
//! strings. The default is false.
//!
//! \sa verbatimStringEscapeSequencesAllowed()
void setVerbatimStringEscapeSequencesAllowed(bool allowed);
//! Returns true if hash quoted strings should be highlighted.
//!
//! \sa setVerbatimStringEscapeSequencesAllowed()
bool verbatimStringEscapeSequencesAllowed() const {return vs_escape;}
public slots:
//! If \a fold is true then "} else {" lines can be folded. The
//! default is false.
//!
//! \sa foldAtElse()
virtual void setFoldAtElse(bool fold);
//! If \a fold is true then multi-line comment blocks can be folded.
//! The default is false.
//!
//! \sa foldComments()
virtual void setFoldComments(bool fold);
//! If \a fold is true then trailing blank lines are included in a fold
//! block. The default is true.
//!
//! \sa foldCompact()
virtual void setFoldCompact(bool fold);
//! If \a fold is true then preprocessor blocks can be folded. The
//! default is true.
//!
//! \sa foldPreprocessor()
virtual void setFoldPreprocessor(bool fold);
//! If \a style is true then preprocessor lines (after the preprocessor
//! directive) are styled. The default is false.
//!
//! \sa stylePreprocessor()
virtual void setStylePreprocessor(bool style);
protected:
//! The lexer's properties are read from the settings \a qs. \a prefix
//! (which has a trailing '/') should be used as a prefix to the key of
//! each setting. true is returned if there is no error.
//!
//! \sa writeProperties()
bool readProperties(QSettings &qs,const QString &prefix);
//! The lexer's properties are written to the settings \a qs.
//! \a prefix (which has a trailing '/') should be used as a prefix to
//! the key of each setting. true is returned if there is no error.
//!
//! \sa readProperties()
bool writeProperties(QSettings &qs,const QString &prefix) const;
private:
void setAtElseProp();
void setCommentProp();
void setCompactProp();
void setPreprocProp();
void setStylePreprocProp();
void setDollarsProp();
void setHighlightTripleProp();
void setHighlightHashProp();
void setHighlightBackProp();
void setHighlightEscapeProp();
void setVerbatimStringEscapeProp();
bool fold_atelse;
bool fold_comments;
bool fold_compact;
bool fold_preproc;
bool style_preproc;
bool dollars;
bool highlight_triple;
bool highlight_hash;
bool highlight_back;
bool highlight_escape;
bool vs_escape;
bool nocase;
QsciLexerCPP(const QsciLexerCPP &);
QsciLexerCPP &operator=(const QsciLexerCPP &);
};
#endif

View File

@@ -0,0 +1,532 @@
// This defines the interface to the QsciLexerHTML class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#ifndef QSCILEXERHTML_H
#define QSCILEXERHTML_H
#include <QObject>
#include <Qsci/qsciglobal.h>
#include <Qsci/qscilexer.h>
//! \brief The QsciLexerHTML class encapsulates the Scintilla HTML lexer.
class QSCINTILLA_EXPORT QsciLexerHTML : public QsciLexer
{
Q_OBJECT
public:
//! This enum defines the meanings of the different styles used by the
//! HTML lexer.
enum {
//! The default.
Default = 0,
//! A tag.
Tag = 1,
//! An unknown tag.
UnknownTag = 2,
//! An attribute.
Attribute = 3,
//! An unknown attribute.
UnknownAttribute = 4,
//! An HTML number.
HTMLNumber = 5,
//! An HTML double-quoted string.
HTMLDoubleQuotedString = 6,
//! An HTML single-quoted string.
HTMLSingleQuotedString = 7,
//! Other text within a tag.
OtherInTag = 8,
//! An HTML comment.
HTMLComment = 9,
//! An entity.
Entity = 10,
//! The end of an XML style tag.
XMLTagEnd = 11,
//! The start of an XML fragment.
XMLStart = 12,
//! The end of an XML fragment.
XMLEnd = 13,
//! A script tag.
Script = 14,
//! The start of an ASP fragment with @.
ASPAtStart = 15,
//! The start of an ASP fragment.
ASPStart = 16,
//! CDATA.
CDATA = 17,
//! The start of a PHP fragment.
PHPStart = 18,
//! An unquoted HTML value.
HTMLValue = 19,
//! An ASP X-Code comment.
ASPXCComment = 20,
//! The default for SGML.
SGMLDefault = 21,
//! An SGML command.
SGMLCommand = 22,
//! The first parameter of an SGML command.
SGMLParameter = 23,
//! An SGML double-quoted string.
SGMLDoubleQuotedString = 24,
//! An SGML single-quoted string.
SGMLSingleQuotedString = 25,
//! An SGML error.
SGMLError = 26,
//! An SGML special entity.
SGMLSpecial = 27,
//! An SGML entity.
SGMLEntity = 28,
//! An SGML comment.
SGMLComment = 29,
//! A comment with the first parameter of an SGML command.
SGMLParameterComment = 30,
//! The default for an SGML block.
SGMLBlockDefault = 31,
//! The start of a JavaScript fragment.
JavaScriptStart = 40,
//! The default for JavaScript.
JavaScriptDefault = 41,
//! A JavaScript comment.
JavaScriptComment = 42,
//! A JavaScript line comment.
JavaScriptCommentLine = 43,
//! A JavaDoc style JavaScript comment.
JavaScriptCommentDoc = 44,
//! A JavaScript number.
JavaScriptNumber = 45,
//! A JavaScript word.
JavaScriptWord = 46,
//! A JavaScript keyword.
JavaScriptKeyword = 47,
//! A JavaScript double-quoted string.
JavaScriptDoubleQuotedString = 48,
//! A JavaScript single-quoted string.
JavaScriptSingleQuotedString = 49,
//! A JavaScript symbol.
JavaScriptSymbol = 50,
//! The end of a JavaScript line where a string is not closed.
JavaScriptUnclosedString = 51,
//! A JavaScript regular expression.
JavaScriptRegex = 52,
//! The start of an ASP JavaScript fragment.
ASPJavaScriptStart = 55,
//! The default for ASP JavaScript.
ASPJavaScriptDefault = 56,
//! An ASP JavaScript comment.
ASPJavaScriptComment = 57,
//! An ASP JavaScript line comment.
ASPJavaScriptCommentLine = 58,
//! An ASP JavaDoc style JavaScript comment.
ASPJavaScriptCommentDoc = 59,
//! An ASP JavaScript number.
ASPJavaScriptNumber = 60,
//! An ASP JavaScript word.
ASPJavaScriptWord = 61,
//! An ASP JavaScript keyword.
ASPJavaScriptKeyword = 62,
//! An ASP JavaScript double-quoted string.
ASPJavaScriptDoubleQuotedString = 63,
//! An ASP JavaScript single-quoted string.
ASPJavaScriptSingleQuotedString = 64,
//! An ASP JavaScript symbol.
ASPJavaScriptSymbol = 65,
//! The end of an ASP JavaScript line where a string is not
//! closed.
ASPJavaScriptUnclosedString = 66,
//! An ASP JavaScript regular expression.
ASPJavaScriptRegex = 67,
//! The start of a VBScript fragment.
VBScriptStart = 70,
//! The default for VBScript.
VBScriptDefault = 71,
//! A VBScript comment.
VBScriptComment = 72,
//! A VBScript number.
VBScriptNumber = 73,
//! A VBScript keyword.
VBScriptKeyword = 74,
//! A VBScript string.
VBScriptString = 75,
//! A VBScript identifier.
VBScriptIdentifier = 76,
//! The end of a VBScript line where a string is not closed.
VBScriptUnclosedString = 77,
//! The start of an ASP VBScript fragment.
ASPVBScriptStart = 80,
//! The default for ASP VBScript.
ASPVBScriptDefault = 81,
//! An ASP VBScript comment.
ASPVBScriptComment = 82,
//! An ASP VBScript number.
ASPVBScriptNumber = 83,
//! An ASP VBScript keyword.
ASPVBScriptKeyword = 84,
//! An ASP VBScript string.
ASPVBScriptString = 85,
//! An ASP VBScript identifier.
ASPVBScriptIdentifier = 86,
//! The end of an ASP VBScript line where a string is not
//! closed.
ASPVBScriptUnclosedString = 87,
//! The start of a Python fragment.
PythonStart = 90,
//! The default for Python.
PythonDefault = 91,
//! A Python comment.
PythonComment = 92,
//! A Python number.
PythonNumber = 93,
//! A Python double-quoted string.
PythonDoubleQuotedString = 94,
//! A Python single-quoted string.
PythonSingleQuotedString = 95,
//! A Python keyword.
PythonKeyword = 96,
//! A Python triple single-quoted string.
PythonTripleSingleQuotedString = 97,
//! A Python triple double-quoted string.
PythonTripleDoubleQuotedString = 98,
//! The name of a Python class.
PythonClassName = 99,
//! The name of a Python function or method.
PythonFunctionMethodName = 100,
//! A Python operator.
PythonOperator = 101,
//! A Python identifier.
PythonIdentifier = 102,
//! The start of an ASP Python fragment.
ASPPythonStart = 105,
//! The default for ASP Python.
ASPPythonDefault = 106,
//! An ASP Python comment.
ASPPythonComment = 107,
//! An ASP Python number.
ASPPythonNumber = 108,
//! An ASP Python double-quoted string.
ASPPythonDoubleQuotedString = 109,
//! An ASP Python single-quoted string.
ASPPythonSingleQuotedString = 110,
//! An ASP Python keyword.
ASPPythonKeyword = 111,
//! An ASP Python triple single-quoted string.
ASPPythonTripleSingleQuotedString = 112,
//! An ASP Python triple double-quoted string.
ASPPythonTripleDoubleQuotedString = 113,
//! The name of an ASP Python class.
ASPPythonClassName = 114,
//! The name of an ASP Python function or method.
ASPPythonFunctionMethodName = 115,
//! An ASP Python operator.
ASPPythonOperator = 116,
//! An ASP Python identifier
ASPPythonIdentifier = 117,
//! The default for PHP.
PHPDefault = 118,
//! A PHP double-quoted string.
PHPDoubleQuotedString = 119,
//! A PHP single-quoted string.
PHPSingleQuotedString = 120,
//! A PHP keyword.
PHPKeyword = 121,
//! A PHP number.
PHPNumber = 122,
//! A PHP variable.
PHPVariable = 123,
//! A PHP comment.
PHPComment = 124,
//! A PHP line comment.
PHPCommentLine = 125,
//! A PHP double-quoted variable.
PHPDoubleQuotedVariable = 126,
//! A PHP operator.
PHPOperator = 127
};
//! Construct a QsciLexerHTML with parent \a parent. \a parent is
//! typically the QsciScintilla instance.
QsciLexerHTML(QObject *parent = 0);
//! Destroys the QsciLexerHTML instance.
virtual ~QsciLexerHTML();
//! Returns the name of the language.
const char *language() const;
//! Returns the name of the lexer. Some lexers support a number of
//! languages.
const char *lexer() const;
//! \internal Returns the auto-completion fillup characters.
const char *autoCompletionFillups() const;
//! Returns the string of characters that comprise a word.
const char *wordCharacters() const;
//! Returns the foreground colour of the text for style number \a style.
//!
//! \sa defaultPaper()
QColor defaultColor(int style) const;
//! Returns the end-of-line fill for style number \a style.
bool defaultEolFill(int style) const;
//! Returns the font for style number \a style.
QFont defaultFont(int style) const;
//! Returns the background colour of the text for style number \a style.
//!
//! \sa defaultColor()
QColor defaultPaper(int style) const;
//! Returns the set of keywords for the keyword set \a set recognised
//! by the lexer as a space separated string.
const char *keywords(int set) const;
//! Returns the descriptive name for style number \a style. If the
//! style is invalid for this language then an empty QString is returned.
//! This is intended to be used in user preference dialogs.
QString description(int style) const;
//! Causes all properties to be refreshed by emitting the
//! propertyChanged() signal as required.
void refreshProperties();
//! Returns true if tags are case sensitive.
//!
//! \sa setCaseSensitiveTags()
bool caseSensitiveTags() const {return case_sens_tags;}
//! If \a enabled is true then Django templates are enabled. The default
//! is false.
//!
//! \sa djangoTemplates()
void setDjangoTemplates(bool enabled);
//! Returns true if support for Django templates is enabled.
//!
//! \sa setDjangoTemplates()
bool djangoTemplates() const {return django_templates;}
//! Returns true if trailing blank lines are included in a fold block.
//!
//! \sa setFoldCompact()
bool foldCompact() const {return fold_compact;}
//! Returns true if preprocessor blocks can be folded.
//!
//! \sa setFoldPreprocessor()
bool foldPreprocessor() const {return fold_preproc;}
//! If \a fold is true then script comments can be folded. The default is
//! false.
//!
//! \sa foldScriptComments()
void setFoldScriptComments(bool fold);
//! Returns true if script comments can be folded.
//!
//! \sa setFoldScriptComments()
bool foldScriptComments() const {return fold_script_comments;}
//! If \a fold is true then script heredocs can be folded. The default is
//! false.
//!
//! \sa foldScriptHeredocs()
void setFoldScriptHeredocs(bool fold);
//! Returns true if script heredocs can be folded.
//!
//! \sa setFoldScriptHeredocs()
bool foldScriptHeredocs() const {return fold_script_heredocs;}
//! If \a enabled is true then Mako templates are enabled. The default is
//! false.
//!
//! \sa makoTemplates()
void setMakoTemplates(bool enabled);
//! Returns true if support for Mako templates is enabled.
//!
//! \sa setMakoTemplates()
bool makoTemplates() const {return mako_templates;}
public slots:
//! If \a fold is true then trailing blank lines are included in a fold
//! block. The default is true.
//!
//! \sa foldCompact()
virtual void setFoldCompact(bool fold);
//! If \a fold is true then preprocessor blocks can be folded. The
//! default is false.
//!
//! \sa foldPreprocessor()
virtual void setFoldPreprocessor(bool fold);
//! If \a sens is true then tags are case sensitive. The default is false.
//!
//! \sa caseSensitiveTags()
virtual void setCaseSensitiveTags(bool sens);
protected:
//! The lexer's properties are read from the settings \a qs. \a prefix
//! (which has a trailing '/') should be used as a prefix to the key of
//! each setting. true is returned if there is no error.
//!
bool readProperties(QSettings &qs,const QString &prefix);
//! The lexer's properties are written to the settings \a qs.
//! \a prefix (which has a trailing '/') should be used as a prefix to
//! the key of each setting. true is returned if there is no error.
//!
bool writeProperties(QSettings &qs,const QString &prefix) const;
private:
void setCompactProp();
void setPreprocProp();
void setCaseSensTagsProp();
void setScriptCommentsProp();
void setScriptHeredocsProp();
void setDjangoProp();
void setMakoProp();
bool fold_compact;
bool fold_preproc;
bool case_sens_tags;
bool fold_script_comments;
bool fold_script_heredocs;
bool django_templates;
bool mako_templates;
QsciLexerHTML(const QsciLexerHTML &);
QsciLexerHTML &operator=(const QsciLexerHTML &);
};
#endif

View File

@@ -0,0 +1,81 @@
// This defines the interface to the QsciLexerJavaScript class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#ifndef QSCILEXERJSCRIPT_H
#define QSCILEXERJSCRIPT_H
#include <QObject>
#include <Qsci/qsciglobal.h>
#include <Qsci/qscilexercpp.h>
//! \brief The QsciLexerJavaScript class encapsulates the Scintilla JavaScript
//! lexer.
class QSCINTILLA_EXPORT QsciLexerJavaScript : public QsciLexerCPP
{
Q_OBJECT
public:
//! Construct a QsciLexerJavaScript with parent \a parent. \a parent is
//! typically the QsciScintilla instance.
QsciLexerJavaScript(QObject *parent = 0);
//! Destroys the QsciLexerJavaScript instance.
virtual ~QsciLexerJavaScript();
//! Returns the name of the language.
const char *language() const;
//! Returns the foreground colour of the text for style number \a style.
//!
//! \sa defaultPaper()
QColor defaultColor(int style) const;
//! Returns the end-of-line fill for style number \a style.
bool defaultEolFill(int style) const;
//! Returns the font for style number \a style.
QFont defaultFont(int style) const;
//! Returns the background colour of the text for style number \a style.
//!
//! \sa defaultColor()
QColor defaultPaper(int style) const;
//! Returns the set of keywords for the keyword set \a set recognised
//! by the lexer as a space separated string.
const char *keywords(int set) const;
//! Returns the descriptive name for style number \a style. If the
//! style is invalid for this language then an empty QString is returned.
//! This is intended to be used in user preference dialogs.
QString description(int style) const;
private:
friend class QsciLexerHTML;
static const char *keywordClass;
QsciLexerJavaScript(const QsciLexerJavaScript &);
QsciLexerJavaScript &operator=(const QsciLexerJavaScript &);
};
#endif

View File

@@ -0,0 +1,321 @@
// This defines the interface to the QsciLexerPython class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#ifndef QSCILEXERPYTHON_H
#define QSCILEXERPYTHON_H
#include <QObject>
#include <Qsci/qsciglobal.h>
#include <Qsci/qscilexer.h>
#include "Qsci/qsciscintillabase.h"
//! \brief The QsciLexerPython class encapsulates the Scintilla Python lexer.
class QSCINTILLA_EXPORT QsciLexerPython : public QsciLexer
{
Q_OBJECT
public:
//! This enum defines the meanings of the different styles used by the
//! Python lexer.
enum {
//! The default.
Default = 0,
//! A comment.
Comment = 1,
//! A number.
Number = 2,
//! A double-quoted string.
DoubleQuotedString = 3,
//! A single-quoted string.
SingleQuotedString = 4,
//! A keyword.
Keyword = 5,
//! A triple single-quoted string.
TripleSingleQuotedString = 6,
//! A triple double-quoted string.
TripleDoubleQuotedString = 7,
//! The name of a class.
ClassName = 8,
//! The name of a function or method.
FunctionMethodName = 9,
//! An operator.
Operator = 10,
//! An identifier
Identifier = 11,
//! A comment block.
CommentBlock = 12,
//! The end of a line where a string is not closed.
UnclosedString = 13,
//! A highlighted identifier. These are defined by keyword set
//! 2. Reimplement keywords() to define keyword set 2.
HighlightedIdentifier = 14,
//! A decorator.
Decorator = 15
};
//! This enum defines the different conditions that can cause
//! indentations to be displayed as being bad.
enum IndentationWarning {
//! Bad indentation is not displayed differently.
NoWarning = 0,
//! The indentation is inconsistent when compared to the
//! previous line, ie. it is made up of a different combination
//! of tabs and/or spaces.
Inconsistent = 1,
//! The indentation is made up of spaces followed by tabs.
TabsAfterSpaces = 2,
//! The indentation contains spaces.
Spaces = 3,
//! The indentation contains tabs.
Tabs = 4
};
//! Construct a QsciLexerPython with parent \a parent. \a parent is
//! typically the QsciScintilla instance.
QsciLexerPython(QObject *parent = 0);
//! Destroys the QsciLexerPython instance.
virtual ~QsciLexerPython();
//! Returns the name of the language.
const char *language() const;
//! Returns the name of the lexer. Some lexers support a number of
//! languages.
const char *lexer() const;
//! \internal Returns the character sequences that can separate
//! auto-completion words.
QStringList autoCompletionWordSeparators() const;
//! \internal Returns the number of lines prior to the current one when
//! determining the scope of a block when auto-indenting.
int blockLookback() const;
//! \internal Returns a space separated list of words or characters in
//! a particular style that define the start of a block for
//! auto-indentation. The styles is returned via \a style.
const char *blockStart(int *style = 0) const;
//! \internal Returns the style used for braces for brace matching.
int braceStyle() const;
//! Returns the foreground colour of the text for style number \a style.
//!
//! \sa defaultPaper()
QColor defaultColor(int style) const;
//! Returns the end-of-line fill for style number \a style.
bool defaultEolFill(int style) const;
//! Returns the font for style number \a style.
QFont defaultFont(int style) const;
//! Returns the background colour of the text for style number \a style.
//!
//! \sa defaultColor()
QColor defaultPaper(int style) const;
//! \internal Returns the view used for indentation guides.
virtual int indentationGuideView() const;
//! Returns the set of keywords for the keyword set \a set recognised
//! by the lexer as a space separated string.
const char *keywords(int set) const;
//! Returns the descriptive name for style number \a style. If the
//! style is invalid for this language then an empty QString is returned.
//! This is intended to be used in user preference dialogs.
QString description(int style) const;
//! Causes all properties to be refreshed by emitting the
//! propertyChanged() signal as required.
void refreshProperties();
//! Returns true if indented comment blocks can be folded.
//!
//! \sa setFoldComments()
bool foldComments() const {return fold_comments;}
//! If \a fold is true then trailing blank lines are included in a fold
//! block. The default is true.
//!
//! \sa foldCompact()
void setFoldCompact(bool fold);
//! Returns true if trailing blank lines are included in a fold block.
//!
//! \sa setFoldCompact()
bool foldCompact() const {return fold_compact;}
//! Returns true if triple quoted strings can be folded.
//!
//! \sa setFoldQuotes()
bool foldQuotes() const {return fold_quotes;}
//! Returns the condition that will cause bad indentations to be
//! displayed.
//!
//! \sa setIndentationWarning()
QsciLexerPython::IndentationWarning indentationWarning() const {return indent_warn;}
//! If \a enabled is true then sub-identifiers defined in keyword set 2
//! will be highlighted. For example, if it is false and "open" is defined
//! in keyword set 2 then "foo.open" will not be highlighted. The default
//! is true.
//!
//! \sa highlightSubidentifiers()
void setHighlightSubidentifiers(bool enabled);
//! Returns true if string literals are allowed to span newline characters.
//!
//! \sa setHighlightSubidentifiers()
bool highlightSubidentifiers() const {return highlight_subids;}
//! If \a allowed is true then string literals are allowed to span newline
//! characters. The default is false.
//!
//! \sa stringsOverNewlineAllowed()
void setStringsOverNewlineAllowed(bool allowed);
//! Returns true if string literals are allowed to span newline characters.
//!
//! \sa setStringsOverNewlineAllowed()
bool stringsOverNewlineAllowed() const {return strings_over_newline;}
//! If \a allowed is true then Python v2 unicode string literals (e.g.
//! u"utf8") are allowed. The default is true.
//!
//! \sa v2UnicodeAllowed()
void setV2UnicodeAllowed(bool allowed);
//! Returns true if Python v2 unicode string literals (e.g. u"utf8") are
//! allowed.
//!
//! \sa setV2UnicodeAllowed()
bool v2UnicodeAllowed() const {return v2_unicode;}
//! If \a allowed is true then Python v3 binary and octal literals (e.g.
//! 0b1011, 0o712) are allowed. The default is true.
//!
//! \sa v3BinaryOctalAllowed()
void setV3BinaryOctalAllowed(bool allowed);
//! Returns true if Python v3 binary and octal literals (e.g. 0b1011,
//! 0o712) are allowed.
//!
//! \sa setV3BinaryOctalAllowed()
bool v3BinaryOctalAllowed() const {return v3_binary_octal;}
//! If \a allowed is true then Python v3 bytes string literals (e.g.
//! b"bytes") are allowed. The default is true.
//!
//! \sa v3BytesAllowed()
void setV3BytesAllowed(bool allowed);
//! Returns true if Python v3 bytes string literals (e.g. b"bytes") are
//! allowed.
//!
//! \sa setV3BytesAllowed()
bool v3BytesAllowed() const {return v3_bytes;}
public slots:
//! If \a fold is true then indented comment blocks can be folded. The
//! default is false.
//!
//! \sa foldComments()
virtual void setFoldComments(bool fold);
//! If \a fold is true then triple quoted strings can be folded. The
//! default is false.
//!
//! \sa foldQuotes()
virtual void setFoldQuotes(bool fold);
//! Sets the condition that will cause bad indentations to be
//! displayed.
//!
//! \sa indentationWarning()
virtual void setIndentationWarning(QsciLexerPython::IndentationWarning warn);
protected:
//! The lexer's properties are read from the settings \a qs. \a prefix
//! (which has a trailing '/') should be used as a prefix to the key of
//! each setting. true is returned if there is no error.
//!
bool readProperties(QSettings &qs,const QString &prefix);
//! The lexer's properties are written to the settings \a qs.
//! \a prefix (which has a trailing '/') should be used as a prefix to
//! the key of each setting. true is returned if there is no error.
//!
bool writeProperties(QSettings &qs,const QString &prefix) const;
private:
void setCommentProp();
void setCompactProp();
void setQuotesProp();
void setTabWhingeProp();
void setStringsOverNewlineProp();
void setV2UnicodeProp();
void setV3BinaryOctalProp();
void setV3BytesProp();
void setHighlightSubidsProp();
bool fold_comments;
bool fold_compact;
bool fold_quotes;
IndentationWarning indent_warn;
bool strings_over_newline;
bool v2_unicode;
bool v3_binary_octal;
bool v3_bytes;
bool highlight_subids;
friend class QsciLexerHTML;
static const char *keywordClass;
QsciLexerPython(const QsciLexerPython &);
QsciLexerPython &operator=(const QsciLexerPython &);
};
#endif

View File

@@ -0,0 +1,106 @@
// This defines the interface to the QsciLexerXML class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#ifndef QSCILEXERXML_H
#define QSCILEXERXML_H
#include <QObject>
#include <Qsci/qsciglobal.h>
#include <Qsci/qscilexerhtml.h>
//! \brief The QsciLexerXML class encapsulates the Scintilla XML lexer.
class QSCINTILLA_EXPORT QsciLexerXML : public QsciLexerHTML
{
Q_OBJECT
public:
//! Construct a QsciLexerXML with parent \a parent. \a parent is typically
//! the QsciScintilla instance.
QsciLexerXML(QObject *parent = 0);
//! Destroys the QsciLexerXML instance.
virtual ~QsciLexerXML();
//! Returns the name of the language.
const char *language() const;
//! Returns the name of the lexer. Some lexers support a number of
//! languages.
const char *lexer() const;
//! Returns the foreground colour of the text for style number \a style.
//!
//! \sa defaultPaper()
QColor defaultColor(int style) const;
//! Returns the end-of-line fill for style number \a style.
bool defaultEolFill(int style) const;
//! Returns the font for style number \a style.
QFont defaultFont(int style) const;
//! Returns the background colour of the text for style number \a style.
//!
//! \sa defaultColor()
QColor defaultPaper(int style) const;
//! Returns the set of keywords for the keyword set \a set recognised
//! by the lexer as a space separated string.
const char *keywords(int set) const;
//! Causes all properties to be refreshed by emitting the
//! propertyChanged() signal as required.
void refreshProperties();
//! If \a allowed is true then scripts are styled. The default is true.
//!
//! \sa scriptsStyled()
void setScriptsStyled(bool styled);
//! Returns true if scripts are styled.
//!
//! \sa setScriptsStyled()
bool scriptsStyled() const;
protected:
//! The lexer's properties are read from the settings \a qs. \a prefix
//! (which has a trailing '/') should be used as a prefix to the key of
//! each setting. true is returned if there is no error.
//!
bool readProperties(QSettings &qs, const QString &prefix);
//! The lexer's properties are written to the settings \a qs.
//! \a prefix (which has a trailing '/') should be used as a prefix to
//! the key of each setting. true is returned if there is no error.
//!
bool writeProperties(QSettings &qs, const QString &prefix) const;
private:
void setScriptsProp();
bool scripts;
QsciLexerXML(const QsciLexerXML &);
QsciLexerXML &operator=(const QsciLexerXML &);
};
#endif

View File

@@ -0,0 +1,801 @@
// This module implements the QsciLexerCPP class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include "Qsci/qscilexercpp.h"
#include <qcolor.h>
#include <qfont.h>
#include <qsettings.h>
// The ctor.
QsciLexerCPP::QsciLexerCPP(QObject *parent, bool caseInsensitiveKeywords)
: QsciLexer(parent),
fold_atelse(false), fold_comments(false), fold_compact(true),
fold_preproc(true), style_preproc(false), dollars(true),
highlight_triple(false), highlight_hash(false), highlight_back(false),
highlight_escape(false), vs_escape(false),
nocase(caseInsensitiveKeywords)
{
}
// The dtor.
QsciLexerCPP::~QsciLexerCPP()
{
}
// Returns the language name.
const char *QsciLexerCPP::language() const
{
return "C++";
}
// Returns the lexer name.
const char *QsciLexerCPP::lexer() const
{
return (nocase ? "cppnocase" : "cpp");
}
// Return the set of character sequences that can separate auto-completion
// words.
QStringList QsciLexerCPP::autoCompletionWordSeparators() const
{
QStringList wl;
wl << "::" << "->" << ".";
return wl;
}
// Return the list of keywords that can start a block.
const char *QsciLexerCPP::blockStartKeyword(int *style) const
{
if (style)
*style = Keyword;
return "case catch class default do else finally for if private "
"protected public struct try union while";
}
// Return the list of characters that can start a block.
const char *QsciLexerCPP::blockStart(int *style) const
{
if (style)
*style = Operator;
return "{";
}
// Return the list of characters that can end a block.
const char *QsciLexerCPP::blockEnd(int *style) const
{
if (style)
*style = Operator;
return "}";
}
// Return the style used for braces.
int QsciLexerCPP::braceStyle() const
{
return Operator;
}
// Return the string of characters that comprise a word.
const char *QsciLexerCPP::wordCharacters() const
{
return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#";
}
// Returns the foreground colour of the text for a style.
QColor QsciLexerCPP::defaultColor(int style) const
{
switch (style)
{
case Default:
return QColor(0x80, 0x80, 0x80);
case Comment:
case CommentLine:
return QColor(0x00, 0x7f, 0x00);
case CommentDoc:
case CommentLineDoc:
case PreProcessorCommentLineDoc:
return QColor(0x3f, 0x70, 0x3f);
case Number:
return QColor(0x00, 0x7f, 0x7f);
case Keyword:
return QColor(0x00, 0x00, 0x7f);
case DoubleQuotedString:
case SingleQuotedString:
case RawString:
return QColor(0x7f, 0x00, 0x7f);
case PreProcessor:
return QColor(0x7f, 0x7f, 0x00);
case Operator:
case UnclosedString:
return QColor(0x00, 0x00, 0x00);
case VerbatimString:
case TripleQuotedVerbatimString:
case HashQuotedString:
return QColor(0x00, 0x7f, 0x00);
case Regex:
return QColor(0x3f, 0x7f, 0x3f);
case CommentDocKeyword:
return QColor(0x30, 0x60, 0xa0);
case CommentDocKeywordError:
return QColor(0x80, 0x40, 0x20);
case PreProcessorComment:
return QColor(0x65, 0x99, 0x00);
case InactiveDefault:
case InactiveUUID:
case InactiveCommentLineDoc:
case InactiveKeywordSet2:
case InactiveCommentDocKeyword:
case InactiveCommentDocKeywordError:
case InactivePreProcessorCommentLineDoc:
return QColor(0xc0, 0xc0, 0xc0);
case InactiveComment:
case InactiveCommentLine:
case InactiveNumber:
case InactiveVerbatimString:
case InactiveTripleQuotedVerbatimString:
case InactiveHashQuotedString:
return QColor(0x90, 0xb0, 0x90);
case InactiveCommentDoc:
return QColor(0xd0, 0xd0, 0xd0);
case InactiveKeyword:
return QColor(0x90, 0x90, 0xb0);
case InactiveDoubleQuotedString:
case InactiveSingleQuotedString:
case InactiveRawString:
return QColor(0xb0, 0x90, 0xb0);
case InactivePreProcessor:
return QColor(0xb0, 0xb0, 0x90);
case InactiveOperator:
case InactiveIdentifier:
case InactiveGlobalClass:
return QColor(0xb0, 0xb0, 0xb0);
case InactiveUnclosedString:
return QColor(0x00, 0x00, 0x00);
case InactiveRegex:
return QColor(0x7f, 0xaf, 0x7f);
case InactivePreProcessorComment:
return QColor(0xa0, 0xc0, 0x90);
case UserLiteral:
return QColor(0xc0, 0x60, 0x00);
case InactiveUserLiteral:
return QColor(0xd7, 0xa0, 0x90);
case TaskMarker:
return QColor(0xbe, 0x07, 0xff);
case InactiveTaskMarker:
return QColor(0xc3, 0xa1, 0xcf);
}
return QsciLexer::defaultColor(style);
}
// Returns the end-of-line fill for a style.
bool QsciLexerCPP::defaultEolFill(int style) const
{
switch (style)
{
case UnclosedString:
case InactiveUnclosedString:
case VerbatimString:
case InactiveVerbatimString:
case Regex:
case InactiveRegex:
case TripleQuotedVerbatimString:
case InactiveTripleQuotedVerbatimString:
case HashQuotedString:
case InactiveHashQuotedString:
return true;
}
return QsciLexer::defaultEolFill(style);
}
// Returns the font of the text for a style.
QFont QsciLexerCPP::defaultFont(int style) const
{
QFont f;
switch (style)
{
case Comment:
case InactiveComment:
case CommentLine:
case InactiveCommentLine:
case CommentDoc:
case InactiveCommentDoc:
case CommentLineDoc:
case InactiveCommentLineDoc:
case CommentDocKeyword:
case InactiveCommentDocKeyword:
case CommentDocKeywordError:
case InactiveCommentDocKeywordError:
case TaskMarker:
case InactiveTaskMarker:
#if defined(Q_OS_WIN)
f = QFont("Comic Sans MS",9);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
#else
f = QFont("Bitstream Vera Serif",9);
#endif
break;
case Keyword:
case InactiveKeyword:
case Operator:
case InactiveOperator:
f = QsciLexer::defaultFont(style);
f.setBold(true);
break;
case DoubleQuotedString:
case InactiveDoubleQuotedString:
case SingleQuotedString:
case InactiveSingleQuotedString:
case UnclosedString:
case InactiveUnclosedString:
case VerbatimString:
case InactiveVerbatimString:
case Regex:
case InactiveRegex:
case TripleQuotedVerbatimString:
case InactiveTripleQuotedVerbatimString:
case HashQuotedString:
case InactiveHashQuotedString:
#if defined(Q_OS_WIN)
f = QFont("Courier New",10);
#elif defined(Q_OS_MAC)
f = QFont("Courier", 12);
#else
f = QFont("Bitstream Vera Sans Mono",9);
#endif
break;
default:
f = QsciLexer::defaultFont(style);
}
return f;
}
// Returns the set of keywords.
const char *QsciLexerCPP::keywords(int set) const
{
if (set == 1)
return
"and and_eq asm auto bitand bitor bool break case "
"catch char class compl const const_cast continue "
"default delete do double dynamic_cast else enum "
"explicit export extern false float for friend goto if "
"inline int long mutable namespace new not not_eq "
"operator or or_eq private protected public register "
"reinterpret_cast return short signed sizeof static "
"static_cast struct switch template this throw true "
"try typedef typeid typename union unsigned using "
"virtual void volatile wchar_t while xor xor_eq";
if (set == 3)
return
"a addindex addtogroup anchor arg attention author b "
"brief bug c class code date def defgroup deprecated "
"dontinclude e em endcode endhtmlonly endif "
"endlatexonly endlink endverbatim enum example "
"exception f$ f[ f] file fn hideinitializer "
"htmlinclude htmlonly if image include ingroup "
"internal invariant interface latexonly li line link "
"mainpage name namespace nosubgrouping note overload "
"p page par param post pre ref relates remarks return "
"retval sa section see showinitializer since skip "
"skipline struct subsection test throw todo typedef "
"union until var verbatim verbinclude version warning "
"weakgroup $ @ \\ & < > # { }";
return 0;
}
// Returns the user name of a style.
QString QsciLexerCPP::description(int style) const
{
switch (style)
{
case Default:
return tr("Default");
case InactiveDefault:
return tr("Inactive default");
case Comment:
return tr("C comment");
case InactiveComment:
return tr("Inactive C comment");
case CommentLine:
return tr("C++ comment");
case InactiveCommentLine:
return tr("Inactive C++ comment");
case CommentDoc:
return tr("JavaDoc style C comment");
case InactiveCommentDoc:
return tr("Inactive JavaDoc style C comment");
case Number:
return tr("Number");
case InactiveNumber:
return tr("Inactive number");
case Keyword:
return tr("Keyword");
case InactiveKeyword:
return tr("Inactive keyword");
case DoubleQuotedString:
return tr("Double-quoted string");
case InactiveDoubleQuotedString:
return tr("Inactive double-quoted string");
case SingleQuotedString:
return tr("Single-quoted string");
case InactiveSingleQuotedString:
return tr("Inactive single-quoted string");
case UUID:
return tr("IDL UUID");
case InactiveUUID:
return tr("Inactive IDL UUID");
case PreProcessor:
return tr("Pre-processor block");
case InactivePreProcessor:
return tr("Inactive pre-processor block");
case Operator:
return tr("Operator");
case InactiveOperator:
return tr("Inactive operator");
case Identifier:
return tr("Identifier");
case InactiveIdentifier:
return tr("Inactive identifier");
case UnclosedString:
return tr("Unclosed string");
case InactiveUnclosedString:
return tr("Inactive unclosed string");
case VerbatimString:
return tr("C# verbatim string");
case InactiveVerbatimString:
return tr("Inactive C# verbatim string");
case Regex:
return tr("JavaScript regular expression");
case InactiveRegex:
return tr("Inactive JavaScript regular expression");
case CommentLineDoc:
return tr("JavaDoc style C++ comment");
case InactiveCommentLineDoc:
return tr("Inactive JavaDoc style C++ comment");
case KeywordSet2:
return tr("Secondary keywords and identifiers");
case InactiveKeywordSet2:
return tr("Inactive secondary keywords and identifiers");
case CommentDocKeyword:
return tr("JavaDoc keyword");
case InactiveCommentDocKeyword:
return tr("Inactive JavaDoc keyword");
case CommentDocKeywordError:
return tr("JavaDoc keyword error");
case InactiveCommentDocKeywordError:
return tr("Inactive JavaDoc keyword error");
case GlobalClass:
return tr("Global classes and typedefs");
case InactiveGlobalClass:
return tr("Inactive global classes and typedefs");
case RawString:
return tr("C++ raw string");
case InactiveRawString:
return tr("Inactive C++ raw string");
case TripleQuotedVerbatimString:
return tr("Vala triple-quoted verbatim string");
case InactiveTripleQuotedVerbatimString:
return tr("Inactive Vala triple-quoted verbatim string");
case HashQuotedString:
return tr("Pike hash-quoted string");
case InactiveHashQuotedString:
return tr("Inactive Pike hash-quoted string");
case PreProcessorComment:
return tr("Pre-processor C comment");
case InactivePreProcessorComment:
return tr("Inactive pre-processor C comment");
case PreProcessorCommentLineDoc:
return tr("JavaDoc style pre-processor comment");
case InactivePreProcessorCommentLineDoc:
return tr("Inactive JavaDoc style pre-processor comment");
case UserLiteral:
return tr("User-defined literal");
case InactiveUserLiteral:
return tr("Inactive user-defined literal");
case TaskMarker:
return tr("Task marker");
case InactiveTaskMarker:
return tr("Inactive task marker");
case EscapeSequence:
return tr("Escape sequence");
case InactiveEscapeSequence:
return tr("Inactive escape sequence");
}
return QString();
}
// Returns the background colour of the text for a style.
QColor QsciLexerCPP::defaultPaper(int style) const
{
switch (style)
{
case UnclosedString:
case InactiveUnclosedString:
return QColor(0xe0,0xc0,0xe0);
case VerbatimString:
case InactiveVerbatimString:
case TripleQuotedVerbatimString:
case InactiveTripleQuotedVerbatimString:
return QColor(0xe0,0xff,0xe0);
case Regex:
case InactiveRegex:
return QColor(0xe0,0xf0,0xe0);
case RawString:
case InactiveRawString:
return QColor(0xff,0xf3,0xff);
case HashQuotedString:
case InactiveHashQuotedString:
return QColor(0xe7,0xff,0xd7);
}
return QsciLexer::defaultPaper(style);
}
// Refresh all properties.
void QsciLexerCPP::refreshProperties()
{
setAtElseProp();
setCommentProp();
setCompactProp();
setPreprocProp();
setStylePreprocProp();
setDollarsProp();
setHighlightTripleProp();
setHighlightHashProp();
setHighlightBackProp();
setHighlightEscapeProp();
setVerbatimStringEscapeProp();
}
// Read properties from the settings.
bool QsciLexerCPP::readProperties(QSettings &qs,const QString &prefix)
{
fold_atelse = qs.value(prefix + "foldatelse", false).toBool();
fold_comments = qs.value(prefix + "foldcomments", false).toBool();
fold_compact = qs.value(prefix + "foldcompact", true).toBool();
fold_preproc = qs.value(prefix + "foldpreprocessor", true).toBool();
style_preproc = qs.value(prefix + "stylepreprocessor", false).toBool();
dollars = qs.value(prefix + "dollars", true).toBool();
highlight_triple = qs.value(prefix + "highlighttriple", false).toBool();
highlight_hash = qs.value(prefix + "highlighthash", false).toBool();
highlight_back = qs.value(prefix + "highlightback", false).toBool();
highlight_escape = qs.value(prefix + "highlightescape", false).toBool();
vs_escape = qs.value(prefix + "verbatimstringescape", false).toBool();
return true;
}
// Write properties to the settings.
bool QsciLexerCPP::writeProperties(QSettings &qs,const QString &prefix) const
{
qs.setValue(prefix + "foldatelse", fold_atelse);
qs.setValue(prefix + "foldcomments", fold_comments);
qs.setValue(prefix + "foldcompact", fold_compact);
qs.setValue(prefix + "foldpreprocessor", fold_preproc);
qs.setValue(prefix + "stylepreprocessor", style_preproc);
qs.setValue(prefix + "dollars", dollars);
qs.setValue(prefix + "highlighttriple", highlight_triple);
qs.setValue(prefix + "highlighthash", highlight_hash);
qs.setValue(prefix + "highlightback", highlight_back);
qs.setValue(prefix + "highlightescape", highlight_escape);
qs.setValue(prefix + "verbatimstringescape", vs_escape);
return true;
}
// Set if else can be folded.
void QsciLexerCPP::setFoldAtElse(bool fold)
{
fold_atelse = fold;
setAtElseProp();
}
// Set the "fold.at.else" property.
void QsciLexerCPP::setAtElseProp()
{
emit propertyChanged("fold.at.else",(fold_atelse ? "1" : "0"));
}
// Set if comments can be folded.
void QsciLexerCPP::setFoldComments(bool fold)
{
fold_comments = fold;
setCommentProp();
}
// Set the "fold.comment" property.
void QsciLexerCPP::setCommentProp()
{
emit propertyChanged("fold.comment",(fold_comments ? "1" : "0"));
}
// Set if folds are compact
void QsciLexerCPP::setFoldCompact(bool fold)
{
fold_compact = fold;
setCompactProp();
}
// Set the "fold.compact" property.
void QsciLexerCPP::setCompactProp()
{
emit propertyChanged("fold.compact",(fold_compact ? "1" : "0"));
}
// Set if preprocessor blocks can be folded.
void QsciLexerCPP::setFoldPreprocessor(bool fold)
{
fold_preproc = fold;
setPreprocProp();
}
// Set the "fold.preprocessor" property.
void QsciLexerCPP::setPreprocProp()
{
emit propertyChanged("fold.preprocessor",(fold_preproc ? "1" : "0"));
}
// Set if preprocessor lines are styled.
void QsciLexerCPP::setStylePreprocessor(bool style)
{
style_preproc = style;
setStylePreprocProp();
}
// Set the "styling.within.preprocessor" property.
void QsciLexerCPP::setStylePreprocProp()
{
emit propertyChanged("styling.within.preprocessor",(style_preproc ? "1" : "0"));
}
// Set if '$' characters are allowed.
void QsciLexerCPP::setDollarsAllowed(bool allowed)
{
dollars = allowed;
setDollarsProp();
}
// Set the "lexer.cpp.allow.dollars" property.
void QsciLexerCPP::setDollarsProp()
{
emit propertyChanged("lexer.cpp.allow.dollars",(dollars ? "1" : "0"));
}
// Set if triple quoted strings are highlighted.
void QsciLexerCPP::setHighlightTripleQuotedStrings(bool enabled)
{
highlight_triple = enabled;
setHighlightTripleProp();
}
// Set the "lexer.cpp.triplequoted.strings" property.
void QsciLexerCPP::setHighlightTripleProp()
{
emit propertyChanged("lexer.cpp.triplequoted.strings",
(highlight_triple ? "1" : "0"));
}
// Set if hash quoted strings are highlighted.
void QsciLexerCPP::setHighlightHashQuotedStrings(bool enabled)
{
highlight_hash = enabled;
setHighlightHashProp();
}
// Set the "lexer.cpp.hashquoted.strings" property.
void QsciLexerCPP::setHighlightHashProp()
{
emit propertyChanged("lexer.cpp.hashquoted.strings",
(highlight_hash ? "1" : "0"));
}
// Set if back-quoted strings are highlighted.
void QsciLexerCPP::setHighlightBackQuotedStrings(bool enabled)
{
highlight_back = enabled;
setHighlightBackProp();
}
// Set the "lexer.cpp.backquoted.strings" property.
void QsciLexerCPP::setHighlightBackProp()
{
emit propertyChanged("lexer.cpp.backquoted.strings",
(highlight_back ? "1" : "0"));
}
// Set if escape sequences in strings are highlighted.
void QsciLexerCPP::setHighlightEscapeSequences(bool enabled)
{
highlight_escape = enabled;
setHighlightEscapeProp();
}
// Set the "lexer.cpp.escape.sequence" property.
void QsciLexerCPP::setHighlightEscapeProp()
{
emit propertyChanged("lexer.cpp.escape.sequence",
(highlight_escape ? "1" : "0"));
}
// Set if escape sequences in verbatim strings are allowed.
void QsciLexerCPP::setVerbatimStringEscapeSequencesAllowed(bool allowed)
{
vs_escape = allowed;
setVerbatimStringEscapeProp();
}
// Set the "lexer.cpp.verbatim.strings.allow.escapes" property.
void QsciLexerCPP::setVerbatimStringEscapeProp()
{
emit propertyChanged("lexer.cpp.verbatim.strings.allow.escapes",
(vs_escape ? "1" : "0"));
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,120 @@
// This module implements the QsciLexerJavaScript class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include "Qsci/qscilexerjavascript.h"
#include <qcolor.h>
#include <qfont.h>
// The list of JavaScript keywords that can be used by other friendly lexers.
const char *QsciLexerJavaScript::keywordClass =
"abstract boolean break byte case catch char class const continue "
"debugger default delete do double else enum export extends final "
"finally float for function goto if implements import in instanceof "
"int interface long native new package private protected public "
"return short static super switch synchronized this throw throws "
"transient try typeof var void volatile while with";
// The ctor.
QsciLexerJavaScript::QsciLexerJavaScript(QObject *parent)
: QsciLexerCPP(parent)
{
}
// The dtor.
QsciLexerJavaScript::~QsciLexerJavaScript()
{
}
// Returns the language name.
const char *QsciLexerJavaScript::language() const
{
return "JavaScript";
}
// Returns the foreground colour of the text for a style.
QColor QsciLexerJavaScript::defaultColor(int style) const
{
if (style == Regex)
return QColor(0x3f,0x7f,0x3f);
return QsciLexerCPP::defaultColor(style);
}
// Returns the end-of-line fill for a style.
bool QsciLexerJavaScript::defaultEolFill(int style) const
{
if (style == Regex)
return true;
return QsciLexerCPP::defaultEolFill(style);
}
// Returns the font of the text for a style.
QFont QsciLexerJavaScript::defaultFont(int style) const
{
if (style == Regex)
#if defined(Q_OS_WIN)
return QFont("Courier New",10);
#elif defined(Q_OS_MAC)
return QFont("Courier", 12);
#else
return QFont("Bitstream Vera Sans Mono",9);
#endif
return QsciLexerCPP::defaultFont(style);
}
// Returns the set of keywords.
const char *QsciLexerJavaScript::keywords(int set) const
{
if (set != 1)
return 0;
return keywordClass;
}
// Returns the user name of a style.
QString QsciLexerJavaScript::description(int style) const
{
if (style == Regex)
return tr("Regular expression");
return QsciLexerCPP::description(style);
}
// Returns the background colour of the text for a style.
QColor QsciLexerJavaScript::defaultPaper(int style) const
{
if (style == Regex)
return QColor(0xe0,0xf0,0xff);
return QsciLexer::defaultPaper(style);
}

View File

@@ -0,0 +1,489 @@
// This module implements the QsciLexerPython class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include "Qsci/qscilexerpython.h"
#include <qcolor.h>
#include <qfont.h>
#include <qsettings.h>
// The list of Python keywords that can be used by other friendly lexers.
const char *QsciLexerPython::keywordClass =
"and as assert break class continue def del elif else except exec "
"finally for from global if import in is lambda None not or pass "
"print raise return try while with yield";
// The ctor.
QsciLexerPython::QsciLexerPython(QObject *parent)
: QsciLexer(parent),
fold_comments(false), fold_compact(true), fold_quotes(false),
indent_warn(NoWarning), strings_over_newline(false), v2_unicode(true),
v3_binary_octal(true), v3_bytes(true), highlight_subids(true)
{
}
// The dtor.
QsciLexerPython::~QsciLexerPython()
{
}
// Returns the language name.
const char *QsciLexerPython::language() const
{
return "Python";
}
// Returns the lexer name.
const char *QsciLexerPython::lexer() const
{
return "python";
}
// Return the view used for indentation guides.
int QsciLexerPython::indentationGuideView() const
{
return QsciScintillaBase::SC_IV_LOOKFORWARD;
}
// Return the set of character sequences that can separate auto-completion
// words.
QStringList QsciLexerPython::autoCompletionWordSeparators() const
{
QStringList wl;
wl << ".";
return wl;
}
// Return the list of characters that can start a block.
const char *QsciLexerPython::blockStart(int *style) const
{
if (style)
*style = Operator;
return ":";
}
// Return the number of lines to look back when auto-indenting.
int QsciLexerPython::blockLookback() const
{
// This must be 0 otherwise de-indenting a Python block gets very
// difficult.
return 0;
}
// Return the style used for braces.
int QsciLexerPython::braceStyle() const
{
return Operator;
}
// Returns the foreground colour of the text for a style.
QColor QsciLexerPython::defaultColor(int style) const
{
switch (style)
{
case Default:
return QColor(0x80,0x80,0x80);
case Comment:
return QColor(0x00,0x7f,0x00);
case Number:
return QColor(0x00,0x7f,0x7f);
case DoubleQuotedString:
case SingleQuotedString:
return QColor(0x7f,0x00,0x7f);
case Keyword:
return QColor(0x00,0x00,0x7f);
case TripleSingleQuotedString:
case TripleDoubleQuotedString:
return QColor(0x7f,0x00,0x00);
case ClassName:
return QColor(0x00,0x00,0xff);
case FunctionMethodName:
return QColor(0x00,0x7f,0x7f);
case Operator:
case Identifier:
break;
case CommentBlock:
return QColor(0x7f,0x7f,0x7f);
case UnclosedString:
return QColor(0x00,0x00,0x00);
case HighlightedIdentifier:
return QColor(0x40,0x70,0x90);
case Decorator:
return QColor(0x80,0x50,0x00);
}
return QsciLexer::defaultColor(style);
}
// Returns the end-of-line fill for a style.
bool QsciLexerPython::defaultEolFill(int style) const
{
if (style == UnclosedString)
return true;
return QsciLexer::defaultEolFill(style);
}
// Returns the font of the text for a style.
QFont QsciLexerPython::defaultFont(int style) const
{
QFont f;
switch (style)
{
case Comment:
#if defined(Q_OS_WIN)
f = QFont("Comic Sans MS",9);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
#else
f = QFont("Bitstream Vera Serif",9);
#endif
break;
case DoubleQuotedString:
case SingleQuotedString:
case UnclosedString:
#if defined(Q_OS_WIN)
f = QFont("Courier New",10);
#elif defined(Q_OS_MAC)
f = QFont("Courier", 12);
#else
f = QFont("Bitstream Vera Sans Mono",9);
#endif
break;
case Keyword:
case ClassName:
case FunctionMethodName:
case Operator:
f = QsciLexer::defaultFont(style);
f.setBold(true);
break;
default:
f = QsciLexer::defaultFont(style);
}
return f;
}
// Returns the set of keywords.
const char *QsciLexerPython::keywords(int set) const
{
if (set != 1)
return 0;
return keywordClass;
}
// Returns the user name of a style.
QString QsciLexerPython::description(int style) const
{
switch (style)
{
case Default:
return tr("Default");
case Comment:
return tr("Comment");
case Number:
return tr("Number");
case DoubleQuotedString:
return tr("Double-quoted string");
case SingleQuotedString:
return tr("Single-quoted string");
case Keyword:
return tr("Keyword");
case TripleSingleQuotedString:
return tr("Triple single-quoted string");
case TripleDoubleQuotedString:
return tr("Triple double-quoted string");
case ClassName:
return tr("Class name");
case FunctionMethodName:
return tr("Function or method name");
case Operator:
return tr("Operator");
case Identifier:
return tr("Identifier");
case CommentBlock:
return tr("Comment block");
case UnclosedString:
return tr("Unclosed string");
case HighlightedIdentifier:
return tr("Highlighted identifier");
case Decorator:
return tr("Decorator");
}
return QString();
}
// Returns the background colour of the text for a style.
QColor QsciLexerPython::defaultPaper(int style) const
{
if (style == UnclosedString)
return QColor(0xe0,0xc0,0xe0);
return QsciLexer::defaultPaper(style);
}
// Refresh all properties.
void QsciLexerPython::refreshProperties()
{
setCommentProp();
setCompactProp();
setQuotesProp();
setTabWhingeProp();
setStringsOverNewlineProp();
setV2UnicodeProp();
setV3BinaryOctalProp();
setV3BytesProp();
setHighlightSubidsProp();
}
// Read properties from the settings.
bool QsciLexerPython::readProperties(QSettings &qs,const QString &prefix)
{
int rc = true, num;
fold_comments = qs.value(prefix + "foldcomments", false).toBool();
fold_compact = qs.value(prefix + "foldcompact", true).toBool();
fold_quotes = qs.value(prefix + "foldquotes", false).toBool();
indent_warn = (IndentationWarning)qs.value(prefix + "indentwarning", (int)NoWarning).toInt();
strings_over_newline = qs.value(prefix + "stringsovernewline", false).toBool();
v2_unicode = qs.value(prefix + "v2unicode", true).toBool();
v3_binary_octal = qs.value(prefix + "v3binaryoctal", true).toBool();
v3_bytes = qs.value(prefix + "v3bytes", true).toBool();
highlight_subids = qs.value(prefix + "highlightsubids", true).toBool();
return rc;
}
// Write properties to the settings.
bool QsciLexerPython::writeProperties(QSettings &qs,const QString &prefix) const
{
int rc = true;
qs.setValue(prefix + "foldcomments", fold_comments);
qs.setValue(prefix + "foldcompact", fold_compact);
qs.setValue(prefix + "foldquotes", fold_quotes);
qs.setValue(prefix + "indentwarning", (int)indent_warn);
qs.setValue(prefix + "stringsovernewline", strings_over_newline);
qs.setValue(prefix + "v2unicode", v2_unicode);
qs.setValue(prefix + "v3binaryoctal", v3_binary_octal);
qs.setValue(prefix + "v3bytes", v3_bytes);
qs.setValue(prefix + "highlightsubids", highlight_subids);
return rc;
}
// Set if comments can be folded.
void QsciLexerPython::setFoldComments(bool fold)
{
fold_comments = fold;
setCommentProp();
}
// Set the "fold.comment.python" property.
void QsciLexerPython::setCommentProp()
{
emit propertyChanged("fold.comment.python",(fold_comments ? "1" : "0"));
}
// Set if folds are compact.
void QsciLexerPython::setFoldCompact(bool fold)
{
fold_compact = fold;
setCompactProp();
}
// Set the "fold.compact" property.
void QsciLexerPython::setCompactProp()
{
emit propertyChanged("fold.compact",(fold_compact ? "1" : "0"));
}
// Set if quotes can be folded.
void QsciLexerPython::setFoldQuotes(bool fold)
{
fold_quotes = fold;
setQuotesProp();
}
// Set the "fold.quotes.python" property.
void QsciLexerPython::setQuotesProp()
{
emit propertyChanged("fold.quotes.python",(fold_quotes ? "1" : "0"));
}
// Set the indentation warning.
void QsciLexerPython::setIndentationWarning(QsciLexerPython::IndentationWarning warn)
{
indent_warn = warn;
setTabWhingeProp();
}
// Set the "tab.timmy.whinge.level" property.
void QsciLexerPython::setTabWhingeProp()
{
emit propertyChanged("tab.timmy.whinge.level", QByteArray::number(indent_warn));
}
// Set if string literals can span newlines.
void QsciLexerPython::setStringsOverNewlineAllowed(bool allowed)
{
strings_over_newline = allowed;
setStringsOverNewlineProp();
}
// Set the "lexer.python.strings.u" property.
void QsciLexerPython::setStringsOverNewlineProp()
{
emit propertyChanged("lexer.python.strings.over.newline", (strings_over_newline ? "1" : "0"));
}
// Set if v2 unicode string literals are allowed.
void QsciLexerPython::setV2UnicodeAllowed(bool allowed)
{
v2_unicode = allowed;
setV2UnicodeProp();
}
// Set the "lexer.python.strings.u" property.
void QsciLexerPython::setV2UnicodeProp()
{
emit propertyChanged("lexer.python.strings.u", (v2_unicode ? "1" : "0"));
}
// Set if v3 binary and octal literals are allowed.
void QsciLexerPython::setV3BinaryOctalAllowed(bool allowed)
{
v3_binary_octal = allowed;
setV3BinaryOctalProp();
}
// Set the "lexer.python.literals.binary" property.
void QsciLexerPython::setV3BinaryOctalProp()
{
emit propertyChanged("lexer.python.literals.binary", (v3_binary_octal ? "1" : "0"));
}
// Set if v3 bytes string literals are allowed.
void QsciLexerPython::setV3BytesAllowed(bool allowed)
{
v3_bytes = allowed;
setV3BytesProp();
}
// Set the "lexer.python.strings.b" property.
void QsciLexerPython::setV3BytesProp()
{
emit propertyChanged("lexer.python.strings.b",(v3_bytes ? "1" : "0"));
}
// Set if sub-identifiers are highlighted.
void QsciLexerPython::setHighlightSubidentifiers(bool enabled)
{
highlight_subids = enabled;
setHighlightSubidsProp();
}
// Set the "lexer.python.keywords2.no.sub.identifiers" property.
void QsciLexerPython::setHighlightSubidsProp()
{
emit propertyChanged("lexer.python.keywords2.no.sub.identifiers",
(highlight_subids ? "0" : "1"));
}

View File

@@ -0,0 +1,252 @@
// This module implements the QsciLexerXML class.
//
// Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include "Qsci/qscilexerxml.h"
#include <qcolor.h>
#include <qfont.h>
#include <qsettings.h>
// The ctor.
QsciLexerXML::QsciLexerXML(QObject *parent)
: QsciLexerHTML(parent), scripts(true)
{
}
// The dtor.
QsciLexerXML::~QsciLexerXML()
{
}
// Returns the language name.
const char *QsciLexerXML::language() const
{
return "XML";
}
// Returns the lexer name.
const char *QsciLexerXML::lexer() const
{
return "xml";
}
// Returns the foreground colour of the text for a style.
QColor QsciLexerXML::defaultColor(int style) const
{
switch (style)
{
case Default:
return QColor(0x00,0x00,0x00);
case Tag:
case UnknownTag:
case XMLTagEnd:
case SGMLDefault:
case SGMLCommand:
return QColor(0x00,0x00,0x80);
case Attribute:
case UnknownAttribute:
return QColor(0x00,0x80,0x80);
case HTMLNumber:
return QColor(0x00,0x7f,0x7f);
case HTMLDoubleQuotedString:
case HTMLSingleQuotedString:
return QColor(0x7f,0x00,0x7f);
case OtherInTag:
case Entity:
case XMLStart:
case XMLEnd:
return QColor(0x80,0x00,0x80);
case HTMLComment:
case SGMLComment:
return QColor(0x80,0x80,0x00);
case CDATA:
case PHPStart:
case SGMLDoubleQuotedString:
case SGMLError:
return QColor(0x80,0x00,0x00);
case HTMLValue:
return QColor(0x60,0x80,0x60);
case SGMLParameter:
return QColor(0x00,0x66,0x00);
case SGMLSingleQuotedString:
return QColor(0x99,0x33,0x00);
case SGMLSpecial:
return QColor(0x33,0x66,0xff);
case SGMLEntity:
return QColor(0x33,0x33,0x33);
case SGMLBlockDefault:
return QColor(0x00,0x00,0x66);
}
return QsciLexerHTML::defaultColor(style);
}
// Returns the end-of-line fill for a style.
bool QsciLexerXML::defaultEolFill(int style) const
{
if (style == CDATA)
return true;
return QsciLexerHTML::defaultEolFill(style);
}
// Returns the font of the text for a style.
QFont QsciLexerXML::defaultFont(int style) const
{
QFont f;
switch (style)
{
case Default:
case Entity:
case CDATA:
#if defined(Q_OS_WIN)
f = QFont("Times New Roman",11);
#elif defined(Q_OS_MAC)
f = QFont("Times New Roman", 12);
#else
f = QFont("Bitstream Charter",10);
#endif
break;
case XMLStart:
case XMLEnd:
case SGMLCommand:
f = QsciLexer::defaultFont(style);
f.setBold(true);
break;
default:
f = QsciLexerHTML::defaultFont(style);
}
return f;
}
// Returns the set of keywords.
const char *QsciLexerXML::keywords(int set) const
{
if (set == 6)
return QsciLexerHTML::keywords(set);
return 0;
}
// Returns the background colour of the text for a style.
QColor QsciLexerXML::defaultPaper(int style) const
{
switch (style)
{
case CDATA:
return QColor(0xff,0xf0,0xf0);
case SGMLDefault:
case SGMLCommand:
case SGMLParameter:
case SGMLDoubleQuotedString:
case SGMLSingleQuotedString:
case SGMLSpecial:
case SGMLEntity:
case SGMLComment:
return QColor(0xef,0xef,0xff);
case SGMLError:
return QColor(0xff,0x66,0x66);
case SGMLBlockDefault:
return QColor(0xcc,0xcc,0xe0);
}
return QsciLexerHTML::defaultPaper(style);
}
// Refresh all properties.
void QsciLexerXML::refreshProperties()
{
setScriptsProp();
}
// Read properties from the settings.
bool QsciLexerXML::readProperties(QSettings &qs, const QString &prefix)
{
int rc = QsciLexerHTML::readProperties(qs, prefix), num;
scripts = qs.value(prefix + "scriptsstyled", true).toBool();
return rc;
}
// Write properties to the settings.
bool QsciLexerXML::writeProperties(QSettings &qs, const QString &prefix) const
{
int rc = QsciLexerHTML::writeProperties(qs, prefix);
qs.setValue(prefix + "scriptsstyled", scripts);
return rc;
}
// Return true if scripts are styled.
bool QsciLexerXML::scriptsStyled() const
{
return scripts;
}
// Set if scripts are styled.
void QsciLexerXML::setScriptsStyled(bool styled)
{
scripts = styled;
setScriptsProp();
}
// Set the "lexer.xml.allow.scripts" property.
void QsciLexerXML::setScriptsProp()
{
emit propertyChanged("lexer.xml.allow.scripts",(scripts ? "1" : "0"));
}

File diff suppressed because it is too large Load Diff

View File

@@ -79,6 +79,8 @@ int Scintilla_LinkLexers() {
//**\(\tLINK_LEXER(\*);\n\)
LINK_LEXER(lmSQL);
LINK_LEXER(lmJSON);
LINK_LEXER(lmHTML);
LINK_LEXER(lmXML);
//--Autogenerated -- end of automatically generated section

View File

@@ -3,6 +3,7 @@
#include "sqlitedb.h"
#include "Settings.h"
#include "src/qhexedit.h"
#include "docktextedit.h"
#include "FileDialog.h"
#include "Data.h"
@@ -13,6 +14,7 @@
#include <QBuffer>
#include <QModelIndex>
#include <QJsonDocument>
#include <QDomDocument>
#include <QMessageBox>
EditDialog::EditDialog(QWidget* parent)
@@ -21,7 +23,6 @@ EditDialog::EditDialog(QWidget* parent)
currentIndex(QModelIndex()),
dataSource(TextBuffer),
dataType(Null),
textNullSet(false),
isReadOnly(true)
{
ui->setupUi(this);
@@ -34,17 +35,18 @@ EditDialog::EditDialog(QWidget* parent)
hexLayout->addWidget(hexEdit);
hexEdit->setOverwriteMode(false);
QHBoxLayout* jsonLayout = new QHBoxLayout(ui->editorJSON);
jsonEdit = new JsonTextEdit(this);
jsonLayout->addWidget(jsonEdit);
QHBoxLayout* sciLayout = new QHBoxLayout(ui->editorSci);
sciEdit = new DockTextEdit(this);
sciLayout->addWidget(sciEdit);
QShortcut* ins = new QShortcut(QKeySequence(Qt::Key_Insert), this);
connect(ins, SIGNAL(activated()), this, SLOT(toggleOverwriteMode()));
connect(ui->editorText, SIGNAL(textChanged()), this, SLOT(updateApplyButton()));
connect(hexEdit, SIGNAL(dataChanged()), this, SLOT(updateApplyButton()));
connect(jsonEdit, SIGNAL(textChanged()), this, SLOT(updateApplyButton()));
connect(jsonEdit, SIGNAL(textChanged()), this, SLOT(editTextChanged()));
connect(sciEdit, SIGNAL(textChanged()), this, SLOT(updateApplyButton()));
connect(sciEdit, SIGNAL(textChanged()), this, SLOT(editTextChanged()));
mustIndentAndCompact = Settings::getValue("databrowser", "indent_compact").toBool();
ui->buttonIndent->setChecked(mustIndentAndCompact);
@@ -99,15 +101,15 @@ void EditDialog::loadData(const QByteArray& data)
// Determine the data type, saving that info in the class variable
dataType = checkDataType(data);
// Get the current editor mode (eg text, hex, or image mode)
int editMode = ui->editorStack->currentIndex();
// Get the current editor mode (eg text, hex, image, json or xml mode)
int editMode = ui->comboMode->currentIndex();
// Data type specific handling
switch (dataType) {
case Null:
// Set enabled any of the text widgets
ui->editorText->setEnabled(true);
jsonEdit->setEnabled(true);
sciEdit->setEnabled(true);
switch (editMode) {
case TextEditor:
// The text widget buffer is now the main data source
@@ -119,15 +121,16 @@ void EditDialog::loadData(const QByteArray& data)
break;
case JsonEditor:
case XmlEditor:
// The JSON widget buffer is now the main data source
dataSource = JsonBuffer;
dataSource = SciBuffer;
// Empty the text editor contents, then enable text editing
jsonEdit->clear();
sciEdit->clear();
break;
case HexEditor:
// The hex widget buffer is now the main data source
dataSource = HexBuffer;
@@ -153,78 +156,27 @@ void EditDialog::loadData(const QByteArray& data)
case Text:
case JSON:
// Set enabled any of the text widgets
ui->editorText->setEnabled(true);
jsonEdit->setEnabled(true);
// Can be stored in any widget, except the ImageViewer
switch (editMode) {
case TextEditor:
{
// The text widget buffer is now the main data source
dataSource = TextBuffer;
// Load the text into the text editor, remove BOM first if there is one
QByteArray dataWithoutBom = data;
removedBom = removeBom(dataWithoutBom);
textData = QString::fromUtf8(dataWithoutBom.constData(), dataWithoutBom.size());
ui->editorText->setPlainText(textData);
// Select all of the text by default
ui->editorText->selectAll();
setDataInBuffer(data, TextBuffer);
break;
}
case JsonEditor:
// The JSON widget buffer is now the main data source
dataSource = JsonBuffer;
{
QJsonParseError parseError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(QByteArray(data.constData(), data.size()), &parseError);
if (mustIndentAndCompact && !jsonDoc.isNull()) {
// Load indented JSON into the JSON editor
textData = QString(jsonDoc.toJson(QJsonDocument::Indented));
jsonEdit->setText(textData);
} else {
// Fallback case. The data is not yet valid JSON.
textData = QString::fromUtf8(data.constData(), data.size());
jsonEdit->setText(textData);
}
jsonEdit->clearErrorIndicators();
if (parseError.error != QJsonParseError::NoError)
jsonEdit->setErrorIndicator(parseError.offset-1);
}
case XmlEditor:
setDataInBuffer(data, SciBuffer);
break;
case HexEditor:
// The hex widget buffer is now the main data source
dataSource = HexBuffer;
// Load the text into the hex editor
hexEdit->setData(data);
setDataInBuffer(data, HexBuffer);
break;
case ImageViewer:
// The text widget buffer is now the main data source
dataSource = TextBuffer;
// The image viewer cannot hold data nor display text.
// Clear any image from the image viewing widget
ui->editorImage->setPixmap(QPixmap(0,0));
// Load the text into the text editor
textData = QString::fromUtf8(data.constData(), data.size());
ui->editorText->setPlainText(textData);
// Enable text editing
ui->editorText->setEnabled(true);
// Select all of the text by default
ui->editorText->selectAll();
setDataInBuffer(data, TextBuffer);
break;
}
@@ -235,10 +187,7 @@ void EditDialog::loadData(const QByteArray& data)
// stored it in the editorImage widget instead, it would be a pixmap
// and there's no good way to restore that back to the original
// (pristine) image data. eg image metadata would be lost
hexEdit->setData(data);
// The hex widget buffer is now the main data source
dataSource = HexBuffer;
setDataInBuffer(data, HexBuffer);
// Update the display if in text edit or image viewer mode
switch (editMode) {
@@ -250,10 +199,12 @@ void EditDialog::loadData(const QByteArray& data)
ui->editorText->setEnabled(false);
break;
case XmlEditor:
case JsonEditor:
// Disable text editing, and use a warning message as the contents
jsonEdit->setText(tr("Image data can't be viewed with the JSON editor"));
jsonEdit->setEnabled(false);
sciEdit->setText(tr("Image data can't be viewed with this editor"));
sciEdit->setEnabled(false);
break;
case ImageViewer:
@@ -264,16 +215,44 @@ void EditDialog::loadData(const QByteArray& data)
break;
}
break;
case SVG:
// Set the XML data in any buffer or update image in image viewer mode
switch (editMode) {
case TextEditor:
setDataInBuffer(data, TextBuffer);
break;
case JsonEditor:
case XmlEditor:
setDataInBuffer(data, SciBuffer);
break;
case HexEditor:
setDataInBuffer(data, HexBuffer);
break;
case ImageViewer:
// Set data in the XML (Sci) Buffer and load the SVG Image
setDataInBuffer(data, SciBuffer);
sciEdit->setLanguage(DockTextEdit::XML);
// Load the image into the image viewing widget
if (img.loadFromData(data)) {
ui->editorImage->setPixmap(QPixmap::fromImage(img));
}
break;
}
break;
default:
// The hex widget buffer is now the main data source
dataSource = HexBuffer;
// The data seems to be general binary data, which is always loaded
// into the hex widget (the only safe place for it)
// Load the data into the hex editor
hexEdit->setData(data);
// Load the data into the hex buffer
setDataInBuffer(data, HexBuffer);
switch (editMode) {
case TextEditor:
@@ -285,9 +264,10 @@ void EditDialog::loadData(const QByteArray& data)
break;
case JsonEditor:
case XmlEditor:
// Disable text editing, and use a warning message as the contents
jsonEdit->setText(QString(tr("Binary data can't be viewed with the JSON editor")));
jsonEdit->setEnabled(false);
sciEdit->setText(QString(tr("Binary data can't be viewed with this editor")));
sciEdit->setEnabled(false);
break;
case ImageViewer:
@@ -310,7 +290,7 @@ void EditDialog::importData()
this,
tr("Choose a file to import")
#ifndef Q_OS_MAC // Filters on OS X are buggy
, tr("Text files(*.txt);;Image files(%1);;JSON files(*.json);;All files(*)").arg(image_formats)
, tr("Text files (*.txt);;Image files (%1);;JSON files (*.json);;XML files (*.xml);;All files (*)").arg(image_formats)
#endif
);
if(QFile::exists(fileName))
@@ -361,11 +341,10 @@ void EditDialog::exportData()
// Data source is the text buffer
file.write(ui->editorText->toPlainText().toUtf8());
break;
case JsonBuffer:
case SciBuffer:
// Data source is the JSON buffer
file.write(jsonEdit->text().toUtf8());
file.write(sciEdit->text().toUtf8());
break;
}
file.close();
}
@@ -377,25 +356,17 @@ void EditDialog::setNull()
ui->editorText->clear();
ui->editorImage->clear();
hexEdit->setData(QByteArray());
jsonEdit->clear();
sciEdit->clear();
dataType = Null;
removedBom.clear();
// Check if in text editor mode
int editMode = ui->editorStack->currentIndex();
if (editMode == TextEditor || editMode == JsonEditor) {
// Setting NULL in the text editor switches the data source to it
dataSource = TextBuffer;
// The text editors don't know the difference between an empty string
// and a NULL, so we need to record NULL outside of that
dataType = Null;
// Ensure the text editor is enabled
ui->editorText->setEnabled(true);
// Ensure the JSON editor is enabled
jsonEdit->setEnabled(true);
// The text editor doesn't know the difference between an empty string
// and a NULL, so we need to record NULL outside of that
textNullSet = true;
}
// Ensure the text (plain and Scintilla) editors are enabled
ui->editorText->setEnabled(true);
sciEdit->setEnabled(true);
// Update the cell data info in the bottom left of the Edit Cell
updateCellInfo(hexEdit->data());
@@ -424,47 +395,46 @@ void EditDialog::accept()
if(!currentIndex.isValid())
return;
if (dataType == Null) {
emit recordTextUpdated(currentIndex, hexEdit->data(), true);
return;
}
switch (dataSource) {
case TextBuffer:
// Check if a NULL is set in the text editor
if (textNullSet) {
emit recordTextUpdated(currentIndex, hexEdit->data(), true);
} else {
// It's not NULL, so proceed with normal text string checking
QString oldData = currentIndex.data(Qt::EditRole).toString();
QString newData = removedBom + ui->editorText->toPlainText();
if (oldData != newData)
// The data is different, so commit it back to the database
emit recordTextUpdated(currentIndex, removedBom + newData.toUtf8(), false);
}
{
QString oldData = currentIndex.data(Qt::EditRole).toString();
QString newData = removedBom + ui->editorText->toPlainText();
if (oldData != newData)
// The data is different, so commit it back to the database
emit recordTextUpdated(currentIndex, removedBom + newData.toUtf8(), false);
break;
case JsonBuffer:
// Check if a NULL is set in the text editor
if (textNullSet) {
emit recordTextUpdated(currentIndex, hexEdit->data(), true);
} else {
// It's not NULL, so proceed with normal text string checking
}
case SciBuffer:
switch (sciEdit->language()) {
case DockTextEdit::JSON:
{
QString oldData = currentIndex.data(Qt::EditRole).toString();
QString newData;
QJsonParseError parseError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonEdit->text().toUtf8(), &parseError);
QJsonDocument jsonDoc = QJsonDocument::fromJson(sciEdit->text().toUtf8(), &parseError);
bool proceed;
jsonEdit->clearErrorIndicators();
sciEdit->clearErrorIndicators();
if (parseError.error != QJsonParseError::NoError)
jsonEdit->setErrorIndicator(parseError.offset-1);
sciEdit->setErrorIndicator(parseError.offset-1);
if (!jsonDoc.isNull()) {
if (mustIndentAndCompact)
// Compact the JSON data before storing
newData = QString(jsonDoc.toJson(QJsonDocument::Compact));
else
newData = jsonEdit->text();
newData = sciEdit->text();
proceed = (oldData != newData);
} else {
newData = jsonEdit->text();
newData = sciEdit->text();
proceed = (oldData != newData && promptInvalidData("JSON", parseError.errorString()));
}
if (proceed)
@@ -472,7 +442,38 @@ void EditDialog::accept()
emit recordTextUpdated(currentIndex, newData.toUtf8(), false);
}
break;
case DockTextEdit::XML:
{
QString oldData = currentIndex.data(Qt::EditRole).toString();
QString newData;
QDomDocument xmlDoc;
QString errorMsg;
int errorLine, errorColumn;
bool isValid = xmlDoc.setContent(sciEdit->text().toUtf8(), true, &errorMsg, &errorLine, &errorColumn);
bool proceed;
sciEdit->clearErrorIndicators();
if (!isValid) {
sciEdit->setErrorIndicator(errorLine-1, errorColumn-1, errorLine, 0);
newData = sciEdit->text();
proceed = (oldData != newData && promptInvalidData("XML", errorMsg));
} else {
if (mustIndentAndCompact)
// Compact the XML data before storing. If indent is -1, no whitespace at all is added.
newData = xmlDoc.toString(-1);
else
newData = sciEdit->text();
proceed = (oldData != newData);
}
if (proceed)
// The data is different, so commit it back to the database
emit recordTextUpdated(currentIndex, newData.toUtf8(), false);
}
break;
}
break;
case HexBuffer:
// The data source is the hex widget buffer, thus binary data
QByteArray oldData = currentIndex.data(Qt::EditRole).toByteArray();
@@ -483,10 +484,94 @@ void EditDialog::accept()
}
}
void EditDialog::setDataInBuffer(const QByteArray& data, DataSources source)
{
dataSource = source;
QString textData;
// 1) Perform validation and text formatting (if applicable).
// 2) Set the text in the corresponding editor widget (the text widget for the Image case).
// 3) Enable the widget.
switch (dataSource) {
case TextBuffer:
{
// Load the text into the text editor, remove BOM first if there is one
QByteArray dataWithoutBom = data;
removedBom = removeBom(dataWithoutBom);
textData = QString::fromUtf8(dataWithoutBom.constData(), dataWithoutBom.size());
ui->editorText->setPlainText(textData);
// Select all of the text by default (this is useful for simple text data that we usually edit as a whole)
ui->editorText->selectAll();
ui->editorText->setEnabled(true);
break;
}
case SciBuffer:
switch (sciEdit->language()) {
case DockTextEdit::JSON:
{
QJsonParseError parseError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(QByteArray(data.constData(), data.size()), &parseError);
if (mustIndentAndCompact && !jsonDoc.isNull()) {
// Load indented JSON into the JSON editor
textData = QString(jsonDoc.toJson(QJsonDocument::Indented));
} else {
// Fallback case. The data is not yet valid JSON or no auto-formatting applied.
textData = QString::fromUtf8(data.constData(), data.size());
}
sciEdit->setText(textData);
sciEdit->clearErrorIndicators();
if (parseError.error != QJsonParseError::NoError)
sciEdit->setErrorIndicator(parseError.offset-1);
sciEdit->setEnabled(true);
}
break;
case DockTextEdit::XML:
{
QString errorMsg;
int errorLine, errorColumn;
QDomDocument xmlDoc;
bool isValid = xmlDoc.setContent(data, true, &errorMsg, &errorLine, &errorColumn);
if (mustIndentAndCompact && isValid) {
// Load indented XML into the XML editor
textData = xmlDoc.toString(Settings::getValue("editor", "tabsize").toInt());
} else {
// Fallback case. The data is not yet valid JSON or no auto-formatting applied.
textData = QString::fromUtf8(data.constData(), data.size());
}
sciEdit->setText(textData);
sciEdit->clearErrorIndicators();
if (!isValid)
// Adjust line and column by one (Scintilla starts at 1 and QDomDocument at 0)
sciEdit->setErrorIndicator(errorLine-1, errorColumn-1, errorLine, 0);
sciEdit->setEnabled(true);
}
break;
}
break;
case HexBuffer:
hexEdit->setData(data);
hexEdit->setEnabled(true);
break;
}
}
// Called when the user manually changes the "Mode" drop down combobox
void EditDialog::editModeChanged(int newMode)
{
ui->buttonIndent->setEnabled(newMode == JsonEditor);
ui->buttonIndent->setEnabled(newMode == JsonEditor || newMode == XmlEditor);
setStackCurrentIndex(newMode);
// * If the dataSource is the text buffer, the data is always text *
switch (dataSource) {
@@ -496,30 +581,16 @@ void EditDialog::editModeChanged(int newMode)
// Nothing to do, as the text is already in the text buffer
break;
case JsonEditor: // Switching to the JSON editor
case JsonEditor: // Switching to one of the Scintilla editor modes
case XmlEditor:
// Convert the text widget buffer for the JSON widget
// * If the dataSource is the TextBuffer, the contents could
// be still compacted so we just pass it to our loadData()
// function to handle, for indenting if necessary *
// Switch to the selected editor first, as loadData() relies
// on it being current
ui->editorStack->setCurrentIndex(newMode);
// Load the data into the appropriate widget, as done by loadData()
loadData(ui->editorText->toPlainText().toUtf8());
// jsonEdit->setText(ui->editorText->toPlainText().toUtf8());
// The JSON widget buffer is now the main data source
dataSource = JsonBuffer;
setDataInBuffer(ui->editorText->toPlainText().toUtf8(), SciBuffer);
break;
case HexEditor: // Switching to the hex editor
// Convert the text widget buffer for the hex widget
hexEdit->setData(removedBom + ui->editorText->toPlainText().toUtf8());
// The hex widget buffer is now the main data source
dataSource = HexBuffer;
setDataInBuffer(removedBom + ui->editorText->toPlainText().toUtf8(), HexBuffer);
break;
case ImageViewer:
@@ -527,72 +598,76 @@ void EditDialog::editModeChanged(int newMode)
ui->editorImage->setPixmap(QPixmap(0,0));
break;
}
// Switch to the selected editor
ui->editorStack->setCurrentIndex(newMode);
return;
break;
case HexBuffer:
// * If the dataSource is the hex buffer, the contents could be anything
// so we just pass it to our loadData() function to handle *
// Switch to the selected editor first, as loadData() relies on it
// Note that we have already set the editor, as loadData() relies on it
// being current
ui->editorStack->setCurrentIndex(newMode);
// Load the data into the appropriate widget, as done by loadData()
loadData(hexEdit->data());
break;
case JsonBuffer:
case SciBuffer:
switch (newMode) {
case TextEditor: // Switching to the text editor
// Convert the text widget buffer for the JSON widget
ui->editorText->setText(jsonEdit->text());
// The Text widget buffer is now the main data source
dataSource = TextBuffer;
setDataInBuffer(sciEdit->text().toUtf8(), TextBuffer);
break;
case JsonEditor: // Switching to the JSON editor
// Nothing to do, as the text is already in the JSON buffer
break;
case HexEditor: // Switching to the hex editor
// Convert the text widget buffer for the hex widget
hexEdit->setData(jsonEdit->text().toUtf8());
// The hex widget buffer is now the main data source
dataSource = HexBuffer;
setDataInBuffer(sciEdit->text().toUtf8(), HexBuffer);
break;
case ImageViewer:
// Clear any image from the image viewing widget
ui->editorImage->setPixmap(QPixmap(0,0));
{
// When SVG format, load the image, else clear it.
QByteArray data = sciEdit->text().toUtf8();
dataType = checkDataType(data);
if (dataType == SVG) {
QImage img;
if (img.loadFromData(data))
ui->editorImage->setPixmap(QPixmap::fromImage(img));
else
// Clear any image from the image viewing widget
ui->editorImage->setPixmap(QPixmap(0,0));
}
}
break;
case JsonEditor: // Switching to the JSON editor
case XmlEditor: // Switching to the XML editor
// The text is already in the Sci buffer but we need to perform the necessary formatting.
setDataInBuffer(sciEdit->text().toUtf8(), SciBuffer);
break;
}
// Switch to the selected editor
ui->editorStack->setCurrentIndex(newMode);
}
}
}
// Called for every keystroke in the text editor (only)
void EditDialog::editTextChanged()
{
if (dataSource == TextBuffer || dataSource == JsonBuffer) {
if (dataSource == TextBuffer || dataSource == SciBuffer) {
// Data has been changed in the text editor, so it can't be a NULL
// any more
textNullSet = false;
// any more. It hasn't been validated yet, so it cannot be JSON nor XML.
if (dataType == Null) {
dataType = Text;
ui->labelType->setText(tr("Type of data currently in cell: Text / Numeric"));
}
// Update the cell info in the bottom left manually. This is because
// updateCellInfo() only works with QByteArray's (for now)
int dataLength;
if (dataSource == TextBuffer)
switch (dataSource) {
case TextBuffer:
dataLength = ui->editorText->toPlainText().length();
else
dataLength = jsonEdit->text().length();
ui->labelType->setText(tr("Type of data currently in cell: Text / Numeric"));
break;
case SciBuffer:
dataLength = sciEdit->text().length();
break;
}
ui->labelSize->setText(tr("%n char(s)", "", dataLength));
}
}
@@ -601,12 +676,11 @@ void EditDialog::setMustIndentAndCompact(bool enable)
{
mustIndentAndCompact = enable;
// Indent or compact if necessary. If data has changed, reload from the widget, else from the table.
if (ui->buttonApply->isEnabled())
loadData(jsonEdit->text().toUtf8());
else
// Indent or compact if necessary. If data has changed (button Apply indicates so), reload from the widget, else from the table.
if (ui->buttonApply->isEnabled()) {
setDataInBuffer(sciEdit->text().toUtf8(), SciBuffer);
} else
setCurrentIndex(currentIndex);
}
// Determine the type of data in the cell
@@ -623,13 +697,14 @@ int EditDialog::checkDataType(const QByteArray& data)
// that returned true, do a more sophisticated test of the data. This way we get both, good performance and proper data checking.
QBuffer imageBuffer(&cellData);
QImageReader readerBuffer(&imageBuffer);
QString imageFormat = readerBuffer.format();
if(readerBuffer.canRead() && !readerBuffer.read().isNull())
return Image;
return imageFormat == "svg" ? SVG : Image;
// Check if it's text only
if(isTextOnly(cellData))
{
QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(cellData).toUtf8());
QJsonDocument jsonDoc = QJsonDocument::fromJson(cellData);
if (!jsonDoc.isNull())
return JSON;
else
@@ -647,7 +722,7 @@ void EditDialog::toggleOverwriteMode()
hexEdit->setOverwriteMode(currentMode);
ui->editorText->setOverwriteMode(currentMode);
jsonEdit->setOverwriteMode(currentMode);
sciEdit->setOverwriteMode(currentMode);
}
void EditDialog::setFocus()
@@ -658,9 +733,25 @@ void EditDialog::setFocus()
// to the dock itself doesn't make much sense as it's just a frame; you'd
// have to tab to the editor which is what you most likely want to use. So
// in order to save the user from doing this we explicitly set the focus
// to the editor.
ui->editorText->setFocus();
ui->editorText->selectAll();
// to the current editor.
int editMode = ui->editorStack->currentIndex();
switch (editMode) {
case TextEditor:
ui->editorText->setFocus();
ui->editorText->selectAll();
break;
case HexEditor:
hexEdit->setFocus();
break;
case SciEditor:
sciEdit->setFocus();
break;
case ImageViewer:
// Nothing to do
break;
}
}
// Enables or disables the Apply, Null, & Import buttons in the Edit Cell dock
@@ -677,7 +768,7 @@ void EditDialog::setReadOnly(bool ro)
ui->editorText->setTextInteractionFlags(textFlags);
ui->editorBinary->setEnabled(!ro); // We disable the entire hex editor here instead of setting it to read only because it doesn't have a setReadOnly() method
jsonEdit->setReadOnly(ro);
sciEdit->setReadOnly(ro);
}
// Update the information labels in the bottom left corner of the dialog
@@ -686,7 +777,7 @@ void EditDialog::updateCellInfo(const QByteArray& data)
QByteArray cellData = data;
// Image data needs special treatment
if (dataType == Image) {
if (dataType == Image || dataType == SVG) {
QBuffer imageBuffer(&cellData);
QImageReader imageReader(&imageBuffer);
@@ -776,6 +867,27 @@ void EditDialog::reloadSettings()
hexFont.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
hexEdit->setFont(hexFont);
jsonEdit->reloadSettings();
sciEdit->reloadSettings();
}
void EditDialog::setStackCurrentIndex(int editMode)
{
switch (editMode) {
case TextEditor:
case HexEditor:
case ImageViewer:
// General case: switch to the selected editor
ui->editorStack->setCurrentIndex(editMode);
break;
case JsonEditor:
// Scintilla case: switch to the single Scintilla editor and set language
ui->editorStack->setCurrentIndex(SciEditor);
sciEdit->setLanguage(DockTextEdit::JSON);
break;
case XmlEditor:
// Scintilla case: switch to the single Scintilla editor and set language
ui->editorStack->setCurrentIndex(SciEditor);
sciEdit->setLanguage(DockTextEdit::XML);
break;
}
}

View File

@@ -4,9 +4,8 @@
#include <QDialog>
#include <QPersistentModelIndex>
#include "jsontextedit.h"
class QHexEdit;
class DockTextEdit;
namespace Ui {
class EditDialog;
@@ -50,11 +49,10 @@ signals:
private:
Ui::EditDialog* ui;
QHexEdit* hexEdit;
JsonTextEdit* jsonEdit;
DockTextEdit* sciEdit;
QPersistentModelIndex currentIndex;
int dataSource;
int dataType;
bool textNullSet;
bool isReadOnly;
bool mustIndentAndCompact;
QByteArray removedBom;
@@ -62,27 +60,34 @@ private:
enum DataSources {
TextBuffer,
HexBuffer,
JsonBuffer
SciBuffer
};
// SVG is both an Image and an XML document so it is treated separately
enum DataTypes {
Binary,
Image,
Null,
Text,
JSON
JSON,
SVG
};
// Edit modes and editor stack (this must be aligned with the UI)
// Note that JSON and XML share the Scintilla widget.
enum EditModes {
TextEditor = 0,
HexEditor = 1,
JsonEditor = 2,
ImageViewer = 3
ImageViewer = 2,
JsonEditor, SciEditor = 3,
XmlEditor = 4
};
int checkDataType(const QByteArray& data);
QString humanReadableSize(double byteCount) const;
bool promptInvalidData(const QString& dataType, const QString& errorString);
void setDataInBuffer(const QByteArray& data, DataSources source);
void setStackCurrentIndex(int editMode);
};
#endif

View File

@@ -47,6 +47,11 @@
<string>Binary</string>
</property>
</item>
<item>
<property name="text">
<string>Image</string>
</property>
</item>
<item>
<property name="text">
<string>JSON</string>
@@ -54,7 +59,7 @@
</item>
<item>
<property name="text">
<string>Image</string>
<string>XML</string>
</property>
</item>
</widget>
@@ -182,13 +187,6 @@
</layout>
</widget>
<widget class="QWidget" name="editorBinary"/>
<widget class="QWidget" name="editorJSON">
<property name="whatsThis">
<string>This editor mode lets you edit JSON data with syntax highlighting, automatic formatting and validation before saving.
Errors are indicated with a red squiggle underline.</string>
</property>
</widget>
<widget class="QScrollArea" name="editorImageScrollArea">
<property name="widgetResizable">
<bool>true</bool>
@@ -213,6 +211,13 @@ Errors are indicated with a red squiggle underline.</string>
</layout>
</widget>
</widget>
<widget class="QWidget" name="editorSci">
<property name="whatsThis">
<string>This editor mode lets you edit JSON or XML data with syntax highlighting, automatic formatting and validation before saving.
Errors are indicated with a red squiggle underline.</string>
</property>
</widget>
</widget>
</item>
<item>
@@ -305,22 +310,6 @@ Errors are indicated with a red squiggle underline.</string>
</hint>
</hints>
</connection>
<connection>
<sender>editorStack</sender>
<signal>currentChanged(int)</signal>
<receiver>comboMode</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>185</x>
<y>169</y>
</hint>
<hint type="destinationlabel">
<x>149</x>
<y>39</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonApply</sender>
<signal>clicked()</signal>

View File

@@ -87,16 +87,16 @@ void ExtendedScintilla::dropEvent(QDropEvent* e)
f.close();
}
void ExtendedScintilla::setupSyntaxHighlightingFormat(const QString& settings_name, int style)
void ExtendedScintilla::setupSyntaxHighlightingFormat(QsciLexer *lexer, const QString& settings_name, int style)
{
lexer()->setColor(QColor(Settings::getValue("syntaxhighlighter", settings_name + "_colour").toString()), style);
lexer->setColor(QColor(Settings::getValue("syntaxhighlighter", settings_name + "_colour").toString()), style);
QFont font(Settings::getValue("editor", "font").toString());
font.setPointSize(Settings::getValue("editor", "fontsize").toInt());
font.setBold(Settings::getValue("syntaxhighlighter", settings_name + "_bold").toBool());
font.setItalic(Settings::getValue("syntaxhighlighter", settings_name + "_italic").toBool());
font.setUnderline(Settings::getValue("syntaxhighlighter", settings_name + "_underline").toBool());
lexer()->setFont(font, style);
lexer->setFont(font, style);
}
void ExtendedScintilla::reloadKeywords()
@@ -107,23 +107,16 @@ void ExtendedScintilla::reloadKeywords()
void ExtendedScintilla::reloadSettings()
{
// Enable auto completion if it hasn't been disabled
if(Settings::getValue("editor", "auto_completion").toBool())
{
setAutoCompletionThreshold(3);
setAutoCompletionCaseSensitivity(false);
setAutoCompletionShowSingle(true);
setAutoCompletionSource(QsciScintilla::AcsAPIs);
} else {
setAutoCompletionThreshold(0);
}
reloadLexerSettings(lexer());
}
void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer)
{
// Set syntax highlighting settings
QFont defaultfont(Settings::getValue("editor", "font").toString());
defaultfont.setStyleHint(QFont::TypeWriter);
defaultfont.setPointSize(Settings::getValue("editor", "fontsize").toInt());
lexer()->setDefaultColor(Qt::black);
lexer()->setFont(defaultfont);
lexer->setDefaultColor(Qt::black);
lexer->setFont(defaultfont);
// Set font
QFont font(Settings::getValue("editor", "font").toString());
@@ -145,7 +138,7 @@ void ExtendedScintilla::reloadSettings()
// Set tab width
setTabWidth(Settings::getValue("editor", "tabsize").toInt());
lexer()->refreshProperties();
lexer->refreshProperties();
// Check if error indicators are enabled and clear them if they just got disabled
showErrorIndicators = Settings::getValue("editor", "error_indicators").toBool();

View File

@@ -32,7 +32,8 @@ public slots:
protected:
void dropEvent(QDropEvent* e);
void setupSyntaxHighlightingFormat(const QString& settings_name, int style);
void setupSyntaxHighlightingFormat(QsciLexer *lexer, const QString& settings_name, int style);
void reloadLexerSettings(QsciLexer *lexer);
int errorIndicatorNumber;
bool showErrorIndicators;

View File

@@ -175,7 +175,7 @@ QVariant Settings::getDefaultValue(const QString& group, const QString& name)
return 10;
if(name == "symbol_limit")
return 5000;
if(name == "compact_indent")
if(name == "indent_compact")
return false;
if(name == "null_text")
return "NULL";

79
src/docktextedit.cpp Normal file
View File

@@ -0,0 +1,79 @@
#include "docktextedit.h"
#include "Settings.h"
QsciLexerJSON* DockTextEdit::jsonLexer = nullptr;
QsciLexerXML* DockTextEdit::xmlLexer = nullptr;
DockTextEdit::DockTextEdit(QWidget* parent) :
ExtendedScintilla(parent)
{
// Create lexer objects if not done yet
if(jsonLexer == nullptr)
jsonLexer = new QsciLexerJSON(this);
if(xmlLexer == nullptr)
xmlLexer = new QsciLexerXML(this);
// Set the JSON lexer as default
setLexer(jsonLexer);
jsonLexer->setFoldCompact(false);
jsonLexer->setHighlightComments(true);
// Do rest of initialisation
reloadSettings();
}
DockTextEdit::~DockTextEdit()
{
}
void DockTextEdit::reloadSettings()
{
// Set the parent settings for both lexers
reloadLexerSettings(jsonLexer);
reloadLexerSettings(xmlLexer);
setupSyntaxHighlightingFormat(jsonLexer, "comment", QsciLexerJSON::CommentLine);
setupSyntaxHighlightingFormat(jsonLexer, "comment", QsciLexerJSON::CommentBlock);
setupSyntaxHighlightingFormat(jsonLexer, "keyword", QsciLexerJSON::Keyword);
setupSyntaxHighlightingFormat(jsonLexer, "keyword", QsciLexerJSON::KeywordLD);
setupSyntaxHighlightingFormat(jsonLexer, "string", QsciLexerJSON::String);
setupSyntaxHighlightingFormat(jsonLexer, "table", QsciLexerJSON::Number);
setupSyntaxHighlightingFormat(jsonLexer, "identifier", QsciLexerJSON::Property);
// The default style for invalid JSON or unclosed strings uses red
// background and white foreground, but the current line has
// precedence, so it is by default white over gray. We change the
// default to something more readable for the current line at
// invalid JSON.
QColor stringColor = QColor(Settings::getValue("syntaxhighlighter", "string_colour").toString());
jsonLexer->setColor(stringColor, QsciLexerJSON::Error);
jsonLexer->setColor(stringColor, QsciLexerJSON::UnclosedString);
QFont errorFont(Settings::getValue("editor", "font").toString());
errorFont.setPointSize(Settings::getValue("editor", "fontsize").toInt());
errorFont.setItalic(true);
jsonLexer->setFont(errorFont, QsciLexerJSON::Error);
jsonLexer->setFont(errorFont, QsciLexerJSON::UnclosedString);
jsonLexer->setPaper(jsonLexer->defaultPaper(QsciLexerJSON::String), QsciLexerJSON::Error);
jsonLexer->setPaper(jsonLexer->defaultPaper(QsciLexerJSON::String), QsciLexerJSON::UnclosedString);
setupSyntaxHighlightingFormat(xmlLexer, "comment", QsciLexerHTML::HTMLComment);
setupSyntaxHighlightingFormat(xmlLexer, "keyword", QsciLexerHTML::Tag);
setupSyntaxHighlightingFormat(xmlLexer, "string", QsciLexerHTML::HTMLDoubleQuotedString);
setupSyntaxHighlightingFormat(xmlLexer, "string", QsciLexerHTML::HTMLSingleQuotedString);
setupSyntaxHighlightingFormat(xmlLexer, "table", QsciLexerHTML::HTMLNumber);
setupSyntaxHighlightingFormat(xmlLexer, "identifier", QsciLexerHTML::Attribute);
}
void DockTextEdit::setLanguage(Language lang)
{
m_language = lang;
switch (lang) {
case JSON:
setLexer(jsonLexer);
break;
case XML:
setLexer(xmlLexer);
break;
}
}

40
src/docktextedit.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef DOCKTEXTEDIT_H
#define DOCKTEXTEDIT_H
#include "ExtendedScintilla.h"
#include <Qsci/qscilexerjson.h>
#include <Qsci/qscilexerxml.h>
/**
* @brief The DockTextEdit class
* This class is based on our Extended QScintilla widget
*/
class DockTextEdit : public ExtendedScintilla
{
Q_OBJECT
public:
explicit DockTextEdit(QWidget *parent = nullptr);
virtual ~DockTextEdit();
// Enumeration of supported languages
enum Language
{
JSON,
XML
};
void setLanguage(Language lang);
Language language() { return m_language; };
public slots:
void reloadSettings();
protected:
static QsciLexerJSON* jsonLexer;
static QsciLexerXML* xmlLexer;
private:
Language m_language;
};
#endif

View File

@@ -1,54 +0,0 @@
#include "jsontextedit.h"
#include "Settings.h"
QsciLexerJSON* JsonTextEdit::jsonLexer = nullptr;
JsonTextEdit::JsonTextEdit(QWidget* parent) :
ExtendedScintilla(parent)
{
// Create lexer object if not done yet
if(jsonLexer == nullptr)
jsonLexer = new QsciLexerJSON(this);
// Set the JSON lexer
setLexer(jsonLexer);
jsonLexer->setFoldCompact(false);
// Do rest of initialisation
reloadSettings();
}
JsonTextEdit::~JsonTextEdit()
{
}
void JsonTextEdit::reloadSettings()
{
ExtendedScintilla::reloadSettings();
setupSyntaxHighlightingFormat("comment", QsciLexerJSON::CommentLine);
setupSyntaxHighlightingFormat("comment", QsciLexerJSON::CommentBlock);
setupSyntaxHighlightingFormat("keyword", QsciLexerJSON::Keyword);
setupSyntaxHighlightingFormat("keyword", QsciLexerJSON::KeywordLD);
setupSyntaxHighlightingFormat("string", QsciLexerJSON::String);
setupSyntaxHighlightingFormat("table", QsciLexerJSON::Number);
setupSyntaxHighlightingFormat("identifier", QsciLexerJSON::Property);
jsonLexer->setHighlightComments(true);
// The default style for invalid JSON or unclosed strings uses red
// background and white foreground, but the current line has
// precedence, so it is by default white over gray. We change the
// default to something more readable for the current line at
// invalid JSON.
QColor stringColor = QColor(Settings::getValue("syntaxhighlighter", "string_colour").toString());
jsonLexer->setColor(stringColor, QsciLexerJSON::Error);
jsonLexer->setColor(stringColor, QsciLexerJSON::UnclosedString);
QFont errorFont(Settings::getValue("editor", "font").toString());
errorFont.setPointSize(Settings::getValue("editor", "fontsize").toInt());
errorFont.setItalic(true);
jsonLexer->setFont(errorFont, QsciLexerJSON::Error);
jsonLexer->setFont(errorFont, QsciLexerJSON::UnclosedString);
jsonLexer->setPaper(jsonLexer->defaultPaper(QsciLexerJSON::String), QsciLexerJSON::Error);
jsonLexer->setPaper(jsonLexer->defaultPaper(QsciLexerJSON::String), QsciLexerJSON::UnclosedString);
}

View File

@@ -1,25 +0,0 @@
#ifndef JSONTEXTEDIT_H
#define JSONTEXTEDIT_H
#include "ExtendedScintilla.h"
#include <Qsci/qscilexerjson.h>
/**
* @brief The JsonTextEdit class
* This class is based on our Extended QScintilla widget
*/
class JsonTextEdit : public ExtendedScintilla
{
Q_OBJECT
public:
explicit JsonTextEdit(QWidget *parent = nullptr);
virtual ~JsonTextEdit();
static QsciLexerJSON* jsonLexer;
public slots:
void reloadSettings();
};
#endif

View File

@@ -30,16 +30,27 @@ SqlTextEdit::~SqlTextEdit()
void SqlTextEdit::reloadSettings()
{
// Enable auto completion if it hasn't been disabled
if(Settings::getValue("editor", "auto_completion").toBool())
{
setAutoCompletionThreshold(3);
setAutoCompletionCaseSensitivity(true);
setAutoCompletionShowSingle(true);
setAutoCompletionSource(QsciScintilla::AcsAPIs);
} else {
setAutoCompletionThreshold(0);
}
ExtendedScintilla::reloadSettings();
setupSyntaxHighlightingFormat("comment", QsciLexerSQL::Comment);
setupSyntaxHighlightingFormat("comment", QsciLexerSQL::CommentLine);
setupSyntaxHighlightingFormat("comment", QsciLexerSQL::CommentDoc);
setupSyntaxHighlightingFormat("keyword", QsciLexerSQL::Keyword);
setupSyntaxHighlightingFormat("table", QsciLexerSQL::KeywordSet6);
setupSyntaxHighlightingFormat("function", QsciLexerSQL::KeywordSet7);
setupSyntaxHighlightingFormat("string", QsciLexerSQL::DoubleQuotedString);
setupSyntaxHighlightingFormat("string", QsciLexerSQL::SingleQuotedString);
setupSyntaxHighlightingFormat("identifier", QsciLexerSQL::Identifier);
setupSyntaxHighlightingFormat("identifier", QsciLexerSQL::QuotedIdentifier);
setupSyntaxHighlightingFormat(sqlLexer, "comment", QsciLexerSQL::Comment);
setupSyntaxHighlightingFormat(sqlLexer, "comment", QsciLexerSQL::CommentLine);
setupSyntaxHighlightingFormat(sqlLexer, "comment", QsciLexerSQL::CommentDoc);
setupSyntaxHighlightingFormat(sqlLexer, "keyword", QsciLexerSQL::Keyword);
setupSyntaxHighlightingFormat(sqlLexer, "table", QsciLexerSQL::KeywordSet6);
setupSyntaxHighlightingFormat(sqlLexer, "function", QsciLexerSQL::KeywordSet7);
setupSyntaxHighlightingFormat(sqlLexer, "string", QsciLexerSQL::DoubleQuotedString);
setupSyntaxHighlightingFormat(sqlLexer, "string", QsciLexerSQL::SingleQuotedString);
setupSyntaxHighlightingFormat(sqlLexer, "identifier", QsciLexerSQL::Identifier);
setupSyntaxHighlightingFormat(sqlLexer, "identifier", QsciLexerSQL::QuotedIdentifier);
}

View File

@@ -1,6 +1,6 @@
TEMPLATE = app
QT += core gui network widgets printsupport concurrent
QT += core gui network widgets printsupport concurrent xml
macx: QT += opengl
TARGET = sqlitebrowser
@@ -59,7 +59,7 @@ HEADERS += \
RemoteDock.h \
RemoteModel.h \
RemotePushDialog.h \
jsontextedit.h \
docktextedit.h \
FindReplaceDialog.h \
ExtendedScintilla.h \
FileExtensionManager.h \
@@ -100,7 +100,7 @@ SOURCES += \
RemoteDock.cpp \
RemoteModel.cpp \
RemotePushDialog.cpp \
jsontextedit.cpp \
docktextedit.cpp \
FindReplaceDialog.cpp \
ExtendedScintilla.cpp \
FileExtensionManager.cpp \