You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdewebdev/quanta/components/csseditor/qmyhighlighter.cpp

66 lines
2.4 KiB

/***************************************************************************
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;
}