QCodeEdit 2.2
|
00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr> 00004 ** 00005 ** This file is part of the Edyuk project <http://edyuk.org> 00006 ** 00007 ** This file may be used under the terms of the GNU General Public License 00008 ** version 3 as published by the Free Software Foundation and appearing in the 00009 ** file GPL.txt included in the packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ****************************************************************************/ 00015 00016 #ifndef _QLANGUAGE_DEFINITION_H_ 00017 #define _QLANGUAGE_DEFINITION_H_ 00018 00019 #include "qce-config.h" 00020 00028 #include "qformat.h" 00029 00030 #include <QStringList> 00031 00032 class QKeyEvent; 00033 class QDocument; 00034 class QDocumentCursor; 00035 00036 #define QCE_FOLD_FLAGS(flags, open, close) ((flags) | (open & QLanguageDefinition::OpenMask) | ((close << 12) & QLanguageDefinition::CloseMask)) 00037 #define QCE_FOLD_OPEN_COUNT(flags) ((flags) & QLanguageDefinition::OpenMask) 00038 #define QCE_FOLD_CLOSE_COUNT(flags) (((flags) & QLanguageDefinition::CloseMask) >> 12) 00039 00040 class QCE_EXPORT QLanguageDefinition 00041 { 00042 public: 00044 enum CollapseFlag 00045 { 00046 None = 0x00000000, 00047 Collapsible = 0x10000000, 00048 Collapsed = 0x20000000, 00049 Closure = 0x40000000, 00050 00051 CloseMask = 0x00fff000, 00052 OpenMask = 0x00000fff 00053 }; 00054 00055 Q_DECLARE_FLAGS(CollapseState, CollapseFlag); 00056 00057 QLanguageDefinition(); 00058 virtual ~QLanguageDefinition(); 00059 00060 virtual QString language() const = 0; 00061 virtual QStringList extensions() const = 0; 00062 00063 virtual int tokenize(QDocument *d, int line, int count); 00064 00065 virtual QString singleLineComment() const; 00066 00067 virtual QString defaultLineMark() const; 00068 00069 virtual void match(QDocumentCursor& c); 00070 virtual void clearMatches(QDocument *d); 00071 00072 virtual QString indent(const QDocumentCursor& c); 00073 virtual bool unindent (const QDocumentCursor& c, const QString& ktxt); 00074 00075 virtual void expand(QDocument *d, int line); 00076 virtual void collapse(QDocument *d, int line); 00077 virtual int blockFlags(QDocument *d, int line, int depth = 0) const; 00078 }; 00079 00080 #endif // _QLANGUAGE_DEFINITION_H_