diff --git a/Sources/Buffer/Buffer.cpp b/Sources/Buffer/Buffer.cpp index 6e79b00..e7002b7 100644 --- a/Sources/Buffer/Buffer.cpp +++ b/Sources/Buffer/Buffer.cpp @@ -59,6 +59,10 @@ Buffer::Buffer() tmpAnchor.m_idAnchor = -1; tmpAnchor.m_lineId = 0; tmpAnchor.m_bufferPos = 0; + for(int32_t iii=0; iii Added"); } @@ -415,6 +426,10 @@ void Buffer::AnchorRm(int32_t anchorID) if (localID >=0) { if (m_AnchorList.Size() == 2) { m_AnchorList[0] = m_AnchorList[1]; + for(int32_t iii=0; iii Remove"); @@ -485,3 +500,78 @@ int32_t Buffer::AnchorCurrentId(void) } return 0; } + +void Buffer::AnchorForceRedrawAll(void) +{ + int32_t localID = AnchorCurrentId(); + if (localID >=0) { + m_AnchorList[localID].m_BufferNumberLineOffset = 0; + for(int32_t iii=0; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) { + m_AnchorList[localID].m_redrawLine[iii] = true; + } + } +} + +void Buffer::AnchorForceRedrawLine(int32_t lineID) +{ + for(int32_t iii=0; iii < m_AnchorList.Size(); iii++) { + if( m_AnchorList[iii].m_displayStart.y <= lineID + && m_AnchorList[iii].m_displayStart.y + MAX_LINE_DISPLAYABLE_BY_BUFFER > lineID ) + { + m_AnchorList[iii].m_redrawLine[lineID-m_AnchorList[iii].m_displayStart.y] = true; + } + } +} + + +// TODO : optimiser cette fonction qui met plusieurs fois des variables a true .... + +void Buffer::AnchorForceRedrawOffsef(int32_t offset) +{ + //offset *= -1; + //EDN_DEBUG("** => set ofset : " << offset); + int32_t localID = AnchorCurrentId(); + if (localID >=0) { + m_AnchorList[localID].m_BufferNumberLineOffset += offset; + + if (offset < 0) { + if (-1 * offset < MAX_LINE_DISPLAYABLE_BY_BUFFER) { + 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]); + m_AnchorList[localID].m_redrawLine[iii] = m_AnchorList[localID].m_redrawLine[iii+offset]; + } + 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"); + m_AnchorList[localID].m_redrawLine[iii] = true; + } + } + } else { + if (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]); + m_AnchorList[localID].m_redrawLine[iii] = m_AnchorList[localID].m_redrawLine[iii+offset]; + } + 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"); + 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"); + m_AnchorList[localID].m_redrawLine[iii] = 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; + } + } +} diff --git a/Sources/Buffer/Buffer.h b/Sources/Buffer/Buffer.h index ecdc8cb..91f77fe 100644 --- a/Sources/Buffer/Buffer.h +++ b/Sources/Buffer/Buffer.h @@ -31,6 +31,8 @@ #include "charset.h" #include "Edn.h" +#define MAX_LINE_DISPLAYABLE_BY_BUFFER (200) + extern "C" { typedef struct{ @@ -43,23 +45,27 @@ extern "C" }infoStatBuffer_ts; typedef struct { - int32_t m_idAnchor; //!< reference id of the anchor (real id of the upper displayer of CodeView) - bool m_curent; //!< set at true if the anchor is a reference with the curent display - int32_t m_lineId; //!< first line ID to display - int32_t m_bufferPos; //!< position of the first lineId - position_ts m_displayStart; //!< start display position - position_ts m_displaySize; //!< size of the curent display + int32_t m_idAnchor; //!< reference id of the anchor (real id of the upper displayer of CodeView) + bool m_curent; //!< set at true if the anchor is a reference with the curent display + int32_t m_lineId; //!< first line ID to display + int32_t m_bufferPos; //!< position of the first lineId + position_ts m_displayStart; //!< start display position + position_ts m_displaySize; //!< size of the curent display + bool m_redrawLine[MAX_LINE_DISPLAYABLE_BY_BUFFER]; //!< List of the current line that must be redisplayed + int32_t m_BufferNumberLineOffset; //!< number of line that might be an ofset on the curent screen } bufferAnchorReference_ts; typedef struct { - position_ts m_displayStart; //!< start display position - position_ts m_displaySize; //!< size of the curent display - int32_t m_lineNumber; //!< current line-number id - int32_t m_nbIterationMax; //!< number of cycle needed to end the dispalay - int32_t m_posStart; //!< position of the start of the line - int32_t m_posStop; //!< position of the end of the line - int32_t m_selectionPosStart; //!< position of the selection start - int32_t m_selectionPosStop; //!< position of the selection stop + position_ts m_displayStart; //!< start display position + position_ts m_displaySize; //!< size of the curent display + int32_t m_lineNumber; //!< current line-number id + int32_t m_nbIterationMax; //!< number of cycle needed to end the dispalay + int32_t m_posStart; //!< position of the start of the line + int32_t m_posStop; //!< position of the end of the line + int32_t m_selectionPosStart; //!< position of the selection start + int32_t m_selectionPosStop; //!< position of the selection stop + bool m_redrawLine[MAX_LINE_DISPLAYABLE_BY_BUFFER]; //!< List of the current line that must be redisplayed + int32_t m_BufferNumberLineOffset; //!< number of line that might be an ofset on the curent screen } bufferAnchor_ts; } @@ -152,6 +158,9 @@ class Buffer { int32_t m_lineHeight; int32_t AnchorRealId(int32_t anchorID); int32_t AnchorCurrentId(void); + void AnchorForceRedrawAll(void); + void AnchorForceRedrawLine(int32_t lineID); + void AnchorForceRedrawOffsef(int32_t offset); Edn::VectorType m_AnchorList; //!< list of all line anchor in the current buffer int32_t m_uniqueID; diff --git a/Sources/Buffer/BufferText.cpp b/Sources/Buffer/BufferText.cpp index 281a8c5..9b89d25 100644 --- a/Sources/Buffer/BufferText.cpp +++ b/Sources/Buffer/BufferText.cpp @@ -86,7 +86,6 @@ void BufferText::NameChange(void) m_EdnBuf.SetHLSystem(myHL); } } - } @@ -183,7 +182,7 @@ BufferText::~BufferText(void) */ void BufferText::GetInfo(infoStatBuffer_ts &infoToUpdate) { - + EDN_WARNING("TODO ..."); } /** @@ -196,7 +195,7 @@ void BufferText::GetInfo(infoStatBuffer_ts &infoToUpdate) */ void BufferText::SetLineDisplay(uint32_t lineNumber) { - + EDN_WARNING("TODO ..."); } @@ -515,6 +514,8 @@ void BufferText::SelectNone(void) m_EdnBuf.Unselect(SELECTION_PRIMARY); } +#define SCROLL_NB_LINE (3) + /** * @brief * @@ -525,7 +526,8 @@ void BufferText::SelectNone(void) */ void BufferText::ScrollDown(void) { - MoveUpDown(3); + + MoveUpDown(SCROLL_NB_LINE); } @@ -539,7 +541,7 @@ void BufferText::ScrollDown(void) */ void BufferText::ScrollUp(void) { - MoveUpDown(-3); + MoveUpDown(-1 * SCROLL_NB_LINE); } @@ -558,7 +560,9 @@ void BufferText::MoveUpDown(int32_t ofset) int32_t nbLine = m_EdnBuf.NumberOfLines(); if (m_AnchorList[iii].m_displayStart.y+ofset+3 > nbLine) { m_AnchorList[iii].m_displayStart.y = nbLine-3; + AnchorForceRedrawOffsef(m_AnchorList[iii].m_displayStart.y-(nbLine-3)); } else { + AnchorForceRedrawOffsef(ofset); m_AnchorList[iii].m_displayStart.y += ofset; } m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y); @@ -566,10 +570,12 @@ void BufferText::MoveUpDown(int32_t ofset) } else { ofset *= -1; if (m_AnchorList[iii].m_displayStart.y < ofset) { + AnchorForceRedrawOffsef(-1 * m_AnchorList[iii].m_displayStart.y); m_AnchorList[iii].m_displayStart.y = 0; m_AnchorList[iii].m_bufferPos = 0; m_AnchorList[iii].m_lineId = 0; } else { + AnchorForceRedrawOffsef(-1 * ofset); m_AnchorList[iii].m_displayStart.y -= ofset; m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y); m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y; @@ -703,6 +709,7 @@ bool BufferText::TextDMoveDown(int32_t offset) */ void BufferText::cursorMove(int32_t gtkKey) { + int32_t tmplineID; bool needUpdatePosition = true; switch(gtkKey) { # ifdef USE_GTK_VERSION_3_0 @@ -714,6 +721,8 @@ void BufferText::cursorMove(int32_t gtkKey) if (m_cursorPos > 0) { SetInsertPosition(m_cursorPos - 1); } + tmplineID = m_EdnBuf.CountLines(0, m_cursorPos); + AnchorForceRedrawLine(tmplineID); break; # ifdef USE_GTK_VERSION_3_0 case GDK_KEY_Right: @@ -724,6 +733,8 @@ void BufferText::cursorMove(int32_t gtkKey) if (m_cursorPos < m_EdnBuf.Size() ) { SetInsertPosition(m_cursorPos + 1); } + tmplineID = m_EdnBuf.CountLines(0, m_cursorPos); + AnchorForceRedrawLine(tmplineID); break; # ifdef USE_GTK_VERSION_3_0 case GDK_KEY_Up: @@ -731,7 +742,10 @@ void BufferText::cursorMove(int32_t gtkKey) case GDK_Up: # endif //EDN_INFO("keyEvent : "); + tmplineID = m_EdnBuf.CountLines(0, m_cursorPos); + AnchorForceRedrawLine(tmplineID); TextDMoveUp(1); + AnchorForceRedrawLine(tmplineID-1); break; # ifdef USE_GTK_VERSION_3_0 case GDK_KEY_Down: @@ -740,7 +754,10 @@ void BufferText::cursorMove(int32_t gtkKey) # endif //EDN_INFO("keyEvent : "); // check if we have enought line ... + tmplineID = m_EdnBuf.CountLines(0, m_cursorPos); + AnchorForceRedrawLine(tmplineID); TextDMoveDown(1); + AnchorForceRedrawLine(tmplineID+1); break; # ifdef USE_GTK_VERSION_3_0 case GDK_KEY_Page_Up: @@ -975,7 +992,8 @@ void BufferText::AddChar(char * UTF8data) } } } - + int32_t tmplineID = m_EdnBuf.CountLines(0, m_cursorPos); + AnchorForceRedrawLine(tmplineID); SetModify(true); UpdateWindowsPosition(); } @@ -1248,7 +1266,7 @@ bool BufferText::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor) anchor.m_displayStart.y = m_AnchorList[localID].m_displayStart.y; anchor.m_nbIterationMax = anchor.m_displaySize.y; // update to buffer position - anchor.m_lineNumber = m_AnchorList[localID].m_lineId +1; + anchor.m_lineNumber = m_AnchorList[localID].m_lineId+1; anchor.m_posStart = m_AnchorList[localID].m_bufferPos; if (anchor.m_posStart >= m_EdnBuf.Size()+1) { return false; @@ -1265,6 +1283,17 @@ bool BufferText::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor) anchor.m_selectionPosStart = selStart+1; anchor.m_selectionPosStop = selEnd+1; } + EDN_DEBUG("SET in anchor " << m_AnchorList[localID].m_displaySize.y << " lines to display"); + for(int32_t iii=0; iii m_AnchorList[localID].m_displaySize.y - 4) { + anchor.m_redrawLine[iii] = true; + }*/ + } + anchor.m_BufferNumberLineOffset = m_AnchorList[localID].m_BufferNumberLineOffset; + m_AnchorList[localID].m_BufferNumberLineOffset = 0; + EDN_DEBUG("Request display : line=" << anchor.m_lineNumber << " (" << anchor.m_posStart << "," << anchor.m_posStop << ")"); EDN_DEBUG(" ==> select : (" << anchor.m_selectionPosStart << "," << anchor.m_selectionPosStop << ")"); return true; diff --git a/Sources/CustumWidget/CodeView/CodeView.cpp b/Sources/CustumWidget/CodeView/CodeView.cpp index 3fd4e62..2f78c02 100644 --- a/Sources/CustumWidget/CodeView/CodeView.cpp +++ b/Sources/CustumWidget/CodeView/CodeView.cpp @@ -235,15 +235,8 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo ColorizeManager *myColorManager = NULL; myColorManager = ColorizeManager::getInstance(); - DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY); Buffer * tmpBuf = self->m_bufferManager->Get(self->m_bufferID); - // set cursor : - /* - GdkCursor plop; - plop.GSEAL = GDK_PENCIL; - gdk_window_set_cursor(gtk_widget_get_window(self->m_widget), &plop); - */ #ifdef COUNT_TIME GTimeVal timeStart; g_get_current_time(&timeStart); @@ -252,19 +245,27 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo tmpBuf->AnchorSetSize(self->m_displayUniqueId, self->m_shawableAreaX, self->m_shawableAreaY); bool enableToWrite = tmpBuf->AnchorGet(self->m_displayUniqueId, anchor); + DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY, Display::GetFontHeight()*anchor.m_BufferNumberLineOffset); + + int32_t currentLineID = 0; while (true == enableToWrite) { - tmpBuf->DrawLine(monDrawer, anchor); + if (true == anchor.m_redrawLine[currentLineID]) { + EDN_DEBUG("draw line : " << currentLineID); + tmpBuf->DrawLine(monDrawer, anchor); + } enableToWrite = tmpBuf->AnchorNext(anchor); + currentLineID++; } monDrawer.Flush(); // Need to clean the end of windows (sometimes)... - /* - if (iiiGet(COLOR_CODE_BASIC_BG), 0, positionY, drawer.GetWidth(), letterHeight*(lineIdEnd+1-iii) ); + if(currentLineIDGet(COLOR_CODE_BASIC_BG), 0, positionY, monDrawer.GetWidth(), positionZ ); + monDrawer.Rectangle(myColorManager->Get(COLOR_CODE_CURSOR), 0, positionY, monDrawer.GetWidth(), positionZ ); + currentLineID ++; } - */ #ifdef COUNT_TIME GTimeVal timeStop; g_get_current_time(&timeStop); diff --git a/Sources/tools/Display/Display.cpp b/Sources/tools/Display/Display.cpp index 12c557e..b4fe61e 100644 --- a/Sources/tools/Display/Display.cpp +++ b/Sources/tools/Display/Display.cpp @@ -40,7 +40,7 @@ #define FONT_ITALIC_YES (1) -// Variables privĂ© du namespace +// Variables privé du namespace #define POLICE_NAME "Monospace" #ifdef USE_GTK_VERSION_3_0 @@ -140,7 +140,7 @@ cairo_font_face_t * Display::GetFont(bool bold, bool italic) * @return --- * */ -DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y) +DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y, int32_t scrollOffset) { m_size.x = x; m_size.y = y; @@ -162,8 +162,10 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y) m_cairo = gdk_cairo_create(m_windows); // Copy the previous display data from the current display to the double buffer area: cairo_surface_t * drawableSurface = cairo_get_target(cairoWindows); + TranslateVertical(-1* scrollOffset); cairo_set_source_surface(m_cairo, drawableSurface, 0, 0); cairo_paint(m_cairo); + TranslateVertical(scrollOffset); //cairo_surface_destroy(drawableSurface); cairo_destroy(cairoWindows); } @@ -172,7 +174,7 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y) // for Test only : this remove slowly the old line that is not rewritten cairo_set_source_rgb(m_cairo, 0, 0, 0); - cairo_set_source_rgba(m_cairo, 1, 1, 1, 0.3); + cairo_set_source_rgba(m_cairo, 1, 1, 1, 0.05); cairo_paint(m_cairo); cairo_set_font_size(m_cairo, POLICE_SIZE); @@ -598,6 +600,14 @@ void DrawerManager::UTF8UnknownElement(Colorize *SelectColor, int32_t x, int32_t } +void DrawerManager::TranslateVertical(int32_t nbPixelTranslation) +{ + Flush(); + //scale((xmax-xmin)/W, (ymax-ymin)/H) + cairo_translate(m_cairo, 0, nbPixelTranslation); + cairo_fill(m_cairo); + cairo_paint(m_cairo); +} /* Basic axample with cairo and pango... diff --git a/Sources/tools/Display/Display.h b/Sources/tools/Display/Display.h index ce418e0..2c3f921 100644 --- a/Sources/tools/Display/Display.h +++ b/Sources/tools/Display/Display.h @@ -52,7 +52,7 @@ class DrawerManager; class DrawerManager { public: // Constructeur - DrawerManager(GtkWidget * widget, int32_t x, int32_t y); + DrawerManager(GtkWidget * widget, int32_t x, int32_t y, int32_t scrollOffset=0); ~DrawerManager(); void Rectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height); @@ -72,6 +72,7 @@ class DrawerManager { void Flush(void); int32_t GetWidth(void) { return m_size.x; }; int32_t GetHeight(void) { return m_size.y; }; + void TranslateVertical(int32_t nbPixelTranslation); private: void DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height);