QCodeEdit  2.2
qlanguagedefinition.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
4 **
5 ** This file is part of the Edyuk project <http://edyuk.org>
6 **
7 ** This file may be used under the terms of the GNU General Public License
8 ** version 3 as published by the Free Software Foundation and appearing in the
9 ** file GPL.txt included in the packaging of this file.
10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 **
14 ****************************************************************************/
15 
16 #ifndef _QLANGUAGE_DEFINITION_H_
17 #define _QLANGUAGE_DEFINITION_H_
18 
19 #include "qce-config.h"
20 
28 #include "qformat.h"
29 
30 #include <QStringList>
31 
32 class QKeyEvent;
33 class QDocument;
34 class QDocumentCursor;
35 
36 #define QCE_FOLD_FLAGS(flags, open, close) ((flags) | (open & QLanguageDefinition::OpenMask) | ((close << 12) & QLanguageDefinition::CloseMask))
37 #define QCE_FOLD_OPEN_COUNT(flags) ((flags) & QLanguageDefinition::OpenMask)
38 #define QCE_FOLD_CLOSE_COUNT(flags) (((flags) & QLanguageDefinition::CloseMask) >> 12)
39 
41 {
42  public:
45  {
46  None = 0x00000000,
47  Collapsible = 0x10000000,
48  Collapsed = 0x20000000,
49  Closure = 0x40000000,
50 
51  CloseMask = 0x00fff000,
52  OpenMask = 0x00000fff
53  };
54 
55  Q_DECLARE_FLAGS(CollapseState, CollapseFlag);
56 
58  virtual ~QLanguageDefinition();
59 
60  virtual QString language() const = 0;
61  virtual QStringList extensions() const = 0;
62 
63  virtual int tokenize(QDocument *d, int line, int count);
64 
65  virtual QString singleLineComment() const;
66 
67  virtual QString defaultLineMark() const;
68 
69  virtual void match(QDocumentCursor& c);
70  virtual void clearMatches(QDocument *d);
71 
72  virtual QString indent(const QDocumentCursor& c);
73  virtual bool unindent (const QDocumentCursor& c, const QString& ktxt);
74 
75  virtual void expand(QDocument *d, int line);
76  virtual void collapse(QDocument *d, int line);
77  virtual int blockFlags(QDocument *d, int line, int depth = 0) const;
78 };
79 
80 #endif // _QLANGUAGE_DEFINITION_H_