[DEBUG] correction of some highlight error

This commit is contained in:
Edouard DUPIN 2013-12-05 22:16:04 +01:00
parent 9ce727e481
commit edb2ab58f2
4 changed files with 102 additions and 67 deletions

View File

@ -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.posHLPass1 = 0;
_MData.posHLPass2 = 0; _MData.posHLPass2 = 0;
if (NULL == m_highlight) { if (NULL == m_highlight) {
return; return;
} }
//GTimeVal timeStart; //int64_t timeStart = ewol::getTime();
//g_get_current_time(&timeStart);
_HLStart = (int32_t)getStartLine(position(_HLStart)); appl::Buffer::Iterator HLStartLine = getStartLine(_HLStart);
int64_t HLStartPos = (int64_t)HLStartLine;
_MData.HLData.clear(); _MData.HLData.clear();
int64_t HLStop = countForwardNLines(position(_HLStart), _nbLines); int64_t HLStop = (int64_t)countForwardNLines(HLStartLine, _nbLines);
int64_t startId = 0; int64_t startId = 0;
int64_t stopId = 0; int64_t stopId = 0;
// find element previous // 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) { for (kkk = etk_max(startId, 0); kkk < endSearch; ++kkk) {
// empty section : // empty section :
if (kkk == 0) { if (kkk == 0) {
if (_HLStart < m_HLDataPass1[kkk].beginStart) { if (HLStartPos < m_HLDataPass1[kkk].beginStart) {
//APPL_DEBUG(" == > (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart ); APPL_VERBOSE(" == > (empty section 1 ) kkk=" << kkk <<
m_highlight->parse2(_HLStart, " start=" << HLStartPos <<
" stop=" << m_HLDataPass1[kkk].beginStart );
m_highlight->parse2(HLStartPos,
m_HLDataPass1[kkk].beginStart, m_HLDataPass1[kkk].beginStart,
_MData.HLData, _MData.HLData,
m_data); m_data);
} // else : nothing to do ... } // else : nothing to do ...
} else { } 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_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
m_HLDataPass1[kkk].beginStart, m_HLDataPass1[kkk].beginStart,
_MData.HLData, _MData.HLData,
@ -935,23 +940,26 @@ void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, int64_t
if (endSearch == (int32_t)m_HLDataPass1.size() ){ if (endSearch == (int32_t)m_HLDataPass1.size() ){
//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_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, m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
HLStop, HLStop,
_MData.HLData, _MData.HLData,
m_data); m_data);
} else { } 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, m_highlight->parse2(0,
HLStop, HLStop,
_MData.HLData, _MData.HLData,
m_data); m_data);
} }
} }
/*
//GTimeVal timeStop; int64_t timeStop = ewol::getTime();
//g_get_current_time(&timeStop); APPL_DEBUG("Display 2nd pass = " << (timeStop-timeStart)/1000.0f << " milli-second");
//APPL_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); */
} }

View File

@ -618,7 +618,7 @@ namespace appl {
void generateHighLightAt(int64_t _pos, int64_t _endPos, int64_t _addingPos=0); void generateHighLightAt(int64_t _pos, int64_t _endPos, int64_t _addingPos=0);
void cleanHighLight(void); void cleanHighLight(void);
appl::HighlightInfo* getElementColorAtPosition(int64_t _pos, int64_t &_starPos); 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); appl::HighlightInfo* getElementColorAtPosition(appl::DisplayHLData& _MData, int64_t _pos);
}; };
}; };

View File

