basic optimisation of line update ==> not tested
This commit is contained in:
parent
7cf06ba256
commit
4477ef0ab5
@ -530,6 +530,7 @@ int32_t Buffer::AnchorCurrentId(void)
|
||||
|
||||
void Buffer::AnchorForceRedrawAll(int32_t realAnchorId)
|
||||
{
|
||||
EDN_DEBUG("AnchorForceRedrawAll(" << realAnchorId << ")");
|
||||
if (-5000 == realAnchorId) {
|
||||
int32_t localID = AnchorCurrentId();
|
||||
if (localID >=0) {
|
||||
@ -572,51 +573,47 @@ void Buffer::AnchorForceRedrawOffsef(int32_t offset)
|
||||
EDN_DEBUG("offset ID=" << localID);
|
||||
m_AnchorList[localID].m_BufferNumberLineOffset += offset;
|
||||
|
||||
EDN_DEBUG("move redraw request : [" << m_AnchorList[localID].m_displaySize.y << "," << MAX_LINE_DISPLAYABLE_BY_BUFFER << "[=true");
|
||||
for(int32_t iii=m_AnchorList[localID].m_displaySize.y; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) {
|
||||
m_AnchorList[localID].m_redrawLine[iii] = true;
|
||||
}
|
||||
|
||||
int32_t maxSize = edn_min(m_AnchorList[localID].m_displaySize.y, MAX_LINE_DISPLAYABLE_BY_BUFFER);
|
||||
|
||||
if (offset < 0) {
|
||||
if (-1 * offset < MAX_LINE_DISPLAYABLE_BY_BUFFER) {
|
||||
EDN_DEBUG("move redraw request : [" << -1*offset << "," << MAX_LINE_DISPLAYABLE_BY_BUFFER << "[=[" << -1*offset + offset << "," << MAX_LINE_DISPLAYABLE_BY_BUFFER+offset << "[");
|
||||
//for(int32_t iii=MAX_LINE_DISPLAYABLE_BY_BUFFER; iii >= -1*offset; iii--) {
|
||||
for(int32_t iii=-1*offset; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) {
|
||||
//EDN_DEBUG("move redraw request : " << iii << " <== " << iii+offset << " val=" << m_AnchorList[localID].m_redrawLine[iii+offset]);
|
||||
if (-1 * offset < maxSize) {
|
||||
EDN_DEBUG("move redraw request : ]" << maxSize << "," << -1*offset << "]=]" << maxSize+offset << "," << -1*offset + offset << "]");
|
||||
for(int32_t iii=maxSize-1; iii >= -1*offset; iii--) {
|
||||
m_AnchorList[localID].m_redrawLine[iii] = m_AnchorList[localID].m_redrawLine[iii+offset];
|
||||
}
|
||||
EDN_DEBUG("move redraw request : [" << 0 << "," << -1*offset << "[=true");
|
||||
for(int32_t iii=0; iii < -1*offset; iii++) {
|
||||
//EDN_DEBUG("move redraw request : " << iii << " <== true");
|
||||
m_AnchorList[localID].m_redrawLine[iii] = true;
|
||||
}
|
||||
} else {
|
||||
EDN_WARNING("FORCE a total redraw... 1");
|
||||
for(int32_t iii=0; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) {
|
||||
//EDN_DEBUG("move redraw request : " << iii << " <== true");
|
||||
for(int32_t iii=0; iii < maxSize; iii++) {
|
||||
m_AnchorList[localID].m_redrawLine[iii] = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (offset < MAX_LINE_DISPLAYABLE_BY_BUFFER) {
|
||||
EDN_DEBUG("move redraw request : [" << 0 << "," << MAX_LINE_DISPLAYABLE_BY_BUFFER-offset << "[=[" << offset << "," << MAX_LINE_DISPLAYABLE_BY_BUFFER << "[");
|
||||
for(int32_t iii=0; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER-offset ; iii++) {
|
||||
//EDN_DEBUG("move redraw request : " << iii << " <== " << iii+offset << " val=" << m_AnchorList[localID].m_redrawLine[iii+offset]);
|
||||
if (offset < maxSize) {
|
||||
EDN_DEBUG("move redraw request : [" << 0 << "," << maxSize-offset << "[=[" << offset << "," << maxSize << "[");
|
||||
for(int32_t iii=0; iii < maxSize-offset ; iii++) {
|
||||
m_AnchorList[localID].m_redrawLine[iii] = m_AnchorList[localID].m_redrawLine[iii+offset];
|
||||
}
|
||||
EDN_DEBUG("move redraw request : [" << MAX_LINE_DISPLAYABLE_BY_BUFFER-offset+1 << "," << MAX_LINE_DISPLAYABLE_BY_BUFFER << "[=true");
|
||||
for(int32_t iii=MAX_LINE_DISPLAYABLE_BY_BUFFER-offset+1; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) {
|
||||
//EDN_DEBUG("move redraw request : " << iii << " <== true");
|
||||
// note the -1 is to force the redisplay of the previous of the last line ==> special case of the gtk 3.0 marker to resize the windows
|
||||
EDN_DEBUG("move redraw request : [" << maxSize-offset-1 << "," << maxSize << "[=true");
|
||||
for(int32_t iii=maxSize-offset-1; iii < maxSize; iii++) {
|
||||
m_AnchorList[localID].m_redrawLine[iii] = true;
|
||||
}
|
||||
} else {
|
||||
EDN_WARNING("FORCE a total redraw... 2");
|
||||
for(int32_t iii=0; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) {
|
||||
//EDN_DEBUG("move redraw request : " << iii << " <== true");
|
||||
for(int32_t iii=0; iii < maxSize; iii++) {
|
||||
m_AnchorList[localID].m_redrawLine[iii] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
EDN_DEBUG("move redraw request : [" << m_AnchorList[localID].m_displaySize.y << "," << MAX_LINE_DISPLAYABLE_BY_BUFFER << "[=true");
|
||||
for(int32_t iii=m_AnchorList[localID].m_displaySize.y; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) {
|
||||
//EDN_DEBUG("move redraw request : " << iii << " <== true");
|
||||
m_AnchorList[localID].m_redrawLine[iii] = true;
|
||||
}
|
||||
} else {
|
||||
EDN_ERROR("can not find the real ID in linste.Size()=" << m_AnchorList.Size());
|
||||
}
|
||||
|
@ -807,24 +807,23 @@ void BufferText::cursorMove(int32_t gtkKey)
|
||||
*/
|
||||
void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
{
|
||||
int32_t linePreviousID = m_EdnBuf.CountLines(0, m_cursorPosPrevious);
|
||||
AnchorForceRedrawLine(linePreviousID);
|
||||
|
||||
if (centerPage == false) {
|
||||
// Display position (Y mode):
|
||||
int32_t lineStartPos;
|
||||
// Get current position of cursor :
|
||||
position_ts cursorPosition;
|
||||
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
|
||||
AnchorForceRedrawLine(cursorPosition.y);
|
||||
lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
|
||||
cursorPosition.x = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos);
|
||||
//EDN_INFO(" curent cursor position : (" << cursorPosition.x << "," << cursorPosition.y << ")");
|
||||
int32_t iii = AnchorCurrentId();
|
||||
if (iii >=0) {
|
||||
int32_t linePreviousID = m_EdnBuf.GetLinesIdWithRef(m_cursorPosPrevious, m_AnchorList[iii].m_bufferPos, m_AnchorList[iii].m_lineId);
|
||||
AnchorForceRedrawLine(linePreviousID);
|
||||
|
||||
// Done for all Anchor elements ...
|
||||
//for (int32_t iii=0; iii < m_AnchorList.Size() ; iii++) {
|
||||
int32_t iii = AnchorCurrentId();
|
||||
if (iii >=0) {
|
||||
if (centerPage == false) {
|
||||
// Display position (Y mode):
|
||||
int32_t lineStartPos;
|
||||
// Get current position of cursor :
|
||||
position_ts cursorPosition;
|
||||
EDN_WARNING("plop");
|
||||
cursorPosition.y = m_EdnBuf.GetLinesIdWithRef(m_cursorPos, m_AnchorList[iii].m_bufferPos, m_AnchorList[iii].m_lineId);
|
||||
AnchorForceRedrawLine(cursorPosition.y);
|
||||
lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
|
||||
cursorPosition.x = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos);
|
||||
//EDN_INFO(" curent cursor position : (" << cursorPosition.x << "," << cursorPosition.y << ")");
|
||||
|
||||
position_ts displayPreviousStart = m_AnchorList[iii].m_displayStart;
|
||||
//EDN_INFO(" m_displayStart(" << m_AnchorList[iii].m_displayStart.x << "," << m_AnchorList[iii].m_displayStart.y << ") m_displaySize(" << m_AnchorList[iii].m_displaySize.x << "," << m_AnchorList[iii].m_displaySize.y << ")");
|
||||
if (m_AnchorList[iii].m_displayStart.y > (int32_t)cursorPosition.y - globals::getNbLineBorder() ) {
|
||||
@ -853,10 +852,10 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
AnchorForceRedrawAll(iii);
|
||||
} else {
|
||||
if (m_AnchorList[iii].m_displayStart.y != displayPreviousStart.y) {
|
||||
EDN_WARNING("SELECT an ofset : displayPreviousStart.y=" << displayPreviousStart.y << " m_AnchorList[iii].m_displayStart.y=" << m_AnchorList[iii].m_displayStart.y << " ==>" << m_AnchorList[iii].m_displayStart.y - displayPreviousStart.y);
|
||||
EDN_WARNING("SELECT ... offset = " << m_AnchorList[iii].m_BufferNumberLineOffset);
|
||||
//EDN_WARNING("SELECT an ofset : displayPreviousStart.y=" << displayPreviousStart.y << " m_AnchorList[iii].m_displayStart.y=" << m_AnchorList[iii].m_displayStart.y << " ==>" << m_AnchorList[iii].m_displayStart.y - displayPreviousStart.y);
|
||||
//EDN_WARNING("SELECT ... offset = " << m_AnchorList[iii].m_BufferNumberLineOffset);
|
||||
AnchorForceRedrawOffsef(m_AnchorList[iii].m_displayStart.y - displayPreviousStart.y);
|
||||
EDN_WARNING("SELECT ... offset = " << m_AnchorList[iii].m_BufferNumberLineOffset);
|
||||
//EDN_WARNING("SELECT ... offset = " << m_AnchorList[iii].m_BufferNumberLineOffset);
|
||||
}
|
||||
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
|
||||
bool SelectionIsRect;
|
||||
@ -864,24 +863,20 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
if (true == haveSelectionActive) {
|
||||
int32_t start = edn_min(linePreviousID, cursorPosition.y);
|
||||
int32_t stop = edn_max(linePreviousID, cursorPosition.y);
|
||||
EDN_WARNING("SELECT force redraw range of lines : (" << start << "," << stop << ")");
|
||||
//EDN_WARNING("SELECT force redraw range of lines : (" << start << "," << stop << ")");
|
||||
for (int32_t jjj=start; jjj <= stop; jjj++) {
|
||||
AnchorForceRedrawLine(jjj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// center the line at the middle of the screen :
|
||||
position_ts cursorPosition;
|
||||
//EDN_DEBUG(" -------------------------------------------------");
|
||||
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
|
||||
//EDN_DEBUG(" cursor position : " << m_cursorPos << " ==> ligne=" << cursorPosition.y);
|
||||
cursorPosition.x = 0;
|
||||
// Done for all Anchor elements ...
|
||||
//for (int32_t iii=0; iii < m_AnchorList.Size() ; iii++) {
|
||||
int32_t iii = AnchorCurrentId();
|
||||
if (iii >=0) {
|
||||
} else {
|
||||
// center the line at the middle of the screen :
|
||||
position_ts cursorPosition;
|
||||
//EDN_DEBUG(" -------------------------------------------------");
|
||||
cursorPosition.y = m_EdnBuf.GetLinesIdWithRef(m_cursorPos, m_AnchorList[iii].m_bufferPos, m_AnchorList[iii].m_lineId);
|
||||
//EDN_DEBUG(" cursor position : " << m_cursorPos << " ==> ligne=" << cursorPosition.y);
|
||||
cursorPosition.x = 0;
|
||||
|
||||
m_AnchorList[iii].m_displayStart.x = 0;
|
||||
//EDN_DEBUG(" display size : " << m_displaySize.y);
|
||||
m_AnchorList[iii].m_displayStart.y = cursorPosition.y - m_AnchorList[iii].m_displaySize.y/2;
|
||||
|
@ -646,8 +646,22 @@ int32_t EdnBuf::CountLines(int32_t startPos, int32_t endPos)
|
||||
EdnVectorBuf::Iterator myPosIt = m_data.Position(startPos);
|
||||
int32_t lineCount = 0;
|
||||
|
||||
#ifndef NDEBUG
|
||||
GTimeVal timeStart;
|
||||
if (0 == startPos) {
|
||||
g_get_current_time(&timeStart);
|
||||
}
|
||||
#endif
|
||||
|
||||
while (myPosIt) {
|
||||
if (myPosIt.Position() == endPos) {
|
||||
#ifndef NDEBUG
|
||||
if (0 == startPos) {
|
||||
GTimeVal timeStop;
|
||||
g_get_current_time(&timeStop);
|
||||
EDN_ERROR("Count line (" << startPos << "," << endPos << ") time = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
|
||||
}
|
||||
#endif
|
||||
return lineCount;
|
||||
}
|
||||
if ('\n' == *myPosIt) {
|
||||
@ -655,6 +669,76 @@ int32_t EdnBuf::CountLines(int32_t startPos, int32_t endPos)
|
||||
}
|
||||
myPosIt++;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (0 == startPos) {
|
||||
GTimeVal timeStop;
|
||||
g_get_current_time(&timeStop);
|
||||
EDN_ERROR("Count line (" << startPos << "," << endPos << ") time = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
|
||||
}
|
||||
#endif
|
||||
|
||||
return lineCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Id of the line where is positionned the current pos element
|
||||
*
|
||||
* @param[in] pos posithion in the buffer where we need to know the current line
|
||||
* @param[in] refPos reference position
|
||||
* @param[in] refLine reference Line of the position
|
||||
*
|
||||
* @return the current line ID of the pos
|
||||
*
|
||||
*/
|
||||
int32_t EdnBuf::GetLinesIdWithRef(int32_t pos, int32_t refPos, int32_t refLine)
|
||||
{
|
||||
EdnVectorBuf::Iterator myPosIt = m_data.Position(refPos);
|
||||
int32_t lineCount = refLine;
|
||||
|
||||
#ifndef NDEBUG
|
||||
GTimeVal timeStart;
|
||||
g_get_current_time(&timeStart);
|
||||
#endif
|
||||
if (pos == refPos) {
|
||||
return refLine;
|
||||
} else if (pos > refPos) {
|
||||
while (myPosIt) {
|
||||
if (myPosIt.Position() == pos) {
|
||||
#ifndef NDEBUG
|
||||
GTimeVal timeStop;
|
||||
g_get_current_time(&timeStop);
|
||||
EDN_DEBUG("Count line " << pos << " with ref(" << refPos << "," << refPos << ") time = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
|
||||
#endif
|
||||
return lineCount;
|
||||
}
|
||||
if ('\n' == *myPosIt) {
|
||||
lineCount++;
|
||||
}
|
||||
myPosIt++;
|
||||
}
|
||||
} else {
|
||||
while (myPosIt) {
|
||||
if (myPosIt.Position() == pos) {
|
||||
#ifndef NDEBUG
|
||||
GTimeVal timeStop;
|
||||
g_get_current_time(&timeStop);
|
||||
EDN_DEBUG("Count line " << pos << " with ref(" << refPos << "," << refPos << ") time = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
|
||||
#endif
|
||||
return lineCount;
|
||||
}
|
||||
if ('\n' == *myPosIt) {
|
||||
lineCount--;
|
||||
}
|
||||
myPosIt--;
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
GTimeVal timeStop;
|
||||
g_get_current_time(&timeStop);
|
||||
EDN_DEBUG("Count line " << pos << " with ref(" << refPos << "," << refPos << ") time = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
|
||||
#endif
|
||||
|
||||
return lineCount;
|
||||
}
|
||||
|
||||
@ -685,12 +769,21 @@ int32_t EdnBuf::CountLines(void)
|
||||
EdnVectorBuf::Iterator myPosIt = m_data.Begin();
|
||||
int32_t lineCount = 0;
|
||||
|
||||
#ifndef NDEBUG
|
||||
GTimeVal timeStart;
|
||||
g_get_current_time(&timeStart);
|
||||
#endif
|
||||
while(myPosIt) {
|
||||
if ('\n' == *myPosIt) {
|
||||
lineCount++;
|
||||
}
|
||||
myPosIt++;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
GTimeVal timeStop;
|
||||
g_get_current_time(&timeStop);
|
||||
EDN_DEBUG("count total number of line time = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
|
||||
#endif
|
||||
return lineCount;
|
||||
}
|
||||
|
||||
@ -720,6 +813,12 @@ void EdnBuf::CountNumberOfLines(void)
|
||||
*/
|
||||
int32_t EdnBuf::CountForwardNLines(int32_t startPos, int32_t nLines)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
GTimeVal timeStart;
|
||||
if (0 == startPos) {
|
||||
g_get_current_time(&timeStart);
|
||||
}
|
||||
#endif
|
||||
if (nLines == 0) {
|
||||
return startPos;
|
||||
} else if (startPos > m_data.Size() ) {
|
||||
@ -739,6 +838,14 @@ int32_t EdnBuf::CountForwardNLines(int32_t startPos, int32_t nLines)
|
||||
}
|
||||
myPosIt++;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (0 == startPos) {
|
||||
GTimeVal timeStop;
|
||||
g_get_current_time(&timeStop);
|
||||
EDN_DEBUG("get poiner line (pos=" << startPos << "=>" << nLines << "lines) time = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
|
||||
}
|
||||
#endif
|
||||
//EDN_INFO(" ==> (2) at position=" << myPosIt.Position() );
|
||||
return myPosIt.Position();
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ class EdnBuf {
|
||||
int32_t CharWidth( char c, int32_t indent); // TODO : rework this
|
||||
int32_t CountDispChars( int32_t lineStartPos, int32_t targetPos);
|
||||
int32_t CountForwardDispChars( int32_t lineStartPos, int32_t nChars);
|
||||
int32_t GetLinesIdWithRef( int32_t pos, int32_t refPos, int32_t refLine);
|
||||
int32_t CountLines( int32_t startPos, int32_t endPos);
|
||||
int32_t CountLines( void);
|
||||
int32_t CountLines( Edn::VectorType<int8_t> &data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user