[DEBUG] correction of some highlight error
This commit is contained in:
parent
9ce727e481
commit
edb2ab58f2
@ -889,17 +889,18 @@ appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(int64_t _pos, int64
|
||||
}
|
||||
|
||||
|
||||
void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, int64_t _HLStart, int64_t _nbLines) {
|
||||
void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, const appl::Buffer::Iterator& _HLStart, int64_t _nbLines) {
|
||||
_MData.posHLPass1 = 0;
|
||||
_MData.posHLPass2 = 0;
|
||||
if (NULL == m_highlight) {
|
||||
return;
|
||||
}
|
||||
//GTimeVal timeStart;
|
||||
//g_get_current_time(&timeStart);
|
||||
_HLStart = (int32_t)getStartLine(position(_HLStart));
|
||||
//int64_t timeStart = ewol::getTime();
|
||||
|
||||
appl::Buffer::Iterator HLStartLine = getStartLine(_HLStart);
|
||||
int64_t HLStartPos = (int64_t)HLStartLine;
|
||||
_MData.HLData.clear();
|
||||
int64_t HLStop = countForwardNLines(position(_HLStart), _nbLines);
|
||||
int64_t HLStop = (int64_t)countForwardNLines(HLStartLine, _nbLines);
|
||||
int64_t startId = 0;
|
||||
int64_t stopId = 0;
|
||||
// find element previous
|
||||
@ -914,15 +915,19 @@ void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, int64_t
|
||||
for (kkk = etk_max(startId, 0); kkk < endSearch; ++kkk) {
|
||||
// empty section :
|
||||
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,
|
||||
if (HLStartPos < m_HLDataPass1[kkk].beginStart) {
|
||||
APPL_VERBOSE(" == > (empty section 1 ) kkk=" << kkk <<
|
||||
" start=" << HLStartPos <<
|
||||
" stop=" << m_HLDataPass1[kkk].beginStart );
|
||||
m_highlight->parse2(HLStartPos,
|
||||
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 );
|
||||
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,
|
||||
_MData.HLData,
|
||||
@ -935,23 +940,26 @@ void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, int64_t
|
||||
if (endSearch == (int32_t)m_HLDataPass1.size() ){
|
||||
//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 );
|
||||
APPL_VERBOSE(" == > (empty section 3 ) kkk=" << kkk <<
|
||||
" start=" << m_HLDataPass1[kkk-1].endStop <<
|
||||
" stop=" << HLStop );
|
||||
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 );
|
||||
APPL_VERBOSE(" == > (empty section 4 ) kkk=" << kkk <<
|
||||
" start=0 stop=" << HLStop );
|
||||
m_highlight->parse2(0,
|
||||
HLStop,
|
||||
_MData.HLData,
|
||||
m_data);
|
||||
}
|
||||
}
|
||||
|
||||
//GTimeVal timeStop;
|
||||
//g_get_current_time(&timeStop);
|
||||
//APPL_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
|
||||
/*
|
||||
int64_t timeStop = ewol::getTime();
|
||||
APPL_DEBUG("Display 2nd pass = " << (timeStop-timeStart)/1000.0f << " milli-second");
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -618,7 +618,7 @@ namespace appl {
|
||||
void generateHighLightAt(int64_t _pos, int64_t _endPos, int64_t _addingPos=0);
|
||||
void cleanHighLight(void);
|
||||
appl::HighlightInfo* getElementColorAtPosition(int64_t _pos, int64_t &_starPos);
|
||||
void hightlightGenerateLines(appl::DisplayHLData& _MData, int64_t _HLStart, int64_t _nbLines);
|
||||
void hightlightGenerateLines(appl::DisplayHLData& _MData, const appl::Buffer::Iterator& _HLStart, int64_t _nbLines);
|
||||
appl::HighlightInfo* getElementColorAtPosition(appl::DisplayHLData& _MData, int64_t _pos);
|
||||
};
|
||||
};
|
||||
|
@ -191,7 +191,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
|
||||
m_displayText.setClipping(vec2(m_lastOffsetDisplay, 0), m_size);
|
||||
}
|
||||
appl::DisplayHLData displayLocalSyntax;
|
||||
m_buffer->hightlightGenerateLines(displayLocalSyntax, (int64_t)startingIt, m_size.y());
|
||||
m_buffer->hightlightGenerateLines(displayLocalSyntax, startingIt, (m_size.y()/tmpLetterSize.y()) + 5);
|
||||
float maxSizeX = 0;
|
||||
appl::HighlightInfo * HLColor = NULL;
|
||||
bool DisplayCursorAndSelection = isSelectedLast();
|
||||
@ -502,9 +502,18 @@ bool appl::TextViewer::onEventInput(const ewol::EventInput& _event) {
|
||||
return true;
|
||||
} else if (_event.getStatus() == ewol::keyEvent::statusMove) {
|
||||
if (m_buffer->getSelectMode() == true) {
|
||||
//int64_t timeStart = ewol::getTime();
|
||||
appl::Buffer::Iterator newPos = getMousePosition(relativePos);
|
||||
//int64_t timeMedium1 = ewol::getTime();
|
||||
moveCursor(newPos);
|
||||
//int64_t timeMedium2 = ewol::getTime();
|
||||
markToRedraw();
|
||||
/*
|
||||
int64_t timeStop = ewol::getTime();
|
||||
APPL_DEBUG("Display selection=" << (timeStop-timeStart)/1000.0f << " ms");
|
||||
APPL_DEBUG(" 1=" << (timeMedium1-timeStart)/1000.0f << " ms");
|
||||
APPL_DEBUG(" 2=" << (timeMedium2-timeMedium1)/1000.0f << " ms");
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -536,6 +545,7 @@ void appl::TextViewer::mouseEventTriple(void) {
|
||||
m_buffer->setSelectionPos(m_buffer->getStartLine(m_buffer->cursor()));
|
||||
}
|
||||
|
||||
// TODO : optimise this with retaine the display position buffer and his position in the real view ...
|
||||
appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativePos) {
|
||||
char32_t currentValue;
|
||||
vec3 positionCurentDisplay(0,0,0);
|
||||
@ -549,17 +559,23 @@ appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativeP
|
||||
(bool)it == true;
|
||||
++it) {
|
||||
currentValue = *it;
|
||||
m_buffer->expand(countColomn, currentValue, stringToDisplay);
|
||||
for (size_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
||||
if (stringToDisplay[kkk] == etk::UChar::Return) {
|
||||
m_displayText.forceLineReturn();
|
||||
countColomn = 0;
|
||||
} else {
|
||||
//note : Without this condithion the time od selection change to 0.6 ms to 8ms ...
|
||||
if (-_relativePos.y() >= positionCurentDisplay.y()) {
|
||||
m_displayText.print(stringToDisplay[kkk]);
|
||||
if (currentValue == etk::UChar::Return) {
|
||||
m_displayText.forceLineReturn();
|
||||
countColomn = 0;
|
||||
} else {
|
||||
if (-_relativePos.y() >= positionCurentDisplay.y()) {
|
||||
m_buffer->expand(countColomn, currentValue, stringToDisplay);
|
||||
for (size_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
||||
if (stringToDisplay[kkk] == etk::UChar::Return) {
|
||||
m_displayText.forceLineReturn();
|
||||
countColomn = 0;
|
||||
} else {
|
||||
//note : Without this condithion the time od selection change to 0.6 ms to 8ms ...
|
||||
//APPL_DEBUG("check : " << -_relativePos.y() << ">=" << positionCurentDisplay.y());
|
||||
m_displayText.print(stringToDisplay[kkk]);
|
||||
++countColomn;
|
||||
}
|
||||
}
|
||||
++countColomn;
|
||||
}
|
||||
}
|
||||
if (-_relativePos.y() >= positionCurentDisplay.y()) {
|
||||
@ -697,6 +713,7 @@ void appl::TextViewer::setFontName(const std::string& _fontName) {
|
||||
m_displayText.setFontName(_fontName);
|
||||
}
|
||||
|
||||
// TODO : Update process time ==> a little expensive (2->4ms) in end of file
|
||||
void appl::TextViewer::updateScrolling(void) {
|
||||
if (m_buffer == NULL) {
|
||||
return;
|
||||
|
@ -16,6 +16,13 @@
|
||||
#undef __class__
|
||||
#define __class__ "Highlight"
|
||||
|
||||
// first pass
|
||||
//#define HL_DEBUG APPL_INFO
|
||||
#define HL_DEBUG APPL_VERBOSE
|
||||
|
||||
// second pass
|
||||
//#define HL2_DEBUG APPL_INFO
|
||||
#define HL2_DEBUG APPL_VERBOSE
|
||||
|
||||
void appl::Highlight::parseRules(exml::Element* _child,
|
||||
std::vector<HighlightPattern*>& _mListPatern,
|
||||
@ -57,7 +64,7 @@ appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _
|
||||
if (child->getValue() == "ext") {
|
||||
std::string myData = child->getText();
|
||||
if (myData.size()!=0) {
|
||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
|
||||
//HL_DEBUG("(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
|
||||
m_listExtentions.push_back(myData);
|
||||
}
|
||||
} else if (child->getValue() == "pass1") {
|
||||
@ -158,42 +165,42 @@ void appl::Highlight::display(void) {
|
||||
/* TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas très grave...
|
||||
* Il suffirait juste de suprimer celui d'avant si il n'est pas terminer...
|
||||
*/
|
||||
void appl::Highlight::parse(int64_t start,
|
||||
int64_t stop,
|
||||
std::vector<appl::HighlightInfo> &metaData,
|
||||
int64_t addingPos,
|
||||
etk::Buffer &buffer) {
|
||||
if (0 > addingPos) {
|
||||
addingPos = 0;
|
||||
void appl::Highlight::parse(int64_t _start,
|
||||
int64_t _stop,
|
||||
std::vector<appl::HighlightInfo> & _metaData,
|
||||
int64_t _addingPos,
|
||||
etk::Buffer & _buffer) {
|
||||
if (0 > _addingPos) {
|
||||
_addingPos = 0;
|
||||
}
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.size() << " == > position search: (" << start << "," << stop << ")" );
|
||||
int64_t elementStart = start;
|
||||
int64_t elementStop = stop;
|
||||
HL_DEBUG("Parse element 0 => " << m_listHighlightPass1.size() << " == > position search: (" << _start << "," << _stop << ")" );
|
||||
int64_t elementStart = _start;
|
||||
int64_t elementStop = _stop;
|
||||
appl::HighlightInfo resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
while (elementStart <= elementStop) {
|
||||
HL_DEBUG("Parse element in the buffer pos=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
for (int64_t jjj=0; jjj<m_listHighlightPass1.size(); jjj++){
|
||||
enum resultFind ret = HLP_FIND_OK;
|
||||
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.size() << ")" );
|
||||
HL_DEBUG("Parse HL id=" << jjj << " position search: (" << elementStart << "," << _stop << ")" );
|
||||
// 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) {
|
||||
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
|
||||
HL_DEBUG("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
|
||||
// remove element in the current List where the current Element have a end inside the next...
|
||||
int64_t kkk=addingPos;
|
||||
while(kkk < metaData.size() ) {
|
||||
if (metaData[kkk].beginStart <= resultat.endStop) {
|
||||
int64_t kkk=_addingPos;
|
||||
while(kkk < _metaData.size() ) {
|
||||
if (_metaData[kkk].beginStart <= resultat.endStop) {
|
||||
// remove element
|
||||
//APPL_INFO("Erase element=" << kkk);
|
||||
metaData.erase(metaData.begin()+kkk, metaData.begin()+kkk+1);
|
||||
HL_DEBUG("Erase element=" << kkk);
|
||||
_metaData.erase(_metaData.begin()+kkk, _metaData.begin()+kkk+1);
|
||||
// Increase the end of search
|
||||
if (kkk < metaData.size()) {
|
||||
if (kkk < _metaData.size()) {
|
||||
// just befor the end of the next element
|
||||
elementStop = metaData[kkk].beginStart-1;
|
||||
elementStop = _metaData[kkk].beginStart-1;
|
||||
} else {
|
||||
// end of the buffer
|
||||
elementStop = buffer.size();
|
||||
elementStop = _buffer.size();
|
||||
}
|
||||
} else {
|
||||
// Not find == > exit the cycle :
|
||||
@ -201,12 +208,12 @@ void appl::Highlight::parse(int64_t start,
|
||||
}
|
||||
}
|
||||
// add curent element in the list ...
|
||||
metaData.insert(metaData.begin()+addingPos, resultat);
|
||||
//APPL_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
|
||||
_metaData.insert(_metaData.begin()+_addingPos, resultat);
|
||||
HL_DEBUG("INSERT at "<< _addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
|
||||
// update the current research starting element: (set position at the end of the current element
|
||||
elementStart = resultat.endStop-1;
|
||||
// increment the position of insertion:
|
||||
addingPos++;
|
||||
_addingPos++;
|
||||
// We find a pattern == > Stop search for the current element
|
||||
break;
|
||||
}
|
||||
@ -221,26 +228,29 @@ void appl::Highlight::parse(int64_t start,
|
||||
* @brief second pass of the hightlight
|
||||
*
|
||||
*/
|
||||
void appl::Highlight::parse2(int64_t start,
|
||||
int64_t stop,
|
||||
std::vector<appl::HighlightInfo> &metaData,
|
||||
etk::Buffer &buffer) {
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " == > position search: (" << start << "," << stop << ")" );
|
||||
int64_t elementStart = start;
|
||||
int64_t elementStop = stop;
|
||||
void appl::Highlight::parse2(int64_t _start,
|
||||
int64_t _stop,
|
||||
std::vector<appl::HighlightInfo> &_metaData,
|
||||
etk::Buffer &_buffer) {
|
||||
HL2_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() <<
|
||||
" == > position search: (" << _start << "," << _stop << ")" );
|
||||
int64_t elementStart = _start;
|
||||
int64_t elementStop = _stop;
|
||||
appl::HighlightInfo resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
|
||||
while (elementStart < elementStop) {
|
||||
//HL2_DEBUG("Parse element in the buffer pos=" << elementStart << "," << _buffer.size() << ")" );
|
||||
//try to fond the HL in ALL of we have
|
||||
for (int64_t jjj=0; jjj<m_listHighlightPass2.size(); jjj++){
|
||||
enum resultFind ret = HLP_FIND_OK;
|
||||
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.size() << ")" );
|
||||
HL2_DEBUG("Parse HL id=" << jjj << " position search: (" <<
|
||||
_start << "," << _buffer.size() << ")" );
|
||||
// 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) {
|
||||
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
|
||||
HL2_DEBUG("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
|
||||
// add curent element in the list ...
|
||||
metaData.push_back(resultat);
|
||||
_metaData.push_back(resultat);
|
||||
elementStart = resultat.endStop-1;
|
||||
// Exit current cycle
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user