@ -191,7 +191,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
m_displayText.setClipping(vec2(m_lastOffsetDisplay, 0), m_size); m_displayText.setClipping(vec2(m_lastOffsetDisplay, 0), m_size);
} }
appl::DisplayHLData displayLocalSyntax; 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; float maxSizeX = 0;
appl::HighlightInfo * HLColor = NULL; appl::HighlightInfo * HLColor = NULL;
bool DisplayCursorAndSelection = isSelectedLast(); bool DisplayCursorAndSelection = isSelectedLast();
@ -502,9 +502,18 @@ bool appl::TextViewer::onEventInput(const ewol::EventInput& _event) {
return true; return true;
} else if (_event.getStatus() == ewol::keyEvent::statusMove) { } else if (_event.getStatus() == ewol::keyEvent::statusMove) {
if (m_buffer->getSelectMode() == true) { if (m_buffer->getSelectMode() == true) {
//int64_t timeStart = ewol::getTime();
appl::Buffer::Iterator newPos = getMousePosition(relativePos); appl::Buffer::Iterator newPos = getMousePosition(relativePos);
//int64_t timeMedium1 = ewol::getTime();
moveCursor(newPos); moveCursor(newPos);
//int64_t timeMedium2 = ewol::getTime();
markToRedraw(); 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; return true;
} }
} }
@ -536,6 +545,7 @@ void appl::TextViewer::mouseEventTriple(void) {
m_buffer->setSelectionPos(m_buffer->getStartLine(m_buffer->cursor())); 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) { appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativePos) {
char32_t currentValue; char32_t currentValue;
vec3 positionCurentDisplay(0,0,0); vec3 positionCurentDisplay(0,0,0);
@ -549,6 +559,11 @@ appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativeP
(bool)it == true; (bool)it == true;
++it) { ++it) {
currentValue = *it; currentValue = *it;
if (currentValue == etk::UChar::Return) {
m_displayText.forceLineReturn();
countColomn = 0;
} else {
if (-_relativePos.y() >= positionCurentDisplay.y()) {
m_buffer->expand(countColomn, currentValue, stringToDisplay); m_buffer->expand(countColomn, currentValue, stringToDisplay);
for (size_t kkk=0; kkk<stringToDisplay.size(); ++kkk) { for (size_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
if (stringToDisplay[kkk] == etk::UChar::Return) { if (stringToDisplay[kkk] == etk::UChar::Return) {
@ -556,12 +571,13 @@ appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativeP
countColomn = 0; countColomn = 0;
} else { } else {
//note : Without this condithion the time od selection change to 0.6 ms to 8ms ... //note : Without this condithion the time od selection change to 0.6 ms to 8ms ...
if (-_relativePos.y() >= positionCurentDisplay.y()) { //APPL_DEBUG("check : " << -_relativePos.y() << ">=" << positionCurentDisplay.y());
m_displayText.print(stringToDisplay[kkk]); m_displayText.print(stringToDisplay[kkk]);
}
++countColomn; ++countColomn;
} }
} }
}
}
if (-_relativePos.y() >= positionCurentDisplay.y()) { if (-_relativePos.y() >= positionCurentDisplay.y()) {
if (-_relativePos.y() < positionCurentDisplay.y()+tmpLetterSize.y()) { if (-_relativePos.y() < positionCurentDisplay.y()+tmpLetterSize.y()) {
APPL_VERBOSE("line position : '" << (char)(*it) << "' = '" << stringToDisplay << "' n=" << countColomn << " " <<positionCurentDisplay.x() << " < " << _relativePos.x() << " < " << m_displayText.getPos().x() ); APPL_VERBOSE("line position : '" << (char)(*it) << "' = '" << stringToDisplay << "' n=" << countColomn << " " <<positionCurentDisplay.x() << " < " << _relativePos.x() << " < " << m_displayText.getPos().x() );
@ -697,6 +713,7 @@ void appl::TextViewer::setFontName(const std::string& _fontName) {
m_displayText.setFontName(_fontName); m_displayText.setFontName(_fontName);
} }
// TODO : Update process time ==> a little expensive (2->4ms) in end of file
void appl::TextViewer::updateScrolling(void) { void appl::TextViewer::updateScrolling(void) {
if (m_buffer == NULL) { if (m_buffer == NULL) {
return; return;

View File

@ -16,6 +16,13 @@
#undef __class__ #undef __class__
#define __class__ "Highlight" #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, void appl::Highlight::parseRules(exml::Element* _child,
std::vector<HighlightPattern*>& _mListPatern, std::vector<HighlightPattern*>& _mListPatern,
@ -57,7 +64,7 @@ appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _
if (child->getValue() == "ext") { if (child->getValue() == "ext") {
std::string myData = child->getText(); std::string myData = child->getText();
if (myData.size()!=0) { 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); m_listExtentions.push_back(myData);
} }
} else if (child->getValue() == "pass1") { } 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... /* 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... * Il suffirait juste de suprimer celui d'avant si il n'est pas terminer...
*/ */
void appl::Highlight::parse(int64_t start, void appl::Highlight::parse(int64_t _start,
int64_t stop, int64_t _stop,
std::vector<appl::HighlightInfo> &metaData, std::vector<appl::HighlightInfo> & _metaData,
int64_t addingPos, int64_t _addingPos,
etk::Buffer &buffer) { etk::Buffer & _buffer) {
if (0 > addingPos) { if (0 > _addingPos) {
addingPos = 0; _addingPos = 0;
} }
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.size() << " == > position search: (" << start << "," << stop << ")" ); HL_DEBUG("Parse element 0 => " << m_listHighlightPass1.size() << " == > position search: (" << _start << "," << _stop << ")" );
int64_t elementStart = start; int64_t elementStart = _start;
int64_t elementStop = stop; int64_t elementStop = _stop;
appl::HighlightInfo resultat; appl::HighlightInfo resultat;
while (elementStart<elementStop) { while (elementStart <= elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart); HL_DEBUG("Parse element in the buffer pos=" << elementStart);
//try to fond the HL in ALL of we have //try to fond the HL in ALL of we have
for (int64_t jjj=0; jjj<m_listHighlightPass1.size(); jjj++){ for (int64_t jjj=0; jjj<m_listHighlightPass1.size(); jjj++){
enum resultFind ret = HLP_FIND_OK; 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) // 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) {
//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... // 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 < metaData.size() ) { while(kkk < _metaData.size() ) {
if (metaData[kkk].beginStart <= resultat.endStop) { if (_metaData[kkk].beginStart <= resultat.endStop) {
// remove element // remove element
//APPL_INFO("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 < metaData.size()) { if (kkk < _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].beginStart-1;
} else { } else {
// end of the buffer // end of the buffer
elementStop = buffer.size(); elementStop = _buffer.size();
} }
} else { } else {
// Not find == > exit the cycle : // Not find == > exit the cycle :
@ -201,12 +208,12 @@ 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);
//APPL_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop ); 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 // update the current research starting element: (set position at the end of the current element
elementStart = resultat.endStop-1; elementStart = resultat.endStop-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
break; break;
} }
@ -221,26 +228,29 @@ void appl::Highlight::parse(int64_t start,
* @brief second pass of the hightlight * @brief second pass of the hightlight
* *
*/ */
void appl::Highlight::parse2(int64_t start, void appl::Highlight::parse2(int64_t _start,
int64_t stop, int64_t _stop,
std::vector<appl::HighlightInfo> &metaData, std::vector<appl::HighlightInfo> &_metaData,
etk::Buffer &buffer) { etk::Buffer &_buffer) {
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " == > position search: (" << start << "," << stop << ")" ); HL2_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() <<
int64_t elementStart = start; " == > position search: (" << _start << "," << _stop << ")" );
int64_t elementStop = stop; int64_t elementStart = _start;
int64_t elementStop = _stop;
appl::HighlightInfo resultat; appl::HighlightInfo resultat;
while (elementStart < elementStop) { while (elementStart < elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart); //HL2_DEBUG("Parse element in the buffer pos=" << elementStart << "," << _buffer.size() << ")" );
//try to fond the HL in ALL of we have //try to fond the HL in ALL of we have
for (int64_t jjj=0; jjj<m_listHighlightPass2.size(); jjj++){ for (int64_t jjj=0; jjj<m_listHighlightPass2.size(); jjj++){
enum resultFind ret = HLP_FIND_OK; 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) // 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) {
//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 ... // add curent element in the list ...
metaData.push_back(resultat); _metaData.push_back(resultat);
elementStart = resultat.endStop-1; elementStart = resultat.endStop-1;
// Exit current cycle // Exit current cycle
break; break;