diff --git a/README.md b/README.md
index bec4c8d..1f93d6e 100644
--- a/README.md
+++ b/README.md
@@ -102,3 +102,7 @@ License (GPLv3)
You should have received a copy of the GNU General Public License
along with this program. If not, see .
+
+Annexe
+==================
+ sudo cp data/edn.desktop /usr/share/applications/
diff --git a/sources/appl/Buffer/Buffer.cpp b/sources/appl/Buffer.cpp
similarity index 98%
rename from sources/appl/Buffer/Buffer.cpp
rename to sources/appl/Buffer.cpp
index 7d7dbdf..56bd8a5 100644
--- a/sources/appl/Buffer/Buffer.cpp
+++ b/sources/appl/Buffer.cpp
@@ -7,10 +7,10 @@
*/
-#include
+#include
#include
#include
-#include
+#include
appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ (void) {
m_value = etk::UChar::Null;
@@ -463,9 +463,13 @@ void appl::Buffer::removeSelection(void) {
}
void appl::Buffer::tryFindHighlightType(void) {
- // etk::UString appl::highlightManager::getTypeExtention(const etk::UString& _extention);
- // TODO :...
- setHighlightType("C/C++");
+ etk::FSNode file(m_name);
+ etk::UString type = appl::highlightManager::getTypeExtention(file.fileGetExtention());
+ if (type.size() == 0) {
+ return;
+ }
+ APPL_CRITICAL("Find extention : " << type);
+ setHighlightType(type);
}
void appl::Buffer::setHighlightType(const etk::UString& _type) {
diff --git a/sources/appl/Buffer/Buffer.h b/sources/appl/Buffer.h
similarity index 99%
rename from sources/appl/Buffer/Buffer.h
rename to sources/appl/Buffer.h
index 5fd03bb..8860e92 100644
--- a/sources/appl/Buffer/Buffer.h
+++ b/sources/appl/Buffer.h
@@ -17,7 +17,7 @@
#include
#include
#include
-#include
+#include
namespace appl {
diff --git a/sources/appl/Buffer/BufferManager.h b/sources/appl/Buffer/BufferManager.h
deleted file mode 100644
index 5b7ea63..0000000
--- a/sources/appl/Buffer/BufferManager.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#ifndef __BUFFER_MANAGER_H__
-#define __BUFFER_MANAGER_H__
-
-#include
-#include
-#include
-
-namespace BufferManager
-{
- void init(void);
- void unInit(void);
- int32_t getSelected(void);
- appl::Buffer* get(int32_t BufferID);
- bool exist(int32_t BufferID);
- bool exist(etk::FSNode &myFile);
- int32_t getId(etk::FSNode &myFile);
- // return the number of buffer (open in the past) if 5 buffer open and 4 close == > return 5
- uint32_t size(void);
- uint32_t sizeOpen(void);
- int32_t witchBuffer(int32_t iEmeElement);
-};
-
-#endif
-
diff --git a/sources/appl/Buffer/BufferText.cpp b/sources/appl/Buffer/BufferText.cpp
deleted file mode 100644
index 7d5f179..0000000
--- a/sources/appl/Buffer/BufferText.cpp
+++ /dev/null
@@ -1,1274 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-
-#undef __class__
-#define __class__ "BufferText"
-
-
-const uint32_t nbLineAllocatedInBase = 300;
-
-extern "C"
-{
- const char * g_pointerForTheDisplayLine[] = {"%1d", "%2d","%3d","%4d","%5d","%6d","%7d","%8d","%9d","%d"};
-}
-
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void BufferText::BasicInit(void)
-{
- // set basic position
- m_cursorPos = 0;
- m_cursorPreferredCol = -1;
- //m_cursorMode = CURSOR_DISPLAY_MODE_NORMAL;
- m_displaySize.setValue(200,20);
- m_centerRequested = false;
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void BufferText::NameChange(void)
-{
- // find HL system
- //APPL_DEBUG("check name change");
- if (true == HighlightManager::Exist(m_fileName)) {
- Highlight * myHL = HighlightManager::get(m_fileName);
- // set the new HL
- if (NULL != myHL) {
- m_EdnBuf.setHLSystem(myHL);
- }
- }
-
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-bool BufferText::isModify(void)
-{
- return m_fileModify;
-}
-
-void BufferText::setModify(bool status)
-{
- if (status != m_fileModify) {
- m_fileModify = status;
- // TODO : remove from here
- etk::UString data = "Modify";
- ewol::getContext().getEObjectManager().MultiCast().AnonymousSend(ednMsgBufferState, data);
- }
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-bool BufferText::needToUpdateDisplayPosition(void)
-{
- bool tmpVal = m_updatePositionRequested;
- m_updatePositionRequested = false;
- return tmpVal;
-}
-
-vec2 BufferText::getBorderSize(void)
-{
- return vec2(30,30);;
-}
-
-
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-BufferText::BufferText()
-{
-
- static int32_t fileBasicID = 0;
- m_updatePositionRequested = false;
- m_fileModify = true;
- m_haveName = false;
- etk::UString mString = "Untitle - ";
- mString += fileBasicID++;
- EWOL_DEBUG("Create buffer try name : \"" << mString << "\"");
- setFileName(mString);
- m_haveName = false;
- EWOL_DEBUG("Create buffer with name : " << m_fileName );
-
- BasicInit();
- setModify(true);
- APPL_INFO("New(Empty-Buffer)");
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-BufferText::BufferText(etk::FSNode &fileName)
-{
- m_fileModify = false;
- EWOL_DEBUG("Create buffer try name : \"" << fileName << "\"");
- setFileName(fileName);
- EWOL_DEBUG("Create buffer with name : " << m_fileName );
-
- BasicInit();
- NameChange();
- APPL_INFO("Add Data from file(" << getFileName() << ")");
- etk::FSNode myFile(fileName);
- if (true == myFile.Exist()) {
- if (false == myFile.fileOpenRead()) {
- APPL_WARNING("File can not be open in read mode : " << myFile);
- setModify(true);
- } else {
- m_EdnBuf.DumpFrom(myFile);
- myFile.fileClose();
- setModify(false);
- }
- } else {
- // fichier inexistant... creation d'un nouveaux
- APPL_WARNING("No file == > created a new one(" << getFileName() << ")");
- setModify(true);
- }
- RequestUpdateOfThePosition();
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void BufferText::Save(void)
-{
- APPL_INFO("Save file : \"" << getFileName() << "\"" );
- etk::FSNode myFile(getFileName());
- if (false == myFile.fileOpenWrite()) {
- APPL_ERROR("Can not open in writing the specify file");
- } else {
- m_EdnBuf.DumpIn(myFile);
- myFile.fileClose();
- setModify(false);
- }
-}
-
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-BufferText::~BufferText(void)
-{
- APPL_INFO("Delete(BufferText)");
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void BufferText::getInfo(infoStatBuffer_ts &infoToUpdate)
-{
-
-}
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void BufferText::setLineDisplay(uint32_t lineNumber)
-{
-
-}
-
-#define SEPARATION_SIZE_LINE_NUMBER (3)
-
-void BufferText::drawLineNumber(ewol::Text* OOText, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY)
-{
- char tmpLineNumber[50];
- sprintf(tmpLineNumber, "%*d", nbColomn, lineNumber);
- OOText->setColorBg(ColorizeManager::get(COLOR_LIST_BG_2));
- OOText->setColor(ColorizeManager::get(COLOR_CODE_LINE_NUMBER));
- OOText->setPos(vec3(1.0f, (float)positionY, 0.0f) );
- OOText->print(tmpLineNumber);
-}
-
-
-/**
- * @brief get the number of colomn neede to display lineNumber
- *
- * @param[in,out] ---
- *
- * @return the number of colomn
- *
- */
-int32_t BufferText::getLineNumberNumberOfElement(void)
-{
- int32_t nbColoneForLineNumber = 1;
- // get the number of line in the buffer
- int32_t maxNumberLine = m_EdnBuf.NumberOfLines();
- if (10 > maxNumberLine) { nbColoneForLineNumber = 1;
- } else if (100 > maxNumberLine) { nbColoneForLineNumber = 2;
- } else if (1000 > maxNumberLine) { nbColoneForLineNumber = 3;
- } else if (10000 > maxNumberLine) { nbColoneForLineNumber = 4;
- } else if (100000 > maxNumberLine) { nbColoneForLineNumber = 5;
- } else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 6;
- } else if (10000000 > maxNumberLine) { nbColoneForLineNumber = 7;
- } else if (100000000 > maxNumberLine) { nbColoneForLineNumber = 8;
- } else if (1000000000 > maxNumberLine) { nbColoneForLineNumber = 9;
- } else { nbColoneForLineNumber = 10;
- }
- return nbColoneForLineNumber;
-}
-
-int32_t BufferText::getNumberOfLine(void)
-{
- return m_EdnBuf.CountLines();
-}
-
-/**
- * @brief display the curent buffer with all the probematic imposed by the xharset and the user contraint.
- *
- * @param[in,out] drawer the basic user drawer of EDN.
- *
- * @return
- *
- */
-int32_t BufferText::display(ewol::Text& OOText,
- int32_t offsetX, int32_t offsetY,
- int32_t sizeX, int32_t sizeY)
-{
- int32_t selStart, selEnd, selRectStart, selRectEnd;
- bool selIsRect;
- int32_t selHave;
-
- vec3 tmpLetterSize = OOText.calculateSize((etk::UChar)'A');
-
- int32_t letterWidth = tmpLetterSize.x();
- int32_t letterHeight = tmpLetterSize.y();
-
- int32_t displayStartLineId = offsetY / letterHeight - 1;
- displayStartLineId = etk_max(0, displayStartLineId);
- int32_t y = - offsetY + displayStartLineId*letterHeight;
-
- // update the display position with the scroll ofset :
- int32_t displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, displayStartLineId);
- vec2 maxSize;
- maxSize.setX(0);
- maxSize.setY(m_EdnBuf.NumberOfLines() * tmpLetterSize.y());
- int32_t nbColoneForLineNumber = getLineNumberNumberOfElement();
-
- // update the number of element that can be displayed
- m_displaySize.setX((sizeX/letterWidth) + 1 - nbColoneForLineNumber);
- m_displaySize.setY((sizeY/letterHeight) + 1);
- APPL_VERBOSE("main DIPLAY " << m_displaySize.x() << " char * " << m_displaySize.y() << " char");
-
- selHave = m_EdnBuf.getSelectionPos(selStart, selEnd, selIsRect, selRectStart, selRectEnd);
-
- appl::HighlightInfo * HLColor = NULL;
-
- int32_t iii, new_i;
- // get color :
- Colorize * myColor = ColorizeManager::get("normal");
- Colorize * myColorSel = ColorizeManager::get("SelectedText");
- etk::Color<> & myColorSpace = ColorizeManager::get(COLOR_CODE_SPACE);
- etk::Color<> & myColorTab = ColorizeManager::get(COLOR_CODE_TAB);
- Colorize * selectColor = NULL;
- int mylen = m_EdnBuf.size();
- int32_t x_base=nbColoneForLineNumber*letterWidth;
- int32_t idX = 0;
-
- int64_t startTime = ewol::getTime();
- int displayLines = 0;
- // Regenerate the colorizing if necessary ...
- appl::DisplayHLData m_displayLocalSyntax;
- m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, displayStartBufferPos, m_displaySize.y());
-
- int64_t stopTime = ewol::getTime();
- APPL_DEBUG("Parsing Highlight = " << stopTime - startTime << " micro-s");
-
- etk::UChar displayChar[MAX_EXP_CHAR_LEN];
- memset(displayChar, 0, sizeof(etk::UChar)*MAX_EXP_CHAR_LEN);
- etk::UString myStringToDisplay;
- // draw the lineNumber :
- int32_t currentLineID = displayStartLineId+1;
- APPL_VERBOSE("Start display of text buffer [" << displayStartBufferPos<< ".." << mylen << "]");
- APPL_VERBOSE("cursor Pos : " << m_cursorPos << "start at pos=" << displayStartBufferPos);
-
- // note corection of the openGl invertion system :
- y = sizeY - y;
- y -= letterHeight;
-
- OOText.setClippingMode(false);
- drawLineNumber(&OOText, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
- int32_t pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
-
- vec3 drawClippingPos(0,0,-0.5);
- vec3 drawClippingSize(sizeX, sizeY, 1);
- OOText.setClippingWidth(vec3((float)pixelX, 0.0f, -0.5f),
- vec3((float)(sizeX - drawClippingPos.x()), (float)sizeY, 0.5f) );
-
- // clear the line intexation :
- m_elmentList.clear();
- // every char element is register to find the diplay pos when mouse event arrive
- CharElement tmpElementProperty;
- tmpElementProperty.m_yOffset = y;
- tmpElementProperty.m_xOffset = 0;
- tmpElementProperty.m_ySize = 10;
- tmpElementProperty.m_bufferPos = displayStartBufferPos;
- m_elmentList.pushBack(tmpElementProperty);
-
- vec3 tmpCursorPosition(0, 0, -1); //Cursor is display only at the end to be all time over the background ... (-1 in z no cursor)
-
- float lineMaxSize = 0.0;
- for (iii=displayStartBufferPos; iii= 0 && y >= -2*letterHeight; iii = new_i) {
- //APPL_DEBUG("display pos =" << y);
- int displaywidth;
- uint32_t currentChar = '\0';
- new_i = iii;
- // update the element buffer pos:
- tmpElementProperty.m_bufferPos = new_i;
- displaywidth = m_EdnBuf.getExpandedChar(new_i, idX, displayChar, currentChar);
- int32_t drawSize = 0;
-
- // update display position :
- vec2 textPos(pixelX-offsetX, y);
- // update X pos
- tmpElementProperty.m_xOffset = textPos.x();
- tmpElementProperty.m_yOffset = textPos.y();
-
- //APPL_INFO("diplay element=" << new_i);
- if (currentChar!='\n') {
- selectColor = myColor;
- HLColor = m_EdnBuf.getElementColorAtPosition(m_displayLocalSyntax, iii);
- if (HLColor != NULL) {
- if (HLColor->patern != NULL) {
- selectColor = HLColor->patern->getColor();
- }
- }
- OOText.setColorBg(etk::color::none);
- if( true == selHave
- && selStart <= iii
- && selEnd > iii)
- {
- selectColor = myColorSel;
- OOText.setColorBg(selectColor->getBG() );
- } else {
- if(false == selectColor->haveBg()) {
- if( currentChar == ' '
- && globals::isSetDisplaySpaceChar() == true )
- {
- OOText.setColorBg(myColorSpace);
- } else if( currentChar == '\t'
- && globals::isSetDisplayTabChar() == true )
- {
- OOText.setColorBg(myColorTab);
- }
- } else {
- OOText.setColorBg(selectColor->getBG());
- }
- }
- tmpElementProperty.m_ySize = 20;//OOText.getHeight();
- OOText.setColor(selectColor->getFG() );
- //OOText.setColorBg(selectColor->getFG());
- OOText.setFontBold(selectColor->getBold());
- OOText.setFontItalic(selectColor->getItalic());
- myStringToDisplay = displayChar;
- OOText.setPos(vec3(textPos.x(), textPos.y(), 0.0f) );
- OOText.print(myStringToDisplay);
- // To update the display position
- drawSize = OOText.getPos().x() - textPos.x();
- //APPL_DEBUG("add element : " << tmpElementProperty.m_yOffset << "," << tmpElementProperty.m_xOffset);
- m_elmentList.pushBack(tmpElementProperty);
-
- }
- idX += displaywidth;
- // display cursor :
- if (m_cursorPos == iii) {
- tmpCursorPosition = vec3(pixelX - offsetX, y, 0);
- }
- lineMaxSize += drawSize;
- pixelX += drawSize;
- // move to next line ...
- if (currentChar == '\n') {
- maxSize.setX(etk_max(lineMaxSize, maxSize.x()));
- lineMaxSize = 0.0;
- idX =0;
- pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
- y -= letterHeight;
- //APPL_DEBUG("display pos =" << y);
- displayLines++;
- currentLineID++;
- OOText.setClippingMode(false);
- OOText.setFontBold(false);
- OOText.setFontItalic(false);
- drawLineNumber(&OOText, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
- OOText.setClippingMode(true);
- // add elements :
- m_elmentList.pushBack(tmpElementProperty);
- }
- }
- //APPL_DEBUG("end at pos buf =" << iii << " / " << m_EdnBuf.size());
- // special case : the cursor is at the end of the buffer...
- if (m_cursorPos == iii) {
- tmpCursorPosition = vec3(pixelX - offsetX, y, 0);
- }
- if (tmpCursorPosition.z()!=-1) {
- // display the cursor:
- OOText.setPos(tmpCursorPosition);
- OOText.setColor(ColorizeManager::get(COLOR_CODE_CURSOR));
- OOText.setColorBg(ColorizeManager::get(COLOR_CODE_CURSOR));
- OOText.printCursor(false);
- }
- // display the 80 colomn limit line :
-
- OOText.setClippingMode(false);
- OOText.getDrawing().setThickness(2);
- OOText.getDrawing().setColor(etk::Color<>(200,200,0,255));
- OOText.getDrawing().setPos(vec2((float)((nbColoneForLineNumber+80)*tmpLetterSize.x()), 0.0f));
- OOText.getDrawing().lineRel(vec2(0.0f, 2500.0f));
- // set the maximum size for the display ...
- setMaximumSize(maxSize);
- int64_t stopTime2 = ewol::getTime();
- APPL_DEBUG("DRAW text (brut) = " << stopTime2 - stopTime << " micro-s");
-
- return 0;
-}
-
-
-
-int32_t BufferText::getMousePosition(vec2 pos)
-{
- bool inLineDone=false;
- //APPL_DEBUG("try to find in : " << width << "," << height);
- for(int32_t iii=0; iii= m_elmentList[iii].m_yOffset
- && pos.y() note : Some problem can appear here when the size are not the same ...
- // this is to prevent multiple size font ...
- inLineDone = true;
- //APPL_DEBUG(" == > " << m_elmentList[iii+1].m_xOffset << "> " << pos.x << " >= " << m_elmentList[iii].m_xOffset);
- }
- }
- // we detected the line
- if(true == inLineDone) {
- if( pos.x() >= m_elmentList[iii].m_xOffset
- && pos.x()= m_elmentList[iii+1].m_xOffset) {
- // prevent "end of line" cursor pos ...
- return m_elmentList[iii].m_bufferPos;
- }
- }
- }
- if (m_elmentList.size()>0) {
- if(pos.y() m_EdnBuf.size()) {
- newPos = m_EdnBuf.size();
- }
- m_cursorPos = newPos;
- }
- m_cursorPreferredCol = -1;
-
- // special case when insert char ...
- if (true == insertChar) {
- return;
- }
-
- if( false == haveSelectionActive
- && true == false ) //ewol::getCurrentSpecialKeyStatus().isSetShift() )
- {
- // new selection
- m_EdnBuf.Select(rememberCursorPos, m_cursorPos);
- } else if( true == false //ewol::getCurrentSpecialKeyStatus().isSetShift()
- && true == haveSelectionActive)
- {
- // update selection
- if (rememberCursorPos == SelectionStart) {
- m_EdnBuf.Select(m_cursorPos, SelectionEnd);
- } else {
- m_EdnBuf.Select(SelectionStart, m_cursorPos);
- }
- }
-}
-
-bool BufferText::TextDMoveUp(int32_t offset)
-{
- int32_t lineStartPos, column, prevLineStartPos, newPos;
-
- // find the position of the start of the line.
- lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
- // check if we can go up ...
- if (lineStartPos == 0) {
- return false;
- }
-
- // Decide what column to move to, if there's a preferred column use that
- if (m_cursorPreferredCol >= 0) {
- column = m_cursorPreferredCol;
- } else {
- column = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos);
- }
-
- // get the previous line
- prevLineStartPos = m_EdnBuf.CountBackwardNLines(lineStartPos, offset);
- //APPL_INFO("Move line UP result : prevLineStartPos=" << prevLineStartPos);
- // get the display char position
- newPos = m_EdnBuf.CountForwardDispChars(prevLineStartPos, column);
- //APPL_INFO("Move to colomn : column=" << column << " newPos=" << newPos);
-
- // move the cursor
- setInsertPosition(newPos);
-
- // if a preferred column wasn't aleady established, establish it
- if (m_cursorPreferredCol < 0) {
- m_cursorPreferredCol = column;
- }
-
- return true;
-}
-
-bool BufferText::TextDMoveDown(int32_t offset)
-{
- int32_t lineStartPos, column, nextLineStartPos, newPos;
-
- // check if we are not at the end of Buffer
- if (m_cursorPos == m_EdnBuf.size() ) {
- return false;
- }
- // find the position of the start of the line.
- lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
-
- if (m_cursorPreferredCol >= 0) {
- column = m_cursorPreferredCol;
- } else {
- column = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos);
- }
- // get the next line :
- nextLineStartPos = m_EdnBuf.CountForwardNLines(lineStartPos, offset);
- //APPL_INFO("Move line DOWN result : nextLineStartPos=" << nextLineStartPos);
- // get the display char position
- newPos = m_EdnBuf.CountForwardDispChars(nextLineStartPos, column);
- //APPL_INFO("Move to colomn : column=" << column << " newPos=" << newPos);
-
- setInsertPosition(newPos);
- // if a preferred column wasn't aleady established, establish it
- if (m_cursorPreferredCol < 0) {
- m_cursorPreferredCol = column;
- }
- return true;
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void BufferText::cursorMove(ewol::keyEvent::keyboard_te moveTypeEvent)
-{
- bool needUpdatePosition = true;
- // check selection event ...
- switch(moveTypeEvent) {
- case ewol::keyEvent::keyboardLeft:
- //APPL_INFO("keyEvent : ");
- if (m_cursorPos > 0) {
- setInsertPosition(m_cursorPos - 1);
- }
- break;
- case ewol::keyEvent::keyboardRight:
- //APPL_INFO("keyEvent : ");
- if (m_cursorPos < m_EdnBuf.size() ) {
- setInsertPosition(m_cursorPos + 1);
- }
- break;
- case ewol::keyEvent::keyboardUp:
- //APPL_INFO("keyEvent : ");
- TextDMoveUp(1);
- break;
- case ewol::keyEvent::keyboardDown:
- //APPL_INFO("keyEvent : ");
- // check if we have enought line ...
- TextDMoveDown(1);
- break;
- case ewol::keyEvent::keyboardPageUp:
- //APPL_INFO("keyEvent : ");
- TextDMoveUp(m_displaySize.y());
- break;
- case ewol::keyEvent::keyboardPageDown:
- //APPL_INFO("keyEvent : ");
- TextDMoveDown(m_displaySize.y());
- break;
- case ewol::keyEvent::keyboardStart:
- //APPL_INFO("keyEvent : ");
- setInsertPosition(m_EdnBuf.StartOfLine(m_cursorPos) );
- break;
- case ewol::keyEvent::keyboardEnd:
- //APPL_INFO("keyEvent : ");
- setInsertPosition(m_EdnBuf.EndOfLine(m_cursorPos) );
- break;
- default:
- //LastUpDownoutputPosition = -1;
- needUpdatePosition = false;
- break;
- }
- if ( true == needUpdatePosition) {
- RequestUpdateOfThePosition();
- }
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-vec2 BufferText::getPosition(int32_t fontId, bool& centerRequested)
-{
- centerRequested = m_centerRequested;
- m_centerRequested = false;
- vec2 outputPosition(0,0);
-
- // display position (Y mode):
- APPL_INFO("change the position : " << m_cursorPos);
- // get the line id of the curent position of the cursor :
- outputPosition.setY(m_EdnBuf.CountLines(0, m_cursorPos));
- // get the first position of the current line
- int32_t lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
- // count the number of char in the line (real displayed char with whar like )
- outputPosition.setX(m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos));
- APPL_INFO("Curent cursor pos=" << outputPosition);
-
- // get font porperties :
- // TODO : change this :
- // TODO : set it back ...
- /*
- float letterWidth = ewol::getWidth(fontId, "A");
- float letterHeight = ewol::getHeight(fontId);
- */
- float letterWidth = 10;
- float letterHeight = 15;
- outputPosition.setValue(outputPosition.x() * letterWidth,
- outputPosition.y() * letterHeight);
- return outputPosition;
-
- /* if we request a center :
- } else {
- // center the line at the middle of the screen :
- vec2 outputPosition(0,0);
- //APPL_DEBUG(" -------------------------------------------------");
- outputPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
- //APPL_DEBUG(" cursor position : " << m_cursorPos << " == > ligne=" << outputPosition.y);
- outputPosition.x = 0;
-
- m_displayStartPixelX = 0;
- //APPL_DEBUG(" display size : " << m_displaySize.y);
- m_displayStartLineId = outputPosition.y - m_displaySize.y/2;
- m_displayStartLineId = edn_max(m_displayStartLineId, 0);
-
- m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
- //APPL_DEBUG(" display start : " << m_displayStartPixelX << "x" << m_displayStartLineId);
- //APPL_DEBUG(" -------------------------------------------------");
- }
- */
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void BufferText::addChar(etk::UChar unicodeData)
-{
- int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
- bool SelectionIsRect;
- bool haveSelectionActive = m_EdnBuf.getSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
- if (unicodeData == 0x09) {
- if (false == haveSelectionActive) {
- etk::Vector tmpVect;
- tmpVect.pushBack(0x09);
- m_EdnBuf.insert(m_cursorPos, tmpVect);
- setInsertPosition(m_cursorPos+1, true);
- } else {
- // Indent depend of the multiline in the selection ...
- // count the number of line :
- int32_t nbSelectedLines = m_EdnBuf.CountLines(SelectionStart, SelectionEnd);
- if (0 == nbSelectedLines) {
- etk::Vector tmpVect;
- tmpVect.pushBack(0x09);
- m_EdnBuf.ReplaceSelected(tmpVect);
- setInsertPosition(SelectionStart+tmpVect.size(), true);
- } else {
- if (true == false ) { //ewol::getCurrentSpecialKeyStatus().isSetShift() ) {
- m_cursorPos = m_EdnBuf.UnIndent();
- } else {
- m_cursorPos = m_EdnBuf.Indent();
- }
- }
- }
- } else if (unicodeData == '\n') {
- etk::Vector tmpVect;
- if (true == false ) { //ewol::getCurrentSpecialKeyStatus().isSetShift()) {
- tmpVect.pushBack('\r');
- } else {
- tmpVect.pushBack('\n');
- // if Auto indent enable == > we get the start of the previous line and add it to tne new one
- if (true == globals::isSetAutoIndent() ) {
- int32_t l_lineStart;
- // get the begin of the line or the begin of the line befor selection
- if (false == haveSelectionActive) {
- l_lineStart = m_EdnBuf.StartOfLine(m_cursorPos);
- } else {
- l_lineStart = m_EdnBuf.StartOfLine(SelectionStart);
- }
- // add same characters in the temporar buffer
- for (int32_t kk=l_lineStart; kk pos=" << m_cursorPos);
- if (false == haveSelectionActive) {
- m_EdnBuf.remove(m_cursorPos, m_cursorPos+1);
- } else {
- m_EdnBuf.removeSelected();
- setInsertPosition(SelectionStart, true);
- }
- } else if (unicodeData == 0x08) {
- //APPL_INFO("keyEvent : pos=" << m_cursorPos);
- if (false == haveSelectionActive) {
- m_EdnBuf.remove(m_cursorPos-1, m_cursorPos);
- setInsertPosition(m_cursorPos-1, true);
- } else {
- m_EdnBuf.removeSelected();
- setInsertPosition(SelectionStart, true);
- }
- } else {
- // normal adding char ...
- if (true == m_EdnBuf.getUTF8Mode()) {
- char tmpUTF8[16];
- unicodeData.getUtf8(tmpUTF8);
- etk::Vector tmpVect;
- int32_t localOfset = strlen(tmpUTF8);
- tmpVect.pushBack((int8_t*)tmpUTF8, localOfset);
- if (false == haveSelectionActive) {
- m_EdnBuf.insert(m_cursorPos, tmpVect);
- setInsertPosition(m_cursorPos+localOfset, true);
- } else {
- m_EdnBuf.ReplaceSelected(tmpVect);
- setInsertPosition(SelectionStart+localOfset, true);
- }
- } else {
- // convert in the Good ISO format :
- char output_ISO;
- unicode::convertUnicodeToIso(m_EdnBuf.getCharsetType(), unicodeData, output_ISO);
- //printf(" insert : \"%s\" == > 0x%08x=%d ", UTF8data, (unsigned int)output_ISO, (int)output_ISO);
- etk::Vector tmpVect;
- tmpVect.pushBack(output_ISO);
- if (false == haveSelectionActive) {
- m_EdnBuf.insert(m_cursorPos, tmpVect);
- setInsertPosition(m_cursorPos+1, true);
- } else {
- m_EdnBuf.ReplaceSelected(tmpVect);
- setInsertPosition(SelectionStart+1, true);
- }
- }
- }
-
- setModify(true);
- RequestUpdateOfThePosition();
-}
-
-
-int32_t BufferText::findLine(etk::UString &data)
-{
- if ( 0 == data.size()) {
- APPL_WARNING("no search data");
- return 0;
- }
- APPL_INFO("Search data line : \"" << data << "\"");
- etk::Vector mVectSearch;
- mVectSearch = data.getVector();
- //APPL_INFO("search data Forward : startSearchPos=" << startSearchPos );
- /*
- int32_t foundPos;
- bool findSomething = m_EdnBuf.SearchForward(0, mVectSearch, &foundPos, true);
- // if find data :
- if (true == findSomething) {
- return m_EdnBuf.CountLines(0, foundPos);
- } else {
- return 0;
- }
- */
- APPL_TODO("Remove for now ...");
- return 0;
-}
-
-void BufferText::JumpAtLine(int32_t newLine)
-{
- int32_t positionLine = m_EdnBuf.CountForwardNLines(0, newLine);
- m_EdnBuf.Unselect();
- APPL_DEBUG("jump at the line : " << newLine );
- setInsertPosition(positionLine);
- m_centerRequested = true;
- RequestUpdateOfThePosition();
-}
-
-/**
- * @brief get the current line (to know where to jump)
- *
- * @param ---
- *
- * @return Return the current line number
- *
- */
-int32_t BufferText::getCurrentLine(void)
-{
- return m_EdnBuf.CountLines(0, m_cursorPos);
-}
-
-
-
-void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp)
-{
- APPL_INFO("Search data : \"" << data << "\"");
-
- int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
- bool SelectionIsRect;
- bool haveSelectionActive = m_EdnBuf.getSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
-
- int32_t startSearchPos = m_cursorPos;
- if (true == haveSelectionActive) {
- if (false == back) {
- startSearchPos = SelectionEnd;
- } else {
- startSearchPos = SelectionStart;
- }
- }
-
- if ( 0 == data.size()) {
- APPL_WARNING("no search data");
- return;
- }
- if (false == back) {
- //APPL_INFO("search data Forward : startSearchPos=" << startSearchPos );
- int32_t foundPos;
- int32_t foundPosEnd;
- bool findSomething = m_EdnBuf.SearchForward(startSearchPos, data, &foundPos, &foundPosEnd, caseSensitive);
- if( false == findSomething
- && true == wrap)
- {
- //APPL_INFO("WrapMode !!! 0 == > end");
- findSomething = m_EdnBuf.SearchForward(0, data, &foundPos, &foundPosEnd, caseSensitive);
- }
- // if find data :
- if (true == findSomething) {
- // select new position
- setInsertPosition(foundPosEnd);
- m_EdnBuf.Select(foundPos, foundPosEnd);
- }
- } else {
- //APPL_INFO("search data Backward : " << data.getDirectPointer() );
- int32_t foundPos;
- int32_t foundPosEnd;
- bool findSomething = m_EdnBuf.SearchBackward(startSearchPos, data, &foundPos, &foundPosEnd, caseSensitive);
- if( false == findSomething
- && true == wrap)
- {
- //APPL_INFO("WrapMode !!! end == > 0");
- findSomething = m_EdnBuf.SearchBackward(m_EdnBuf.size(), data, &foundPos, &foundPosEnd, caseSensitive);
- }
- // if find data :
- if (true == findSomething) {
- // select new position
- setInsertPosition(foundPos);
- m_EdnBuf.Select(foundPos, foundPosEnd);
- }
- }
- m_centerRequested = true;
- RequestUpdateOfThePosition();
-}
-
-
-void BufferText::Replace(etk::UString &data)
-{
- int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
- bool SelectionIsRect;
- bool haveSelectionActive = m_EdnBuf.getSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
- if (true == haveSelectionActive) {
- // Replace Data :
- int32_t size = m_EdnBuf.ReplaceSelected(data);
- setInsertPosition(SelectionStart + size);
- }
- setModify(true);
-}
-
-
-/**
- * @brief request a copy of the selection in the named clipBoard ID
- *
- * @param[in] clipboardID Id of the buffer we want to get data [0..10] (0 copy normal / 10 middle button)
- *
- * @return ---
- *
- */
-void BufferText::Copy(ewol::clipBoard::clipboardListe_te clipboardID)
-{
- etk::UString mVect;
- // get the curent selected data
- if (true == m_EdnBuf.SelectHasSelection() ) {
- m_EdnBuf.getSelectionText(mVect);
- }
- // copy data in the click board :
- ewol::clipBoard::set(clipboardID, mVect);
-}
-
-
-/**
- * @brief Request a copy and a remove of the curent selection in the named clipBoard ID
- *
- * @param[in] clipboardID Id of the buffer we want to get data [0..10] (0 copy normal / 10 middle button)
- *
- * @return ---
- *
- */
-void BufferText::Cut(ewol::clipBoard::clipboardListe_te clipboardID)
-{
-
- int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
- bool SelectionIsRect;
- bool haveSelectionActive = m_EdnBuf.getSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
-
- // copy data
- Copy(clipboardID);
- // remove data :
- if (true == haveSelectionActive ) {
- APPL_INFO("REMOVE SELECTION");
- m_EdnBuf.removeSelected();
- m_cursorPos = SelectionStart;
- }
- RequestUpdateOfThePosition();
- setModify(true);
-}
-
-
-/**
- * @brief request the past of a specific clipboard on the curent position or selection
- *
- * @param[in] clipboardID Id of the buffer we want to get data [0..10] (0 copy normal / 10 middle button)
- *
- * @return ---
- *
- */
-void BufferText::Paste(ewol::clipBoard::clipboardListe_te clipboardID)
-{
- etk::UString mVect;
- // copy data from the click board :
- mVect = ewol::clipBoard::get(clipboardID);
-
- int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
- bool SelectionIsRect;
- bool haveSelectionActive = m_EdnBuf.getSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
-
- if (true == haveSelectionActive ) {
- // replace data
- int32_t size = m_EdnBuf.ReplaceSelected(mVect );
- m_cursorPos = SelectionStart + size;
- } else {
- // insert data
- int32_t size = m_EdnBuf.insert(m_cursorPos, mVect);
- m_cursorPos += size;
- }
- RequestUpdateOfThePosition();
- setModify(true);
-}
-
-
-void BufferText::Undo(void)
-{
- int32_t newPos = m_EdnBuf.Undo();
- if (newPos >= 0) {
- setInsertPosition(newPos, true);
- RequestUpdateOfThePosition();
- setModify(true);
- }
-}
-
-void BufferText::Redo(void)
-{
- int32_t newPos = m_EdnBuf.Redo();
- if (newPos >= 0) {
- setInsertPosition(newPos, true);
- RequestUpdateOfThePosition();
- setModify(true);
- }
-}
-
-
-void BufferText::setCharset(unicode::charset_te newCharset)
-{
- m_EdnBuf.setCharsetType(newCharset);
-}
-
diff --git a/sources/appl/Buffer/BufferText.h b/sources/appl/Buffer/BufferText.h
deleted file mode 100644
index cd6427f..0000000
--- a/sources/appl/Buffer/BufferText.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#ifndef __BUFFER_TEXT_H__
-#define __BUFFER_TEXT_H__
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "ColorizeManager.h"
-#include "EdnBuf.h"
-
-typedef enum {
- CURSOR_DISPLAY_MODE_NORMAL = 259,
- CURSOR_DISPLAY_MODE_INSERT,
- CURSOR_DISPLAY_MODE_NOT_FOCUS,
-} cursorDisplayMode_te;
-
-class CharElement
-{
- public:
- float m_LineOffset; // TODO : DEPRECATED ...
- int16_t m_yOffset;
- int16_t m_xOffset;
- int16_t m_ySize;
- int32_t m_bufferPos;
-};
-
-
-typedef struct{
- uint32_t nbTotalLine; //!< Number of line in the buffer
- uint32_t nbTotalColomn; //!< Number of line in the buffer
- uint32_t startLineDisplay; //!< First line display.
- uint32_t startColomnDisplay; //!< First Colomn displayed
- uint32_t diplayableColomn; //!< NB colomn that can be displayed
- uint32_t diplayableLine; //!< NB line that can be displayed
-}infoStatBuffer_ts;
-
-
-class BufferText
-{
- private:
- bool m_fileModify;
- // naming
- etk::FSNode m_fileName; //!< filename of the curent buffer
- bool m_haveName; //!< to know if the file have a name or NOT
- bool m_updatePositionRequested; //!< if a position xhange in the windows ...
- vec2 m_maximumSize; //!< current maxSize of the buffer
- public:
- void setModify(bool status);
- virtual vec2 getBorderSize(void);
- void RequestUpdateOfThePosition(void) { m_updatePositionRequested = true; };
- void setMaximumSize(vec2 maxSize) { m_maximumSize = maxSize; };
- bool needToUpdateDisplayPosition(void);
- vec2 getMaxSize(void) { return m_maximumSize; };
- bool isModify(void);
- public:
- etk::FSNode getFileName(void) { return m_fileName; };
-
- void setFileName(etk::FSNode &newName)
- {
- m_fileName = newName;
- m_haveName = true;
- NameChange();
- };
-
- void setFileName(etk::UString &newName)
- {
- m_fileName.setName(newName);
- m_haveName = true;
- NameChange();
- };
-
- bool haveName(void)
- {
- return m_haveName;
- }
- public:
- BufferText(void);
- BufferText(etk::FSNode &fileName);
- virtual ~BufferText(void);
- void Save(void);
-
- void getInfo(infoStatBuffer_ts &infoToUpdate);
- void setLineDisplay(uint32_t lineNumber);
- int32_t display(ewol::Text& OOText,
- int32_t offsetX, int32_t offsetY,
- int32_t sizeX, int32_t sizeY);
- void addChar(etk::UChar unicodeData);
- void cursorMove(ewol::keyEvent::keyboard_te moveTypeEvent);
- void MouseSelectFromCursorTo(vec2 pos);
- void MouseEvent(vec2 pos);
- void MouseEventDouble(void);
- void MouseEventTriple(void);
-
- void Copy(ewol::clipBoard::clipboardListe_te clipboardID);
- void Cut(ewol::clipBoard::clipboardListe_te clipboardID);
- void Paste(ewol::clipBoard::clipboardListe_te clipboardID);
-
- void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp);
- void Replace(etk::UString &data);
- int32_t findLine(etk::UString &data);
- void JumpAtLine(int32_t newLine);
- int32_t getCurrentLine(void);
-
- void removeLine(void);
- void SelectAll(void);
- void SelectNone(void);
- void Undo(void);
- void Redo(void);
- void setCharset(unicode::charset_te newCharset);
- int32_t getNumberOfLine(void);
- protected:
- void NameChange(void);
-
- private:
- int32_t getLineNumberNumberOfElement(void);
-
- // Direct buffer IO
- EdnBuf m_EdnBuf; //!< buffer associated on this displayer
- vec2 m_displaySize; //!< number of char displayable in the screan
- // Cursor :
- int32_t m_cursorPos; //!< position in the buffer of the cursor
- int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
- cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
- etk::Vector m_elmentList; //!< Elemnt position for every char displayed
-
- // internal function
- void BasicInit(void);
- private:
- bool m_centerRequested;
- public:
- virtual vec2 getPosition(int32_t fontId, bool& centerRequested);
- private:
- bool TextDMoveUp(int32_t offset);
- bool TextDMoveDown(int32_t offset);
- void setInsertPosition(int32_t newPosition, bool insertChar = false);
-
- int32_t getMousePosition(vec2 pos);
-
- void drawLineNumber(ewol::Text* OOText, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
-
-};
-
-#endif
-
-
diff --git a/sources/appl/Buffer/EdnBuf/EdnBuf.cpp b/sources/appl/Buffer/EdnBuf/EdnBuf.cpp
deleted file mode 100644
index 2023ace..0000000
--- a/sources/appl/Buffer/EdnBuf/EdnBuf.cpp
+++ /dev/null
@@ -1,1260 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#include
-#include
-#include
-#include
-
-
-#undef __class__
-#define __class__ "EdnBuf"
-
-/**
- * @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"};
-
-
-
-/**
- * @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)
-{
- // TODO : set it configurable !!!
- m_tabDist = 8;
- m_useTabs = true;
-
- // Current selection
- m_selectionList.selected = false;
- m_selectionList.zeroWidth = false;
- m_selectionList.rectangular = false;
- m_selectionList.start = m_selectionList.end = 0;
-
- // charset :
- m_isUtf8 = false;
- m_charsetType = unicode::EDN_CHARSET_ISO_8859_15;
-
- m_isUndoProcessing = false;
- m_isRedoProcessing = false;
-
- // basicly no HL system ...
- m_Highlight = NULL;
- m_nbLine = 1;
-}
-
-/**
- * @brief Destructor of the Edn buffer Text :
- */
-EdnBuf::~EdnBuf(void)
-{
- // TODO : remove history and Future
-}
-
-/**
- * @brief Save in the current file open
- *
- * @param[in,out] myFile pointer on the file where data might be writed
- *
- * @return true if OK / false if an error occured
- *
- */
-bool EdnBuf::DumpIn(etk::FSNode &file)
-{
- // write Data
- return m_data.DumpIn(file);
-}
-
-
-/**
- * @brief load in the current file open
- *
- * @param[in,out] myFile pointer on the file where data might be read
- *
- * @return true if OK / false if an error occured
- *
- */
-bool EdnBuf::DumpFrom(etk::FSNode &file)
-{
- if (true == m_data.DumpFrom(file) ) {
- // set no selection
- updateSelection(0, 0, m_data.size() );
- // generate HighLight
- CleanHighLight();
- generateHighLightAt(0, m_data.size());
- CountNumberOfLines();
- return true;
- }
- return false;
-}
-
-
-void EdnBuf::getAll(etk::Vector &text)
-{
- // Clean output vector
- text.clear();
- // set data on the vector
- text = m_data.get(0, m_data.size());
-}
-
-
-void EdnBuf::setAll(etk::Vector &text)
-{
- etk::Vector deletedText;
-
- // extract all data of the buffer :
- getAll(deletedText);
-
- // remove all data in the buffer:
- m_data.clear();
-
- // inset text data :
- m_data.insert(0, text);
-
- // Zero all of the existing selections
- updateSelection(0, deletedText.size(), 0);
-
- // Call the modification Event Manager
- eventModification(0, m_data.size(), deletedText);
-}
-
-void EdnBuf::getRange(int32_t start, int32_t end, etk::Vector &output)
-{
- // remove all data ...
- output.clear();
- // import data :
- output = m_data.get(start, end-start);
- //APPL_DEBUG("request start=" << start << " end="<< end << " size="<< end-start << " result size=" << output.size() );
-}
-
-void EdnBuf::getRange(int32_t start, int32_t end, etk::UString &output)
-{
- // remove all data ...
- output = "";
- // import data :
- etk::Vector localOutput = m_data.get(start, end-start);
- // transcript in UNICODE ...
- if (true == m_isUtf8) {
- localOutput.pushBack('\0');
- output = (char*)&localOutput[0];
- } else {
- etk::Vector tmpUnicodeData;
- // transform in unicode :
- convertIsoToUnicode(m_charsetType, localOutput, tmpUnicodeData);
- output = tmpUnicodeData;
- }
- //APPL_DEBUG("request start=" << start << " end="<< end << " size="<< end-start << " result size=" << output.size() );
-}
-
-
-/**
- * @brief get an element at the selected position
- *
- * @param[in] pos Charecters Position, [0..n]
- *
- * @return The character at buffer position "pos"
- *
- */
-int8_t EdnBuf::operator[] (int32_t pos) const
-{
- int8_t res = m_data.get(pos);
- return res;
-}
-
-
-/**
- * @brief insert Data in the Buffer
- *
- * @param[in] pos Position in the Buffer
- * @param[in] insertText Text to insert
- *
- * @return ---
- *
- */
-int32_t EdnBuf::insert(int32_t pos, etk::Vector &insertText)
-{
- // if pos is not contiguous to existing text, make it
- pos = etk_avg(0, pos, m_data.size() );
- // insert Data
- int32_t sizeInsert=LocalInsert(pos, insertText);
-
- // Call the redisplay ...
- etk::Vector deletedText;
- eventModification(pos, insertText.size(), deletedText);
- return sizeInsert;
-}
-int32_t EdnBuf::insert(int32_t pos, etk::UString &insertText)
-{
- // if pos is not contiguous to existing text, make it
- pos = etk_avg(0, pos, m_data.size() );
- // insert Data
- int32_t sizeInsert=LocalInsert(pos, insertText);
-
- // Call the redisplay ...
- etk::Vector deletedText;
- eventModification(pos, insertText.size(), deletedText);
- return sizeInsert;
-}
-
-/**
- * @brief Replace data in the buffer
- *
- * @param[in] start Position started in the buffer
- * @param[in] end Position ended in the buffer
- * @param[in] insertText Test to set in the range [start..end]
- *
- * @return nb Octet inserted
- *
- */
-int32_t EdnBuf::Replace(int32_t start, int32_t end, etk::Vector &insertText)
-{
- if (end-start == 0) {
- return 0;
- }
- etk::Vector deletedText;
- getRange(start, end, deletedText);
- m_data.Replace(start, end-start, insertText);
- // update internal elements
- eventModification(start, insertText.size(), deletedText);
- return insertText.size();
-}
-
-int32_t EdnBuf::Replace(int32_t start, int32_t end, etk::UString &insertText)
-{
- if (end-start == 0) {
- return 0;
- }
- etk::Vector deletedText;
- getRange(start, end, deletedText);
- etk::Vector tmpInsertText;
- if (true == m_isUtf8) {
- etk::Char tmpChar = insertText.c_str();
- const char * tmpPointer = tmpChar;
- while (*tmpPointer != '\0') {
- tmpInsertText.pushBack(*tmpPointer++);
- }
- } else {
- etk::Vector tmppp = insertText.getVector();
- convertUnicodeToIso(m_charsetType, tmppp, tmpInsertText);
- }
- if (tmpInsertText.size()>0) {
- if (tmpInsertText[tmpInsertText.size()-1] == '\0') {
- tmpInsertText.popBack();
- }
- }
- if (tmpInsertText.size()>0) {
- if (tmpInsertText[tmpInsertText.size()-1] == '\0') {
- tmpInsertText.popBack();
- }
- }
- m_data.Replace(start, end-start, tmpInsertText);
- // update internal elements
- eventModification(start, tmpInsertText.size(), deletedText);
- return tmpInsertText.size();
-}
-
-
-/**
- * @brief remove data between [start..end]
- *
- * @param[in] start Position started in the buffer
- * @param[in] end Position ended in the buffer
- *
- * @return ---
- *
- */
-void EdnBuf::remove(int32_t start, int32_t end)
-{
-
- etk::Vector deletedText;
- // Make sure the arguments make sense
- if (start > end) {
- int32_t temp = start;
- start = end;
- end = temp;
- }
- start = etk_avg(0 , start, m_data.size());
- end = etk_avg(0 , end, m_data.size());
-
- // remove and redisplay
- getRange(start, end, deletedText);
- m_data.remove(start, end - start);
- eventModification(start, 0, deletedText);
-}
-
-
-int32_t EdnBuf::Indent(void)
-{
- int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
- bool SelectionIsRect;
- bool haveSelectionActive = getSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
-
- if (false == haveSelectionActive) {
- return SelectionEnd;
- }
- // disable selection:
- Unselect();
- // get Range :
- int32_t l_start = StartOfLine(SelectionStart);
- int32_t l_end = EndOfLine(SelectionEnd);
- etk::Vector l_tmpData;
- getRange(l_start, l_end, l_tmpData);
-
- l_tmpData.insert(0, '\n');
- for (int32_t i=1; i l_tmpData;
- getRange(l_start, l_end, l_tmpData);
-
- l_tmpData.insert(0, '\n');
- for (int32_t i=1; i &text)
-{
- getRange( StartOfLine(pos), EndOfLine(pos), text);
-}
-
-
-/**
- * @brief find the position of the start of the current line
- *
- * @param[in] pos position inside the line whe we need to find the start
- *
- * @return position of the start of the line
- *
- */
-int32_t EdnBuf::StartOfLine(int32_t pos)
-{
- int32_t startPos;
- if (false == SearchBackward(pos, '\n', &startPos)) {
- return 0;
- }
- return startPos + 1;
-}
-
-
-/**
- * @brief find the position of the end of the current line
- *
- * @param[in] pos position inside the line whe we need to find the end
- *
- * @return position of the end of the line
- *
- */
-int32_t EdnBuf::EndOfLine(int32_t pos)
-{
- int32_t endPos;
- if (false == SearchForward(pos, '\n', &endPos)) {
- endPos = m_data.size();
- }
- return endPos;
-}
-
-
-/**
- * @brief Transform the current caracter in the buffer in a displayable vector of char
- *
- * @param[in,out] pos position of the char that might be converted (incremented to the next char (in case of UTF8)
- * @param[in] indent Curent indentation befor the curent char
- * @param[out] outUTF8 string of the displayed element
- * @param[out] currentChar curent unicode output char
- *
- * @return number of displayable char (display char width)
- *
- */
-int32_t EdnBuf::getExpandedChar(int32_t &pos, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN], uint32_t ¤tChar)
-{
- int32_t i, nSpaces;
- char c = m_data.get(pos);
- currentChar = (uint32_t)c & 0xFF;
- /* convert tabs to spaces */
- if (c == '\t') {
- nSpaces = m_tabDist - (indent % m_tabDist);
- for (i=0; i';
- outUTF8[5] = '\0';
- pos++;
- return 5;
- }
- if (((unsigned char)c) == '\n') {
- outUTF8[0] = (unsigned char)c;
- outUTF8[1] = '\0';
- pos++;
- return 1;
- }
- if (((unsigned char)c) <= 31) {
- const char * tmp = ControlCodeTable[(unsigned char)c];
- int32_t nbElem = 2;
- *outUTF8++ = '<';
- while (*tmp!='\0') {
- *outUTF8++ = *tmp;
- tmp++;
- nbElem++;
- }
- *outUTF8++ = '>';
- *outUTF8++ = '\0';
- pos++;
- return nbElem;
- } else if (c == 127) {
- outUTF8[0] = '<';
- outUTF8[1] = 'd';
- outUTF8[2] = 'e';
- outUTF8[3] = 'l';
- outUTF8[4] = '>';
- outUTF8[5] = '\0';
- pos++;
- return 5;
- }
-
- // Otherwise, just return the character
- if (m_isUtf8 == false) {
- convertIsoToUtf8(m_charsetType, c, outUTF8);
- pos++;
- } else {
- char tmpString[8];
- for (int32_t k=0; k<6 && k< m_data.size() - pos; k++) {
- tmpString[k] = m_data.get(pos+k);
- }
- tmpString[6] = '\0';
- uint8_t size;
- bool baseValid;
- unicode::Utf8_SizeElement(tmpString, 6 , size, baseValid);
- currentChar = 0; // TODO : set UNICODE char ...
- if (baseValid == true) {
- char *tmp = outUTF8;
- for (int32_t kkk=0; kkk");
- }
- if (0 == size) {
- APPL_ERROR("plop");
- }
- pos+=size;
- return strlen(outUTF8);
- }
- return 1;
-}
-
-/**
- * @brief Transform the current caracter in the buffer in a displayable vector of char
- *
- * @param[in,out] pos position of the char that might be converted (incremented to the next char (in case of UTF8)
- * @param[in] indent Curent indentation befor the curent char
- * @param[out] outUTF8 string of the displayed element
- * @param[out] currentChar curent unicode output char
- *
- * @return number of displayable char (display char width)
- *
- */
-int32_t EdnBuf::getExpandedChar(int32_t &pos, int32_t indent, etk::UChar outUnicode[MAX_EXP_CHAR_LEN], uint32_t ¤tChar)
-{
- int32_t i, nSpaces;
- char c = m_data.get(pos);
- currentChar = (uint32_t)c & 0xFF;
- /* convert tabs to spaces */
- if (c == '\t') {
- nSpaces = m_tabDist - (indent % m_tabDist);
- for (i=0; i';
- outUnicode[5] = '\0';
- pos++;
- return 5;
- }
- if (((unsigned char)c) == '\n') {
- outUnicode[0] = (unsigned char)c;
- outUnicode[1] = '\0';
- pos++;
- return 1;
- }
- if (((unsigned char)c) <= 31) {
- const char * tmp = ControlCodeTable[(unsigned char)c];
- int32_t nbElem = 2;
- *outUnicode++ = '<';
- while (*tmp!='\0') {
- *outUnicode++ = *tmp;
- tmp++;
- nbElem++;
- }
- *outUnicode++ = '>';
- *outUnicode++ = '\0';
- pos++;
- return nbElem;
- } else if (c == 127) {
- outUnicode[0] = '<';
- outUnicode[1] = 'd';
- outUnicode[2] = 'e';
- outUnicode[3] = 'l';
- outUnicode[4] = '>';
- outUnicode[5] = '\0';
- pos++;
- return 5;
- }
- // clear all the data ...
- memset(outUnicode, 0, sizeof(etk::UChar)*MAX_EXP_CHAR_LEN);
-
- // Otherwise, just return the character
- if (false == m_isUtf8) {
- unicode::convertIsoToUnicode(m_charsetType, c, outUnicode[0]);
- pos++;
- } else {
- char tmpString[8];
- for (int32_t k=0; k<6 && k< m_data.size() - pos; k++) {
- tmpString[k] = m_data.get(pos+k);
- }
- tmpString[6] = '\0';
- uint8_t size;
- bool baseValid;
- unicode::Utf8_SizeElement(tmpString, 6 , size, baseValid);
- currentChar = 0;
- if (true == baseValid) {
- char tmp[20];
- for (int32_t kkk=0; kkk';
- outUnicode[5] = 0;
- }
- if (0 == size) {
- APPL_ERROR("plop");
- }
- pos+=size;
- int32_t outSize = 0;
- while (outUnicode[outSize]!=0) {
- outSize++;
- }
- return outSize;
- }
- return 1;
-}
-
-
-/**
- * @brief generate the real display of character of the output (ex : \t == > 4 spaces or less ...)
- *
- * @param[in] c Char that might be converted
- * @param[in] indent Curent indentation befor the curent char
- * @param[out] outStr string of the displayed element
- *
- * @return size of the display
- *
- */
-int32_t EdnBuf::ExpandCharacter(char c, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN])
-{
- int32_t i, nSpaces;
-
- /* convert tabs to spaces */
- if (c == '\t') {
- nSpaces = m_tabDist - (indent % m_tabDist);
- for (i=0; i';
- outUTF8[5] = '\0';
- return 5;
- }
- if (((unsigned char)c) <= 31) {
- const char * tmp = ControlCodeTable[(unsigned char)c];
- *outUTF8++ = '<';
- while (*tmp!='\0') {
- *outUTF8++ = *tmp;
- tmp++;
- }
- *outUTF8++ = '>';
- *outUTF8++ = '\0';
- return ControlCodeTable[(unsigned char)c] - tmp + 2;
- } else if (c == 127) {
- outUTF8[0] = '<';
- outUTF8[1] = 'd';
- outUTF8[2] = 'e';
- outUTF8[3] = 'l';
- outUTF8[4] = '>';
- outUTF8[5] = '\0';
- return 5;
- }
-
- // Otherwise, just return the character
- //*outStr = c; // deprecated
- convertIsoToUtf8(unicode::EDN_CHARSET_ISO_8859_15, c, outUTF8);
- return 1;
-}
-
-/**
- * @brief generate the size of the display of one element
- *
- * @param[in] c Char that might be converted
- * @param[in] indent Curent indentation befor the curent char
- *
- * @return size of the display
- *
- */
-int32_t EdnBuf::CharWidth(char c, int32_t indent)
-{
- /* Note, this code must parallel that in ExpandCharacter */
- if (c == '\0') {
- return 5;
- } else if (c == '\t') {
- return m_tabDist - (indent % m_tabDist);
- } else if (((unsigned char)c) <= 31) {
- return strlen(ControlCodeTable[(unsigned char)c]) + 2;
- } else if (c == 127) {
- return 5;
- }
- return 1;
-}
-
-
-/**
- * @brief Count the number of displayed characters between buffer position
- *
- * displayed characters are the characters shown on the screen to represent characters in the
- * buffer, where tabs and control characters are expanded
- *
- * @param[in] lineStartPos Start position in the line
- * @param[in] targetPos displayed target position in char
- *
- * @return the ID in the buffer of the requested char
- *
- */
-int32_t EdnBuf::CountDispChars(int32_t lineStartPos, int32_t targetPos)
-{
- int32_t charCount = 0;
- char expandedChar[MAX_EXP_CHAR_LEN];
- //APPL_DEBUG("lineStartPos="<< lineStartPos << " targetPos=" << targetPos);
- for(int32_t iii = lineStartPos; iii< targetPos && iii m_data.size() ) {
- return m_data.size();
- }
- int32_t lineCount = 0;
- //APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
- int32_t iii = 0;
- for(iii = startPos; iii (1) at position=" << myPosIt.Position()+1 );
- return iii+1;
- }
- }
- }
- //APPL_INFO(" == > (2) at position=" << myPosIt.Position() );
- return iii;
-}
-
-
-/**
- * @brief find the first character of the line "nLines" backwards
- *
- * @param[in,out] startPos Start position to count (this caracter is not counted)
- * @param[in,out] nLines number of line to count (if == 0 means find the beginning of the line)
- *
- * @return position of the starting the line
- *
- */
-int32_t EdnBuf::CountBackwardNLines(int32_t startPos, int32_t nLines)
-{
- if (startPos <= 0) {
- return 0;
- } else if (startPos > m_data.size() ) {
- startPos = m_data.size();
- }
- //APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
-
- int32_t lineCount = -1;
- for(int32_t iii = startPos-1; iii >= 0 ; iii-- ) {
- if ('\n' == m_data[iii]) {
- lineCount++;
- if (lineCount >= nLines) {
- //APPL_INFO(" == > (1) at position=" << myPosIt.Position()+1 );
- return iii+1;
- }
- }
- }
- //APPL_INFO(" == > (2) at position=0");
- return 0;
-}
-
-
-bool EdnBuf::charMatch(char first, char second, bool caseSensitive)
-{
- if (false == caseSensitive) {
- if ('A' <= first && 'Z' >= first) {
- first = first - 'A' + 'a';
- }
- if ('A' <= second && 'Z' >= second) {
- second = second - 'A' + 'a';
- }
- }
- if(first == second) {
- //APPL_DEBUG("charMatch(" << first << ", " << second << ", " << caseSensitive << ") == > true");
- return true;
- } else {
- //APPL_DEBUG("charMatch(" << first << ", " << second << ", " << caseSensitive << ") == > false");
- return false;
- }
-}
-
-/**
- * @brief Search forwards in buffer
- *
- * @param[in] startPos Position to start the search
- * @param[in] searchVect String to search
- * @param[out] foundPos Current position founded
- *
- * @return true == > found data
- * @return false == > not found data
- *
- */
-bool EdnBuf::SearchForward(int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive)
-{
- etk::Vector searchVect;
- if (true == m_isUtf8) {
- etk::Char tmpChar = search.c_str();
- const char * tmpPointer = tmpChar;
- while (*tmpPointer != '\0') {
- searchVect.pushBack(*tmpPointer++);
- }
- } else {
- etk::Vector tmppp = search.getVector();
- convertUnicodeToIso(m_charsetType, tmppp, searchVect);
- }
- // remove the '\0' at the end of the string ...
- searchVect.popBack();
- int32_t position;
- int32_t searchLen = searchVect.size();
- int32_t dataLen = m_data.size();
- char currentChar = '\0';
- APPL_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
- for (position=startPos; position found data
- * @return false == > not found data
- *
- */
-bool EdnBuf::SearchBackward(int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive)
-{
- etk::Vector searchVect;
- if (true == m_isUtf8) {
- etk::Char tmpChar = search.c_str();
- const char * tmpPointer = tmpChar;
- while (*tmpPointer != '\0') {
- searchVect.pushBack(*tmpPointer++);
- }
- } else {
- etk::Vector tmppp = search.getVector();
- convertUnicodeToIso(m_charsetType, tmppp, searchVect);
- }
- // remove the '\0' at the end of the string ...
- searchVect.popBack();
-
- int32_t position;
- int32_t searchLen = searchVect.size();
- char currentChar = '\0';
- //APPL_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
- for (position=startPos; position >= searchLen-1; position--) {
- currentChar = m_data[position];
- if (true == charMatch(currentChar, searchVect[searchLen-1], caseSensitive)) {
- int32_t i;
- bool found = true;
- for (i=searchLen-1; i >= 0; i--) {
- currentChar = m_data[position - (searchLen-1) + i];
- if (false == charMatch(currentChar, searchVect[i], caseSensitive)) {
- found = false;
- break;
- }
- }
- if (true == found) {
- *foundPos = position - (searchLen-1);
- *foundPosEnd = position + searchVect.size();
- return true;
- }
- }
- }
- *foundPos = m_data.size();
- *foundPosEnd = m_data.size();
- return false;
-}
-
-static bool isChar(char value)
-{
- if( ('a' <= value && 'z' >= value)
- || ('A' <= value && 'Z' >= value)
- || ('0' <= value && '9' >= value)
- || '_' == value
- || '~' == value)
- {
- //APPL_DEBUG(" is a char \"" << value << "\"");
- return true;
- }
- //APPL_DEBUG(" is NOT a char \"" << value << "\"");
- return false;
-}
-
-
-bool EdnBuf::SelectAround(int32_t startPos, int32_t &beginPos, int32_t &endPos)
-{
- char currentChar = m_data[startPos];
- if( '\t' == currentChar
- || ' ' == currentChar)
- {
- APPL_DEBUG("select spacer");
- // special case we are looking for separation
- for (beginPos=startPos; beginPos >= 0; beginPos--) {
- currentChar = m_data[beginPos];
- if( '\t' != currentChar
- && ' ' != currentChar)
- {
- beginPos++;
- break;
- }
- }
- // special case we are looking for separation
- for (endPos=startPos; endPos= 0; beginPos--) {
- currentChar = m_data[beginPos];
- if( false == isChar(currentChar)) {
- beginPos++;
- break;
- }
- }
- // Search forward
- for (endPos=startPos; endPos= 0; beginPos--) {
- currentChar = m_data[beginPos];
- if(comparechar != currentChar)
- {
- beginPos++;
- break;
- }
- }
- // Search forward
- for (endPos=startPos; endPos &insertText)
-{
- // insert data in buffer
- m_data.insert(pos, insertText);
- // update the current selected area
- updateSelection(pos, 0, insertText.size() );
- // return the number of element inserted ...
- return insertText.size();
-}
-int32_t EdnBuf::LocalInsert(int32_t pos, etk::UString &insertText)
-{
- etk::Vector tmpInsertText;
- if (true == m_isUtf8) {
- etk::Char tmpChar = insertText.c_str();
- const char * tmpPointer = tmpChar;
- while (*tmpPointer != '\0') {
- tmpInsertText.pushBack(*tmpPointer++);
- }
- } else {
- etk::Vector tmppp = insertText.getVector();
- convertUnicodeToIso(m_charsetType, tmppp, tmpInsertText);
- }
- if (tmpInsertText.size()>0) {
- if (tmpInsertText[tmpInsertText.size()-1] == '\0') {
- tmpInsertText.popBack();
- }
- }
- return LocalInsert(pos, tmpInsertText);
-}
-
-
-/**
- * @brief when modification appeare in the buffer we save it in the undo vector...
- *
- * @param[in] pos position of the add or remove
- * @param[in] nInserted nb element inserted
- * @param[in] deletedText Deleted elevent in a vector
- *
- * @return ---
- *
- */
-void EdnBuf::eventModification(int32_t pos, int32_t nInserted, etk::Vector &deletedText)
-{
- if( 0 == deletedText.size()
- && 0 == nInserted)
- {
- // we do nothing ...
- //APPL_INFO("EdnBuf::eventModification(pos="<= 0; i--) {
- if (NULL != m_historyRedo[i]) {
- delete(m_historyRedo[i]);
- }
- m_historyRedo.popBack();
- }
- }
- } else {
- // undo processing == > add element in Redo vector ...
- EdnBufHistory *exempleHistory = new EdnBufHistory(pos, nInserted, deletedText);
- m_historyRedo.pushBack(exempleHistory);
- }
- // Regenerate the Highlight :
- RegenerateHighLightAt(pos, deletedText.size(), nInserted);
- }
-}
-
-
-
-
-
-/**
- * @brief Search a character in the current buffer
- *
- * @param[in] startPos Position to start the search of the element
- * @param[in] searchChar Character to search
- * @param[out] foundPos Position where it was found
- *
- * @return true when find element
- *
- */
-bool EdnBuf::SearchForward(int32_t startPos, char searchChar, int32_t *foundPos)
-{
- // move in the string
- for(int32_t iii=startPos ; iii= 0 ; iii-- ) {
- if (m_data[iii] == searchChar) {
- *foundPos = iii;
- return true;
- }
- }
- *foundPos = 0;
- return false;
-}
-
-
diff --git a/sources/appl/Buffer/EdnBuf/EdnBuf.h b/sources/appl/Buffer/EdnBuf/EdnBuf.h
deleted file mode 100644
index 414e89c..0000000
--- a/sources/appl/Buffer/EdnBuf/EdnBuf.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#ifndef __EDN_BUF_H__
-#define __EDN_BUF_H__
-
-/* Maximum length in characters of a tab or control character expansion
- of a single buffer character */
-#define MAX_EXP_CHAR_LEN 20*4
-
-class EdnBuf;
-
-#include
-#include
-#include
-#include
-
-/*
-
- rectStart rectStart
-start ************* *************
- ********** * xxxx*xxxxxx *
- * ******** xxxx*xxxxxxxxxxx*xxxxx
-end *************** *************
- rectEnd rectEnd
-
-
-
-*/
-typedef struct {
- bool selected; //!< True if the selection is active
- bool rectangular; //!< True if the selection is rectangular
- bool zeroWidth; //!< Width 0 selections aren't "real" selections, but they can be useful when creating rectangular selections from the keyboard.
- int32_t start; //!< Pos. of start of selection, or if rectangular start of line containing it.
- int32_t end; //!< Pos. of end of selection, or if rectangular end of line containing it.
- int32_t rectStart; //!< Indent of left edge of rect. selection
- int32_t rectEnd; //!< Indent of right edge of rect. selection
-} selection;
-
-typedef struct {
- etk::Vector HLData;
- int32_t posHLPass1;
- int32_t posHLPass2;
-}appl::DisplayHLData;
-
-class EdnBuf {
- // TODO : set an iterator to acces at every data without knowin the system ...
- public:
- // constructer
- EdnBuf(void);
- // destructer
- ~EdnBuf(void);
- // public function :
- void getAll(etk::Vector& _text);
- void setAll(etk::Vector& _text);
- void getRange(int32_t _start, int32_t _end, etk::Vector& _output);
- void getRange(int32_t _start, int32_t _end, etk::UString& _output);
- bool DumpIn(etk::FSNode& _file);
- bool DumpFrom(etk::FSNode& _file);
- // replace with operator [] ...
- int8_t operator[] (int32_t) const;
- int32_t insert(int32_t _pos, etk::Vector& _insertText);
- int32_t insert(int32_t _pos, etk::UString& _insertText);
- int32_t Replace(int32_t _start, int32_t _end, etk::Vector& _insertText);
- int32_t Replace(int32_t _start, int32_t _end, etk::UString& _insertText);
- void remove(int32_t _start, int32_t _end);
- int32_t Indent(void);
- int32_t UnIndent(void);
-
-
- void getLineText(int32_t _pos, etk::Vector& _text);
- int32_t StartOfLine(int32_t _pos);
- int32_t EndOfLine(int32_t _pos);
-
- int32_t getExpandedChar(int32_t& _pos, int32_t _indent, etk::UChar _outUnicode[MAX_EXP_CHAR_LEN], uint32_t& _currentChar);
- int32_t getExpandedChar(int32_t& _pos, int32_t _indent, char _outUTF8[MAX_EXP_CHAR_LEN], uint32_t& _currentChar);
- int32_t ExpandCharacter(char _c, int32_t _indent, char _outUTF8[MAX_EXP_CHAR_LEN]); // TODO : remove
- 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 CountLines(int32_t _startPos, int32_t _endPos);
- int32_t CountLines(void);
- int32_t CountLines(etk::Vector& _data);
- int32_t CountForwardNLines(int32_t _startPos, int32_t _nLines);
- int32_t CountBackwardNLines(int32_t _startPos, int32_t _nLines);
-
- bool SearchForward(int32_t _startPos, etk::UString& _search, int32_t* _foundPos, int32_t* _foundPosEnd, bool _caseSensitive = true);
- bool SearchBackward(int32_t _startPos, etk::UString& _search, int32_t* _foundPos, int32_t* _foundPosEnd, bool _caseSensitive = true);
- bool SearchForward(int32_t _startPos, char _searchChar, int32_t* _foundPos);
- bool SearchBackward(int32_t _startPos, char _searchChar, int32_t* _foundPos);
- bool SelectAround(int32_t _startPos, int32_t& _beginPos, int32_t& _endPos);
-
- // Buffer size system :
- int32_t size(void) { return m_data.size(); };
- int32_t NumberOfLines(void) { return m_nbLine; };
-
- // -----------------------------------------
- // selection remember...
- // -----------------------------------------
- public:
- bool SelectHasSelection(void);
- void Select(int32_t _start, int32_t _end);
- void Unselect(void);
- void RectSelect(int32_t _start, int32_t _end, int32_t _rectStart, int32_t _rectEnd);
- bool getSelectionPos(int32_t& _start, int32_t& _end, bool& _isRect, int32_t& _rectStart, int32_t& _rectEnd);
- void getSelectionText(etk::Vector& _text);
- void getSelectionText(etk::UString& _text);
- void removeSelected(void);
- int32_t ReplaceSelected(etk::Vector& _text);
- int32_t ReplaceSelected(etk::UString& _text);
- private:
- // current selection of the buffer
- selection m_selectionList; //!< Selection area of the buffer
- void updateSelection(int32_t _pos, int32_t _nDeleted, int32_t _nInserted);
-
- // -----------------------------------------
- // History section :
- // -----------------------------------------
- public:
- int32_t Undo(void);
- int32_t Redo(void);
- private:
- bool m_isUndoProcessing;
- bool m_isRedoProcessing;
- etk::Vector m_historyUndo;
- etk::Vector m_historyRedo;
-
- // -----------------------------------------
- // hightlight section :
- // -----------------------------------------
- private:
- Highlight * m_Highlight; //!< internal link with the Highlight system
- etk::Vector m_HLDataPass1; //!< colorisation position in the current buffer pass 1
- void RegenerateHighLightAt(int32_t _pos, int32_t _nbDeleted, int32_t _nbAdded);
- void generateHighLightAt(int32_t _pos, int32_t _endPos, int32_t _addinPos=0);
- void CleanHighLight(void);
- void findMainHighLightPosition(int32_t _startPos, int32_t _endPos, int32_t &_startId, int32_t &_stopId, bool _backPreviousNotEnded);
- public:
- void setHLSystem(Highlight* _newHLSystem);
- void HightlightGenerateLines(appl::DisplayHLData& _MData, int32_t _startPos, int32_t _nbLines);
- appl::HighlightInfo* getElementColorAtPosition(appl::DisplayHLData& _MData, int32_t _pos);
- private:
- appl::HighlightInfo* getElementColorAtPosition(int32_t _pos, int32_t &_starPos);
-
- private:
- etk::Buffer m_data; //!< buffer of the data in the mode int8_t
- void CountNumberOfLines(void);
- int32_t m_nbLine; //!< Number of line in the biffer
-
- // -----------------------------------------
- // display property and charset ...
- // -----------------------------------------
- public:
- int32_t getTabDistance(void) { return m_tabDist; } ;
- void setTabDistance(int32_t _tabDist) { m_tabDist = _tabDist; };
- unicode::charset_te getCharsetType(void) { return m_charsetType; };
- void setCharsetType(unicode::charset_te _newOne) { m_charsetType = _newOne; if (unicode::EDN_CHARSET_UTF8 == _newOne){m_isUtf8=true;} else {m_isUtf8=false;} };
- bool getUTF8Mode(void) { return m_isUtf8; };
- void setUTF8Mode(bool _newOne) { m_isUtf8 = _newOne; m_charsetType=unicode::EDN_CHARSET_UTF8; };
- private:
- // Special mode of the buffer :
- bool m_isUtf8; //!< true if we are in UTF8 mode == > if true the size of a char is 0, otherwise .. 1->4 ( TODO : not now)
- unicode::charset_te m_charsetType; //!< if UTF8 mode is at false : the charset type of the buffer
- // Local Tabulation policies
- int32_t m_tabDist; //!< equiv. number of characters in a tab
- bool m_useTabs; //!< True if buffer routines are allowed to use tabs for padding in rectangular operations
-
- // -----------------------------------------
- // Local function :
- // -----------------------------------------
- private:
- void findRectSelBoundariesForCopy(int32_t _lineStartPos, int32_t _rectStart, int32_t _rectEnd, int32_t *_selStart, int32_t *_selEnd);
- char* getSelectionText(selection& _sel);
- void removeSelected(selection& _sel);
- void replaceSelected(selection& _sel, const char* _text);
- void eventModification(int32_t _pos, int32_t _nInserted, etk::Vector& _deletedText);
- int32_t LocalInsert(int32_t _pos, etk::Vector &_insertText);
- int32_t LocalInsert(int32_t _pos, etk::UString &_insertText);
- bool charMatch(char _first, char _second, bool _caseSensitive = true);
-};
-
-#endif
diff --git a/sources/appl/Buffer/EdnBuf/EdnBufHistory.cpp b/sources/appl/Buffer/EdnBuf/EdnBufHistory.cpp
deleted file mode 100644
index 1fbc64f..0000000
--- a/sources/appl/Buffer/EdnBuf/EdnBufHistory.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#include
-#include
-#include
-
-
-#undef __class__
-#define __class__ "EdnBufHistory"
-
-EdnBufHistory::EdnBufHistory(void)
-{
- //APPL_INFO("EdnBufHistory new");
- m_pos = 0;
- m_nInserted = 0;
-}
-
-EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, etk::Vector &deletedText)
-{
- //APPL_INFO("EdnBufHistory new + data");
- m_pos = pos;
- m_nInserted = nInserted;
- m_deletedText = deletedText;
-}
-
-void EdnBufHistory::set(int32_t pos, int32_t nInserted, etk::Vector &deletedText)
-{
- //APPL_INFO("EdnBufHistory new + data");
- m_pos = pos;
- m_nInserted = nInserted;
- m_deletedText = deletedText;
-}
-
-EdnBufHistory::~EdnBufHistory(void)
-{
- // nothing to do ...
-}
-
-int32_t EdnBufHistory::getPos(void)
-{
- return m_pos;
-}
-
-int32_t EdnBufHistory::getnbDeleted(void)
-{
- return m_deletedText.size();
-}
-
-int32_t EdnBufHistory::getnbInserted(void)
-{
- return m_nInserted;
-}
-
-void EdnBufHistory::getData(etk::Vector &deletedText)
-{
- deletedText = m_deletedText;
-}
-
diff --git a/sources/appl/Buffer/EdnBuf/EdnBufHistory.h b/sources/appl/Buffer/EdnBuf/EdnBufHistory.h
deleted file mode 100644
index 5c25623..0000000
--- a/sources/appl/Buffer/EdnBuf/EdnBufHistory.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#ifndef __EDN_BUFFER_HISTORY_H__
-#define __EDN_BUFFER_HISTORY_H__
-
-
-#include
-
-class EdnBufHistory{
- public:
- EdnBufHistory(void);
- EdnBufHistory(int32_t pos, int32_t nInserted, etk::Vector &deletedText);
- ~EdnBufHistory(void);
- void set(int32_t pos, int32_t nInserted, etk::Vector &deletedText);
- int32_t getPos(void);
- int32_t getnbDeleted(void);
- int32_t getnbInserted(void);
- void getData(etk::Vector &deletedText);
- private:
- int32_t m_pos;
- int32_t m_nInserted;
- etk::Vector m_deletedText;
-};
-
-#endif
-
diff --git a/sources/appl/Buffer/EdnBuf/EdnBuf_HighLight.cpp b/sources/appl/Buffer/EdnBuf/EdnBuf_HighLight.cpp
deleted file mode 100644
index 3af55c8..0000000
--- a/sources/appl/Buffer/EdnBuf/EdnBuf_HighLight.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#include
-#include
-#include
-
-
-#undef __class__
-#define __class__ "EdnBuf{HighLight}"
-
-void EdnBuf::setHLSystem(Highlight * newHLSystem)
-{
- if (m_Highlight != newHLSystem) {
- m_Highlight = newHLSystem;
- m_HLDataPass1.clear();
- RegenerateHighLightAt(0, 0, m_data.size());
- }
-}
-
-// TODO : Check this fuction it have too many conditionnal inside == > can do a better algo
-void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded)
-{
- //GTimeVal timeStart;
- //g_get_current_time(&timeStart);
-
- // prevent ERROR...
- if (NULL == m_Highlight) {
- return;
- }
- // prevent No data Call
- if( 0 == nbDeleted
- && 0 == nbAdded)
- {
- return;
- }
- // normal case
- //APPL_INFO("(pos="<getName();
- }
- APPL_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;
- int32_t stopId;
- // clean data if needed
- if (0 != m_HLDataPass1.size()) {
- // find element previous
- findMainHighLightPosition(pos, posEnd, startId, stopId, true);
-
- // remove deprecated element
- if( -1 == startId
- && -1 == stopId)
- {
- m_HLDataPass1.clear();
- } else if(-1 == startId) {
- if (0 == stopId){
- m_HLDataPass1.Erase(0);
- //APPL_DEBUG("1 * Erase 0");
- } else {
- m_HLDataPass1.EraseLen(0,stopId);
- //APPL_DEBUG("2 * Erase 0->" << stopId);
- }
- } else if(-1 == stopId) {
- //APPL_DEBUG("3 * Erase " << startId+1 << "-> end");
- m_HLDataPass1.EraseLen(startId+1, m_HLDataPass1.size() - startId);
- stopId = -1;
- } else {
- int32_t currentSize = m_HLDataPass1.size();
- //APPL_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" );
- m_HLDataPass1.EraseLen(startId+1, stopId - startId);
- if (stopId == currentSize-1) {
- stopId = -1;
- }
- }
- //APPL_DEBUG("new size=" << (int32_t)m_HLDataPass1.size()-1);
- /*
- for (i=0; i< (int32_t)m_HLDataPass1.size(); i++) {
- etk::UString ploppp;
- if (NULL != m_HLDataPass1[i].patern ) {
- ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->getName();
- }
- APPL_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) {
- elemStart = 0;
- } else {
- elemStart = startId+1;
- }
- for (i=elemStart; i< (int32_t)m_HLDataPass1.size(); i++) {
- //APPL_DEBUG("move element=" << i);
- m_HLDataPass1[i].beginStart += nbAdded - nbDeleted;
- m_HLDataPass1[i].beginStop += nbAdded - nbDeleted;
- m_HLDataPass1[i].endStart += nbAdded - nbDeleted;
- m_HLDataPass1[i].endStop += nbAdded - nbDeleted;
- }
- //Regenerate Element inside range
- if( -1 == startId
- && -1 == stopId)
- {
- //APPL_DEBUG("******* Regenerate ALL");
- generateHighLightAt(0, m_data.size());
- } else if(-1 == startId) {
- //APPL_DEBUG("******* Regenerate START");
- generateHighLightAt(0, m_HLDataPass1[0].beginStart, 0);
- } else if(-1 == stopId) {
- //APPL_DEBUG("******* Regenerate STOP");
- generateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].endStop, m_data.Size(), m_HLDataPass1.Size());
- } else {
- //APPL_DEBUG("******* Regenerate RANGE");
- generateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1);
- }
- } else {
- // Parse the new element ...
- generateHighLightAt(0, m_data.size());
- }
- /*
- for (i=0; i< (int32_t)m_HLDataPass1.size(); i++) {
- etk::UString ploppp;
- if (NULL != m_HLDataPass1[i].patern ) {
- ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->getName();
- }
- APPL_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);
- //APPL_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
-}
-
-void EdnBuf::findMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded)
-{
- startId = -1;
- stopId = -1;
- /* rules to start stop:
- HighLight data ----
- remove area ****
- Start pos S
- End pos E
-
- Some Case :
- ----------- ------------ ------------- ----------
- S **** E
-
- ----------- ------------ ------------- ----------
- S ********** E
-
- ----------- ------------ ------------- ----------
- S **** E
-
- ----------- ------------ ------------- ----------
- S ********* E
-
- ----------- ------------ ------------- ----------
- S ********************* E
-
- ----------- ------------ ------------- ----------
- S ************************ E
-
- ----------- ------------ ------------- ----------
- S ***************** E
-
- ----------- ------------ ------------- ----------
- S *************** E
-
- ----------- ------------
- S *************** E=-1
-
- ------------ ------------- ----------
- S=-1 *************** E
- */
- int32_t i;
- for (i=0; i< (int32_t)m_HLDataPass1.size(); i++) {
- if (m_HLDataPass1[i].endStop > startPos) {
- break;
- }
- startId = i;
- }
- // go back while the previous element is not eneded
- if (true == backPreviousNotEnded) {
- for (i=startId; i >= 0; i--) {
- if (m_HLDataPass1[i].notEnded == false) {
- break;
- }
- startId = i-1;
- }
- }
- int32_t elemStart;
- if(-1 == startId) {
- elemStart = 0;
- } else {
- elemStart = startId+1;
- }
- for (i=elemStart; i< (int32_t)m_HLDataPass1.size(); i++) {
- if (m_HLDataPass1[i].beginStart > endPos)
- {
- stopId = i;
- break;
- }
- }
- /*
- if (-1 != startId && startId < (int32_t)m_HLDataPass1.size()) {
- APPL_DEBUG(" == > BEGIN : start="< BEGIN : start=???, stop=??? id=" << startId);
- }
- if (-1 != stopId && stopId < (int32_t)m_HLDataPass1.size()) {
- APPL_DEBUG(" == > END : start="< END : start=???, stop=??? id=" << stopId);
- }
- */
-}
-
-
-
-
-void EdnBuf::generateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos)
-{
- if (NULL == m_Highlight) {
- return;
- }
- //APPL_DEBUG("area : ("<Parse(pos, endPos, m_HLDataPass1, addinPos, m_data);
-}
-
-
-
-void EdnBuf::CleanHighLight(void)
-{
- // remove all element in the list...
- m_HLDataPass1.clear();
-}
-
-
-appl::ColorInfo *EdnBuf::getElementColorAtPosition(int32_t pos, int32_t &starPos)
-{
- int32_t i;
- int32_t start = etk_max(0, starPos-1);
- for (i=start; i<(int32_t)m_HLDataPass1.size(); i++) {
- starPos = i;
- if( m_HLDataPass1[i].beginStart <= pos
- && m_HLDataPass1[i].endStop > pos)
- {
- return &m_HLDataPass1[i];
- }
- if(m_HLDataPass1[i].beginStart > pos) {
- return NULL;
- }
- }
- return NULL;
-}
-
-
-void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines)
-{
- MData.posHLPass1 = 0;
- MData.posHLPass2 = 0;
- if (NULL == m_Highlight) {
- return;
- }
- //GTimeVal timeStart;
- //g_get_current_time(&timeStart);
- HLStart = StartOfLine(HLStart);
- MData.HLData.clear();
- int32_t HLStop = CountForwardNLines(HLStart, nbLines);
- int32_t startId, stopId;
- // find element previous
- findMainHighLightPosition(HLStart, HLStop, startId, stopId, true);
-
- int32_t k;
- //APPL_DEBUG("List of section between : "<< startId << " & " << stopId);
- int32_t endSearch = stopId+1;
- if (-1 == stopId) {
- endSearch = m_HLDataPass1.size();
- }
- for (k=etk_max(startId, 0); k (empty section 1 ) k="< (empty section 2 ) k="< (under section ) k="< (empty section 3 ) k="< (empty section 4 ) k="< pos)
- {
- return &MData.HLData[i];
- }
- if(MData.HLData[i].beginStart > pos) {
- return getElementColorAtPosition(pos, MData.posHLPass1);
- }
- }
- return getElementColorAtPosition(pos, MData.posHLPass1);
-}
diff --git a/sources/appl/Buffer/EdnBuf/EdnBuf_History.cpp b/sources/appl/Buffer/EdnBuf/EdnBuf_History.cpp
deleted file mode 100644
index 77a65d1..0000000
--- a/sources/appl/Buffer/EdnBuf/EdnBuf_History.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#include
-#include
-#include
-
-
-#undef __class__
-#define __class__ "EdnBuf{History}"
-
-
-
-
-int32_t EdnBuf::Undo(void)
-{
- int32_t nbElement = m_historyUndo.size();
- //APPL_DEBUG("EdnBuf::Undo Request id="< remove it");
- m_historyUndo.popBack();
- return -1;
- }
- int32_t pos = m_historyUndo[nbElement]->getPos();
- int32_t nbDeleted = m_historyUndo[nbElement]->getnbDeleted();
- int32_t nbInserted = m_historyUndo[nbElement]->getnbInserted();
- etk::Vector deletedText;
- m_historyUndo[nbElement]->getData(deletedText);
- m_isUndoProcessing = true;
- if (0 == nbInserted) {
- // just add data at position ...
- if (0 == nbDeleted) {
- APPL_DEBUG("EdnBuf::Undo nothing to do in UNDO");
- } else {
- insert(pos, deletedText);
- posDest = pos + nbDeleted;
- }
- } else {
- if (0 == nbDeleted) {
- // only remove data
- remove(pos, pos+nbInserted);
- posDest = pos;
- } else {
- // replace data
- Replace(pos, pos+nbInserted, deletedText);
- posDest = pos + nbDeleted;
- }
- }
- // remove element in the list :
- delete(m_historyUndo[nbElement]);
- m_historyUndo.popBack();
- m_isUndoProcessing = false;
- return posDest;
-}
-
-int32_t EdnBuf::Redo(void)
-{
- int32_t nbElement = m_historyRedo.size();
- //APPL_DEBUG("EdnBuf::Redo Request id="< remove it");
- m_historyRedo.popBack();
- return -1;
- }
- int32_t pos = m_historyRedo[nbElement]->getPos();
- int32_t nbDeleted = m_historyRedo[nbElement]->getnbDeleted();
- int32_t nbInserted = m_historyRedo[nbElement]->getnbInserted();
- etk::Vector deletedText;
- m_historyRedo[nbElement]->getData(deletedText);
- m_isRedoProcessing = true;
- if (0 == nbInserted) {
- // just add data at position ...
- if (0 == nbDeleted) {
- APPL_ERROR("EdnBuf::Redo nothing to do in REDO");
- } else {
- insert(pos, deletedText);
- posDest = pos + nbDeleted;
- }
- } else {
- if (0 == nbDeleted) {
- // only remove data
- remove(pos, pos+nbInserted);
- posDest = pos;
- } else {
- // replace data
- Replace(pos, pos+nbInserted, deletedText);
- posDest = pos + nbDeleted;
- }
- }
- // remove element in the list :
- delete(m_historyRedo[nbElement]);
- m_historyRedo.popBack();
- m_isRedoProcessing = false;
- return posDest;
-}
-
-
diff --git a/sources/appl/Buffer/EdnBuf/EdnBuf_Selection.cpp b/sources/appl/Buffer/EdnBuf/EdnBuf_Selection.cpp
deleted file mode 100644
index 02ad860..0000000
--- a/sources/appl/Buffer/EdnBuf/EdnBuf_Selection.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#include
-#include
-#include
-
-
-#undef __class__
-#define __class__ "EdnBuf{Selection}"
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-bool EdnBuf::SelectHasSelection(void)
-{
- return m_selectionList.selected;
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void EdnBuf::Select(int32_t start, int32_t end)
-{
- //selection oldSelection = m_selectionList[select];
- m_selectionList.selected = start != end;
- m_selectionList.zeroWidth = (start == end) ? true : false;
- m_selectionList.rectangular = false;
- m_selectionList.start = etk_min(start, end);
- m_selectionList.end = etk_max(start, end);
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void EdnBuf::Unselect(void)
-{
- //selection oldSelection = m_selectionList[select];
- m_selectionList.selected = false;
- m_selectionList.zeroWidth = false;
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- * @param[in,out] ---
- * @param[in,out] ---
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void EdnBuf::RectSelect(int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd)
-{
- m_selectionList.selected = rectStart < rectEnd;
- m_selectionList.zeroWidth = (rectStart == rectEnd) ? false : true;
- m_selectionList.rectangular = true;
- m_selectionList.start = start;
- m_selectionList.end = end;
- m_selectionList.rectStart = rectStart;
- m_selectionList.rectEnd = rectEnd;
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-bool EdnBuf::getSelectionPos(int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd)
-{
- /* Always fill in the parameters (zero-width can be requested too). */
- isRect = m_selectionList.rectangular;
- start = m_selectionList.start;
- end = m_selectionList.end;
- if (m_selectionList.rectangular) {
- rectStart = m_selectionList.rectStart;
- rectEnd = m_selectionList.rectEnd;
- }
- return m_selectionList.selected;
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void EdnBuf::getSelectionText(etk::Vector &text)
-{
- int32_t start, end, rectStart, rectEnd;
- bool isRect;
- // remove output data
- text.clear();
-
- bool isSelected = getSelectionPos(start, end, isRect, rectStart, rectEnd);
-
- // No data selected ...
- if (false == isSelected) {
- return;
- }
-
- // Rectangular selection
- if (true == isRect) {
- //GetTextInRect(start, end, rectStart, rectEnd, text);
- // TODO : ...
- } else {
- getRange(start, end, text);
- }
-}
-void EdnBuf::getSelectionText(etk::UString &text)
-{
- int32_t start, end, rectStart, rectEnd;
- bool isRect;
- // remove output data
- text = "";
-
- bool isSelected = getSelectionPos(start, end, isRect, rectStart, rectEnd);
-
- // No data selected ...
- if (false == isSelected) {
- return;
- }
-
- // Rectangular selection
- if (true == isRect) {
- //GetTextInRect(start, end, rectStart, rectEnd, text);
- // TODO : ...
- } else {
- getRange(start, end, text);
- }
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void EdnBuf::removeSelected(void)
-{
- int32_t start, end;
- int32_t rectStart, rectEnd;
- bool isRect;
- bool isSelected = getSelectionPos(start, end, isRect, rectStart, rectEnd);
-
- // No data selected ...
- if (false == isSelected) {
- return;
- }
- // Rectangular selection
- if (true == isRect) {
- //RemoveRect(start, end, rectStart, rectEnd);
- // TODO : ...
- } else {
- remove(start, end);
- }
- Unselect();
-}
-
-
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-int32_t EdnBuf::ReplaceSelected(etk::Vector &text)
-{
- int32_t start, end, rectStart, rectEnd;
- bool isRect;
- bool isSelected = getSelectionPos(start, end, isRect, rectStart, rectEnd);
-
- // No data selected ...
- if (false == isSelected) {
- return 0;
- }
- int32_t returnSize = 0;
- // Rectangular selection
- if (true == isRect) {
- //ReplaceRect(start, end, rectStart, rectEnd, text);
- // TODO : ...
- } else {
- returnSize = Replace(start, end, text);
- }
- // Clean selection
- m_selectionList.selected = false;
- return returnSize;
-}
-int32_t EdnBuf::ReplaceSelected(etk::UString &text)
-{
- int32_t start, end, rectStart, rectEnd;
- bool isRect;
- bool isSelected = getSelectionPos(start, end, isRect, rectStart, rectEnd);
-
- // No data selected ...
- if (false == isSelected) {
- return 0;
- }
- int32_t returnSize = 0;
- // Rectangular selection
- if (true == isRect) {
- //ReplaceRect(start, end, rectStart, rectEnd, text);
- // TODO : ...
- } else {
- returnSize = Replace(start, end, text);
- }
- // Clean selection
- m_selectionList.selected = false;
- return returnSize;
-}
-
-
-/*
-** update an individual selection for changes in the corresponding text
-*/
-/**
- * @brief
- *
- * @param[in,out] ---
- *
- * @return ---
- *
- */
-void EdnBuf::updateSelection(int32_t pos, int32_t nDeleted, int32_t nInserted)
-{
- if( ( false == m_selectionList.selected
- && false == m_selectionList.zeroWidth)
- || pos > m_selectionList.end )
- {
- return;
- }
- if (pos+nDeleted <= m_selectionList.start) {
- m_selectionList.start += nInserted - nDeleted;
- m_selectionList.end += nInserted - nDeleted;
- } else if( pos <= m_selectionList.start
- && pos+nDeleted >= m_selectionList.end)
- {
- m_selectionList.start = pos;
- m_selectionList.end = pos;
- m_selectionList.selected = false;
- m_selectionList.zeroWidth = false;
- } else if( pos <= m_selectionList.start
- && pos+nDeleted < m_selectionList.end)
- {
- m_selectionList.start = pos;
- m_selectionList.end = nInserted + m_selectionList.end - nDeleted;
- } else if(pos < m_selectionList.end) {
- m_selectionList.end += nInserted - nDeleted;
- if (m_selectionList.end <= m_selectionList.start) {
- m_selectionList.selected = false;
- }
- }
-}
-
diff --git a/sources/appl/Buffer/BufferManager.cpp b/sources/appl/BufferManager.cpp
similarity index 78%
rename from sources/appl/Buffer/BufferManager.cpp
rename to sources/appl/BufferManager.cpp
index e9c6ede..92b31d6 100644
--- a/sources/appl/Buffer/BufferManager.cpp
+++ b/sources/appl/BufferManager.cpp
@@ -13,17 +13,13 @@
#include
#undef __class__
-#define __class__ "classBufferManager"
-#if 0
+#define __class__ "BufferManager"
+
class classBufferManager: public ewol::EObject {
public:
// Constructeur
classBufferManager(void);
~classBufferManager(void);
- const char * const getObjectType(void)
- {
- return "ApplBufferManager";
- }
public:
virtual void onReceiveMessage(const ewol::EMessage& _msg);
private:
@@ -398,123 +394,35 @@ int32_t classBufferManager::witchBuffer(int32_t iEmeElement) {
}
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Namespace part :
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+appl::Buffer* get(const etk::UString& _filename);
+appl::Buffer* get(esize_t _bufferID);
+esize_t size(void):
-static classBufferManager * localManager = NULL;
-#endif
-void BufferManager::init(void) {
- /*
- if (NULL != localManager) {
- EWOL_ERROR("classBufferManager == > already exist, just unlink the previous ...");
- localManager = NULL;
- }
- localManager = new classBufferManager();
-
- if (NULL == localManager) {
- EWOL_CRITICAL("Allocation of classBufferManager not done ...");
- }
- */
-}
-void BufferManager::unInit(void) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
- return;
- }
- delete(localManager);
- localManager = NULL;
- */
-}
-int32_t BufferManager::getSelected(void) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
- return -1;
+appl::BufferManager* appl::BufferManager::keep(void) {
+ //EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\"");
+ appl::GlyphPainting* object = static_cast(getManager().localKeep("???BufferManager???"));
+ if (NULL != object) {
+ return object;
}
- return localManager->getSelected();
- */
- return -1;
-}
-
-appl::Buffer * BufferManager::get(int32_t BufferID) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
+ // this element create a new one every time ....
+ EWOL_INFO("CREATE : appl::BufferManager: ???BufferManager???");
+ object = new appl::BufferManager();
+ if (NULL == object) {
+ EWOL_ERROR("allocation error of a resource : ???BufferManager???");
return NULL;
}
- return localManager->get(BufferID);
- */
- return NULL;
+ getManager().localAdd(object);
+ return object;
}
-bool BufferManager::exist(int32_t BufferID) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
- return false;
+void appl::GlyphPainting::release(appl::BufferManager*& _object) {
+ if (NULL == _object) {
+ return;
}
- return localManager->exist(BufferID);
- */
- return false;
+ ewol::Resource* object2 = static_cast(_object);
+ getManager().release(object2);
+ _object = NULL;
}
-bool BufferManager::exist(etk::FSNode &myFile) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
- return false;
- }
- return localManager->exist(myFile);
- */
- return false;
-}
-
-int32_t BufferManager::getId(etk::FSNode &myFile) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
- return -1;
- }
- return localManager->getId(myFile);
- */
- return -1;
-}
-
-uint32_t BufferManager::size(void) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
- return 0;
- }
- return localManager->size();
- */
- return 0;
-}
-
-uint32_t BufferManager::sizeOpen(void) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
- return 0;
- }
- return localManager->sizeOpen();
- */
- return 0;
-}
-
-int32_t BufferManager::witchBuffer(int32_t iEmeElement) {
- /*
- if (NULL == localManager) {
- EWOL_ERROR("classBufferManager == > request UnInit, but does not exist ...");
- return -1;
- }
- return localManager->witchBuffer(iEmeElement);
- */
- return -1;
-}
-
-
diff --git a/sources/appl/BufferManager.h b/sources/appl/BufferManager.h
new file mode 100644
index 0000000..5e2e1c4
--- /dev/null
+++ b/sources/appl/BufferManager.h
@@ -0,0 +1,43 @@
+/**
+ * @author Edouard DUPIN
+ *
+ * @copyright 2010, Edouard DUPIN, all right reserved
+ *
+ * @license GPL v3 (see license file)
+ */
+
+#ifndef __BUFFER_MANAGER_H__
+#define __BUFFER_MANAGER_H__
+
+#include
+#include
+#include
+#include
+
+namespace appl {
+ class BufferManager : public ewol::Resource {
+ protected:
+ void BufferManager(void);
+ void ~BufferManager(void);
+ public:
+ appl::Buffer* get(const etk::UString& _filename);
+ appl::Buffer* get(esize_t _bufferID);
+ esize_t size(void):
+
+ /**
+ * @brief keep the resource pointer.
+ * @note Never free this pointer by your own...
+ * @param[in] _filename Name of the configuration file.
+ * @return pointer on the resource or NULL if an error occured.
+ */
+ static appl::BufferManager* keep(void);
+ /**
+ * @brief release the keeped resources
+ * @param[in,out] reference on the object pointer
+ */
+ static void release(appl::BufferManager*& _object);
+ };
+};
+
+#endif
+
diff --git a/sources/appl/glyphDecoration/GlyphDecoration.cpp b/sources/appl/GlyphDecoration.cpp
similarity index 96%
rename from sources/appl/glyphDecoration/GlyphDecoration.cpp
rename to sources/appl/GlyphDecoration.cpp
index c6b2cdf..e29fe63 100644
--- a/sources/appl/glyphDecoration/GlyphDecoration.cpp
+++ b/sources/appl/GlyphDecoration.cpp
@@ -8,7 +8,7 @@
#include
#include
-#include
+#include
#undef __class__
#define __class__ "GlyphDecoration"
diff --git a/sources/appl/glyphDecoration/GlyphDecoration.h b/sources/appl/GlyphDecoration.h
similarity index 100%
rename from sources/appl/glyphDecoration/GlyphDecoration.h
rename to sources/appl/GlyphDecoration.h
diff --git a/sources/appl/glyphDecoration/GlyphPainting.cpp b/sources/appl/GlyphPainting.cpp
similarity index 94%
rename from sources/appl/glyphDecoration/GlyphPainting.cpp
rename to sources/appl/GlyphPainting.cpp
index 21d17b7..c6c81b3 100644
--- a/sources/appl/glyphDecoration/GlyphPainting.cpp
+++ b/sources/appl/GlyphPainting.cpp
@@ -8,7 +8,7 @@
#include
#include
-#include
+#include
#include
#include
#include
@@ -50,7 +50,7 @@ void appl::GlyphPainting::reload(void) {
etk::UString foreground = tmpObj->getStringValue("foreground", "#000F");
bool italic = tmpObj->getBooleanValue("italic", false);
bool bold = tmpObj->getBooleanValue("bold", false);
- APPL_DEBUG("find new color : '" << name << "' fg='" << foreground << "' bg='" << background << "' italic='" << italic << "' bold='" << bold << "'");
+ APPL_VERBOSE("find new color : '" << name << "' fg='" << foreground << "' bg='" << background << "' italic='" << italic << "' bold='" << bold << "'");
bool findElement = false;
for (esize_t jjj=0; jjj
#include
#include
-#include
+#include
namespace appl {
class GlyphPainting : public ewol::Resource {
diff --git a/sources/appl/Gui/CodeView.cpp b/sources/appl/Gui/CodeView.cpp
deleted file mode 100644
index 0a06a0e..0000000
--- a/sources/appl/Gui/CodeView.cpp
+++ /dev/null
@@ -1,480 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-
-#undef __class__
-#define __class__ "CodeView"
-
-void CodeView::init(void)
-{
- m_label = "CodeView is disable ...";
-
- m_bufferID = -1;
- m_buttunOneSelected = false;
-
- m_lineNumberList.clear();
-
- m_textColorFg = etk::color::black;
-
- m_textColorBg = etk::color::black;
- m_textColorBg.setA(0x40);
- setCanHaveFocus(true);
- RegisterMultiCast(ednMsgBufferId);
- RegisterMultiCast(ednMsgGuiCopy);
- RegisterMultiCast(ednMsgGuiPaste);
- RegisterMultiCast(ednMsgGuiCut);
- RegisterMultiCast(ednMsgGuiRedo);
- RegisterMultiCast(ednMsgGuiUndo);
- RegisterMultiCast(ednMsgGuiRm);
- RegisterMultiCast(ednMsgGuiSelect);
- RegisterMultiCast(ednMsgGuiChangeCharset);
- RegisterMultiCast(ednMsgGuiFind);
- RegisterMultiCast(ednMsgGuiReplace);
- RegisterMultiCast(ednMsgGuiGotoLine);
- setLimitScrolling(0.2);
-
- ShortCutAdd("ctrl+w", ednMsgGuiRm, "Line");
- ShortCutAdd("ctrl+shift+w", ednMsgGuiRm, "Paragraph");
- ShortCutAdd("ctrl+x", ednMsgGuiCut, "STD");
- ShortCutAdd("ctrl+c", ednMsgGuiCopy, "STD");
- ShortCutAdd("ctrl+v", ednMsgGuiPaste, "STD");
- ShortCutAdd("ctrl+a", ednMsgGuiSelect, "ALL");
- ShortCutAdd("ctrl+shift+a", ednMsgGuiSelect, "NONE");
-}
-
-CodeView::CodeView(etk::UString fontName, int32_t fontSize) :
- m_displayText(fontName, fontSize)
-{
- init();
-}
-
-CodeView::CodeView(void)
-{
- init();
-}
-
-CodeView::~CodeView(void)
-{
-
-}
-
-
-/**
- * @brief Check if the number of reference buffer is good or not ...
- * @param[in] bufferID id of the current Buffer that needed to have a reference
- */
-void CodeView::updateNumberOfLineReference(int32_t bufferID)
-{
- vec2 tmpCoord(0,0);
- if (m_lineNumberList.size() <= bufferID) {
- // update the number of elements :
- for (int32_t iii=m_lineNumberList.size(); iii <= bufferID; iii++) {
- // add start line at 0 :
- m_lineNumberList.pushBack(tmpCoord);
- }
- }
-}
-
-
-bool CodeView::calculateMinSize(void)
-{
- m_minSize.setValue(50,50);
- return true;
-}
-
-void CodeView::calculateMaxSize(void)
-{
- m_maxSize.setX(2048);
- int32_t letterHeight = m_displayText.calculateSize(etk::UChar('A')).y();
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- m_maxSize.setY(tmpBuffer->getNumberOfLine() * letterHeight);
- } else {
- m_maxSize.setY(50);
- }
-}
-
-
-void CodeView::onDraw(void)
-{
- m_displayDrawing.draw();
- m_displayText.draw();
- WidgetScrooled::onDraw();
-}
-
-void CodeView::onRegenerateDisplay(void)
-{
- if (true == needRedraw()) {
- int64_t startTime = ewol::getTime();
-
- // For the scrooling windows
- calculateMaxSize();
- m_displayDrawing.clear();
- m_displayText.clear();
-
- // reset the background :
- m_displayDrawing.setPos(vec3(-2048, -2048, 0));
- m_displayDrawing.setColor(ColorizeManager::get(COLOR_CODE_BASIC_BG));
- m_displayDrawing.rectangleWidth(vec3(4096, 4096, 0) );
-
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if( NULL != tmpBuffer
- && true == tmpBuffer->needToUpdateDisplayPosition() ) {
- vec2 borderWidth = BufferManager::get(m_bufferID)->getBorderSize();
- bool centerRequested = false;
- // TODO : set it back ...
- vec2 currentPosition = BufferManager::get(m_bufferID)->getPosition(999/*m_OObjectTextNormal.getFontID()*/, centerRequested);
- setScrollingPositionDynamic(borderWidth, currentPosition, centerRequested);
- } // else : nothing to do ...
-
- // generate the objects :
- if (-1 == m_bufferID) {
- m_displayText.setTextAlignement(10, m_size.x()-20, ewol::Text::alignLeft);
- m_displayDrawing.setColor(0x00000022);
- m_displayDrawing.setPos(vec3(10, 0, 0));
- m_displayDrawing.rectangle(vec3((int32_t)m_size.x()-20, 1500, 0) );
-
- m_displayText.setRelPos(vec3(10, 0, 0));
- // nothing to display :
- etk::UString tmpString("
\n"
- "\n"
- " \n"
- " edn - Editeur De N'ours\n"
- " \n"
- "\n"
- "
\n"
- "
\n"
- "\n"
- " \n"
- " No Buffer Availlable to display\n"
- " \n"
- "\n");
- m_displayText.setPos(vec3(0.0f, m_size.y(), 0.0f) );
- m_displayText.forceLineReturn();
- m_displayText.printDecorated(tmpString);
- } else {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->display(m_displayText, m_originScrooled.x(), m_originScrooled.y(), m_size.x(), m_size.y());
- }
- // set the current size of the windows
- setMaxSize(BufferManager::get(m_bufferID)->getMaxSize());
- }
- int64_t stopTime = ewol::getTime();
- APPL_DEBUG("Display Code Generation = " << stopTime - startTime << " micro-s");
-
- // call the herited class...
- WidgetScrooled::onRegenerateDisplay();
- }
-}
-
-
-bool CodeView::onEventEntry(const ewol::EventEntry& _event)
-{
- if (_event.getType() == ewol::keyEvent::keyboardChar) {
- //APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
- if (_event.getStatus() == ewol::keyEvent::statusDown) {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->addChar(_event.getChar());
- }
- markToRedraw();
- }
- return true;
- }
- // move events ...
- if (_event.getStatus() == ewol::keyEvent::statusDown) {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->cursorMove(_event.getType());
- }
- markToRedraw();
- }
- return true;
-}
-
-void CodeView::onEventClipboard(ewol::clipBoard::clipboardListe_te _clipboardID)
-{
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Paste(_clipboardID);
- }
- markToRedraw();
-}
-
-bool CodeView::onEventInput(const ewol::EventInput& _event)
-{
- vec2 relativePos = relativePosition(_event.getPos());
- //APPL_DEBUG("Event at pos : " << _event.getPos() << " == > " << relativePos );
- // corection for the openGl abstraction
- //relativePos.y = m_size.y - relativePos.y;
-
- vec2 limitedPos = relativePos;
- limitedPos.setValue(etk_avg(1, limitedPos.x(), m_size.x()-1),
- etk_avg(1, limitedPos.y(), m_size.y()-1));
- if (true == WidgetScrooled::onEventInput(_event)) {
- keepFocus();
- // nothing to do ... done on upper widget ...
- return true;
- }
-
- if (m_bufferID < 0) {
- return false;
- }
-
- if (1 == _event.getId()) {
-
- if (ewol::keyEvent::typeMouse == _event.getType()) {
- if (ewol::keyEvent::statusDown == _event.getStatus()) {
- m_buttunOneSelected = true;
- keepFocus();
- // TODO : set something good
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->MouseEvent(limitedPos);
- }
- markToRedraw();
- } else if (ewol::keyEvent::statusUp == _event.getStatus()) {
- m_buttunOneSelected = false;
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Copy(ewol::clipBoard::clipboardSelection);
- }
- markToRedraw();
- }
- }
- if (ewol::keyEvent::statusSingle == _event.getStatus()) {
- if (ewol::keyEvent::typeMouse == _event.getType()) {
- keepFocus();
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->MouseEvent(limitedPos);
- }
- markToRedraw();
- } else {
- // nothing to do ...
- }
- } else if (ewol::keyEvent::statusDouble == _event.getStatus()) {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->MouseEventDouble();
- }
- markToRedraw();
- } else if (ewol::keyEvent::statusTriple == _event.getStatus()) {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->MouseEventTriple();
- }
- markToRedraw();
- } else if (ewol::keyEvent::statusMove == _event.getStatus()) {
- if (true == m_buttunOneSelected) {
- int xxx, yyy;
- xxx = relativePos.x();
- yyy = relativePos.y();
- if (xxx<0) {
- xxx = 0;
- }
- if (yyy<0) {
- yyy = 0;
- }
- //APPL_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
- // TODO : set something good
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->MouseSelectFromCursorTo(limitedPos);
- }
- markToRedraw();
- }
- }
- } else if (2 == _event.getId()) {
- if (ewol::keyEvent::statusSingle == _event.getStatus()) {
- // TODO : set something good
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->MouseEvent(limitedPos);
- }
- ewol::clipBoard::Request(ewol::clipBoard::clipboardSelection);
- keepFocus();
- }
- }
- return true;
-}
-
-void CodeView::onReceiveMessage(const ewol::EMessage& _msg)
-{
- widget::WidgetScrooled::onReceiveMessage(_msg);
- APPL_DEBUG("Extern Event : " << _msg.getCaller() << " type : " << _msg.GetMessage() << " data=\"" << _msg.GetData() << "\"");
-
- if(_msg.getMessage() == ednMsgBufferId) {
- //keep the reference of the display offset :
- if( m_bufferID >= 0
- && m_bufferID < m_lineNumberList.size()) {
- m_lineNumberList[m_bufferID] = m_originScrooled;
- }
- int32_t bufferID = 0;
- sscanf(_msg.getData().c_str(), "%d", &bufferID);
- APPL_INFO("Select a new Buffer ... " << bufferID);
- // set the new buffer ID
- m_bufferID = bufferID;
- // update the start display position...
- updateNumberOfLineReference(m_bufferID);
- // set back if needed the display position ...
- if( m_bufferID >= 0
- && m_bufferID < m_lineNumberList.size()) {
- m_originScrooled = m_lineNumberList[m_bufferID];
- }
- } else if (_msg.getMessage() == ednMsgGuiCopy) {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Copy(ewol::clipBoard::clipboardStd);
- }
- } else if (_msg.getMessage() == ednMsgGuiCut) {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Cut(ewol::clipBoard::clipboardStd);
- }
- } else if (_msg.getMessage() == ednMsgGuiPaste) {
- ewol::clipBoard::Request(ewol::clipBoard::clipboardStd);
- } else if (_msg.getMessage() == ednMsgGuiUndo) {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Undo();
- }
- } else if (_msg.getMessage() == ednMsgGuiRedo) {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Redo();
- }
- } else if (_msg.getMessage() == ednMsgGuiRm) {
- // data : "Word" "Line" "Paragraph"
- if (_msg.getData() == "Word") {
- APPL_WARNING(" on event " << _msg.getMessage() << " data=\"" << _msg.GetData() << "\" == > not coded" );
- } else if (_msg.getData() == "Line") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->removeLine();
- }
- } else if (_msg.getData() == "Paragraph") {
- APPL_WARNING(" on event " << _msg.getMessage() << " data=\"" << _msg.GetData() << "\" == > not coded" );
- } else {
- APPL_ERROR(" on event " << _msg.getMessage() << " unknow data=\"" << _msg.GetData() << "\"" );
- }
- } else if (_msg.getMessage() == ednMsgGuiSelect) {
- // data : "ALL" "NONE"
- if (_msg.getData() == "ALL") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->SelectAll();
- }
- } else if (_msg.getData() == "NONE") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->SelectNone();
- }
- } else {
- APPL_ERROR(" on event " << _msg.getMessage() << " unknow data=\"" << _msg.GetData() << "\"" );
- }
- } else if (_msg.getMessage() == ednMsgGuiChangeCharset) {
- // data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
- if (_msg.getData() == "UTF-8") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->setCharset(unicode::EDN_CHARSET_UTF8);
- }
- } else if (_msg.getData() == "ISO-8859-1") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->setCharset(unicode::EDN_CHARSET_ISO_8859_1);
- }
- } else if (_msg.getData() == "ISO-8859-15") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->setCharset(unicode::EDN_CHARSET_ISO_8859_15);
- }
- } else {
- APPL_ERROR(" on event " << _msg.getMessage() << " unknow data=\"" << _msg.GetData() << "\"" );
- }
- } else if (_msg.getMessage() == ednMsgGuiFind) {
- etk::UString myDataString;
- SearchData::getSearch(myDataString);
- if (_msg.getData() == "Next") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Search(myDataString, false, SearchData::getCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
- }
- } else if (_msg.getData() == "Previous") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Search(myDataString, true, SearchData::getCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
- }
- }
- } else if (_msg.getMessage() == ednMsgGuiReplace) {
- etk::UString myDataString;
- SearchData::getReplace(myDataString);
- if (_msg.getData() == "Normal") {
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->Replace(myDataString);
- }
- } else if (_msg.getData() == "All") {
-
- }
- } else if (_msg.getMessage() == ednMsgGuiGotoLine) {
- int32_t lineID = 0;
- sscanf(_msg.getData().c_str(), "%d", &lineID);
- APPL_INFO("Goto line : " << lineID);
- BufferText* tmpBuffer = BufferManager::get(m_bufferID);
- if (NULL!=tmpBuffer) {
- tmpBuffer->JumpAtLine(lineID);
- }
- }
- // force redraw of the widget
- markToRedraw();
-}
-
-
-void CodeView::onGetFocus(void)
-{
- /*
- ewol::widgetMessageMultiCast::Send(getWidgetId(), ednMsgBufferId, m_bufferID);
- */
- ShowKeyboard();
- APPL_INFO("Focus - In");
-}
-
-
-void CodeView::onLostFocus(void)
-{
- HideKeyboard();
- APPL_INFO("Focus - out");
-}
-
-void CodeView::setFontSize(int32_t size)
-{
- m_displayText.setFontSize(size);
- setScrollingSize(size*3.0*1.46); // 1.46 is a magic nmber ...
-}
-
-void CodeView::setFontName(etk::UString fontName)
-{
- m_displayText.setFontName(fontName);
-}
-
diff --git a/sources/appl/Gui/CodeView.h b/sources/appl/Gui/CodeView.h
deleted file mode 100644
index 8c01ce2..0000000
--- a/sources/appl/Gui/CodeView.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#ifndef __CODE_VIEW_H__
-#define __CODE_VIEW_H__
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-class CodeView :public widget::WidgetScrooled
-{
- public:
- void init(void);
- CodeView(etk::UString fontName, int32_t fontSize);
- CodeView(void);
- virtual ~CodeView(void);
- private:
- etk::UString m_label;
- etk::Color<> m_textColorFg; //!< Text color
- etk::Color<> m_textColorBg; //!< Background color
- int32_t m_bufferID;
- bool m_buttunOneSelected;
- etk::Vector m_lineNumberList;
- void updateNumberOfLineReference(int32_t bufferID);
- // drawing elements :
- ewol::Text m_displayText;
- ewol::drawing m_displayDrawing;
- public:
- void setFontSize(int32_t size);
- void setFontName(etk::UString fontName);
- private:
- void calculateMaxSize(void);
- protected: // derived function
- virtual void onDraw(void);
- public: // Derived function
- const char * const getObjectType(void) { return "ApplCodeView"; };
- virtual bool calculateMinSize(void);
- virtual void onRegenerateDisplay(void);
- virtual void onReceiveMessage(const ewol::EMessage& _msg);
- virtual bool onEventInput(const ewol::EventInput& _event);
- virtual bool onEventEntry(const ewol::EventEntry& _event);
- virtual void onEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
- virtual void onGetFocus(void);
- virtual void onLostFocus(void);
-};
-
-#endif
-
diff --git a/sources/appl/Gui/MainWindows.h b/sources/appl/Gui/MainWindows.h
index bd6d9bb..8e2116b 100644
--- a/sources/appl/Gui/MainWindows.h
+++ b/sources/appl/Gui/MainWindows.h
@@ -12,8 +12,8 @@
#include
#include
-#include
-#include
+#include
+#include
#include
class MainWindows : public ewol::Windows {
diff --git a/sources/appl/Gui/Search.cpp b/sources/appl/Gui/Search.cpp
index 9bee5fa..9fd5118 100644
--- a/sources/appl/Gui/Search.cpp
+++ b/sources/appl/Gui/Search.cpp
@@ -9,8 +9,8 @@
#include "appl/global.h"
#include "Search.h"
#include "SearchData.h"
-#include "BufferManager.h"
-#include "MainWindows.h"
+#include "appl/BufferManager.h"
+#include "appl/Gui/MainWindows.h"
#include "appl/globalMsg.h"
#include
diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp
index b752a49..c440008 100644
--- a/sources/appl/Gui/TextViewer.cpp
+++ b/sources/appl/Gui/TextViewer.cpp
@@ -16,7 +16,7 @@
#include
#include
-#include
+#include
#undef __class__
#define __class__ "TextViewer"
@@ -52,14 +52,14 @@ appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
m_colorNormal = m_paintingProperties->request("normal");
// by default we load an example object:
-
+ /*
m_buffer = new appl::Buffer();
if (m_buffer == NULL) {
APPL_ERROR("can not create buffer ... ");
return;
}
m_buffer->loadFile("./example.txt");
-
+ */
appl::textPluginManager::connect(*this);
}
@@ -241,7 +241,8 @@ void appl::TextViewer::onRegenerateDisplay(void) {
}
m_buffer->expand(countColomn, *it, stringToDisplay);
if (it >= selectPosStart && it < selectPosStop) {
- m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getForeground());
+ m_displayText.setColor((*m_paintingProperties)[m_colorSelection].getForeground());
+ m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getBackground());
}
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
m_displayText.print(stringToDisplay);
diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h
index 4b4ef90..fbb761f 100644
--- a/sources/appl/Gui/TextViewer.h
+++ b/sources/appl/Gui/TextViewer.h
@@ -10,7 +10,7 @@
#define __APPL_TEXT_VIEWER_H__
#include
-#include
+#include
#include
#include
diff --git a/sources/appl/Highlight/Highlight.cpp b/sources/appl/Highlight.cpp
similarity index 100%
rename from sources/appl/Highlight/Highlight.cpp
rename to sources/appl/Highlight.cpp
diff --git a/sources/appl/Highlight/Highlight.h b/sources/appl/Highlight.h
similarity index 97%
rename from sources/appl/Highlight/Highlight.h
rename to sources/appl/Highlight.h
index 3ff0643..468d829 100644
--- a/sources/appl/Highlight/Highlight.h
+++ b/sources/appl/Highlight.h
@@ -26,8 +26,8 @@ namespace appl {
};
#include
-#include
-#include
+#include
+#include
#include
#include
diff --git a/sources/appl/Highlight/HighlightManager.cpp b/sources/appl/HighlightManager.cpp
similarity index 98%
rename from sources/appl/Highlight/HighlightManager.cpp
rename to sources/appl/HighlightManager.cpp
index b8f84c6..def0c04 100644
--- a/sources/appl/Highlight/HighlightManager.cpp
+++ b/sources/appl/HighlightManager.cpp
@@ -8,7 +8,7 @@
#include
#include
-#include
+#include
#include
#include
@@ -47,12 +47,14 @@ void appl::highlightManager::init(void) {
}
}
// display :
+ /*
for (esize_t iii = 0; iii < hlList.size(); ++iii) {
if (hlList[iii] == NULL) {
continue;
}
hlList[iii]->display();
}
+ */
}
void appl::highlightManager::unInit(void) {
diff --git a/sources/appl/Highlight/HighlightManager.h b/sources/appl/HighlightManager.h
similarity index 100%
rename from sources/appl/Highlight/HighlightManager.h
rename to sources/appl/HighlightManager.h
diff --git a/sources/appl/Highlight/HighlightPattern.cpp b/sources/appl/HighlightPattern.cpp
similarity index 98%
rename from sources/appl/Highlight/HighlightPattern.cpp
rename to sources/appl/HighlightPattern.cpp
index ef6e4e3..7f409c0 100644
--- a/sources/appl/Highlight/HighlightPattern.cpp
+++ b/sources/appl/HighlightPattern.cpp
@@ -65,7 +65,7 @@ void appl::HighlightPattern::setEscapeChar(const etk::UChar& _EscapeChar) {
void appl::HighlightPattern::setColorGlyph(etk::UString& _colorName) {
m_colorName = _colorName;
m_colorId = m_glyphPainting->request(m_colorName);
- APPL_DEBUG("Resuest color name '" << m_colorName << "' => id=" << m_colorId);
+ APPL_VERBOSE("Resuest color name '" << m_colorName << "' => id=" << m_colorId);
}
void appl::HighlightPattern::display(void) {
diff --git a/sources/appl/Highlight/HighlightPattern.h b/sources/appl/HighlightPattern.h
similarity index 98%
rename from sources/appl/Highlight/HighlightPattern.h
rename to sources/appl/HighlightPattern.h
index 1131861..8b96f08 100644
--- a/sources/appl/Highlight/HighlightPattern.h
+++ b/sources/appl/HighlightPattern.h
@@ -15,7 +15,7 @@ class HighlightPattern;
#include
-#include
+#include
#include
#include
#include
diff --git a/sources/appl/Buffer/TextPlugin.cpp b/sources/appl/TextPlugin.cpp
similarity index 95%
rename from sources/appl/Buffer/TextPlugin.cpp
rename to sources/appl/TextPlugin.cpp
index bcb3298..3468fce 100644
--- a/sources/appl/Buffer/TextPlugin.cpp
+++ b/sources/appl/TextPlugin.cpp
@@ -7,7 +7,7 @@
*/
-#include
+#include
#include
#undef __class__
diff --git a/sources/appl/Buffer/TextPlugin.h b/sources/appl/TextPlugin.h
similarity index 100%
rename from sources/appl/Buffer/TextPlugin.h
rename to sources/appl/TextPlugin.h
diff --git a/sources/appl/Buffer/TextPluginAutoIndent.cpp b/sources/appl/TextPluginAutoIndent.cpp
similarity index 97%
rename from sources/appl/Buffer/TextPluginAutoIndent.cpp
rename to sources/appl/TextPluginAutoIndent.cpp
index a22fd0d..bf082a3 100644
--- a/sources/appl/Buffer/TextPluginAutoIndent.cpp
+++ b/sources/appl/TextPluginAutoIndent.cpp
@@ -7,7 +7,7 @@
*/
-#include
+#include
#include
#include
diff --git a/sources/appl/Buffer/TextPluginAutoIndent.h b/sources/appl/TextPluginAutoIndent.h
similarity index 94%
rename from sources/appl/Buffer/TextPluginAutoIndent.h
rename to sources/appl/TextPluginAutoIndent.h
index ffa14fd..ffaf384 100644
--- a/sources/appl/Buffer/TextPluginAutoIndent.h
+++ b/sources/appl/TextPluginAutoIndent.h
@@ -13,7 +13,7 @@
#include
#include
#include
-#include
+#include
namespace appl {
class TextPluginAutoIndent : public appl::TextViewerPlugin {
diff --git a/sources/appl/Buffer/TextPluginCopy.cpp b/sources/appl/TextPluginCopy.cpp
similarity index 97%
rename from sources/appl/Buffer/TextPluginCopy.cpp
rename to sources/appl/TextPluginCopy.cpp
index b0f8d35..48f6dbd 100644
--- a/sources/appl/Buffer/TextPluginCopy.cpp
+++ b/sources/appl/TextPluginCopy.cpp
@@ -7,7 +7,7 @@
*/
-#include
+#include
#include
#include
diff --git a/sources/appl/Buffer/TextPluginCopy.h b/sources/appl/TextPluginCopy.h
similarity index 95%
rename from sources/appl/Buffer/TextPluginCopy.h
rename to sources/appl/TextPluginCopy.h
index 1657108..1b7337a 100644
--- a/sources/appl/Buffer/TextPluginCopy.h
+++ b/sources/appl/TextPluginCopy.h
@@ -13,7 +13,7 @@
#include
#include
#include
-#include
+#include
namespace appl {
class TextPluginCopy : public appl::TextViewerPlugin {
diff --git a/sources/appl/Buffer/TextPluginHistory.cpp b/sources/appl/TextPluginHistory.cpp
similarity index 98%
rename from sources/appl/Buffer/TextPluginHistory.cpp
rename to sources/appl/TextPluginHistory.cpp
index 749368c..8d20c7f 100644
--- a/sources/appl/Buffer/TextPluginHistory.cpp
+++ b/sources/appl/TextPluginHistory.cpp
@@ -7,10 +7,10 @@
*/
-#include
+#include
#include
#include
-#include
+#include
#undef __class__
#define __class__ "TextPluginHistory"
diff --git a/sources/appl/Buffer/TextPluginHistory.h b/sources/appl/TextPluginHistory.h
similarity index 98%
rename from sources/appl/Buffer/TextPluginHistory.h
rename to sources/appl/TextPluginHistory.h
index b844bd4..5883de7 100644
--- a/sources/appl/Buffer/TextPluginHistory.h
+++ b/sources/appl/TextPluginHistory.h
@@ -13,7 +13,7 @@
#include