blob: ce81aedc70bf2222861b55c585eff9a4597815c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/***************************************************************************
bashhighlighter.cpp - description
-------------------
begin : dom mar 16 2003
copyright : (C) 2003 by Emiliano Gulmini
email : emi_barbarossa@yahoo.it
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qmyhighlighter.h"
#include <tqregexp.h>
TQMyHighlighter::TQMyHighlighter(TQTextEdit* TQtxt):TQSyntaxHighlighter(TQtxt){
}
/*****************************************************************************/
TQMyHighlighter::~TQMyHighlighter(){
}
/*****************************************************************************/
int TQMyHighlighter::highlightParagraph( const TQString & text, int /*endStateOfLastPara*/ )
{
//TQRegExp pattern("\\s*\\{([\\w\\s\\d:;-\"]*)\\}\\s*");
TQRegExp pattern("([#:\\.\\w]*)\\s*\\{");
int pos=pattern.search(text,0);
int l=int(pattern.cap(1).length());
setFormat(pos,l,TQColor("red"));
if( pos== -1)
pos = 0;
const int npos = pos+l;
pattern.setPattern("\\s*([\\s\\w\\d-]*)\\s*:");
pos=npos;
while ( pos >= 0 ) {
pos = pattern.search( text, pos );
if ( pos > -1 ) {
l = pattern.matchedLength();
setFormat(pos,l,TQColor("mediumvioletred"));
pos += pattern.matchedLength();
}
}
pattern.setPattern(":\\s*([\\.\\#\\w\\s\\d-\\(\\)\",%/]*)\\s*;");
pattern.setPattern(":\\s*([\\W\\w]*)\\s*;");
pos=npos;
while ( pos >= 0 ) {
pos = pattern.search( text, pos );
if ( pos > -1 ) {
l = pattern.cap(1).length();
setFormat(pos + 2 ,l,TQColor("steelblue"));
pos += pattern.matchedLength();
}
}
return 0;
}
|