~ubuntu-branches/ubuntu/wily/tora/wily-proposed

« back to all changes in this revision

Viewing changes to src/qscintilla2/Qt4/qscilexerxml.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2009-11-19 15:18:19 UTC
  • mfrom: (1.2.9 upstream) (3.3.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091119151819-me89ezmxzkvl0lws
Tags: 2.1.1-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This module implements the QsciLexerXML class.
 
2
//
 
3
// Copyright (c) 2008 Riverbank Computing Limited <info@riverbankcomputing.com>
 
4
// 
 
5
// This file is part of QScintilla.
 
6
// 
 
7
// This file may be used under the terms of the GNU General Public
 
8
// License versions 2.0 or 3.0 as published by the Free Software
 
9
// Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
 
10
// included in the packaging of this file.  Alternatively you may (at
 
11
// your option) use any later version of the GNU General Public
 
12
// License if such license has been publicly approved by Riverbank
 
13
// Computing Limited (or its successors, if any) and the KDE Free Qt
 
14
// Foundation. In addition, as a special exception, Riverbank gives you
 
15
// certain additional rights. These rights are described in the Riverbank
 
16
// GPL Exception version 1.1, which can be found in the file
 
17
// GPL_EXCEPTION.txt in this package.
 
18
// 
 
19
// Please review the following information to ensure GNU General
 
20
// Public Licensing requirements will be met:
 
21
// http://trolltech.com/products/qt/licenses/licensing/opensource/. If
 
22
// you are unsure which license is appropriate for your use, please
 
23
// review the following information:
 
24
// http://trolltech.com/products/qt/licenses/licensing/licensingoverview
 
25
// or contact the sales department at sales@riverbankcomputing.com.
 
26
// 
 
27
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
 
28
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
 
29
// A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly
 
30
// granted herein.
 
31
// 
 
32
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
33
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
34
 
 
35
 
 
36
#include "Qsci/qscilexerxml.h"
 
37
 
 
38
#include <qcolor.h>
 
39
#include <qfont.h>
 
40
 
 
41
 
 
42
// The ctor.
 
43
QsciLexerXML::QsciLexerXML(QObject *parent)
 
44
    : QsciLexerHTML(parent)
 
45
{
 
46
}
 
47
 
 
48
 
 
49
// The dtor.
 
50
QsciLexerXML::~QsciLexerXML()
 
51
{
 
52
}
 
53
 
 
54
 
 
55
// Returns the language name.
 
56
const char *QsciLexerXML::language() const
 
57
{
 
58
    return "XML";
 
59
}
 
60
 
 
61
 
 
62
// Returns the lexer name.
 
63
const char *QsciLexerXML::lexer() const
 
64
{
 
65
    return "xml";
 
66
}
 
67
 
 
68
 
 
69
// Returns the foreground colour of the text for a style.
 
70
QColor QsciLexerXML::defaultColor(int style) const
 
71
{
 
72
    switch (style)
 
73
    {
 
74
    case Default:
 
75
        return QColor(0x00,0x00,0x00);
 
76
 
 
77
    case Tag:
 
78
    case UnknownTag:
 
79
    case XMLTagEnd:
 
80
    case SGMLDefault:
 
81
    case SGMLCommand:
 
82
        return QColor(0x00,0x00,0x80);
 
83
 
 
84
    case Attribute:
 
85
    case UnknownAttribute:
 
86
        return QColor(0x00,0x80,0x80);
 
87
 
 
88
    case HTMLNumber:
 
89
        return QColor(0x00,0x7f,0x7f);
 
90
 
 
91
    case HTMLDoubleQuotedString:
 
92
    case HTMLSingleQuotedString:
 
93
        return QColor(0x7f,0x00,0x7f);
 
94
 
 
95
    case OtherInTag:
 
96
    case Entity:
 
97
    case XMLStart:
 
98
    case XMLEnd:
 
99
        return QColor(0x80,0x00,0x80);
 
100
 
 
101
    case HTMLComment:
 
102
    case SGMLComment:
 
103
        return QColor(0x80,0x80,0x00);
 
104
 
 
105
    case CDATA:
 
106
    case PHPStart:
 
107
    case SGMLDoubleQuotedString:
 
108
    case SGMLError:
 
109
        return QColor(0x80,0x00,0x00);
 
110
 
 
111
    case HTMLValue:
 
112
        return QColor(0x60,0x80,0x60);
 
113
 
 
114
    case SGMLParameter:
 
115
        return QColor(0x00,0x66,0x00);
 
116
 
 
117
    case SGMLSingleQuotedString:
 
118
        return QColor(0x99,0x33,0x00);
 
119
 
 
120
    case SGMLSpecial:
 
121
        return QColor(0x33,0x66,0xff);
 
122
 
 
123
    case SGMLEntity:
 
124
        return QColor(0x33,0x33,0x33);
 
125
 
 
126
    case SGMLBlockDefault:
 
127
        return QColor(0x00,0x00,0x66);
 
128
    }
 
129
 
 
130
    return QsciLexerHTML::defaultColor(style);
 
131
}
 
132
 
 
133
 
 
134
// Returns the end-of-line fill for a style.
 
135
bool QsciLexerXML::defaultEolFill(int style) const
 
136
{
 
137
    if (style == CDATA)
 
138
        return true;
 
139
 
 
140
    return QsciLexerHTML::defaultEolFill(style);
 
141
}
 
142
 
 
143
 
 
144
// Returns the font of the text for a style.
 
145
QFont QsciLexerXML::defaultFont(int style) const
 
146
{
 
147
    QFont f;
 
148
 
 
149
    switch (style)
 
150
    {
 
151
    case Default:
 
152
    case Entity:
 
153
    case CDATA:
 
154
#if defined(Q_OS_WIN)
 
155
        f = QFont("Times New Roman",11);
 
156
#else
 
157
        f = QFont("Bitstream Charter",10);
 
158
#endif
 
159
        break;
 
160
 
 
161
    case XMLStart:
 
162
    case XMLEnd:
 
163
    case SGMLCommand:
 
164
        f = QsciLexer::defaultFont(style);
 
165
        f.setBold(true);
 
166
        break;
 
167
 
 
168
    default:
 
169
        f = QsciLexerHTML::defaultFont(style);
 
170
    }
 
171
 
 
172
    return f;
 
173
}
 
174
 
 
175
 
 
176
// Returns the set of keywords.
 
177
const char *QsciLexerXML::keywords(int set) const
 
178
{
 
179
    if (set == 6)
 
180
        return QsciLexerHTML::keywords(set);
 
181
 
 
182
    return 0;
 
183
}
 
184
 
 
185
 
 
186
// Returns the background colour of the text for a style.
 
187
QColor QsciLexerXML::defaultPaper(int style) const
 
188
{
 
189
    switch (style)
 
190
    {
 
191
    case CDATA:
 
192
        return QColor(0xff,0xf0,0xf0);
 
193
 
 
194
    case SGMLDefault:
 
195
    case SGMLCommand:
 
196
    case SGMLParameter:
 
197
    case SGMLDoubleQuotedString:
 
198
    case SGMLSingleQuotedString:
 
199
    case SGMLSpecial:
 
200
    case SGMLEntity:
 
201
    case SGMLComment:
 
202
        return QColor(0xef,0xef,0xff);
 
203
 
 
204
    case SGMLError:
 
205
        return QColor(0xff,0x66,0x66);
 
206
 
 
207
    case SGMLBlockDefault:
 
208
        return QColor(0xcc,0xcc,0xe0);
 
209
    }
 
210
 
 
211
    return QsciLexerHTML::defaultPaper(style);
 
212
}