[DEV] update new regexp system (not work correctly and only for C++)
This commit is contained in:
parent
b9a1c026fa
commit
86d54590c0
@ -1,14 +1,27 @@
|
||||
[Desktop Entry]
|
||||
Version=0.3.0
|
||||
Name=Edn : Editeur de N'ours
|
||||
Exec=edn
|
||||
Icon=Edn
|
||||
Exec=edn %U
|
||||
Icon=/usr/share/edn/icon.png
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Development;Utility;TextEditor;
|
||||
Categories=Development;
|
||||
GenericName=Text editor
|
||||
GenericName[en]=Text editor
|
||||
GenericName[nl]=Tekst verwerker
|
||||
GenericName[fr]=éditeur de text
|
||||
GenericName[fr]=Éditeur de text
|
||||
Comment=Code editor for c, c++, php, bash, xml ...
|
||||
Comment[fr]=éditeur de text pour les language c, c++, php, bash, xml ...
|
||||
OnlyShowIn=GNOME;Unity;
|
||||
MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;
|
||||
StartupNotify=true
|
||||
Actions=New;
|
||||
|
||||
[Desktop Action New]
|
||||
Name=Open a New Window
|
||||
Name[fr]=Ouvrir une nouvelle fenêtre
|
||||
Name[nl]=Nieuw venster openen
|
||||
Name[en]=Open a New Window
|
||||
Exec=edn
|
||||
|
||||
#desktop-file-validate edn.desktop
|
||||
#sudo cp xxx /usr/share/applications/
|
@ -9,130 +9,106 @@
|
||||
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
|
||||
<rule name="my comment multiline doxygen">
|
||||
<color>commentDoxygen</color>
|
||||
<start>/\*\*</start>
|
||||
<end>\*/</end>
|
||||
<rule name="macro">
|
||||
<color>macro</color>
|
||||
<start>\@[A-Z_]{4,500}\@</start>
|
||||
</rule>
|
||||
<rule name="keyword">
|
||||
<color>keyword</color>
|
||||
<start>@\w*[ \t]*(\[(in|out| |,)*\])?[ \t]*([a-zA-Z0-9\-_]*)</start>
|
||||
<underColor idPThese="1"></underColor><!-- (\[(in|out| |,)*\]) -->
|
||||
<underColor idPThese="3"></underColor><!-- (([a-zA-Z0-9\-_])*) -->
|
||||
</rule>
|
||||
<regex>/\*\*.*\*/</regex>
|
||||
</rule>
|
||||
<rule name="code Review">
|
||||
<color>SYNTAX_ERROR</color>
|
||||
<start>/\*[ \t]*TODO :</start>
|
||||
<end>\*/</end>
|
||||
<regex>/\*[ \t]*TODO :.*\*/</regex>
|
||||
</rule>
|
||||
<rule name="my comment multiline">
|
||||
<color>comment</color>
|
||||
<start>/\*</start>
|
||||
<end>\*/</end>
|
||||
<regex>/\*.*\*/</regex>
|
||||
</rule>
|
||||
<rule name="my if 0">
|
||||
<color>preprocesseur</color>
|
||||
<start>#[ \t]*if 0</start>
|
||||
<end>#endif|#else</end>
|
||||
<EscapeChar>\</EscapeChar>
|
||||
<regex>#[ \t]*if 0.*#(endif|else)</regex>
|
||||
</rule>
|
||||
<rule name="my preprocesseur">
|
||||
<color>preprocesseur</color>
|
||||
<start>#</start>
|
||||
<end>\n</end>
|
||||
<EscapeChar>\</EscapeChar>
|
||||
<regex>#(\\|\\n|.)*$</regex>
|
||||
</rule>
|
||||
<rule name="my comment doxygen">
|
||||
<color>commentDoxygen</color>
|
||||
<start>//!</start>
|
||||
<end>\n</end>
|
||||
<regex>//!.*$</regex>
|
||||
</rule>
|
||||
<rule name="my todo comment">
|
||||
<color>SYNTAX_ERROR</color>
|
||||
<start>//[ \t]*TODO[ \t]*:</start>
|
||||
<end>\n</end>
|
||||
<EscapeChar>\</EscapeChar>
|
||||
<regex>//[ \t]*TODO[ \t]*:.*$</regex>
|
||||
</rule>
|
||||
<rule name="my comment">
|
||||
<color>comment</color>
|
||||
<start>//</start>
|
||||
<end>\n</end>
|
||||
<EscapeChar>\</EscapeChar>
|
||||
<regex>//(\\|\\n|.)*$</regex>
|
||||
</rule>
|
||||
<rule name="doubleQuteText">
|
||||
<color>doubleQuoteText</color>
|
||||
<start>"</start>
|
||||
<end>"</end>
|
||||
<EscapeChar>\</EscapeChar>
|
||||
<regex>"(\\|"|.)*"</regex>
|
||||
</rule>
|
||||
<rule name="simpleQuteText">
|
||||
<color>doubleQuoteText</color>
|
||||
<start>'</start>
|
||||
<end>'</end>
|
||||
<!--<EscapeChar>\</EscapeChar>-->
|
||||
<regex>'(\\|'|.)*'</regex>
|
||||
</rule>
|
||||
</pass1>
|
||||
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
|
||||
<!--
|
||||
<rule name="my keyword">
|
||||
<color>keyword</color>
|
||||
<start>\@return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof\@</start>
|
||||
<regex>\@return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof\@</regex>
|
||||
</rule>
|
||||
<rule name="my function keyword">
|
||||
<color>systemFunction</color>
|
||||
<start>\@new|delete|try|catch|memset|fopen|fread|fwrite|fgets|fclose|printf|(f|s|diag_)printf|calloc|malloc|realloc|(cyg|sup)_([a-z]|[A-Z]|[0-9]|_)+\@</start>
|
||||
<regex>\@new|delete|try|catch|memset|fopen|fread|fwrite|fgets|fclose|printf|(f|s|diag_)printf|calloc|malloc|realloc|(cyg|sup)_([a-z]|[A-Z]|[0-9]|_)+\@</regex>
|
||||
</rule>
|
||||
<rule name="my type">
|
||||
<color>type</color>
|
||||
<start>\@bool|BOOL|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128)\@</start>
|
||||
<regex>\@bool|BOOL|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128)\@</regex>
|
||||
</rule>
|
||||
<rule name="std type">
|
||||
<color>type</color>
|
||||
<start>\@std::(vector|(u16|u32|w)?string|codecvt_utf(16|8_utf16|8)+|complex|iterator(_traits)?|tuple(_element|_size)?|pair)\@</start>
|
||||
<regex>\@std::(vector|(u16|u32|w)?string|codecvt_utf(16|8_utf16|8)+|complex|iterator(_traits)?|tuple(_element|_size)?|pair)\@</regex>
|
||||
</rule>
|
||||
<rule name="my storage keyword">
|
||||
<color>storageKeyword</color>
|
||||
<start>\@inline|const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum\@</start>
|
||||
<regex>\@inline|const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum\@</regex>
|
||||
</rule>
|
||||
<rule name="my common Define">
|
||||
<color>commonDefine</color>
|
||||
<start>\@NULL|MAX|MIN|__LINE__|__DATA__|__FILE__|__func__|__TIME__|__STDC__\@</start>
|
||||
<regex>\@NULL|MAX|MIN|__LINE__|__DATA__|__FILE__|__func__|__TIME__|__STDC__\@</regex>
|
||||
</rule>
|
||||
<rule name="numeric constant">
|
||||
<color>number</color>
|
||||
<start>\@((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?\@</start>
|
||||
<regex>\@((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?\@</regex>
|
||||
</rule>
|
||||
<rule name="my boolean">
|
||||
<color>boolean</color>
|
||||
<start>\@true|TRUE|false|FALSE\@</start>
|
||||
<regex>\@true|TRUE|false|FALSE\@</regex>
|
||||
</rule>
|
||||
<rule name="BIG LETTER">
|
||||
<color>macro</color>
|
||||
<start>\@[A-Z_][A-Z_0-9]{3,500}\@</start>
|
||||
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
|
||||
</rule>
|
||||
<rule name="CPP member">
|
||||
<color>memberClass</color>
|
||||
<start>\@m_[A-Za-z_0-9]*\@</start>
|
||||
<regex>\@m_[A-Za-z_0-9]*\@</regex>
|
||||
</rule>
|
||||
<rule name="function input">
|
||||
<color>inputFunction</color>
|
||||
<start>\@_[A-Za-z_0-9]*\@</start>
|
||||
<regex>\@_[A-Za-z_0-9]*\@</regex>
|
||||
</rule>
|
||||
<rule name="Function name">
|
||||
<color>functionName</color>
|
||||
<start>\@(\w|_)+[ \t]*\(</start>
|
||||
<regex>\@(\w|_)+[ \t]*\(</regex>
|
||||
</rule>
|
||||
<rule name="condition">
|
||||
<color>boolean</color>
|
||||
<start>==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}|</start>
|
||||
<regex>==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}|</regex>
|
||||
</rule>
|
||||
<!-- With all elementes :
|
||||
-->
|
||||
<!-- With all elementes :
|
||||
<rule name="BIG LETTER">
|
||||
<color>macro</color>
|
||||
<start>([A-Z]|_){4,500}</start>
|
||||
<elemSubColor id="1">doxElem</elemSubColor>
|
||||
<regex>([A-Z]|_){4,500}</regex>
|
||||
<elemSubColor id="1">doxElem</elemSubColor>
|
||||
</rule>
|
||||
-->
|
||||
-->
|
||||
</pass2>
|
||||
</EdnLang>
|
||||
|
@ -762,10 +762,8 @@ void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64
|
||||
}
|
||||
for (auto it(m_HLDataPass1.begin()+elemStart); it != m_HLDataPass1.end(); ++it) {
|
||||
//APPL_DEBUG("move element=" << i);
|
||||
it->beginStart += _nbAdded - _nbDeleted;
|
||||
it->beginStop += _nbAdded - _nbDeleted;
|
||||
it->endStart += _nbAdded - _nbDeleted;
|
||||
it->endStop += _nbAdded - _nbDeleted;
|
||||
it->start += _nbAdded - _nbDeleted;
|
||||
it->stop += _nbAdded - _nbDeleted;
|
||||
}
|
||||
//Regenerate Element inside range
|
||||
if ( startId == -1
|
||||
@ -774,13 +772,13 @@ void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64
|
||||
generateHighLightAt(0, m_data.size());
|
||||
} else if(-1 == startId) {
|
||||
//APPL_DEBUG("******* Regenerate START");
|
||||
generateHighLightAt(0, m_HLDataPass1[0].beginStart, 0);
|
||||
generateHighLightAt(0, m_HLDataPass1[0].start, 0);
|
||||
} else if(-1 == stopId) {
|
||||
//APPL_DEBUG("******* Regenerate STOP");
|
||||
generateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].endStop, m_data.size(), m_HLDataPass1.size());
|
||||
generateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].stop, m_data.size(), m_HLDataPass1.size());
|
||||
} else {
|
||||
//APPL_DEBUG("******* Regenerate RANGE");
|
||||
generateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1);
|
||||
generateHighLightAt(m_HLDataPass1[startId].stop, m_HLDataPass1[startId+1].start, startId+1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -829,7 +827,7 @@ void appl::Buffer::findMainHighLightPosition(int64_t _startPos,
|
||||
S=-1 *************** E
|
||||
*/
|
||||
for (size_t iii = 0; iii < m_HLDataPass1.size(); ++iii) {
|
||||
if (m_HLDataPass1[iii].endStop > _startPos) {
|
||||
if (m_HLDataPass1[iii].stop > _startPos) {
|
||||
break;
|
||||
}
|
||||
_startId = iii;
|
||||
@ -850,7 +848,7 @@ void appl::Buffer::findMainHighLightPosition(int64_t _startPos,
|
||||
elemStart = _startId+1;
|
||||
}
|
||||
for (size_t iii = elemStart; iii < m_HLDataPass1.size(); ++iii) {
|
||||
if (m_HLDataPass1[iii].beginStart > _endPos) {
|
||||
if (m_HLDataPass1[iii].start > _endPos) {
|
||||
_stopId = iii;
|
||||
break;
|
||||
}
|
||||
@ -875,11 +873,11 @@ appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(int64_t _pos, int64
|
||||
int32_t start = std::max((int64_t)0, _starPos-1);
|
||||
for (size_t iii = start; iii < m_HLDataPass1.size(); ++iii) {
|
||||
_starPos = iii;
|
||||
if ( m_HLDataPass1[iii].beginStart <= _pos
|
||||
&& m_HLDataPass1[iii].endStop > _pos) {
|
||||
if ( m_HLDataPass1[iii].start <= _pos
|
||||
&& m_HLDataPass1[iii].stop > _pos) {
|
||||
return &m_HLDataPass1[iii];
|
||||
}
|
||||
if(m_HLDataPass1[iii].beginStart > _pos) {
|
||||
if(m_HLDataPass1[iii].start > _pos) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -913,21 +911,21 @@ void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, const ap
|
||||
for (kkk = std::max(startId, (int64_t)0); kkk < endSearch; ++kkk) {
|
||||
// empty section :
|
||||
if (kkk == 0) {
|
||||
if (HLStartPos < m_HLDataPass1[kkk].beginStart) {
|
||||
if (HLStartPos < m_HLDataPass1[kkk].start) {
|
||||
APPL_VERBOSE(" == > (empty section 1 ) kkk=" << kkk <<
|
||||
" start=" << HLStartPos <<
|
||||
" stop=" << m_HLDataPass1[kkk].beginStart );
|
||||
" stop=" << m_HLDataPass1[kkk].start );
|
||||
m_highlight->parse2(HLStartPos,
|
||||
m_HLDataPass1[kkk].beginStart,
|
||||
m_HLDataPass1[kkk].start,
|
||||
_MData.HLData,
|
||||
m_data);
|
||||
} // else : nothing to do ...
|
||||
} else {
|
||||
APPL_VERBOSE(" == > (empty section 2 ) kkk=" << kkk <<
|
||||
" start=" << m_HLDataPass1[kkk-1].endStop <<
|
||||
" stop=" << m_HLDataPass1[kkk].beginStart );
|
||||
m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
|
||||
m_HLDataPass1[kkk].beginStart,
|
||||
" start=" << m_HLDataPass1[kkk-1].stop <<
|
||||
" stop=" << m_HLDataPass1[kkk].start );
|
||||
m_highlight->parse2(m_HLDataPass1[kkk-1].stop,
|
||||
m_HLDataPass1[kkk].start,
|
||||
_MData.HLData,
|
||||
m_data);
|
||||
}
|
||||
@ -939,9 +937,9 @@ void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, const ap
|
||||
//if( k < (int32_t)m_HLDataPass1.size()) {
|
||||
if (m_HLDataPass1.size() != 0) {
|
||||
APPL_VERBOSE(" == > (empty section 3 ) kkk=" << kkk <<
|
||||
" start=" << m_HLDataPass1[kkk-1].endStop <<
|
||||
" start=" << m_HLDataPass1[kkk-1].stop <<
|
||||
" stop=" << HLStop );
|
||||
m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
|
||||
m_highlight->parse2(m_HLDataPass1[kkk-1].stop,
|
||||
HLStop,
|
||||
_MData.HLData,
|
||||
m_data);
|
||||
@ -965,12 +963,12 @@ appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(appl::DisplayHLData
|
||||
int64_t start = std::max((int64_t)0, _MData.posHLPass2-1);
|
||||
for (int64_t iii=start; iii<(int32_t)_MData.HLData.size(); iii++) {
|
||||
_MData.posHLPass2 = iii;
|
||||
if( _MData.HLData[iii].beginStart <= _pos
|
||||
&& _MData.HLData[iii].endStop > _pos)
|
||||
if( _MData.HLData[iii].start <= _pos
|
||||
&& _MData.HLData[iii].stop > _pos)
|
||||
{
|
||||
return &_MData.HLData[iii];
|
||||
}
|
||||
if(_MData.HLData[iii].beginStart > _pos) {
|
||||
if(_MData.HLData[iii].start > _pos) {
|
||||
return getElementColorAtPosition(_pos, _MData.posHLPass1);
|
||||
}
|
||||
}
|
||||
|
@ -181,18 +181,18 @@ void appl::Highlight::parse(int64_t _start,
|
||||
// Stop the search to the end (to get the end of the pattern)
|
||||
ret = m_listHighlightPass1[jjj]->find(elementStart, _buffer.size(), resultat, _buffer);
|
||||
if (HLP_FIND_ERROR != ret) {
|
||||
HL_DEBUG("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
|
||||
HL_DEBUG("Find Pattern in the Buffer : (" << resultat.start << "," << resultat.stop << ")" );
|
||||
// remove element in the current List where the current Element have a end inside the next...
|
||||
int64_t kkk=_addingPos;
|
||||
while(kkk < (int64_t)_metaData.size() ) {
|
||||
if (_metaData[kkk].beginStart <= resultat.endStop) {
|
||||
if (_metaData[kkk].start <= resultat.stop) {
|
||||
// remove element
|
||||
HL_DEBUG("Erase element=" << kkk);
|
||||
_metaData.erase(_metaData.begin()+kkk, _metaData.begin()+kkk+1);
|
||||
// Increase the end of search
|
||||
if (kkk < (int64_t)_metaData.size()) {
|
||||
// just befor the end of the next element
|
||||
elementStop = _metaData[kkk].beginStart-1;
|
||||
elementStop = _metaData[kkk].start-1;
|
||||
} else {
|
||||
// end of the buffer
|
||||
elementStop = _buffer.size();
|
||||
@ -204,9 +204,9 @@ void appl::Highlight::parse(int64_t _start,
|
||||
}
|
||||
// add curent element in the list ...
|
||||
_metaData.insert(_metaData.begin()+_addingPos, resultat);
|
||||
HL_DEBUG("INSERT at "<< _addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
|
||||
HL_DEBUG("INSERT at "<< _addingPos << " S=" << resultat.start << " E=" << resultat.stop );
|
||||
// update the current research starting element: (set position at the end of the current element
|
||||
elementStart = resultat.endStop-1;
|
||||
elementStart = resultat.stop-1;
|
||||
// increment the position of insertion:
|
||||
_addingPos++;
|
||||
// We find a pattern == > Stop search for the current element
|
||||
@ -243,10 +243,10 @@ void appl::Highlight::parse2(int64_t _start,
|
||||
// Stop the search to the end (to get the end of the pattern)
|
||||
ret = m_listHighlightPass2[jjj]->find(elementStart, elementStop, resultat, _buffer);
|
||||
if (HLP_FIND_ERROR != ret) {
|
||||
HL2_DEBUG("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
|
||||
HL2_DEBUG("Find Pattern in the Buffer : (" << resultat.start << "," << resultat.stop << ")" );
|
||||
// add curent element in the list ...
|
||||
_metaData.push_back(resultat);
|
||||
elementStart = resultat.endStop-1;
|
||||
elementStart = resultat.stop-1;
|
||||
// Exit current cycle
|
||||
break;
|
||||
}
|
||||
|
@ -16,10 +16,8 @@ namespace appl {
|
||||
|
||||
class HighlightInfo {
|
||||
public:
|
||||
int32_t beginStart;
|
||||
int32_t beginStop;
|
||||
int32_t endStart;
|
||||
int32_t endStop;
|
||||
int32_t start;
|
||||
int32_t stop;
|
||||
bool notEnded;
|
||||
appl::HighlightPattern* patern; // pointer on class :
|
||||
};
|
||||
|
@ -16,40 +16,21 @@
|
||||
appl::HighlightPattern::HighlightPattern(const ewol::object::Shared<appl::GlyphPainting>& _glyphPainting) :
|
||||
m_glyphPainting(_glyphPainting),
|
||||
m_paternName(""),
|
||||
m_regExpStart(nullptr),
|
||||
m_regExpStop(nullptr),
|
||||
m_regExp(nullptr),
|
||||
m_colorName(""),
|
||||
m_escapeChar(u32char::Null),
|
||||
m_multiline(false),
|
||||
m_level(0) {
|
||||
m_regExpStart = std::unique_ptr<etk::RegExp<etk::Buffer>>(new etk::RegExp<etk::Buffer>());
|
||||
m_regExp = std::unique_ptr<etk::RegExp<etk::Buffer>>(new etk::RegExp<etk::Buffer>());
|
||||
}
|
||||
|
||||
appl::HighlightPattern::~HighlightPattern() {
|
||||
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::setPaternStart(std::string& _regExp) {
|
||||
if (m_regExpStart == nullptr) {
|
||||
void appl::HighlightPattern::setPatern(std::string& _regExp) {
|
||||
if (m_regExp == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_regExpStart->compile(_regExp);
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::setPaternStop(std::string& _regExp) {
|
||||
m_regExpStop.reset();
|
||||
if (_regExp.size() != 0) {
|
||||
m_regExpStop = std::unique_ptr<etk::RegExp<etk::Buffer>>(new etk::RegExp<etk::Buffer>());
|
||||
if (m_regExpStop != nullptr) {
|
||||
m_regExpStop->compile(_regExp);
|
||||
} else {
|
||||
APPL_ERROR("Allocation error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::setEscapeChar(const char32_t& _EscapeChar) {
|
||||
m_escapeChar = _EscapeChar;
|
||||
m_regExp->compile(_regExp);
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
|
||||
@ -59,17 +40,9 @@ void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::display() {
|
||||
APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
|
||||
APPL_INFO(" == > colorName \"" << m_colorName << "\"");
|
||||
APPL_INFO(" == > regExpStart \"" << m_regExpStart->getRegExp() << "\"");
|
||||
if (m_regExpStop != nullptr) {
|
||||
APPL_INFO(" == > regExpStop \"" << m_regExpStop->getRegExp() << "\"");
|
||||
}
|
||||
if (m_multiline == true) {
|
||||
APPL_INFO(" == > multiline pattern: YES");
|
||||
} else {
|
||||
APPL_INFO(" == > multiline pattern: NO");
|
||||
}
|
||||
APPL_INFO("patern : '" << m_paternName << "' level=" << m_level );
|
||||
APPL_INFO(" == > colorName '" << m_colorName << "'");
|
||||
APPL_INFO(" == > regExp '" << m_regExp->getRegExp() << "'");
|
||||
}
|
||||
|
||||
void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
|
||||
@ -77,9 +50,7 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
|
||||
/*
|
||||
<rule name="my preprocesseur">
|
||||
<color>preprocesseur</color>
|
||||
<start>#</start>
|
||||
<end>$</end>
|
||||
<multiline>yes</multiline>
|
||||
<regex>#</regex>
|
||||
</rule>
|
||||
*/
|
||||
//--------------------------------------------------------------------------------------------
|
||||
@ -101,30 +72,13 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
|
||||
setColorGlyph(myEdnData);
|
||||
}
|
||||
}
|
||||
xChild = _child->getNamed("start");
|
||||
xChild = _child->getNamed("regex");
|
||||
if (nullptr != xChild) {
|
||||
std::string myData = xChild->getText();
|
||||
if (myData.size() != 0) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||
std::string myEdnData = myData;
|
||||
setPaternStart(myEdnData);
|
||||
}
|
||||
}
|
||||
xChild = _child->getNamed("end");
|
||||
if (nullptr != xChild) {
|
||||
std::string myData = xChild->getText();
|
||||
if (myData.size() != 0) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||
std::string myEdnData = myData;
|
||||
setPaternStop(myEdnData);
|
||||
}
|
||||
}
|
||||
xChild = _child->getNamed("EscapeChar");
|
||||
if (nullptr != xChild) {
|
||||
std::string myData = xChild->getText();
|
||||
if (myData.size() != 0) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||
setEscapeChar(myData[0]);
|
||||
setPatern(myEdnData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,41 +89,17 @@ enum resultFind appl::HighlightPattern::find(int32_t _start,
|
||||
appl::HighlightInfo& _resultat,
|
||||
etk::Buffer& _buffer) {
|
||||
//APPL_DEBUG(" try to find the element");
|
||||
_resultat.beginStart = -1;
|
||||
_resultat.beginStop = -1;
|
||||
_resultat.endStart = -1;
|
||||
_resultat.endStop = -1;
|
||||
_resultat.start = -1;
|
||||
_resultat.stop = -1;
|
||||
_resultat.notEnded = false;
|
||||
_resultat.patern = this;
|
||||
|
||||
// when we have only one element:
|
||||
if (m_regExpStop == nullptr) {
|
||||
if (true == m_regExpStart->processOneElement(_buffer, _start, _stop)) {
|
||||
_resultat.beginStart = m_regExpStart->start();
|
||||
_resultat.beginStop = m_regExpStart->stop();
|
||||
_resultat.endStart = m_regExpStart->start();
|
||||
_resultat.endStop = m_regExpStart->stop();
|
||||
return HLP_FIND_OK;
|
||||
}
|
||||
//APPL_DEBUG("NOT find hightlightpatern ...");
|
||||
return HLP_FIND_ERROR;
|
||||
}
|
||||
// try while we find the first element
|
||||
if (m_regExpStart->processOneElement(_buffer, _start, _stop, m_escapeChar) == false) {
|
||||
return HLP_FIND_ERROR;
|
||||
}
|
||||
_resultat.beginStart = m_regExpStart->start();
|
||||
_resultat.beginStop = m_regExpStart->stop();
|
||||
if (m_regExpStop->parse(_buffer, _resultat.beginStop, _stop, m_escapeChar) == true) {
|
||||
_resultat.endStart = m_regExpStop->start();
|
||||
_resultat.endStop = m_regExpStop->stop();
|
||||
if (true == m_regExp->processOneElement(_buffer, _start, _stop)) {
|
||||
_resultat.start = m_regExp->start();
|
||||
_resultat.stop = m_regExp->stop();
|
||||
return HLP_FIND_OK;
|
||||
} else {
|
||||
_resultat.endStart = _stop+1;
|
||||
_resultat.endStop = _stop+1;
|
||||
_resultat.notEnded = true;
|
||||
return HLP_FIND_OK_NO_END;
|
||||
}
|
||||
//APPL_DEBUG("NOT find start hightlightpatern ...");
|
||||
//APPL_DEBUG("NOT find hightlightpatern ...");
|
||||
return HLP_FIND_ERROR;
|
||||
}
|
||||
|
@ -44,13 +44,9 @@ namespace appl {
|
||||
return m_paternName;
|
||||
};
|
||||
private:
|
||||
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExpStart; //!< Start of Regular expression
|
||||
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExp; //!< Start of Regular expression
|
||||
public:
|
||||
void setPaternStart(std::string& _regExp);
|
||||
private:
|
||||
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExpStop; //!< Stop of Regular Expression
|
||||
public:
|
||||
void setPaternStop(std::string& _regExp);
|
||||
void setPatern(std::string& _regExp);
|
||||
private:
|
||||
std::string m_colorName; //!< Current color name
|
||||
int32_t m_colorId; //!< Id of the the glyph painting
|
||||
@ -59,16 +55,6 @@ namespace appl {
|
||||
const appl::GlyphDecoration& getColorGlyph() {
|
||||
return (*m_glyphPainting)[m_colorId];
|
||||
};
|
||||
private:
|
||||
char32_t m_escapeChar; //!< Escape char to prevent exeit of patern ....
|
||||
public:
|
||||
void setEscapeChar(const char32_t& _EscapeChar);
|
||||
private:
|
||||
bool m_multiline; //!< The patern is multiline
|
||||
public:
|
||||
void setMultiline(bool _enable) {
|
||||
m_multiline = _enable;
|
||||
};
|
||||
private:
|
||||
int32_t m_level; //!< Level of the pattern == > this is to overwrite next pattern when we create an higher ....
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user