[DEV] add highlight parsing file
This commit is contained in:
parent
49649329eb
commit
4d35830559
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="boulou log">
|
||||
<EdnLang version="0.1" lang="Boulou log">
|
||||
<ext>*.boo</ext>
|
||||
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
|
||||
<rule name="comment ##">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="c">
|
||||
<EdnLang version="0.1" lang="C/C++">
|
||||
<ext>*.c</ext>
|
||||
<ext>*.cpp</ext>
|
||||
<ext>*.cc</ext>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="glsl">
|
||||
<EdnLang version="0.1" lang="Glsl">
|
||||
<ext>*.glsl</ext>
|
||||
<ext>*.vert</ext>
|
||||
<ext>*.frag</ext>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="qconf configuration file">
|
||||
<EdnLang version="0.1" lang="Kernel conf file">
|
||||
<ext>*.in</ext>
|
||||
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
|
||||
<rule name="my preprocesseur">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="java">
|
||||
<EdnLang version="0.1" lang="Java">
|
||||
<ext>*.java</ext>
|
||||
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
|
||||
<rule name="my comment multiline doxygen">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="json">
|
||||
<EdnLang version="0.1" lang="Json">
|
||||
<ext>*.json</ext>
|
||||
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
|
||||
<rule name="doubleQuteText">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="c">
|
||||
<EdnLang version="0.1" lang="Lua">
|
||||
<ext>*.lua</ext>
|
||||
<pass1>
|
||||
<rule name="Comment multiline">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="matlab">
|
||||
<EdnLang version="0.1" lang="Matlab">
|
||||
<ext>*.m</ext>
|
||||
<ext>*.M</ext>
|
||||
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="php: pretty home page">
|
||||
<EdnLang version="0.1" lang="Php: pretty home page">
|
||||
<ext>*.php</ext>
|
||||
<ext>*.php3</ext>
|
||||
<ext>*.php4</ext>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnLang version="0.1" lang="c">
|
||||
<EdnLang version="0.1" lang="Python">
|
||||
<ext>*.py</ext>
|
||||
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
|
||||
<rule name="my comment multiline">
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <appl/Buffer/Buffer.h>
|
||||
#include <appl/debug.h>
|
||||
#include <ewol/clipBoard.h>
|
||||
#include <appl/Highlight/HighlightManager.h>
|
||||
|
||||
appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ (void) {
|
||||
m_value = etk::UChar::Null;
|
||||
@ -100,13 +101,21 @@ appl::Buffer::Buffer(void) :
|
||||
m_cursorPos(0),
|
||||
m_cursorSelectPos(-1),
|
||||
m_cursorPreferredCol(-1),
|
||||
m_nbLines(0) {
|
||||
m_nbLines(0),
|
||||
m_highlight(NULL) {
|
||||
|
||||
}
|
||||
|
||||
appl::Buffer::~Buffer(void) {
|
||||
if (m_highlight == NULL) {
|
||||
appl::Highlight::release(m_highlight);
|
||||
}
|
||||
}
|
||||
|
||||
bool appl::Buffer::loadFile(const etk::UString& _name) {
|
||||
APPL_DEBUG("Load file : '" << _name << "'");
|
||||
m_fileName = _name;
|
||||
setHighlightType("");
|
||||
etk::FSNode file(m_fileName);
|
||||
if (file.exist() == false) {
|
||||
return false;
|
||||
@ -114,6 +123,7 @@ bool appl::Buffer::loadFile(const etk::UString& _name) {
|
||||
m_nbLines = 0;
|
||||
if (true == m_data.dumpFrom(file) ) {
|
||||
countNumberofLine();
|
||||
tryFindHighlightType();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -423,6 +433,7 @@ void appl::Buffer::copy(etk::UString& _data, const appl::Buffer::Iterator& _pos,
|
||||
bool appl::Buffer::write(const etk::UString& _data, const appl::Buffer::Iterator& _pos) {
|
||||
etk::Char output = _data.c_str();
|
||||
m_data.insert(_pos, (int8_t*)((void*)output), output.size());
|
||||
regenerateHighLightAt(_pos, 0, output.size());
|
||||
m_selectMode = false;
|
||||
moveCursor((esize_t)_pos+output.size());
|
||||
countNumberofLine(); // TODO : use more intelligent counter
|
||||
@ -432,6 +443,7 @@ bool appl::Buffer::write(const etk::UString& _data, const appl::Buffer::Iterator
|
||||
bool appl::Buffer::replace(const etk::UString& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
|
||||
etk::Char output = _data.c_str();
|
||||
m_data.replace(_pos, (esize_t)_posEnd-(esize_t)_pos, (int8_t*)((void*)output), output.size());
|
||||
regenerateHighLightAt(_pos, (esize_t)_posEnd-(esize_t)_pos, output.size());
|
||||
m_selectMode = false;
|
||||
moveCursor((esize_t)_pos+output.size());
|
||||
countNumberofLine(); // TODO : use more intelligent counter
|
||||
@ -443,20 +455,37 @@ void appl::Buffer::removeSelection(void) {
|
||||
esize_t startPos = getStartSelectionPos();
|
||||
esize_t endPos = getStopSelectionPos();
|
||||
m_data.remove(startPos, endPos-startPos);
|
||||
regenerateHighLightAt(startPos, endPos-startPos, 0);
|
||||
m_selectMode = false;
|
||||
moveCursor(startPos);
|
||||
countNumberofLine(); // TODO : use more intelligent counter
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void appl::Buffer::tryFindHighlightType(void) {
|
||||
// etk::UString appl::highlightManager::getTypeExtention(const etk::UString& _extention);
|
||||
// TODO :...
|
||||
setHighlightType("C/C++");
|
||||
}
|
||||
|
||||
void appl::Buffer::setHighlightType(const etk::UString& _type) {
|
||||
m_highlightType = "";
|
||||
cleanHighLight();
|
||||
if (m_highlight == NULL) {
|
||||
appl::Highlight::release(m_highlight);
|
||||
}
|
||||
etk::UString resourceName = appl::highlightManager::getFileWithTypeType(_type);
|
||||
if (resourceName == "") {
|
||||
return;
|
||||
}
|
||||
m_highlightType = _type;
|
||||
m_highlight = appl::Highlight::keep(resourceName);
|
||||
generateHighLightAt(0, m_data.size());
|
||||
}
|
||||
|
||||
|
||||
// TODO : Check this fuction it have too many conditionnal inside == > can do a better algo
|
||||
void appl::Buffer::RegenerateHighLightAt(int32_t _pos, int32_t _nbDeleted, int32_t _nbAdded) {
|
||||
void appl::Buffer::regenerateHighLightAt(int32_t _pos, int32_t _nbDeleted, int32_t _nbAdded) {
|
||||
// prevent ERROR...
|
||||
if (NULL == m_Highlight) {
|
||||
if (NULL == m_highlight) {
|
||||
return;
|
||||
}
|
||||
// prevent No data Call
|
||||
@ -482,20 +511,20 @@ void appl::Buffer::RegenerateHighLightAt(int32_t _pos, int32_t _nbDeleted, int32
|
||||
m_HLDataPass1.clear();
|
||||
} else if (startId == -1) {
|
||||
if (stopId == 0){
|
||||
m_HLDataPass1.Erase(0);
|
||||
m_HLDataPass1.erase(0);
|
||||
//APPL_DEBUG("1 * Erase 0");
|
||||
} else {
|
||||
m_HLDataPass1.EraseLen(0, stopId);
|
||||
m_HLDataPass1.eraseLen(0, stopId);
|
||||
//APPL_DEBUG("2 * Erase 0->" << stopId);
|
||||
}
|
||||
} else if (stopId == -1) {
|
||||
//APPL_DEBUG("3 * Erase " << startId+1 << "-> end");
|
||||
m_HLDataPass1.EraseLen(startId+1, m_HLDataPass1.size() - startId);
|
||||
m_HLDataPass1.eraseLen(startId+1, m_HLDataPass1.size() - startId);
|
||||
stopId = -1;
|
||||
} else {
|
||||
int32_t currentSize = m_HLDataPass1.size();
|
||||
//APPL_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" );
|
||||
m_HLDataPass1.EraseLen(startId+1, stopId - startId);
|
||||
m_HLDataPass1.eraseLen(startId+1, stopId - startId);
|
||||
if (stopId == currentSize-1) {
|
||||
stopId = -1;
|
||||
}
|
||||
@ -525,7 +554,7 @@ void appl::Buffer::RegenerateHighLightAt(int32_t _pos, int32_t _nbDeleted, int32
|
||||
generateHighLightAt(0, m_HLDataPass1[0].beginStart, 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].endStop, m_data.size(), m_HLDataPass1.size());
|
||||
} else {
|
||||
//APPL_DEBUG("******* Regenerate RANGE");
|
||||
generateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1);
|
||||
@ -588,7 +617,7 @@ void appl::Buffer::findMainHighLightPosition(int32_t _startPos,
|
||||
}
|
||||
// go back while the previous element is not eneded
|
||||
if (_backPreviousNotEnded == true) {
|
||||
for (int64_t iii = startId; iii >= 0; --iii) {
|
||||
for (int64_t iii = _startId; iii >= 0; --iii) {
|
||||
if (m_HLDataPass1[iii].notEnded == false) {
|
||||
break;
|
||||
}
|
||||
@ -603,30 +632,30 @@ void appl::Buffer::findMainHighLightPosition(int32_t _startPos,
|
||||
}
|
||||
for (esize_t iii = elemStart; iii < m_HLDataPass1.size(); ++iii) {
|
||||
if (m_HLDataPass1[iii].beginStart > _endPos) {
|
||||
_stopId = i;
|
||||
_stopId = iii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void appl::Buffer::generateHighLightAt(int32_t _pos, int32_t _endPos, int32_t _addingPos) {
|
||||
if (NULL == m_Highlight) {
|
||||
if (NULL == m_highlight) {
|
||||
return;
|
||||
}
|
||||
//APPL_DEBUG("area : ("<<pos<<","<<endPos<<") insert at : " << addingPos);
|
||||
m_Highlight->Parse(_pos, _endPos, m_HLDataPass1, _addingPos, m_data);
|
||||
m_highlight->parse(_pos, _endPos, m_HLDataPass1, _addingPos, m_data);
|
||||
}
|
||||
|
||||
void EdnBuf::cleanHighLight(void) {
|
||||
void appl::Buffer::cleanHighLight(void) {
|
||||
// remove all element in the list...
|
||||
m_HLDataPass1.clear();
|
||||
}
|
||||
|
||||
|
||||
appl::ColorInfo *appl::Buffer::getElementColorAtPosition(int32_t _pos, int32_t &_starPos) {
|
||||
appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(int32_t _pos, int32_t &_starPos) {
|
||||
int32_t start = etk_max(0, _starPos-1);
|
||||
for (esize_t iii = start; iii < m_HLDataPass1.size(); ++iii) {
|
||||
starPos = iii;
|
||||
_starPos = iii;
|
||||
if ( m_HLDataPass1[iii].beginStart <= _pos
|
||||
&& m_HLDataPass1[iii].endStop > _pos) {
|
||||
return &m_HLDataPass1[iii];
|
||||
@ -639,17 +668,17 @@ appl::ColorInfo *appl::Buffer::getElementColorAtPosition(int32_t _pos, int32_t &
|
||||
}
|
||||
|
||||
|
||||
void appl::Buffer::HightlightGenerateLines(displayHLData_ts_& _MData, int32_t _HLStart, int32_t _nbLines) {
|
||||
void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, int32_t _HLStart, int32_t _nbLines) {
|
||||
_MData.posHLPass1 = 0;
|
||||
_MData.posHLPass2 = 0;
|
||||
if (NULL == m_Highlight) {
|
||||
if (NULL == m_highlight) {
|
||||
return;
|
||||
}
|
||||
//GTimeVal timeStart;
|
||||
//g_get_current_time(&timeStart);
|
||||
_HLStart = StartOfLine(HLStart);
|
||||
_HLStart = (esize_t)getStartLine(position(_HLStart));
|
||||
_MData.HLData.clear();
|
||||
int32_t HLStop = CountForwardNLines(_HLStart, _nbLines);
|
||||
int32_t HLStop = countForwardNLines(position(_HLStart), _nbLines);
|
||||
int32_t startId, stopId;
|
||||
// find element previous
|
||||
findMainHighLightPosition(_HLStart, HLStop, startId, stopId, true);
|
||||
@ -665,14 +694,14 @@ void appl::Buffer::HightlightGenerateLines(displayHLData_ts_& _MData, int32_t _H
|
||||
if (kkk == 0) {
|
||||
if (_HLStart < m_HLDataPass1[kkk].beginStart) {
|
||||
//APPL_DEBUG(" == > (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart );
|
||||
m_Highlight->Parse2(HLStart,
|
||||
m_highlight->parse2(_HLStart,
|
||||
m_HLDataPass1[kkk].beginStart,
|
||||
_MData.HLData,
|
||||
m_data);
|
||||
} // else : nothing to do ...
|
||||
} else {
|
||||
//APPL_DEBUG(" == > (empty section 2 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<m_HLDataPass1[k].beginStart );
|
||||
m_Highlight->Parse2(m_HLDataPass1[kkk-1].endStop,
|
||||
m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
|
||||
m_HLDataPass1[kkk].beginStart,
|
||||
_MData.HLData,
|
||||
m_data);
|
||||
@ -685,13 +714,13 @@ void appl::Buffer::HightlightGenerateLines(displayHLData_ts_& _MData, int32_t _H
|
||||
//if( k < (int32_t)m_HLDataPass1.size()) {
|
||||
if (m_HLDataPass1.size() != 0) {
|
||||
//APPL_DEBUG(" == > (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
|
||||
m_Highlight->Parse2(m_HLDataPass1[kkk-1].endStop,
|
||||
m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
|
||||
HLStop,
|
||||
_MData.HLData,
|
||||
m_data);
|
||||
} else {
|
||||
//APPL_DEBUG(" == > (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
|
||||
m_Highlight->Parse2(0,
|
||||
m_highlight->parse2(0,
|
||||
HLStop,
|
||||
_MData.HLData,
|
||||
m_data);
|
||||
@ -701,11 +730,10 @@ void appl::Buffer::HightlightGenerateLines(displayHLData_ts_& _MData, int32_t _H
|
||||
//GTimeVal timeStop;
|
||||
//g_get_current_time(&timeStop);
|
||||
//APPL_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
|
||||
|
||||
}
|
||||
|
||||
|
||||
appl::ColorInfo* appl::Buffer::getElementColorAtPosition(displayHLData_ts& _MData, int32_t _pos) {
|
||||
appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(appl::DisplayHLData& _MData, int32_t _pos) {
|
||||
int32_t i;
|
||||
int32_t start = etk_max(0, _MData.posHLPass2-1);
|
||||
for (i=start; i<(int32_t)_MData.HLData.size(); i++) {
|
||||
@ -721,4 +749,3 @@ appl::ColorInfo* appl::Buffer::getElementColorAtPosition(displayHLData_ts& _MDat
|
||||
}
|
||||
return getElementColorAtPosition(_pos, _MData.posHLPass1);
|
||||
}
|
||||
#endif
|
@ -17,8 +17,16 @@
|
||||
#include <ewol/renderer/EObject.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
#include <appl/Highlight/Highlight.h>
|
||||
|
||||
namespace appl {
|
||||
|
||||
class DisplayHLData {
|
||||
public:
|
||||
etk::Vector<appl::HighlightInfo> HLData;
|
||||
int32_t posHLPass1;
|
||||
int32_t posHLPass2;
|
||||
};
|
||||
class Buffer : public ewol::EObject {
|
||||
public:
|
||||
class Iterator {
|
||||
@ -254,7 +262,7 @@ namespace appl {
|
||||
};
|
||||
public:
|
||||
Buffer(void);
|
||||
~Buffer(void) { };
|
||||
~Buffer(void);
|
||||
private:
|
||||
etk::UString m_fileName; //!< name of the file (with his path)
|
||||
public:
|
||||
@ -483,6 +491,9 @@ namespace appl {
|
||||
void countNumberofLine(void);
|
||||
protected:
|
||||
etk::UString m_highlightType; //!< Name of the highlight type
|
||||
|
||||
appl::Highlight* m_highlight; //!< internal link with the Highlight system
|
||||
etk::Vector<appl::HighlightInfo> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
|
||||
public:
|
||||
/**
|
||||
* @brief Find the Highligh capability
|
||||
@ -500,6 +511,19 @@ namespace appl {
|
||||
const etk::UString& setHighlightType(void) {
|
||||
return m_highlightType;
|
||||
};
|
||||
|
||||
void regenerateHighLightAt(int32_t _pos, int32_t _nbDeleted, int32_t _nbAdded);
|
||||
void findMainHighLightPosition(int32_t _startPos,
|
||||
int32_t _endPos,
|
||||
int32_t& _startId,
|
||||
int32_t& _stopId,
|
||||
bool _backPreviousNotEnded);
|
||||
void generateHighLightAt(int32_t _pos, int32_t _endPos, int32_t _addingPos=0);
|
||||
void cleanHighLight(void);
|
||||
appl::HighlightInfo* getElementColorAtPosition(int32_t _pos, int32_t &_starPos);
|
||||
void hightlightGenerateLines(appl::DisplayHLData& _MData, int32_t _HLStart, int32_t _nbLines);
|
||||
appl::HighlightInfo* getElementColorAtPosition(appl::DisplayHLData& _MData, int32_t _pos);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -333,7 +333,7 @@ int32_t BufferText::display(ewol::Text& OOText,
|
||||
|
||||
selHave = m_EdnBuf.getSelectionPos(selStart, selEnd, selIsRect, selRectStart, selRectEnd);
|
||||
|
||||
colorInformation_ts * HLColor = NULL;
|
||||
appl::HighlightInfo * HLColor = NULL;
|
||||
|
||||
int32_t iii, new_i;
|
||||
// get color :
|
||||
@ -349,7 +349,7 @@ int32_t BufferText::display(ewol::Text& OOText,
|
||||
int64_t startTime = ewol::getTime();
|
||||
int displayLines = 0;
|
||||
// Regenerate the colorizing if necessary ...
|
||||
displayHLData_ts m_displayLocalSyntax;
|
||||
appl::DisplayHLData m_displayLocalSyntax;
|
||||
m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, displayStartBufferPos, m_displaySize.y());
|
||||
|
||||
int64_t stopTime = ewol::getTime();
|
||||
|
@ -43,10 +43,10 @@ typedef struct {
|
||||
} selection;
|
||||
|
||||
typedef struct {
|
||||
etk::Vector<colorInformation_ts> HLData;
|
||||
etk::Vector<appl::HighlightInfo> HLData;
|
||||
int32_t posHLPass1;
|
||||
int32_t posHLPass2;
|
||||
}displayHLData_ts;
|
||||
}appl::DisplayHLData;
|
||||
|
||||
class EdnBuf {
|
||||
// TODO : set an iterator to acces at every data without knowin the system ...
|
||||
@ -135,17 +135,17 @@ class EdnBuf {
|
||||
// -----------------------------------------
|
||||
private:
|
||||
Highlight * m_Highlight; //!< internal link with the Highlight system
|
||||
etk::Vector<colorInformation_ts> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
|
||||
etk::Vector<appl::HighlightInfo> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
|
||||
void RegenerateHighLightAt(int32_t _pos, int32_t _nbDeleted, int32_t _nbAdded);
|
||||
void generateHighLightAt(int32_t _pos, int32_t _endPos, int32_t _addinPos=0);
|
||||
void CleanHighLight(void);
|
||||
void findMainHighLightPosition(int32_t _startPos, int32_t _endPos, int32_t &_startId, int32_t &_stopId, bool _backPreviousNotEnded);
|
||||
public:
|
||||
void setHLSystem(Highlight* _newHLSystem);
|
||||
void HightlightGenerateLines(displayHLData_ts& _MData, int32_t _startPos, int32_t _nbLines);
|
||||
colorInformation_ts* getElementColorAtPosition(displayHLData_ts& _MData, int32_t _pos);
|
||||
void HightlightGenerateLines(appl::DisplayHLData& _MData, int32_t _startPos, int32_t _nbLines);
|
||||
appl::HighlightInfo* getElementColorAtPosition(appl::DisplayHLData& _MData, int32_t _pos);
|
||||
private:
|
||||
colorInformation_ts* getElementColorAtPosition(int32_t _pos, int32_t &_starPos);
|
||||
appl::HighlightInfo* getElementColorAtPosition(int32_t _pos, int32_t &_starPos);
|
||||
|
||||
private:
|
||||
etk::Buffer m_data; //!< buffer of the data in the mode int8_t
|
||||
|
@ -29,7 +29,8 @@ void appl::Highlight::parseRules(exml::Element* _child,
|
||||
}
|
||||
|
||||
appl::Highlight::Highlight(const etk::UString& _xmlFilename, const etk::UString& _colorFile) :
|
||||
ewol::Resource(_xmlFilename) {
|
||||
ewol::Resource(_xmlFilename),
|
||||
m_typeName("") {
|
||||
// keep color propertiy file :
|
||||
m_paintingProperties = appl::GlyphPainting::keep(_colorFile);
|
||||
|
||||
@ -43,6 +44,7 @@ appl::Highlight::Highlight(const etk::UString& _xmlFilename, const etk::UString&
|
||||
APPL_ERROR("(l ?) main node not find: \"EdnLang\" ...");
|
||||
return;
|
||||
}
|
||||
m_typeName = root->getAttribute("lang");
|
||||
int32_t level1 = 0;
|
||||
int32_t level2 = 0;
|
||||
// parse all the elements :
|
||||
@ -156,7 +158,7 @@ void appl::Highlight::display(void) {
|
||||
*/
|
||||
void appl::Highlight::parse(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<appl::ColorInfo> &metaData,
|
||||
etk::Vector<appl::HighlightInfo> &metaData,
|
||||
int32_t addingPos,
|
||||
etk::Buffer &buffer) {
|
||||
if (0 > addingPos) {
|
||||
@ -165,7 +167,7 @@ void appl::Highlight::parse(int32_t start,
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.size() << " == > position search: (" << start << "," << stop << ")" );
|
||||
int32_t elementStart = start;
|
||||
int32_t elementStop = stop;
|
||||
appl::ColorInfo resultat;
|
||||
appl::HighlightInfo resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
@ -219,12 +221,12 @@ void appl::Highlight::parse(int32_t start,
|
||||
*/
|
||||
void appl::Highlight::parse2(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<appl::ColorInfo> &metaData,
|
||||
etk::Vector<appl::HighlightInfo> &metaData,
|
||||
etk::Buffer &buffer) {
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " == > position search: (" << start << "," << stop << ")" );
|
||||
int32_t elementStart = start;
|
||||
int32_t elementStop = stop;
|
||||
appl::ColorInfo resultat;
|
||||
appl::HighlightInfo resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
|
@ -14,7 +14,7 @@ namespace appl {
|
||||
class Highlight;
|
||||
class HighlightPattern;
|
||||
|
||||
class ColorInfo {
|
||||
class HighlightInfo {
|
||||
public:
|
||||
int32_t beginStart;
|
||||
int32_t beginStop;
|
||||
@ -39,18 +39,24 @@ namespace appl {
|
||||
// Constructeur
|
||||
Highlight(const etk::UString& _xmlFilename, const etk::UString& _colorFile);
|
||||
~Highlight(void);
|
||||
private:
|
||||
etk::UString m_typeName; //!< descriptive string type like "C/C++"
|
||||
public:
|
||||
const etk::UString& getTypeName(void) {
|
||||
return m_typeName;
|
||||
}
|
||||
public:
|
||||
bool hasExtention(const etk::UString& _ext);
|
||||
bool fileNameCompatible(const etk::UString& _fileName);
|
||||
void display(void);
|
||||
void parse(int32_t _start,
|
||||
int32_t _stop,
|
||||
etk::Vector<appl::ColorInfo> &_metaData,
|
||||
etk::Vector<appl::HighlightInfo> &_metaData,
|
||||
int32_t _addingPos,
|
||||
etk::Buffer &_buffer);
|
||||
void parse2(int32_t _start,
|
||||
int32_t _stop,
|
||||
etk::Vector<appl::ColorInfo> &_metaData,
|
||||
etk::Vector<appl::HighlightInfo> &_metaData,
|
||||
etk::Buffer &_buffer);
|
||||
private:
|
||||
void parseRules(exml::Element* _child,
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <HighlightManager.h>
|
||||
#include <appl/Highlight/HighlightManager.h>
|
||||
#include <ewol/renderer/EObject.h>
|
||||
#include <ewol/renderer/EObjectManager.h>
|
||||
|
||||
@ -73,6 +73,34 @@ void appl::highlightManager::unInit(void) {
|
||||
}
|
||||
|
||||
etk::UString appl::highlightManager::getTypeExtention(const etk::UString& _extention) {
|
||||
if (_extention.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
etk::Vector<Highlight*>& hlList = s_list();
|
||||
for (esize_t iii = 0; iii < hlList.size(); ++iii) {
|
||||
if (hlList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (hlList[iii]->hasExtention(_extention) == true) {
|
||||
return hlList[iii]->getTypeName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
etk::UString appl::highlightManager::getFileWithTypeType(const etk::UString& _type) {
|
||||
if (_type.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
etk::Vector<Highlight*>& hlList = s_list();
|
||||
for (esize_t iii = 0; iii < hlList.size(); ++iii) {
|
||||
if (hlList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (hlList[iii]->getTypeName() == _type) {
|
||||
return hlList[iii]->getName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,12 @@ namespace appl {
|
||||
* @return type of highlight
|
||||
*/
|
||||
etk::UString getTypeExtention(const etk::UString& _extention);
|
||||
/**
|
||||
* @brief Get filename with type.
|
||||
* @param[in] _type Type name of the highlight.
|
||||
* @return filename of the highlight.
|
||||
*/
|
||||
etk::UString getFileWithTypeType(const etk::UString& _type);
|
||||
/**
|
||||
* @brief Get the list of extention type
|
||||
* @return the requested list.
|
||||
|
@ -141,7 +141,7 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
|
||||
|
||||
resultFind_te appl::HighlightPattern::find(int32_t _start,
|
||||
int32_t _stop,
|
||||
appl::ColorInfo& _resultat,
|
||||
appl::HighlightInfo& _resultat,
|
||||
etk::Buffer& _buffer) {
|
||||
//APPL_DEBUG(" try to find the element");
|
||||
_resultat.beginStart = -1;
|
||||
|
@ -94,7 +94,7 @@ namespace appl {
|
||||
*/
|
||||
resultFind_te find(int32_t _start,
|
||||
int32_t _stop,
|
||||
appl::ColorInfo& _resultat,
|
||||
appl::HighlightInfo& _resultat,
|
||||
etk::Buffer& _buffer);
|
||||
|
||||
void parseRules(exml::Element* _child, int32_t _level);
|
||||
|
Loading…
x
Reference in New Issue
Block a user