[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]
|
[Desktop Entry]
|
||||||
Version=0.3.0
|
|
||||||
Name=Edn : Editeur de N'ours
|
Name=Edn : Editeur de N'ours
|
||||||
Exec=edn
|
Exec=edn %U
|
||||||
Icon=Edn
|
Icon=/usr/share/edn/icon.png
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=Development;Utility;TextEditor;
|
Categories=Development;
|
||||||
GenericName=Text editor
|
GenericName=Text editor
|
||||||
GenericName[en]=Text editor
|
GenericName[en]=Text editor
|
||||||
GenericName[nl]=Tekst verwerker
|
GenericName[nl]=Tekst verwerker
|
||||||
GenericName[fr]=éditeur de text
|
GenericName[fr]=Éditeur de text
|
||||||
Comment=Code editor for c, c++, php, bash, xml ...
|
Comment=Code editor for c, c++, php, bash, xml ...
|
||||||
Comment[fr]=éditeur de text pour les language 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 -->
|
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
|
||||||
<rule name="my comment multiline doxygen">
|
<rule name="my comment multiline doxygen">
|
||||||
<color>commentDoxygen</color>
|
<color>commentDoxygen</color>
|
||||||
<start>/\*\*</start>
|
<regex>/\*\*.*\*/</regex>
|
||||||
<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>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="code Review">
|
<rule name="code Review">
|
||||||
<color>SYNTAX_ERROR</color>
|
<color>SYNTAX_ERROR</color>
|
||||||
<start>/\*[ \t]*TODO :</start>
|
<regex>/\*[ \t]*TODO :.*\*/</regex>
|
||||||
<end>\*/</end>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="my comment multiline">
|
<rule name="my comment multiline">
|
||||||
<color>comment</color>
|
<color>comment</color>
|
||||||
<start>/\*</start>
|
<regex>/\*.*\*/</regex>
|
||||||
<end>\*/</end>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="my if 0">
|
<rule name="my if 0">
|
||||||
<color>preprocesseur</color>
|
<color>preprocesseur</color>
|
||||||
<start>#[ \t]*if 0</start>
|
<regex>#[ \t]*if 0.*#(endif|else)</regex>
|
||||||
<end>#endif|#else</end>
|
|
||||||
<EscapeChar>\</EscapeChar>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="my preprocesseur">
|
<rule name="my preprocesseur">
|
||||||
<color>preprocesseur</color>
|
<color>preprocesseur</color>
|
||||||
<start>#</start>
|
<regex>#(\\|\\n|.)*$</regex>
|
||||||
<end>\n</end>
|
|
||||||
<EscapeChar>\</EscapeChar>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="my comment doxygen">
|
<rule name="my comment doxygen">
|
||||||
<color>commentDoxygen</color>
|
<color>commentDoxygen</color>
|
||||||
<start>//!</start>
|
<regex>//!.*$</regex>
|
||||||
<end>\n</end>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="my todo comment">
|
<rule name="my todo comment">
|
||||||
<color>SYNTAX_ERROR</color>
|
<color>SYNTAX_ERROR</color>
|
||||||
<start>//[ \t]*TODO[ \t]*:</start>
|
<regex>//[ \t]*TODO[ \t]*:.*$</regex>
|
||||||
<end>\n</end>
|
|
||||||
<EscapeChar>\</EscapeChar>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="my comment">
|
<rule name="my comment">
|
||||||
<color>comment</color>
|
<color>comment</color>
|
||||||
<start>//</start>
|
<regex>//(\\|\\n|.)*$</regex>
|
||||||
<end>\n</end>
|
|
||||||
<EscapeChar>\</EscapeChar>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="doubleQuteText">
|
<rule name="doubleQuteText">
|
||||||
<color>doubleQuoteText</color>
|
<color>doubleQuoteText</color>
|
||||||
<start>"</start>
|
<regex>"(\\|"|.)*"</regex>
|
||||||
<end>"</end>
|
|
||||||
<EscapeChar>\</EscapeChar>
|
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="simpleQuteText">
|
<rule name="simpleQuteText">
|
||||||
<color>doubleQuoteText</color>
|
<color>doubleQuoteText</color>
|
||||||
<start>'</start>
|
<regex>'(\\|'|.)*'</regex>
|
||||||
<end>'</end>
|
|
||||||
<!--<EscapeChar>\</EscapeChar>-->
|
|
||||||
</rule>
|
</rule>
|
||||||
</pass1>
|
</pass1>
|
||||||
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
|
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
|
||||||
|
<!--
|
||||||
<rule name="my keyword">
|
<rule name="my keyword">
|
||||||
<color>keyword</color>
|
<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>
|
||||||
<rule name="my function keyword">
|
<rule name="my function keyword">
|
||||||
<color>systemFunction</color>
|
<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>
|
||||||
<rule name="my type">
|
<rule name="my type">
|
||||||
<color>type</color>
|
<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>
|
||||||
<rule name="std type">
|
<rule name="std type">
|
||||||
<color>type</color>
|
<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>
|
||||||
<rule name="my storage keyword">
|
<rule name="my storage keyword">
|
||||||
<color>storageKeyword</color>
|
<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>
|
||||||
<rule name="my common Define">
|
<rule name="my common Define">
|
||||||
<color>commonDefine</color>
|
<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>
|
||||||
<rule name="numeric constant">
|
<rule name="numeric constant">
|
||||||
<color>number</color>
|
<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>
|
||||||
<rule name="my boolean">
|
<rule name="my boolean">
|
||||||
<color>boolean</color>
|
<color>boolean</color>
|
||||||
<start>\@true|TRUE|false|FALSE\@</start>
|
<regex>\@true|TRUE|false|FALSE\@</regex>
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="BIG LETTER">
|
<rule name="BIG LETTER">
|
||||||
<color>macro</color>
|
<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>
|
||||||
<rule name="CPP member">
|
<rule name="CPP member">
|
||||||
<color>memberClass</color>
|
<color>memberClass</color>
|
||||||
<start>\@m_[A-Za-z_0-9]*\@</start>
|
<regex>\@m_[A-Za-z_0-9]*\@</regex>
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="function input">
|
<rule name="function input">
|
||||||
<color>inputFunction</color>
|
<color>inputFunction</color>
|
||||||
<start>\@_[A-Za-z_0-9]*\@</start>
|
<regex>\@_[A-Za-z_0-9]*\@</regex>
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="Function name">
|
<rule name="Function name">
|
||||||
<color>functionName</color>
|
<color>functionName</color>
|
||||||
<start>\@(\w|_)+[ \t]*\(</start>
|
<regex>\@(\w|_)+[ \t]*\(</regex>
|
||||||
</rule>
|
</rule>
|
||||||
<rule name="condition">
|
<rule name="condition">
|
||||||
<color>boolean</color>
|
<color>boolean</color>
|
||||||
<start>==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}|</start>
|
<regex>==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}|</regex>
|
||||||
</rule>
|
</rule>
|
||||||
<!-- With all elementes :
|
-->
|
||||||
|
<!-- With all elementes :
|
||||||
<rule name="BIG LETTER">
|
<rule name="BIG LETTER">
|
||||||
<color>macro</color>
|
<color>macro</color>
|
||||||
<start>([A-Z]|_){4,500}</start>
|
<regex>([A-Z]|_){4,500}</regex>
|
||||||
<elemSubColor id="1">doxElem</elemSubColor>
|
<elemSubColor id="1">doxElem</elemSubColor>
|
||||||
</rule>
|
</rule>
|
||||||
-->
|
-->
|
||||||
</pass2>
|
</pass2>
|
||||||
</EdnLang>
|
</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) {
|
for (auto it(m_HLDataPass1.begin()+elemStart); it != m_HLDataPass1.end(); ++it) {
|
||||||
//APPL_DEBUG("move element=" << i);
|
//APPL_DEBUG("move element=" << i);
|
||||||
it->beginStart += _nbAdded - _nbDeleted;
|
it->start += _nbAdded - _nbDeleted;
|
||||||
it->beginStop += _nbAdded - _nbDeleted;
|
it->stop += _nbAdded - _nbDeleted;
|
||||||
it->endStart += _nbAdded - _nbDeleted;
|
|
||||||
it->endStop += _nbAdded - _nbDeleted;
|
|
||||||
}
|
}
|
||||||
//Regenerate Element inside range
|
//Regenerate Element inside range
|
||||||
if ( startId == -1
|
if ( startId == -1
|
||||||
@ -774,13 +772,13 @@ void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64
|
|||||||
generateHighLightAt(0, m_data.size());
|
generateHighLightAt(0, m_data.size());
|
||||||
} else if(-1 == startId) {
|
} else if(-1 == startId) {
|
||||||
//APPL_DEBUG("******* Regenerate START");
|
//APPL_DEBUG("******* Regenerate START");
|
||||||
generateHighLightAt(0, m_HLDataPass1[0].beginStart, 0);
|
generateHighLightAt(0, m_HLDataPass1[0].start, 0);
|
||||||
} else if(-1 == stopId) {
|
} else if(-1 == stopId) {
|
||||||
//APPL_DEBUG("******* Regenerate STOP");
|
//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 {
|
} else {
|
||||||
//APPL_DEBUG("******* Regenerate RANGE");
|
//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
|
S=-1 *************** E
|
||||||
*/
|
*/
|
||||||
for (size_t iii = 0; iii < m_HLDataPass1.size(); ++iii) {
|
for (size_t iii = 0; iii < m_HLDataPass1.size(); ++iii) {
|
||||||
if (m_HLDataPass1[iii].endStop > _startPos) {
|
if (m_HLDataPass1[iii].stop > _startPos) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_startId = iii;
|
_startId = iii;
|
||||||
@ -850,7 +848,7 @@ void appl::Buffer::findMainHighLightPosition(int64_t _startPos,
|
|||||||
elemStart = _startId+1;
|
elemStart = _startId+1;
|
||||||
}
|
}
|
||||||
for (size_t iii = elemStart; iii < m_HLDataPass1.size(); ++iii) {
|
for (size_t iii = elemStart; iii < m_HLDataPass1.size(); ++iii) {
|
||||||
if (m_HLDataPass1[iii].beginStart > _endPos) {
|
if (m_HLDataPass1[iii].start > _endPos) {
|
||||||
_stopId = iii;
|
_stopId = iii;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -875,11 +873,11 @@ appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(int64_t _pos, int64
|
|||||||
int32_t start = std::max((int64_t)0, _starPos-1);
|
int32_t start = std::max((int64_t)0, _starPos-1);
|
||||||
for (size_t iii = start; iii < m_HLDataPass1.size(); ++iii) {
|
for (size_t iii = start; iii < m_HLDataPass1.size(); ++iii) {
|
||||||
_starPos = iii;
|
_starPos = iii;
|
||||||
if ( m_HLDataPass1[iii].beginStart <= _pos
|
if ( m_HLDataPass1[iii].start <= _pos
|
||||||
&& m_HLDataPass1[iii].endStop > _pos) {
|
&& m_HLDataPass1[iii].stop > _pos) {
|
||||||
return &m_HLDataPass1[iii];
|
return &m_HLDataPass1[iii];
|
||||||
}
|
}
|
||||||
if(m_HLDataPass1[iii].beginStart > _pos) {
|
if(m_HLDataPass1[iii].start > _pos) {
|
||||||
return nullptr;
|
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) {
|
for (kkk = std::max(startId, (int64_t)0); kkk < endSearch; ++kkk) {
|
||||||
// empty section :
|
// empty section :
|
||||||
if (kkk == 0) {
|
if (kkk == 0) {
|
||||||
if (HLStartPos < m_HLDataPass1[kkk].beginStart) {
|
if (HLStartPos < m_HLDataPass1[kkk].start) {
|
||||||
APPL_VERBOSE(" == > (empty section 1 ) kkk=" << kkk <<
|
APPL_VERBOSE(" == > (empty section 1 ) kkk=" << kkk <<
|
||||||
" start=" << HLStartPos <<
|
" start=" << HLStartPos <<
|
||||||
" stop=" << m_HLDataPass1[kkk].beginStart );
|
" stop=" << m_HLDataPass1[kkk].start );
|
||||||
m_highlight->parse2(HLStartPos,
|
m_highlight->parse2(HLStartPos,
|
||||||
m_HLDataPass1[kkk].beginStart,
|
m_HLDataPass1[kkk].start,
|
||||||
_MData.HLData,
|
_MData.HLData,
|
||||||
m_data);
|
m_data);
|
||||||
} // else : nothing to do ...
|
} // else : nothing to do ...
|
||||||
} else {
|
} else {
|
||||||
APPL_VERBOSE(" == > (empty section 2 ) kkk=" << kkk <<
|
APPL_VERBOSE(" == > (empty section 2 ) kkk=" << kkk <<
|
||||||
" start=" << m_HLDataPass1[kkk-1].endStop <<
|
" start=" << m_HLDataPass1[kkk-1].stop <<
|
||||||
" stop=" << m_HLDataPass1[kkk].beginStart );
|
" stop=" << m_HLDataPass1[kkk].start );
|
||||||
m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
|
m_highlight->parse2(m_HLDataPass1[kkk-1].stop,
|
||||||
m_HLDataPass1[kkk].beginStart,
|
m_HLDataPass1[kkk].start,
|
||||||
_MData.HLData,
|
_MData.HLData,
|
||||||
m_data);
|
m_data);
|
||||||
}
|
}
|
||||||
@ -939,9 +937,9 @@ void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, const ap
|
|||||||
//if( k < (int32_t)m_HLDataPass1.size()) {
|
//if( k < (int32_t)m_HLDataPass1.size()) {
|
||||||
if (m_HLDataPass1.size() != 0) {
|
if (m_HLDataPass1.size() != 0) {
|
||||||
APPL_VERBOSE(" == > (empty section 3 ) kkk=" << kkk <<
|
APPL_VERBOSE(" == > (empty section 3 ) kkk=" << kkk <<
|
||||||
" start=" << m_HLDataPass1[kkk-1].endStop <<
|
" start=" << m_HLDataPass1[kkk-1].stop <<
|
||||||
" stop=" << HLStop );
|
" stop=" << HLStop );
|
||||||
m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
|
m_highlight->parse2(m_HLDataPass1[kkk-1].stop,
|
||||||
HLStop,
|
HLStop,
|
||||||
_MData.HLData,
|
_MData.HLData,
|
||||||
m_data);
|
m_data);
|
||||||
@ -965,12 +963,12 @@ appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(appl::DisplayHLData
|
|||||||
int64_t start = std::max((int64_t)0, _MData.posHLPass2-1);
|
int64_t start = std::max((int64_t)0, _MData.posHLPass2-1);
|
||||||
for (int64_t iii=start; iii<(int32_t)_MData.HLData.size(); iii++) {
|
for (int64_t iii=start; iii<(int32_t)_MData.HLData.size(); iii++) {
|
||||||
_MData.posHLPass2 = iii;
|
_MData.posHLPass2 = iii;
|
||||||
if( _MData.HLData[iii].beginStart <= _pos
|
if( _MData.HLData[iii].start <= _pos
|
||||||
&& _MData.HLData[iii].endStop > _pos)
|
&& _MData.HLData[iii].stop > _pos)
|
||||||
{
|
{
|
||||||
return &_MData.HLData[iii];
|
return &_MData.HLData[iii];
|
||||||
}
|
}
|
||||||
if(_MData.HLData[iii].beginStart > _pos) {
|
if(_MData.HLData[iii].start > _pos) {
|
||||||
return getElementColorAtPosition(_pos, _MData.posHLPass1);
|
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)
|
// Stop the search to the end (to get the end of the pattern)
|
||||||
ret = m_listHighlightPass1[jjj]->find(elementStart, _buffer.size(), resultat, _buffer);
|
ret = m_listHighlightPass1[jjj]->find(elementStart, _buffer.size(), resultat, _buffer);
|
||||||
if (HLP_FIND_ERROR != ret) {
|
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...
|
// remove element in the current List where the current Element have a end inside the next...
|
||||||
int64_t kkk=_addingPos;
|
int64_t kkk=_addingPos;
|
||||||
while(kkk < (int64_t)_metaData.size() ) {
|
while(kkk < (int64_t)_metaData.size() ) {
|
||||||
if (_metaData[kkk].beginStart <= resultat.endStop) {
|
if (_metaData[kkk].start <= resultat.stop) {
|
||||||
// remove element
|
// remove element
|
||||||
HL_DEBUG("Erase element=" << kkk);
|
HL_DEBUG("Erase element=" << kkk);
|
||||||
_metaData.erase(_metaData.begin()+kkk, _metaData.begin()+kkk+1);
|
_metaData.erase(_metaData.begin()+kkk, _metaData.begin()+kkk+1);
|
||||||
// Increase the end of search
|
// Increase the end of search
|
||||||
if (kkk < (int64_t)_metaData.size()) {
|
if (kkk < (int64_t)_metaData.size()) {
|
||||||
// just befor the end of the next element
|
// just befor the end of the next element
|
||||||
elementStop = _metaData[kkk].beginStart-1;
|
elementStop = _metaData[kkk].start-1;
|
||||||
} else {
|
} else {
|
||||||
// end of the buffer
|
// end of the buffer
|
||||||
elementStop = _buffer.size();
|
elementStop = _buffer.size();
|
||||||
@ -204,9 +204,9 @@ void appl::Highlight::parse(int64_t _start,
|
|||||||
}
|
}
|
||||||
// add curent element in the list ...
|
// add curent element in the list ...
|
||||||
_metaData.insert(_metaData.begin()+_addingPos, resultat);
|
_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
|
// 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:
|
// increment the position of insertion:
|
||||||
_addingPos++;
|
_addingPos++;
|
||||||
// We find a pattern == > Stop search for the current element
|
// 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)
|
// Stop the search to the end (to get the end of the pattern)
|
||||||
ret = m_listHighlightPass2[jjj]->find(elementStart, elementStop, resultat, _buffer);
|
ret = m_listHighlightPass2[jjj]->find(elementStart, elementStop, resultat, _buffer);
|
||||||
if (HLP_FIND_ERROR != ret) {
|
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 ...
|
// add curent element in the list ...
|
||||||
_metaData.push_back(resultat);
|
_metaData.push_back(resultat);
|
||||||
elementStart = resultat.endStop-1;
|
elementStart = resultat.stop-1;
|
||||||
// Exit current cycle
|
// Exit current cycle
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,8 @@ namespace appl {
|
|||||||
|
|
||||||
class HighlightInfo {
|
class HighlightInfo {
|
||||||
public:
|
public:
|
||||||
int32_t beginStart;
|
int32_t start;
|
||||||
int32_t beginStop;
|
int32_t stop;
|
||||||
int32_t endStart;
|
|
||||||
int32_t endStop;
|
|
||||||
bool notEnded;
|
bool notEnded;
|
||||||
appl::HighlightPattern* patern; // pointer on class :
|
appl::HighlightPattern* patern; // pointer on class :
|
||||||
};
|
};
|
||||||
|
@ -16,40 +16,21 @@
|
|||||||
appl::HighlightPattern::HighlightPattern(const ewol::object::Shared<appl::GlyphPainting>& _glyphPainting) :
|
appl::HighlightPattern::HighlightPattern(const ewol::object::Shared<appl::GlyphPainting>& _glyphPainting) :
|
||||||
m_glyphPainting(_glyphPainting),
|
m_glyphPainting(_glyphPainting),
|
||||||
m_paternName(""),
|
m_paternName(""),
|
||||||
m_regExpStart(nullptr),
|
m_regExp(nullptr),
|
||||||
m_regExpStop(nullptr),
|
|
||||||
m_colorName(""),
|
m_colorName(""),
|
||||||
m_escapeChar(u32char::Null),
|
|
||||||
m_multiline(false),
|
|
||||||
m_level(0) {
|
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() {
|
appl::HighlightPattern::~HighlightPattern() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::HighlightPattern::setPaternStart(std::string& _regExp) {
|
void appl::HighlightPattern::setPatern(std::string& _regExp) {
|
||||||
if (m_regExpStart == nullptr) {
|
if (m_regExp == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_regExpStart->compile(_regExp);
|
m_regExp->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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
|
void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
|
||||||
@ -59,17 +40,9 @@ void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void appl::HighlightPattern::display() {
|
void appl::HighlightPattern::display() {
|
||||||
APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
|
APPL_INFO("patern : '" << m_paternName << "' level=" << m_level );
|
||||||
APPL_INFO(" == > colorName \"" << m_colorName << "\"");
|
APPL_INFO(" == > colorName '" << m_colorName << "'");
|
||||||
APPL_INFO(" == > regExpStart \"" << m_regExpStart->getRegExp() << "\"");
|
APPL_INFO(" == > regExp '" << m_regExp->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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
|
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">
|
<rule name="my preprocesseur">
|
||||||
<color>preprocesseur</color>
|
<color>preprocesseur</color>
|
||||||
<start>#</start>
|
<regex>#</regex>
|
||||||
<end>$</end>
|
|
||||||
<multiline>yes</multiline>
|
|
||||||
</rule>
|
</rule>
|
||||||
*/
|
*/
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
@ -101,30 +72,13 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
|
|||||||
setColorGlyph(myEdnData);
|
setColorGlyph(myEdnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xChild = _child->getNamed("start");
|
xChild = _child->getNamed("regex");
|
||||||
if (nullptr != xChild) {
|
if (nullptr != xChild) {
|
||||||
std::string myData = xChild->getText();
|
std::string myData = xChild->getText();
|
||||||
if (myData.size() != 0) {
|
if (myData.size() != 0) {
|
||||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||||
std::string myEdnData = myData;
|
std::string myEdnData = myData;
|
||||||
setPaternStart(myEdnData);
|
setPatern(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]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,41 +89,17 @@ enum resultFind appl::HighlightPattern::find(int32_t _start,
|
|||||||
appl::HighlightInfo& _resultat,
|
appl::HighlightInfo& _resultat,
|
||||||
etk::Buffer& _buffer) {
|
etk::Buffer& _buffer) {
|
||||||
//APPL_DEBUG(" try to find the element");
|
//APPL_DEBUG(" try to find the element");
|
||||||
_resultat.beginStart = -1;
|
_resultat.start = -1;
|
||||||
_resultat.beginStop = -1;
|
_resultat.stop = -1;
|
||||||
_resultat.endStart = -1;
|
|
||||||
_resultat.endStop = -1;
|
|
||||||
_resultat.notEnded = false;
|
_resultat.notEnded = false;
|
||||||
_resultat.patern = this;
|
_resultat.patern = this;
|
||||||
|
|
||||||
// when we have only one element:
|
// when we have only one element:
|
||||||
if (m_regExpStop == nullptr) {
|
if (true == m_regExp->processOneElement(_buffer, _start, _stop)) {
|
||||||
if (true == m_regExpStart->processOneElement(_buffer, _start, _stop)) {
|
_resultat.start = m_regExp->start();
|
||||||
_resultat.beginStart = m_regExpStart->start();
|
_resultat.stop = m_regExp->stop();
|
||||||
_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();
|
|
||||||
return HLP_FIND_OK;
|
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;
|
return HLP_FIND_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,9 @@ namespace appl {
|
|||||||
return m_paternName;
|
return m_paternName;
|
||||||
};
|
};
|
||||||
private:
|
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:
|
public:
|
||||||
void setPaternStart(std::string& _regExp);
|
void setPatern(std::string& _regExp);
|
||||||
private:
|
|
||||||
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExpStop; //!< Stop of Regular Expression
|
|
||||||
public:
|
|
||||||
void setPaternStop(std::string& _regExp);
|
|
||||||
private:
|
private:
|
||||||
std::string m_colorName; //!< Current color name
|
std::string m_colorName; //!< Current color name
|
||||||
int32_t m_colorId; //!< Id of the the glyph painting
|
int32_t m_colorId; //!< Id of the the glyph painting
|
||||||
@ -59,16 +55,6 @@ namespace appl {
|
|||||||
const appl::GlyphDecoration& getColorGlyph() {
|
const appl::GlyphDecoration& getColorGlyph() {
|
||||||
return (*m_glyphPainting)[m_colorId];
|
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:
|
private:
|
||||||
int32_t m_level; //!< Level of the pattern == > this is to overwrite next pattern when we create an higher ....
|
int32_t m_level; //!< Level of the pattern == > this is to overwrite next pattern when we create an higher ....
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user