diff --git a/Sources/Buffer/Buffer.cpp b/Sources/Buffer/Buffer.cpp index f66ffc1..8edbbc3 100644 --- a/Sources/Buffer/Buffer.cpp +++ b/Sources/Buffer/Buffer.cpp @@ -53,7 +53,10 @@ Buffer::Buffer() tmpAnchor.m_idAnchor = -1; tmpAnchor.m_lineId = 0; tmpAnchor.m_bufferPos = 0; - m_AnchorList .PushBack(tmpAnchor); + m_AnchorList.PushBack(tmpAnchor); + + m_lineWidth = 10; + m_lineHeight = 10; } /** @@ -158,7 +161,7 @@ void Buffer::SetLineDisplay(uint32_t lineNumber) * @return --- * */ -void Buffer::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize) +void Buffer::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor) { return; } @@ -174,10 +177,9 @@ void Buffer::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_t * @todo : Set the move up and DOWN... * */ -position_ts Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height) +void Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } @@ -190,10 +192,9 @@ position_ts Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height) * @return --- * */ -position_ts Buffer::MouseEvent(int32_t width, int32_t height) +void Buffer::MouseEvent(int32_t width, int32_t height) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } /** @@ -204,10 +205,9 @@ position_ts Buffer::MouseEvent(int32_t width, int32_t height) * @return --- * */ -position_ts Buffer::MouseEventDouble(void) +void Buffer::MouseEventDouble(void) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } /** @@ -218,10 +218,9 @@ position_ts Buffer::MouseEventDouble(void) * @return --- * */ -position_ts Buffer::MouseEventTriple(void) +void Buffer::MouseEventTriple(void) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } @@ -260,10 +259,9 @@ void Buffer::ScrollUp(void) * @return --- * */ -position_ts Buffer::cursorMove(int32_t gtkKey) +void Buffer::cursorMove(int32_t gtkKey) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } /** @@ -274,22 +272,19 @@ position_ts Buffer::cursorMove(int32_t gtkKey) * @return --- * */ -position_ts Buffer::AddChar(char * UTF8data) +void Buffer::AddChar(char * UTF8data) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } -position_ts Buffer::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) +void Buffer::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } -position_ts Buffer::Replace(Edn::String &data) +void Buffer::Replace(Edn::String &data) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } int32_t Buffer::FindLine(Edn::String &data) @@ -298,10 +293,9 @@ int32_t Buffer::FindLine(Edn::String &data) return 0; } -position_ts Buffer::JumpAtLine(int32_t newLine) +void Buffer::JumpAtLine(int32_t newLine) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } @@ -341,10 +335,9 @@ void Buffer::Copy(int8_t clipboardID) * @return --- * */ -position_ts Buffer::Cut(int8_t clipboardID) +void Buffer::Cut(int8_t clipboardID) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } @@ -356,40 +349,34 @@ position_ts Buffer::Cut(int8_t clipboardID) * @return --- * */ -position_ts Buffer::Paste(int8_t clipboardID) +void Buffer::Paste(int8_t clipboardID) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } -position_ts Buffer::RemoveLine(void) +void Buffer::RemoveLine(void) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do; } -position_ts Buffer::SelectAll(void) +void Buffer::SelectAll(void) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } -position_ts Buffer::SelectNone(void) +void Buffer::SelectNone(void) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } -position_ts Buffer::Undo(void) +void Buffer::Undo(void) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } -position_ts Buffer::Redo(void) +void Buffer::Redo(void) { - position_ts tmp = {0,0}; - return tmp; + // nothing to do } @@ -426,7 +413,7 @@ void Buffer::AnchorRm(int32_t anchorID) } -bool Buffer::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY) +bool Buffer::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor) { EDN_ERROR("AnchorID="<< anchorID << " Main buffer ==> can not manage Anchor (type buffer specific)"); return false; @@ -440,6 +427,32 @@ bool Buffer::AnchorNext(bufferAnchor_ts & anchor) } +void Buffer::AnchorSetSize(int32_t anchorID, int32_t sizePixelX, int32_t sizePixelY) +{ + int32_t localID = AnchorRealId(anchorID); + if (localID >=0) { + m_AnchorList[localID].m_displaySize.x = sizePixelX / m_lineWidth; + m_AnchorList[localID].m_displaySize.y = sizePixelY / m_lineHeight; + } +} + + +void Buffer::AnchorSetStartOffset(int32_t anchorID, int32_t offsetX, int32_t offsetY) +{ + int32_t localID = AnchorRealId(anchorID); + if (localID >=0) { + m_AnchorList[localID].m_displayStart.x += offsetX; + if (0 m_AnchorList; //!< list of all line anchor in the current buffer diff --git a/Sources/Buffer/BufferEmpty.cpp b/Sources/Buffer/BufferEmpty.cpp index 0c32bb5..e599ae7 100644 --- a/Sources/Buffer/BufferEmpty.cpp +++ b/Sources/Buffer/BufferEmpty.cpp @@ -42,7 +42,8 @@ */ BufferEmpty::BufferEmpty() { - + m_lineWidth = Display::GetFontWidth(); + m_lineHeight = Display::GetFontHeight(); } /** @@ -67,7 +68,7 @@ BufferEmpty::~BufferEmpty(void) * @return --- * */ -void BufferEmpty::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize) +void BufferEmpty::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor) { EDN_DEBUG("Request draw : " << anchor.m_lineNumber); ColorizeManager * myColorManager = ColorizeManager::getInstance(); @@ -89,13 +90,15 @@ void BufferEmpty::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, posit -bool BufferEmpty::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY) +bool BufferEmpty::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor) { int32_t localID = AnchorRealId(anchorID); if (localID >=0) { EDN_DEBUG("Request anchor"); - size.x = sizePixelX / Display::GetFontWidth(); - size.y = sizePixelY / Display::GetFontHeight(); + anchor.m_displaySize.x = m_AnchorList[localID].m_displaySize.x; + anchor.m_displaySize.y = m_AnchorList[localID].m_displaySize.y; + anchor.m_displayStart.x = m_AnchorList[localID].m_displayStart.x; + anchor.m_displayStart.y = m_AnchorList[localID].m_displayStart.y; anchor.m_nbIterationMax = 2; anchor.m_lineNumber = m_AnchorList[localID].m_lineId; anchor.m_posStart = -1; diff --git a/Sources/Buffer/BufferEmpty.h b/Sources/Buffer/BufferEmpty.h index 7e89741..4f022ae 100644 --- a/Sources/Buffer/BufferEmpty.h +++ b/Sources/Buffer/BufferEmpty.h @@ -32,8 +32,8 @@ class BufferEmpty : public Buffer { public: BufferEmpty(void); virtual ~BufferEmpty(void); - void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize); - bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY); + void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor); + bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor); bool AnchorNext(bufferAnchor_ts & anchor); }; diff --git a/Sources/Buffer/BufferText.cpp b/Sources/Buffer/BufferText.cpp index ef13c84..d4852c8 100644 --- a/Sources/Buffer/BufferText.cpp +++ b/Sources/Buffer/BufferText.cpp @@ -52,9 +52,6 @@ extern "C" */ void BufferText::BasicInit(void) { - // set the first element that is displayed - m_displayStartBufferPos = 0; - // set the number of the lineNumber; m_nbColoneForLineNumber = 1; // init the link with the buffer manager @@ -66,11 +63,9 @@ void BufferText::BasicInit(void) m_cursorPos = 0; m_cursorPreferredCol = -1; m_cursorOn = true; - //m_cursorMode = CURSOR_DISPLAY_MODE_NORMAL; - m_displayStart.x = 0; - m_displayStart.y = 0; - m_displaySize.x = 200; - m_displaySize.y = 20; + + m_lineWidth = Display::GetFontWidth(); + m_lineHeight = Display::GetFontHeight(); } @@ -231,10 +226,9 @@ void BufferText::SetLineDisplay(uint32_t lineNumber) -void BufferText::DrawLineNumber(DrawerManager &drawer, int32_t lineNumber) +void BufferText::DrawLineNumber(DrawerManager &drawer, int32_t lineNumber, int32_t positionY) { int32_t letterHeight = Display::GetFontHeight(); - int32_t positionY = letterHeight * (lineNumber - m_displayStart.y - 1); char tmpLineNumber[50]; sprintf(tmpLineNumber, g_pointerForTheDisplayLine[m_nbColoneForLineNumber-1], lineNumber); drawer.Text(myColorManager->Get(COLOR_CODE_LINE_NUMBER), 1, positionY, tmpLineNumber); @@ -267,12 +261,16 @@ void BufferText::UpdatePointerNumber(void) } -void BufferText::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize) +void BufferText::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor) { + // TODO : Avec ca ca ne peux pas marcher... + position_ts displayStart; + position_ts displaySize; + int32_t letterHeight = Display::GetFontHeight(); int32_t letterWidth = Display::GetFontWidth(); int32_t positionY = letterHeight * (anchor.m_lineNumber - displayStart.y - 1); - + int32_t idX = 0; int32_t pixelX = m_nbColoneForLineNumber*letterWidth + 3; @@ -288,7 +286,7 @@ void BufferText::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, positi // clean the current Line drawer.Rectangle(myColorManager->Get(COLOR_CODE_BASIC_BG), 0, positionY, drawer.GetWidth(), letterHeight); - DrawLineNumber(drawer, anchor.m_lineNumber); + DrawLineNumber(drawer, anchor.m_lineNumber, positionY); bool selHave = anchor.m_selectionPosStart == -1 ? false : true; char displayChar[MAX_EXP_CHAR_LEN]; @@ -402,8 +400,9 @@ void BufferText::GetMousePosition(int32_t width, int32_t height, int32_t &x, int if (x < 0) { x = 0; } - x += m_displayStart.x; - y += m_displayStart.y; +// TODO : REWORK + //x += m_displayStart.x; + //y += m_displayStart.y; //EDN_DEBUG("BufferText::GetMousePosition(" << width << "," << height << "); ==> (" << x << "," << y << ")" ); } @@ -582,6 +581,8 @@ void BufferText::ScrollUp(void) */ void BufferText::MoveUpDown(int32_t ofset) { + // TODO : REWORK + /* if (ofset >= 0) { int32_t nbLine = m_EdnBuf.NumberOfLines(); if (m_displayStart.y+ofset+3 > nbLine) { @@ -600,7 +601,7 @@ void BufferText::MoveUpDown(int32_t ofset) m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y); } } - + */ } @@ -786,7 +787,8 @@ void BufferText::cursorMove(int32_t gtkKey) case GDK_Page_Up: # endif //EDN_INFO("keyEvent : "); - TextDMoveUp(m_displaySize.x); + // TODO : REWORK + //TextDMoveUp(m_displaySize.x); break; # ifdef USE_GTK_VERSION_3_0 case GDK_KEY_Page_Down: @@ -794,7 +796,8 @@ void BufferText::cursorMove(int32_t gtkKey) case GDK_Page_Down: # endif //EDN_INFO("keyEvent : "); - TextDMoveDown(m_displaySize.x); + // TODO : REWORK + //TextDMoveDown(m_displaySize.x); break; # ifdef USE_GTK_VERSION_3_0 case GDK_KEY_Begin: @@ -833,6 +836,8 @@ void BufferText::cursorMove(int32_t gtkKey) */ void BufferText::UpdateWindowsPosition(bool centerPage) { + // TODO : REWORK + /* if (centerPage == false) { // Display position (Y mode): //EDN_INFO("BufferText::UpdateWindowsPosition() m_displayStart(" << m_displayStart.x << "," << m_displayStart.y << ") m_displaySize(" << m_displaySize.x << "," < mVect; // copy data from the click board : ClipBoard::Get(clipboardID, mVect); @@ -1250,9 +1248,8 @@ position_ts BufferText::Paste(int8_t clipboardID) } -position_ts BufferText::Undo(void) +void BufferText::Undo(void) { - position_ts tmp = {0,0}; int32_t newPos = m_EdnBuf.Undo(); if (newPos >= 0) { SetInsertPosition(newPos, true); @@ -1261,9 +1258,8 @@ position_ts BufferText::Undo(void) } } -position_ts BufferText::Redo(void) +void BufferText::Redo(void) { - position_ts tmp = {0,0}; int32_t newPos = m_EdnBuf.Redo(); if (newPos >= 0) { SetInsertPosition(newPos, true); @@ -1279,16 +1275,19 @@ void BufferText::SetCharset(charset_te newCharset) } -bool BufferText::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY) +bool BufferText::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor) { int32_t localID = AnchorRealId(anchorID); if (localID >=0) { // update internal sise of the width of lineID UpdatePointerNumber(); // Updata uper size of display - size.x = sizePixelX / Display::GetFontWidth(); - size.y = sizePixelY / Display::GetFontHeight(); - anchor.m_nbIterationMax = size.y; + anchor.m_displaySize.x = m_AnchorList[localID].m_displaySize.x; + anchor.m_displaySize.y = m_AnchorList[localID].m_displaySize.y; + anchor.m_displayStart.x = m_AnchorList[localID].m_displayStart.x; + anchor.m_displayStart.y = m_AnchorList[localID].m_displayStart.y; + // TODO : Test de display non complet... + anchor.m_nbIterationMax = anchor.m_displaySize.y - 4; // update to buffer position anchor.m_lineNumber = m_AnchorList[localID].m_lineId; anchor.m_posStart = m_AnchorList[localID].m_bufferPos; diff --git a/Sources/Buffer/BufferText.h b/Sources/Buffer/BufferText.h index 5d66ec6..20f3111 100644 --- a/Sources/Buffer/BufferText.h +++ b/Sources/Buffer/BufferText.h @@ -47,34 +47,34 @@ class BufferText : public Buffer { void GetInfo(infoStatBuffer_ts &infoToUpdate); void SetLineDisplay(uint32_t lineNumber); - void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor, position_ts &displayStart, position_ts &displaySize); - position_ts AddChar(char * UTF8data); - position_ts cursorMove(int32_t gtkKey); - position_ts MouseSelectFromCursorTo(int32_t width, int32_t height); - position_ts MouseEvent(int32_t width, int32_t height); - position_ts MouseEventDouble(void); - position_ts MouseEventTriple(void); + void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor); + void AddChar(char * UTF8data); + void cursorMove(int32_t gtkKey); + void MouseSelectFromCursorTo(int32_t width, int32_t height); + void MouseEvent(int32_t width, int32_t height); + void MouseEventDouble(void); + void MouseEventTriple(void); void ScrollDown(void); void ScrollUp(void); void Copy(int8_t clipboardID); - position_ts Cut(int8_t clipboardID); - position_ts Paste(int8_t clipboardID); + void Cut(int8_t clipboardID); + void Paste(int8_t clipboardID); - position_ts Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp); - position_ts Replace(Edn::String &data); + void Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp); + void Replace(Edn::String &data); int32_t FindLine(Edn::String &data); - position_ts JumpAtLine(int32_t newLine); + void JumpAtLine(int32_t newLine); int32_t GetCurrentLine(void); - position_ts RemoveLine(void); - position_ts SelectAll(void); - position_ts SelectNone(void); - position_ts Undo(void); - position_ts Redo(void); + void RemoveLine(void); + void SelectAll(void); + void SelectNone(void); + void Undo(void); + void Redo(void); void SetCharset(charset_te newCharset); - bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor, position_ts &size, int32_t sizePixelX, int32_t sizePixelY); + bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor); bool AnchorNext(bufferAnchor_ts & anchor); protected: void NameChange(void); @@ -115,7 +115,7 @@ class BufferText : public Buffer { void GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y); void MoveUpDown(int32_t ofset); - void DrawLineNumber(DrawerManager &drawer, int32_t lineNumber); + void DrawLineNumber(DrawerManager &drawer, int32_t lineNumber, int32_t positionY); void UpdatePointerNumber(void); diff --git a/Sources/CustumWidget/CodeView/CodeView.cpp b/Sources/CustumWidget/CodeView/CodeView.cpp index c527eae..2d77ee3 100644 --- a/Sources/CustumWidget/CodeView/CodeView.cpp +++ b/Sources/CustumWidget/CodeView/CodeView.cpp @@ -240,9 +240,10 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo #endif bufferAnchor_ts anchor; - bool enableToWrite = tmpBuf->AnchorGet(self->m_displayUniqueId, anchor, self->m_displaySize, self->m_shawableAreaX, self->m_shawableAreaY); + tmpBuf->AnchorSetSize(self->m_displayUniqueId, self->m_shawableAreaX, self->m_shawableAreaY); + bool enableToWrite = tmpBuf->AnchorGet(self->m_displayUniqueId, anchor); while (true == enableToWrite) { - tmpBuf->DrawLine(monDrawer, anchor, self->m_displayStart, self->m_displaySize); + tmpBuf->DrawLine(monDrawer, anchor); enableToWrite = tmpBuf->AnchorNext(anchor); } monDrawer.Flush(); diff --git a/Sources/CustumWidget/CodeView/CodeView.h b/Sources/CustumWidget/CodeView/CodeView.h index 71d2699..715ddf5 100644 --- a/Sources/CustumWidget/CodeView/CodeView.h +++ b/Sources/CustumWidget/CodeView/CodeView.h @@ -55,8 +55,8 @@ class CodeView : public MsgBroadcast // main windows widget : GtkWidget * m_widget; int32_t m_displayUniqueId; - position_ts m_displayStart; //!< position where the display is starting - position_ts m_displaySize; //!< number of char displayable in the screan + //position_ts m_displayStart; //!< position where the display is starting + //position_ts m_displaySize; //!< number of char displayable in the screan // récupération des proprieter général... BufferManager * m_bufferManager; ColorizeManager * m_colorManager;