HL : Correction of a bug of reparsing the buffer betwwen 2 element Erase was not implemented as std::vector ==> I might change this ...

This commit is contained in:
Edouard Dupin 2011-08-09 14:28:58 +02:00
parent 5a47446a09
commit d96a133c6a
5 changed files with 35 additions and 60 deletions

View File

@ -186,9 +186,10 @@ void Highlight::Display(void)
//m_listHighlightPass2[i]->Display();
}
}
// 13h 46min 22s | (l= 214) Highlight::Parse | [II] Find Pattern in the Buffer : (2457,2479)
// TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas tr\Uffffffffgrave... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
// TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas trègrave... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
void Highlight::Parse(int32_t start,
int32_t stop,
Edn::VectorType<colorInformation_ts> &metaData,
@ -205,8 +206,7 @@ void Highlight::Parse(int32_t start,
while (elementStart<elementStop) {
//EDN_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
int32_t jjj;
for (jjj=0; jjj<m_listHighlightPass1.Size(); jjj++){
for (int32_t jjj=0; jjj<m_listHighlightPass1.Size(); jjj++){
resultFind_te ret = HLP_FIND_OK;
//EDN_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
// Stop the search to the end (to get the end of the pattern)
@ -218,6 +218,7 @@ void Highlight::Parse(int32_t start,
while(kkk < metaData.Size() ) {
if (metaData[kkk].beginStart <= resultat.endStop) {
// Remove element
//EDN_INFO("Erase element=" << kkk);
metaData.Erase(kkk, kkk+1);
// Increase the end of search
if (kkk < metaData.Size()) {

View File

@ -60,8 +60,17 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
return;
}
// normal case
EDN_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");");
//EDN_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");");
int32_t i;
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
Edn::String ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
EDN_DEBUG("HighLight (previous) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
int32_t posEnd = pos + nbDeleted;
// search position of the old element to reparse IT...
int32_t startId;
@ -79,15 +88,29 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
} else if(-1 == startId) {
if (0 == stopId){
m_HLDataPass1.Erase(0);
//EDN_DEBUG("1 * Erase 0");
} else {
m_HLDataPass1.Erase(0,stopId);
//EDN_DEBUG("2 * Erase 0->" << stopId);
}
} else if(-1 == stopId) {
m_HLDataPass1.Erase(startId+1, m_HLDataPass1.Size());
//EDN_DEBUG("3 * Erase " << startId+1 << "-> end");
m_HLDataPass1.Erase(startId+1, m_HLDataPass1.Size() - startId);
stopId = -1;
} else {
m_HLDataPass1.Erase(startId+1, stopId);
//EDN_DEBUG("4 * Erase " << startId+1 << "->" << stopId);
m_HLDataPass1.Erase(startId+1, stopId - startId);
}
EDN_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1);
//EDN_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1);
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
Edn::String ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
EDN_DEBUG("HighLight (Middle) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
// update position after the range position :
int32_t elemStart;
if(-1 == startId) {
@ -123,13 +146,15 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
//GenerateHighLightAt(pos, nbAdded);
GenerateHighLightAt(0, m_data.Size());
}
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
Edn::String ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
//EDN_DEBUG("HighLight element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp.c_str() );
EDN_DEBUG("HighLight (end) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");

View File

@ -36,8 +36,6 @@
*
* @tparam[in] SIZE Size of the current element.
*
* @todo : Need to add : popBack / Assign / Insert / Erase / Swap / Clear
*
* m_data
* <------------ m_dataSize ------------>
* ----------------------------------------

View File

@ -17,7 +17,6 @@
- Project manager phase 1
# action a faire (ordonner) :
- HL : Parsing caracter/caractère et plus section par section ...
- ctags : Back simple et multiple
- ctags : Multiple files
- sys : search complet, replace complet

50
test2.c
View File

@ -19,54 +19,6 @@
#include "tools_globals.h"
#include "EdnBuf.h"
#undef __class__
#define __class__ "EdnBuf"
static void addPadding(char *string, int32_t startIndent, int32_t toIndent, int32_t tabDist, int32_t useTabs, int32_t *charsAdded);
static int32_t textWidth(EdnVectorBin<int8_t> &text, int32_t tabDist);
/**
* @brief convertion table for non printable control caracters
*/
static const char *ControlCodeTable[32] = {
"NUL", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "ht", "nl", "vt", "np", "cr", "so", "si",
"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb", "can", "em", "sub", "esc", "fs", "gs", "rs", "us"};
#endif
/**
* @brief Constructor of the Edn buffer Text :
*
* Create an empty text buffer of a pre-determined size
*
* @param[in] requestedSize use this to avoid unnecessary re-allocation if you know exactly how much the buffer will need to hold
*
*/
EdnBuf::EdnBuf(void)
{
m_tabDist = 4;
m_useTabs = true;
// Current selection
m_selectionList[SELECTION_PRIMARY].selected = false;
m_selectionList[SELECTION_PRIMARY].zeroWidth = false;
m_selectionList[SELECTION_PRIMARY].rectangular = false;
m_selectionList[SELECTION_PRIMARY].start = m_selectionList[SELECTION_PRIMARY].end = 0;
m_selectionList[SELECTION_SECONDARY].selected = false;
m_selectionList[SELECTION_SECONDARY].zeroWidth = false;
m_selectionList[SELECTION_SECONDARY].rectangular = false;
m_selectionList[SELECTION_SECONDARY].start = m_selectionList[SELECTION_SECONDARY].end = 0;
m_selectionList[SELECTION_HIGHTLIGHT].selected = false;
m_selectionList[SELECTION_HIGHTLIGHT].zeroWidth = false;
m_selectionList[SELECTION_HIGHTLIGHT].rectangular = false;
m_selectionList[SELECTION_HIGHTLIGHT].start = m_selectionList[SELECTION_HIGHTLIGHT].end = 0;
// charset :
m_isUtf8 = false;
m_charsetType = EDN_CHARSET_ISO_8859_1;
m_isUndoProcessing = false;
m_isRedoProcessing = false;
@ -77,4 +29,4 @@ EdnBuf::EdnBuf(void)
//m_Highlight = NULL;
m_nbLine = 1;
m_HLDataSequence = 0;
}