12 Commits
0.3.1 ... 0.3.3

40 changed files with 1064 additions and 758 deletions

View File

@@ -16,6 +16,7 @@ LOCAL_SRC_FILES := ewolAndroidAbstraction.cpp \
LOCAL_LDLIBS := -llog -landroid LOCAL_LDLIBS := -llog -landroid
LOCAL_CFLAGS := -D__PLATFORM__Android \ LOCAL_CFLAGS := -D__PLATFORM__Android \
-D__MODE__Touch \
-DEWOL_USE_FREE_TYPE \ -DEWOL_USE_FREE_TYPE \
-DETK_DEBUG_LEVEL=3 \ -DETK_DEBUG_LEVEL=3 \
-DEDN_DEBUG_LEVEL=3 \ -DEDN_DEBUG_LEVEL=3 \

View File

@@ -45,7 +45,7 @@ Buffer::Buffer()
static int32_t fileBasicID = 0; static int32_t fileBasicID = 0;
m_fileModify = true; m_fileModify = true;
m_haveName = false; m_haveName = false;
etk::String mString = "Untitle - "; etk::UString mString = "Untitle - ";
mString += fileBasicID++; mString += fileBasicID++;
SetFileName(mString); SetFileName(mString);
m_haveName = false; m_haveName = false;
@@ -94,7 +94,8 @@ void Buffer::SetModify(bool status)
{ {
if (status != m_fileModify) { if (status != m_fileModify) {
m_fileModify = status; m_fileModify = status;
ewol::widgetMessageMultiCast::Send(-1, ednMsgBufferModify); // TODO : Remove from here
ewol::widgetMessageMultiCast::Send(-1, ednMsgBufferState, "Modify");
} }
} }
@@ -147,7 +148,11 @@ void Buffer::SetLineDisplay(uint32_t lineNumber)
* @return --- * @return ---
* *
*/ */
int32_t Buffer::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) int32_t Buffer::Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic, ewol::OObject2DColored* OOColored,
int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
{ {
return ERR_NONE; return ERR_NONE;
} }
@@ -265,22 +270,22 @@ void Buffer::cursorMove(ewol::eventKbMoveType_te moveTypeEvent)
* @return --- * @return ---
* *
*/ */
void Buffer::AddChar(char * UTF8data) void Buffer::AddChar(uniChar_t unicodeData)
{ {
// nothing to do // nothing to do
} }
void Buffer::Search(etk::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) void Buffer::Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp)
{ {
// nothing to do // nothing to do
} }
void Buffer::Replace(etk::String &data) void Buffer::Replace(etk::UString &data)
{ {
// nothing to do // nothing to do
} }
int32_t Buffer::FindLine(etk::String &data) int32_t Buffer::FindLine(etk::UString &data)
{ {
// nothing to do // nothing to do
return 0; return 0;

View File

@@ -26,7 +26,7 @@
#ifndef __BUFFER_H__ #ifndef __BUFFER_H__
#define __BUFFER_H__ #define __BUFFER_H__
#include <etk/String.h> #include <etk/UString.h>
#include <etk/File.h> #include <etk/File.h>
#include <Display.h> #include <Display.h>
#include <etk/unicode.h> #include <etk/unicode.h>
@@ -61,7 +61,7 @@ class Buffer {
NameChange(); NameChange();
}; };
void SetFileName(etk::String &newName) void SetFileName(etk::UString &newName)
{ {
m_fileName.SetCompleateName(newName, etk::FILE_TYPE_DIRECT); m_fileName.SetCompleateName(newName, etk::FILE_TYPE_DIRECT);
m_haveName = true; m_haveName = true;
@@ -82,9 +82,13 @@ class Buffer {
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate); virtual void GetInfo(infoStatBuffer_ts &infoToUpdate);
virtual void SetLineDisplay(uint32_t lineNumber); virtual void SetLineDisplay(uint32_t lineNumber);
virtual int32_t Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); virtual int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
virtual void ForceReDraw(bool allElement); virtual void ForceReDraw(bool allElement);
virtual void AddChar(char * UTF8data); virtual void AddChar(uniChar_t unicodeData);
virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent); virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
virtual void MouseSelectFromCursorTo(int32_t width, int32_t height); virtual void MouseSelectFromCursorTo(int32_t width, int32_t height);
virtual void MouseEvent(int32_t width, int32_t height); virtual void MouseEvent(int32_t width, int32_t height);
@@ -103,12 +107,14 @@ class Buffer {
virtual void Copy(int8_t clipboardID); virtual void Copy(int8_t clipboardID);
virtual void Cut(int8_t clipboardID); virtual void Cut(int8_t clipboardID);
virtual void Paste(int8_t clipboardID); virtual void Paste(int8_t clipboardID);
virtual void Search(etk::String &data, bool back, bool caseSensitive, bool wrap, bool regExp); virtual void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp);
virtual void Replace(etk::String &data); virtual void Replace(etk::UString &data);
virtual int32_t FindLine(etk::String &data); virtual int32_t FindLine(etk::UString &data);
virtual void JumpAtLine(int32_t newLine); virtual void JumpAtLine(int32_t newLine);
virtual int32_t GetCurrentLine(void); virtual int32_t GetCurrentLine(void);
virtual int32_t GetNumberOfLine(void) { return 1; };
protected: protected:
bool m_fileModify; //!< bool m_fileModify; //!<
// naming // naming

View File

@@ -67,7 +67,11 @@ BufferEmpty::~BufferEmpty(void)
* @return --- * @return ---
* *
*/ */
int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
{ {
ColorizeManager * myColorManager = ColorizeManager::getInstance(); ColorizeManager * myColorManager = ColorizeManager::getInstance();
// Get color : // Get color :
@@ -75,7 +79,7 @@ int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2D
//drawer.Flush(); //drawer.Flush();
if (NULL == OOText) { if (NULL == OOTextNormal) {
EDN_ERROR("Input VALUE is NULL"); EDN_ERROR("Input VALUE is NULL");
return ERR_FAIL; return ERR_FAIL;
} }
@@ -83,14 +87,28 @@ int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2D
EDN_ERROR("Input VALUE is NULL"); EDN_ERROR("Input VALUE is NULL");
return ERR_FAIL; return ERR_FAIL;
} }
int32_t fontId = OOTextNormal->GetFontID();
int32_t letterHeight = ewol::GetHeight(fontId);
coord2D_ts textPos;
textPos.x = 20;
textPos.y = 20;
clipping_ts drawClipping;
drawClipping.x = 0;
drawClipping.y = 0;
drawClipping.w = sizeX;
drawClipping.h = sizeY;
myColor = myColorManager->Get("normal"); myColor = myColorManager->Get("normal");
OOText->SetColor(myColor->GetFG()); OOTextNormal->SetColor(myColor->GetFG());
OOText->TextAdd(20, 20, "edn - Editeur De N'ours, l'Editeur Desoxyribo-Nucleique", sizeX); etk::UString tmpDisplay = "edn - Editeur De N'ours";
OOTextBold->Text(textPos, drawClipping, tmpDisplay);
myColor = myColorManager->Get("commentDoxygen"); myColor = myColorManager->Get("commentDoxygen");
OOText->SetColor(myColor->GetFG()); OOTextNormal->SetColor(myColor->GetFG());
OOText->TextAdd(20, 50, "No Buffer Availlable to display", sizeX); textPos.y = (int32_t)(textPos.y + letterHeight*1.30);
tmpDisplay = "No Buffer Availlable to display";
OOTextNormal->Text(textPos, drawClipping, tmpDisplay);
color_ts bgColor; //!< Text color color_ts bgColor; //!< Text color

View File

@@ -32,7 +32,11 @@ class BufferEmpty : public Buffer {
public: public:
BufferEmpty(void); BufferEmpty(void);
virtual ~BufferEmpty(void); virtual ~BufferEmpty(void);
int32_t Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
}; };

View File

@@ -46,11 +46,20 @@ BufferManager::BufferManager(void)
// nothing to do ... // nothing to do ...
BufferNotExiste = new BufferEmpty(); BufferNotExiste = new BufferEmpty();
m_idSelected = -1; m_idSelected = -1;
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiNew);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgOpenFile);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiClose);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiSave);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewSelectedId);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferId);
/*
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerNewFile); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerNewFile);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerSaveAll); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerSaveAll);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerCloseAll); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerCloseAll);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerClose); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerClose);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerSave); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerSave);
*/
} }
/** /**
@@ -74,55 +83,137 @@ BufferManager::~BufferManager(void)
} }
bool BufferManager::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y) bool BufferManager::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
{ {
/* if (generateEventId == ednMsgBufferId) {
switch (id) // select a new buffer ID :
{ if (NULL == data) {
case EDN_MSG__BUFFER_CHANGE_CURRENT: EDN_ERROR("Request select buffer ID = NULL ????");
m_idSelected = dataID; } else {
break; int32_t newID = -1;
case EDN_MSG__NEW: sscanf(data, "%d", &newID);
{ if(true == Exist(newID)) {
int32_t newOne = Create(); m_idSelected = newID;
if (-1 != newOne) { } else {
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, newOne); m_idSelected = -1;
} EDN_ERROR("Request a non existant ID : " << newID << " reset to -1...");
} }
break; }
case EDN_MSG__BUFF_ID_CLOSE: } else if (generateEventId == ednMsgGuiNew) {
// Check buffer existence int32_t newOne = Create();
if(true == Exist(dataID)) { if (-1 != newOne) {
// Get the new display buffer m_idSelected = newOne;
if (m_idSelected == dataID) { ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_idSelected);
// Try previous buffer ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
int32_t destBuffer = -1; }
for(int32_t ii=dataID-1; ii >= 0; ii--) { } else if (generateEventId == ednMsgOpenFile) {
if (true == Exist(ii) ) { if (NULL != data) {
destBuffer = ii; etk::File myFile(data, etk::FILE_TYPE_DIRECT);
break; int32_t newOne = Open(myFile);
} if (-1 != newOne) {
m_idSelected = newOne;
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_idSelected);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
}
}
} else if (generateEventId == ednMsgGuiSave) {
if (NULL == data) {
EDN_ERROR("Null data for close file ... ");
} else {
if (0 == strcmp(data , "current")) {
// Check buffer existence
if(true == Exist(m_idSelected)) {
// If no name ==> request a Gui display ...
if (Get(m_idSelected)->HaveName() == false) {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSaveAs, "current");
} else {
Get(m_idSelected)->Save();
} }
//EDN_DEBUG("new buffer selected : ?? " << destBuffer); }
// try next buffer } else {
if (-1 == destBuffer) { int32_t newId;
for(int32_t ii=dataID+1; ii < listBuffer.Size(); ii++) { sscanf(data, "%d", &newId);
if (false == Exist(newId)) {
EDN_ERROR("Request a save As with a non existant ID=" << newId);
} else {
// If no name ==> request a Gui display ...
if (Get(newId)->HaveName() == false) {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSaveAs, newId);
} else {
Get(m_idSelected)->Save();
}
}
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferState, "saved");
}
}
} else if (generateEventId == ednMsgGuiClose) {
if (NULL == data) {
EDN_ERROR("Null data for close file ... ");
} else {
if (0 == strcmp(data , "All")) {
} else {
int32_t closeID = -1;
if (0 == strcmp(data , "current")) {
closeID = m_idSelected;
EDN_DEBUG("Close specific buffer ID" << closeID);
} else {
// close specific buffer ...
sscanf(data, "%d", &closeID);
EDN_DEBUG("Close specific buffer ID="<< closeID);
}
if(true == Exist(closeID)) {
// Get the new display buffer
if (m_idSelected == closeID) {
// Try previous buffer
int32_t destBuffer = -1;
for(int32_t ii=closeID-1; ii >= 0; ii--) {
if (true == Exist(ii) ) { if (true == Exist(ii) ) {
destBuffer = ii; destBuffer = ii;
break; break;
} }
} }
// try next buffer
if (-1 == destBuffer) {
for(int32_t ii=closeID+1; ii < listBuffer.Size(); ii++) {
if (true == Exist(ii) ) {
destBuffer = ii;
break;
}
}
}
// set it to the currect display
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, destBuffer);
m_idSelected = destBuffer;
} }
//EDN_DEBUG("new buffer selected : ?? " << destBuffer); // Remove requested buffer
// set it to the currect display Remove(closeID);
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, destBuffer); ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
} else {
EDN_ERROR("Request Close of a non existant ID : " << closeID);
} }
//EDN_DEBUG("Remove : " << dataID);
// Remove requested buffer
Remove(dataID);
} }
break; }
case EDN_MSG__BUFF_ID_SAVE: } else if (generateEventId == ednMsgCodeViewSelectedId) {
//Change the selected buffer
if (NULL == data) {
EDN_ERROR("Null data for changing buffer ID file ... ");
} else {
int32_t newId;
sscanf(data, "%d", &newId);
if (true == Exist(newId)) {
m_idSelected = newId;
} else {
EDN_ERROR("code biew request the selection of an non -existant buffer ==> reset to -1");
m_idSelected = -1;
}
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_idSelected);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
}
}
/*
switch (id)
{
// Check buffer existence // Check buffer existence
if(true == Exist(dataID)) { if(true == Exist(dataID)) {
// If no name ==> request a Gui display ... // If no name ==> request a Gui display ...
@@ -158,8 +249,7 @@ void BufferManager::RemoveAll(void)
for (i=0; i<listBuffer.Size(); i++) { for (i=0; i<listBuffer.Size(); i++) {
Remove(i); Remove(i);
} }
//SendMessage(EDN_MSG__BUFFER_REMOVE_ALL); ewol::widgetMessageMultiCast::Send(-1, ednMsgGuiClose, "All");
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferRemoveAll);
} }
@@ -179,8 +269,6 @@ int32_t BufferManager::Create(void)
// Add at the list of element // Add at the list of element
listBuffer.PushBack(myBuffer); listBuffer.PushBack(myBuffer);
int32_t basicID = listBuffer.Size() - 1; int32_t basicID = listBuffer.Size() - 1;
//SendMessage(EDN_MSG__BUFFER_ADD, basicID);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferAdd);
return basicID; return basicID;
} }
@@ -202,10 +290,7 @@ int32_t BufferManager::Open(etk::File &myFile)
Buffer *myBuffer = new BufferText(myFile); Buffer *myBuffer = new BufferText(myFile);
// Add at the list of element // Add at the list of element
listBuffer.PushBack(myBuffer); listBuffer.PushBack(myBuffer);
int32_t basicID = listBuffer.Size() - 1; return listBuffer.Size() - 1;
//SendMessage(EDN_MSG__BUFFER_ADD, basicID);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferAdd);
return basicID;
} }
@@ -278,6 +363,19 @@ uint32_t BufferManager::Size(void)
return listBuffer.Size(); return listBuffer.Size();
} }
// nb of opens file Now ...
uint32_t BufferManager::SizeOpen(void)
{
uint32_t jjj = 0;
// check if the Buffer existed
for (int32_t iii=0; iii<listBuffer.Size(); iii++) {
// check if the buffer already existed
if (NULL != listBuffer[iii]) {
jjj++;
}
}
return jjj;
}
/** /**
* @brief * @brief
@@ -305,8 +403,7 @@ bool BufferManager::Remove(int32_t BufferID)
// Delete the Buffer // Delete the Buffer
delete( listBuffer[BufferID] ); delete( listBuffer[BufferID] );
listBuffer[BufferID] = NULL; listBuffer[BufferID] = NULL;
//SendMessage(EDN_MSG__BUFFER_REMOVE, BufferID); ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferRemove);
return true; return true;
} else { } else {
EDN_INFO("non existing Buffer " << BufferID); EDN_INFO("non existing Buffer " << BufferID);

View File

@@ -44,23 +44,25 @@ class BufferManager: public etk::Singleton<BufferManager>, public ewol::Widget
public: public:
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y); bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
private:
// return the ID of the buffer allocated // return the ID of the buffer allocated
// create a buffer with no element // create a buffer with no element
int32_t Create(void); int32_t Create(void);
// open curent filename // open curent filename
int32_t Open(etk::File &myFile); int32_t Open(etk::File &myFile);
bool Remove(int32_t BufferID);
public:
int32_t GetSelected(void) { return m_idSelected;}; int32_t GetSelected(void) { return m_idSelected;};
void SetSelected(int32_t id) {m_idSelected = id;}; //void SetSelected(int32_t id) {m_idSelected = id;};
Buffer * Get(int32_t BufferID); Buffer * Get(int32_t BufferID);
bool Exist(int32_t BufferID); bool Exist(int32_t BufferID);
bool Exist(etk::File &myFile); bool Exist(etk::File &myFile);
int32_t GetId(etk::File &myFile); int32_t GetId(etk::File &myFile);
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5 // return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t Size(void); uint32_t Size(void);
uint32_t SizeOpen(void);
int32_t WitchBuffer(int32_t iEmeElement); int32_t WitchBuffer(int32_t iEmeElement);
bool Remove(int32_t BufferID);
private: private:

View File

@@ -29,6 +29,7 @@
#include <BufferText.h> #include <BufferText.h>
#include <toolsMemory.h> #include <toolsMemory.h>
#include <etk/RegExp.h> #include <etk/RegExp.h>
#include <etk/unicode.h>
#include <ewol/ewol.h> #include <ewol/ewol.h>
#include <ewol/OObject.h> #include <ewol/OObject.h>
@@ -79,7 +80,6 @@ void BufferText::BasicInit(void)
m_displayStartLineId = 0; m_displayStartLineId = 0;
m_displaySize.x = 200; m_displaySize.x = 200;
m_displaySize.y = 20; m_displaySize.y = 20;
m_displayLocalSyntax.idSequence = -1;
} }
@@ -138,7 +138,7 @@ BufferText::BufferText(etk::File &fileName) : Buffer(fileName)
FILE * myFile = NULL; FILE * myFile = NULL;
// try to open the file. if not existed, new file // try to open the file. if not existed, new file
myFile = fopen(fileName.GetCompleateName().c_str(), "r"); myFile = fopen(fileName.GetCompleateName().Utf8Data(), "r");
if (NULL != myFile) { if (NULL != myFile) {
m_EdnBuf.DumpFrom(myFile); m_EdnBuf.DumpFrom(myFile);
// close the input file // close the input file
@@ -166,7 +166,7 @@ void BufferText::Save(void)
{ {
EDN_INFO("Save File : \"" << GetFileName() << "\"" ); EDN_INFO("Save File : \"" << GetFileName() << "\"" );
FILE * myFile = NULL; FILE * myFile = NULL;
myFile = fopen(GetFileName().GetCompleateName().c_str(), "w"); myFile = fopen(GetFileName().GetCompleateName().Utf8Data(), "w");
if (NULL != myFile) { if (NULL != myFile) {
m_EdnBuf.DumpIn(myFile); m_EdnBuf.DumpIn(myFile);
fclose(myFile); fclose(myFile);
@@ -238,14 +238,28 @@ void BufferText::SetLineDisplay(uint32_t lineNumber)
} }
#define SEPARATION_SIZE_LINE_NUMBER (3)
void BufferText::DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY) void BufferText::DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY)
{ {
char tmpLineNumber[50]; char tmpLineNumber[50];
sprintf(tmpLineNumber, myPrint, lineNumber); sprintf(tmpLineNumber, myPrint, lineNumber);
OOColored->SetColor(myColorManager->Get(COLOR_LIST_BG_2)); OOColored->SetColor(myColorManager->Get(COLOR_LIST_BG_2));
OOColored->Rectangle( 0, positionY, 68, sizeY); OOColored->Rectangle( 0, positionY, sizeX+0.5*SEPARATION_SIZE_LINE_NUMBER, sizeY);
OOText->SetColor(myColorManager->Get(COLOR_CODE_LINE_NUMBER)); OOText->SetColor(myColorManager->Get(COLOR_CODE_LINE_NUMBER));
OOText->TextAdd(1, positionY, tmpLineNumber, -1);
coord2D_ts textPos;
textPos.x = 1;
textPos.y = positionY;
clipping_ts drawClipping;
drawClipping.x = 0;
drawClipping.y = 0;
drawClipping.w = sizeX;
drawClipping.h = sizeY;
// TODO : Remove this unreallistic leak of time
etk::UString tmppp = tmpLineNumber;
OOText->Text(textPos, drawClipping, tmppp);
} }
#define CURSOR_WIDTH (5) #define CURSOR_WIDTH (5)
@@ -291,6 +305,17 @@ void BufferText::UpdatePointerNumber(void)
} }
} }
*/ */
int32_t BufferText::GetNumberOfLine(void)
{
return m_EdnBuf.CountLines();
}
// TODO : Remove this ... it is really bad...
static int32_t g_basicfontId = 0;
/** /**
* @brief Display the curent buffer with all the probematic imposed by the xharset and the user contraint. * @brief Display the curent buffer with all the probematic imposed by the xharset and the user contraint.
* *
@@ -299,20 +324,38 @@ void BufferText::UpdatePointerNumber(void)
* @return * @return
* *
*/ */
int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY)
{ {
offsetX -= 40;
if (offsetX<0) {
offsetX = 0;
}
int32_t selStart, selEnd, selRectStart, selRectEnd; int32_t selStart, selEnd, selRectStart, selRectEnd;
bool selIsRect; bool selIsRect;
int32_t selHave; int32_t selHave;
int32_t fontId = ewol::GetDefaultFontId(); int32_t fontId = OOTextNormal->GetFontID();
// TODO : Remove this ...
g_basicfontId = fontId;
int32_t letterWidth = ewol::GetWidth(fontId, "A"); int32_t letterWidth = ewol::GetWidth(fontId, "A");
int32_t letterHeight = ewol::GetHeight(fontId); int32_t letterHeight = ewol::GetHeight(fontId);
m_displayStartLineId = offsetY / letterHeight;
// update the display position with the scroll ofset :
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
// update the number of element that can be displayed // update the number of element that can be displayed
m_displaySize.x = (sizeX/letterWidth) + 1 - nbColoneForLineNumber; m_displaySize.x = (sizeX/letterWidth) + 1 - nbColoneForLineNumber;
m_displaySize.y = (sizeY/letterHeight) + 1; m_displaySize.y = (sizeY/letterHeight) + 1;
EDN_INFO("main DIPLAY " << m_displaySize.x << " char * " << m_displaySize.y << " char"); EDN_VERBOSE("main DIPLAY " << m_displaySize.x << " char * " << m_displaySize.y << " char");
selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd); selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd);
@@ -341,9 +384,10 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
color_ts & myColorSpace = myColorManager->Get(COLOR_CODE_SPACE); color_ts & myColorSpace = myColorManager->Get(COLOR_CODE_SPACE);
color_ts & myColorTab = myColorManager->Get(COLOR_CODE_TAB); color_ts & myColorTab = myColorManager->Get(COLOR_CODE_TAB);
Colorize * selectColor = NULL; Colorize * selectColor = NULL;
ewol::OObject2DTextColored* OOTextSelected = NULL;
int mylen = m_EdnBuf.Size(); int mylen = m_EdnBuf.Size();
int32_t x_base=nbColoneForLineNumber*letterWidth + 3; int32_t x_base=nbColoneForLineNumber*letterWidth;
int32_t idX = 0; int32_t idX = 0;
OOColored->SetColor(myColorManager->Get(COLOR_CODE_BASIC_BG)); OOColored->SetColor(myColorManager->Get(COLOR_CODE_BASIC_BG));
@@ -351,6 +395,7 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
int displayLines = 0; int displayLines = 0;
// Regenerate the colorizing if necessary ... // Regenerate the colorizing if necessary ...
displayHLData_ts m_displayLocalSyntax;
m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, m_displayStartBufferPos, m_displaySize.y); m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, m_displayStartBufferPos, m_displaySize.y);
//GTimeVal timeStart; //GTimeVal timeStart;
//g_get_current_time(&timeStart); //g_get_current_time(&timeStart);
@@ -358,10 +403,15 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
uniChar_t displayChar[MAX_EXP_CHAR_LEN]; uniChar_t displayChar[MAX_EXP_CHAR_LEN];
memset(displayChar, 0, sizeof(uniChar_t)*MAX_EXP_CHAR_LEN); memset(displayChar, 0, sizeof(uniChar_t)*MAX_EXP_CHAR_LEN);
etk::UString myStringToDisplay;
// draw the lineNumber : // draw the lineNumber :
int32_t currentLineID = m_displayStartLineId+1; int32_t currentLineID = m_displayStartLineId+1;
EDN_DEBUG("Start display of text buffer [" << m_displayStartBufferPos<< ".." << mylen << "]"); EDN_VERBOSE("Start display of text buffer [" << m_displayStartBufferPos<< ".." << mylen << "]");
EDN_DEBUG("cursor Pos : " << m_cursorPos << "start at pos=" << m_displayStartBufferPos); EDN_VERBOSE("cursor Pos : " << m_cursorPos << "start at pos=" << m_displayStartBufferPos);
DrawLineNumber(OOTextNormal, OOColored, x_base, sizeY, myPrint, currentLineID, y);
int32_t pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
clipping_ts drawClipping; clipping_ts drawClipping;
drawClipping.x = 0; drawClipping.x = 0;
@@ -369,8 +419,12 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
drawClipping.w = sizeX; drawClipping.w = sizeX;
drawClipping.h = sizeY; drawClipping.h = sizeY;
DrawLineNumber(OOText, OOColored, sizeX, sizeY, myPrint, currentLineID, y); clipping_ts drawClippingTextArea;
int32_t pixelX = x_base; drawClippingTextArea.x = pixelX;
drawClippingTextArea.y = 0;
drawClippingTextArea.w = sizeX - drawClipping.x;
drawClippingTextArea.h = sizeY;
for (iii=m_displayStartBufferPos; iii<mylen && displayLines < m_displaySize.y ; iii = new_i) { for (iii=m_displayStartBufferPos; iii<mylen && displayLines < m_displaySize.y ; iii = new_i) {
//EDN_DEBUG("diplay element=" << iii); //EDN_DEBUG("diplay element=" << iii);
int displaywidth; int displaywidth;
@@ -411,13 +465,28 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
haveBg = selectColor->HaveBg(); haveBg = selectColor->HaveBg();
} }
} }
OOText->SetColor(selectColor->GetFG());
coord2D_ts textPos; coord2D_ts textPos;
textPos.x = pixelX-m_displayStartPixelX; textPos.x = pixelX-offsetX;
textPos.y = y; textPos.y = y;
drawSize = OOText->TextAdd(textPos, drawClipping, displayChar); if (true == selectColor->GetItalic() ) {
if (true == selectColor->GetBold() ) {
OOTextSelected = OOTextBoldItalic;
} else {
OOTextSelected = OOTextItalic;
}
} else {
if (true == selectColor->GetBold() ) {
OOTextSelected = OOTextBold;
} else {
OOTextSelected = OOTextNormal;
}
}
OOTextSelected->SetColor(selectColor->GetFG());
// TODO : Remove this unreallistic leak of time
myStringToDisplay = displayChar;
drawSize = OOTextSelected->Text(textPos, drawClippingTextArea, myStringToDisplay);
if (true == haveBg ) { if (true == haveBg ) {
OOColored->Rectangle( pixelX, y, drawSize, letterHeight, drawClipping); OOColored->Rectangle(textPos.x, y, drawSize, letterHeight, drawClippingTextArea);
} }
} }
idX += displaywidth; idX += displaywidth;
@@ -430,11 +499,11 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
// move to next line ... // move to next line ...
if (currentChar=='\n') { if (currentChar=='\n') {
idX =0; idX =0;
pixelX = x_base; pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
y += letterHeight; y += letterHeight;
displayLines++; displayLines++;
currentLineID++; currentLineID++;
DrawLineNumber(OOText, OOColored, sizeX, sizeY, myPrint, currentLineID, y); DrawLineNumber(OOTextNormal, OOColored, x_base, sizeY, myPrint, currentLineID, y);
} }
} }
// special case : the cursor is at the end of the buffer... // special case : the cursor is at the end of the buffer...
@@ -453,9 +522,8 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
int32_t BufferText::GetMousePosition(int32_t width, int32_t height) int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
{ {
int32_t fontId = ewol::GetDefaultFontId(); int32_t letterWidth = ewol::GetWidth(g_basicfontId, "9");
int32_t letterWidth = ewol::GetWidth(fontId, "9"); int32_t letterHeight = ewol::GetHeight(g_basicfontId);
int32_t letterHeight = ewol::GetHeight(fontId);
int32_t lineOffset = height / letterHeight; int32_t lineOffset = height / letterHeight;
@@ -479,7 +547,7 @@ int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
int32_t iii, new_i; int32_t iii, new_i;
int mylen = m_EdnBuf.Size(); int mylen = m_EdnBuf.Size();
int32_t x_base=nbColoneForLineNumber*letterWidth + 3; int32_t x_base=nbColoneForLineNumber*letterWidth + SEPARATION_SIZE_LINE_NUMBER;
int32_t idX = 0; int32_t idX = 0;
uniChar_t displayChar[MAX_EXP_CHAR_LEN]; uniChar_t displayChar[MAX_EXP_CHAR_LEN];
@@ -491,30 +559,30 @@ int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
EDN_DEBUG(" Element : Befor the start of the line ... ==> END"); EDN_DEBUG(" Element : Befor the start of the line ... ==> END");
return startLinePosition; return startLinePosition;
} }
EDN_DEBUG("Get id element : x=" << width << "px y=" << height << "px"); EDN_VERBOSE("Get id element : x=" << width << "px y=" << height << "px");
EDN_DEBUG(" line offset = " << lineOffset); EDN_VERBOSE(" line offset = " << lineOffset);
for (iii=startLinePosition; iii<mylen; iii = new_i) { for (iii=startLinePosition; iii<mylen; iii = new_i) {
int displaywidth; int displaywidth;
uint32_t currentChar = '\0'; uint32_t currentChar = '\0';
new_i = iii; new_i = iii;
displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar); displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar);
if (currentChar!='\n') { if (currentChar!='\n') {
int32_t drawSize = ewol::GetWidth(fontId, displayChar); int32_t drawSize = ewol::GetWidth(g_basicfontId, displayChar);
EDN_DEBUG(" Element : " << currentChar << "=\"" << (char)currentChar << "\" display offset=" << pixelX << "px width=" << drawSize << "px"); EDN_VERBOSE(" Element : " << currentChar << "=\"" << (char)currentChar << "\" display offset=" << pixelX << "px width=" << drawSize << "px");
pixelX += drawSize; pixelX += drawSize;
if (width <= pixelX) { if (width <= pixelX) {
EDN_DEBUG(" Find IT ==> END"); EDN_VERBOSE(" Find IT ==> END");
// find position ... // find position ...
break; break;
} }
} else { } else {
EDN_DEBUG(" Element : \"\\n\" display width=---px ==> end of line ==> END"); EDN_VERBOSE(" Element : \"\\n\" display width=---px ==> end of line ==> END");
// end of line ... exit cycle // end of line ... exit cycle
break; break;
} }
idX += displaywidth; idX += displaywidth;
} }
EDN_DEBUG("BufferText::GetMousePosition(" << width << "," << height << "); ==> " << iii ); EDN_VERBOSE("BufferText::GetMousePosition(" << width << "," << height << "); ==> " << iii );
return iii; return iii;
} }
@@ -687,7 +755,6 @@ void BufferText::ScrollUp(void)
*/ */
void BufferText::MoveUpDown(int32_t ofset) void BufferText::MoveUpDown(int32_t ofset)
{ {
m_displayLocalSyntax.idSequence = -1;
if (ofset >= 0) { if (ofset >= 0) {
int32_t nbLine = m_EdnBuf.NumberOfLines(); int32_t nbLine = m_EdnBuf.NumberOfLines();
if (m_displayStartLineId+ofset+3 > nbLine) { if (m_displayStartLineId+ofset+3 > nbLine) {
@@ -722,7 +789,6 @@ void BufferText::MoveUpDown(int32_t ofset)
void BufferText::ForceReDraw(bool allElement) void BufferText::ForceReDraw(bool allElement)
{ {
NeedToCleanEndPage = true; NeedToCleanEndPage = true;
//m_displayLocalSyntax.idSequence = -1;
} }
void BufferText::SetInsertPosition(int32_t newPos, bool insertChar) void BufferText::SetInsertPosition(int32_t newPos, bool insertChar)
@@ -985,102 +1051,94 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
* @return --- * @return ---
* *
*/ */
void BufferText::AddChar(char * UTF8data) void BufferText::AddChar(uniChar_t unicodeData)
{ {
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd; int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect; bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd); bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (unicodeData == 0x09) {
int32_t size=strlen(UTF8data); if (false == haveSelectionActive) {
bool actionDone = false; etk::VectorType<int8_t> tmpVect;
if (1==size) { tmpVect.PushBack(0x09);
if (UTF8data[0] == 0x09) { m_EdnBuf.Insert(m_cursorPos, tmpVect);
if (false == haveSelectionActive) { 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::VectorType<int8_t> tmpVect; etk::VectorType<int8_t> tmpVect;
tmpVect.PushBack(0x09); 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::VectorType<int8_t> tmpVect;
tmpVect.PushBack(0x09);
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect);
SetInsertPosition(SelectionStart+tmpVect.Size(), true);
} else {
if (true == ewol::IsSetShift() ) {
m_cursorPos = m_EdnBuf.UnIndent(SELECTION_PRIMARY);
} else {
m_cursorPos = m_EdnBuf.Indent(SELECTION_PRIMARY);
}
}
}
actionDone = true;
} else if (UTF8data[0] == '\n') {
etk::VectorType<int8_t> tmpVect;
if (true == ewol::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<m_cursorPos; kk++) {
if (' ' == m_EdnBuf[kk]) {
tmpVect.PushBack(' ');
} else if('\t' == m_EdnBuf[kk]) {
tmpVect.PushBack('\t');
} else {
break;
}
}
}
}
// Set temporary buffer in the real buffer
if (false == haveSelectionActive) {
m_EdnBuf.Insert(m_cursorPos, tmpVect);
SetInsertPosition(m_cursorPos+tmpVect.Size(), true);
} else {
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect); m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect);
SetInsertPosition(SelectionStart+tmpVect.Size(), true); SetInsertPosition(SelectionStart+tmpVect.Size(), true);
}
actionDone = true;
} else if (UTF8data[0] == 0x7F ) {
//EDN_INFO("keyEvent : <Suppr> pos=" << m_cursorPos);
if (false == haveSelectionActive) {
m_EdnBuf.Remove(m_cursorPos, m_cursorPos+1);
} else { } else {
m_EdnBuf.RemoveSelected(SELECTION_PRIMARY); if (true == ewol::IsSetShift() ) {
SetInsertPosition(SelectionStart, true); m_cursorPos = m_EdnBuf.UnIndent(SELECTION_PRIMARY);
} else {
m_cursorPos = m_EdnBuf.Indent(SELECTION_PRIMARY);
}
} }
actionDone = true;
} else if (UTF8data[0] == 0x08) {
//EDN_INFO("keyEvent : <Del> pos=" << m_cursorPos);
if (false == haveSelectionActive) {
m_EdnBuf.Remove(m_cursorPos-1, m_cursorPos);
SetInsertPosition(m_cursorPos-1, true);
} else {
m_EdnBuf.RemoveSelected(SELECTION_PRIMARY);
SetInsertPosition(SelectionStart, true);
}
actionDone = true;
} }
} } else if (unicodeData == '\n') {
etk::VectorType<int8_t> tmpVect;
if (false == actionDone) { if (true == ewol::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<m_cursorPos; kk++) {
if (' ' == m_EdnBuf[kk]) {
tmpVect.PushBack(' ');
} else if('\t' == m_EdnBuf[kk]) {
tmpVect.PushBack('\t');
} else {
break;
}
}
}
}
// Set temporary buffer in the real buffer
if (false == haveSelectionActive) {
m_EdnBuf.Insert(m_cursorPos, tmpVect);
SetInsertPosition(m_cursorPos+tmpVect.Size(), true);
} else {
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect);
SetInsertPosition(SelectionStart+tmpVect.Size(), true);
}
} else if (unicodeData == 0x7F ) {
//EDN_INFO("keyEvent : <Suppr> pos=" << m_cursorPos);
if (false == haveSelectionActive) {
m_EdnBuf.Remove(m_cursorPos, m_cursorPos+1);
} else {
m_EdnBuf.RemoveSelected(SELECTION_PRIMARY);
SetInsertPosition(SelectionStart, true);
}
} else if (unicodeData == 0x08) {
//EDN_INFO("keyEvent : <Del> pos=" << m_cursorPos);
if (false == haveSelectionActive) {
m_EdnBuf.Remove(m_cursorPos-1, m_cursorPos);
SetInsertPosition(m_cursorPos-1, true);
} else {
m_EdnBuf.RemoveSelected(SELECTION_PRIMARY);
SetInsertPosition(SelectionStart, true);
}
} else {
// normal adding char ...
if (true == m_EdnBuf.GetUTF8Mode()) { if (true == m_EdnBuf.GetUTF8Mode()) {
char tmpUTF8[16];
unicode::convertUnicodeToUtf8(unicodeData, tmpUTF8);
etk::VectorType<int8_t> tmpVect; etk::VectorType<int8_t> tmpVect;
int32_t localOfset = strlen(UTF8data); int32_t localOfset = strlen(tmpUTF8);
tmpVect.PushBack((int8_t*)UTF8data, localOfset); tmpVect.PushBack((int8_t*)tmpUTF8, localOfset);
if (false == haveSelectionActive) { if (false == haveSelectionActive) {
m_EdnBuf.Insert(m_cursorPos, tmpVect); m_EdnBuf.Insert(m_cursorPos, tmpVect);
SetInsertPosition(m_cursorPos+localOfset, true); SetInsertPosition(m_cursorPos+localOfset, true);
@@ -1091,7 +1149,7 @@ void BufferText::AddChar(char * UTF8data)
} else { } else {
// convert in the Good ISO format : // convert in the Good ISO format :
char output_ISO; char output_ISO;
convertUtf8ToIso(m_EdnBuf.GetCharsetType(), UTF8data, output_ISO); unicode::convertUnicodeToIso(m_EdnBuf.GetCharsetType(), unicodeData, output_ISO);
//printf(" insert : \"%s\"==> 0x%08x=%d ", UTF8data, (unsigned int)output_ISO, (int)output_ISO); //printf(" insert : \"%s\"==> 0x%08x=%d ", UTF8data, (unsigned int)output_ISO, (int)output_ISO);
etk::VectorType<int8_t> tmpVect; etk::VectorType<int8_t> tmpVect;
tmpVect.PushBack(output_ISO); tmpVect.PushBack(output_ISO);
@@ -1110,16 +1168,17 @@ void BufferText::AddChar(char * UTF8data)
} }
int32_t BufferText::FindLine(etk::String &data) int32_t BufferText::FindLine(etk::UString &data)
{ {
if ( 0 == data.Size()) { if ( 0 == data.Size()) {
EDN_WARNING("no search data"); EDN_WARNING("no search data");
return 0; return 0;
} }
EDN_INFO("Search data line : \"" << data << "\""); EDN_INFO("Search data line : \"" << data << "\"");
etk::VectorType<int8_t> mVectSearch; etk::VectorType<uniChar_t> mVectSearch;
mVectSearch = data.GetVector(); mVectSearch = data.GetVector();
//EDN_INFO("search data Forward : startSearchPos=" << startSearchPos ); //EDN_INFO("search data Forward : startSearchPos=" << startSearchPos );
/*
int32_t foundPos; int32_t foundPos;
bool findSomething = m_EdnBuf.SearchForward(0, mVectSearch, &foundPos, true); bool findSomething = m_EdnBuf.SearchForward(0, mVectSearch, &foundPos, true);
// if find data : // if find data :
@@ -1128,6 +1187,9 @@ int32_t BufferText::FindLine(etk::String &data)
} else { } else {
return 0; return 0;
} }
*/
EDN_TODO("Remove for now ...");
return 0;
} }
void BufferText::JumpAtLine(int32_t newLine) void BufferText::JumpAtLine(int32_t newLine)
@@ -1154,7 +1216,7 @@ int32_t BufferText::GetCurrentLine(void)
void BufferText::Search(etk::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp)
{ {
EDN_INFO("Search data : \"" << data << "\""); EDN_INFO("Search data : \"" << data << "\"");
@@ -1175,8 +1237,10 @@ void BufferText::Search(etk::String &data, bool back, bool caseSensitive, bool w
EDN_WARNING("no search data"); EDN_WARNING("no search data");
return; return;
} }
etk::VectorType<int8_t> mVectSearch; etk::VectorType<uniChar_t> mVectSearch;
mVectSearch = data.GetVector(); mVectSearch = data.GetVector();
EDN_TODO("Remove for now ...");
/*
if (false == back) { if (false == back) {
//EDN_INFO("search data Forward : startSearchPos=" << startSearchPos ); //EDN_INFO("search data Forward : startSearchPos=" << startSearchPos );
int32_t foundPos; int32_t foundPos;
@@ -1214,44 +1278,21 @@ void BufferText::Search(etk::String &data, bool back, bool caseSensitive, bool w
UpdateWindowsPosition(); UpdateWindowsPosition();
} }
} }
*/
// NOTE : Need to be use in the highligner and the current buffer when we select Regular Expression ...
/*
// Test avec le truc de regExp :
char * myBuf = m_EdnBuf.GetRange(0, m_EdnBuf.Size());
regexp *compiledRE;
char *compileMsg;
compiledRE = CompileRE(data.GetDirectPointer(), &compileMsg, REDFLT_STANDARD);
if (compiledRE == NULL) {
EDN_ERROR("RegExpression : \"" << data.GetDirectPointer() << "\" error named : \"" << compileMsg << "\"" );
} else {
EDN_DEBUG("RegExpression : \"" << data.GetDirectPointer() << "\" OK ... ");
if (true == ExecRE(compiledRE, NULL, myBuf, NULL, false, '\0', '\0', NULL, NULL)) {
EDN_INFO(" ==> top_branch=" << compiledRE->top_branch << "; extentpBW=" << (int32_t)(compiledRE->extentpBW - myBuf) << "; extentpFW=" << (int32_t)(compiledRE->extentpFW - myBuf));
} else {
EDN_INFO(" ==> not fined ... ");
}
}
// free copy of buffer ...
if (myBuf != NULL) {
free(myBuf);
}
*/
} }
void BufferText::Replace(etk::String &data) void BufferText::Replace(etk::UString &data)
{ {
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd; int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect; bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd); bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (true == haveSelectionActive) { if (true == haveSelectionActive) {
// Replace Data : // Replace Data :
etk::VectorType<int8_t> myData = data.GetVector(); etk::VectorType<uniChar_t> myData = data.GetVector();
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, myData); EDN_TODO("Remove for now ...");
SetInsertPosition(SelectionStart + myData.Size()); //m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, myData);
//SetInsertPosition(SelectionStart + myData.Size());
} }
SetModify(true); SetModify(true);
} }
@@ -1267,13 +1308,15 @@ void BufferText::Replace(etk::String &data)
*/ */
void BufferText::Copy(int8_t clipboardID) void BufferText::Copy(int8_t clipboardID)
{ {
etk::VectorType<int8_t> mVect; etk::VectorType<uniChar_t> mVect;
// get the curent selected data // get the curent selected data
if (true == m_EdnBuf.SelectHasSelection(SELECTION_PRIMARY) ) { if (true == m_EdnBuf.SelectHasSelection(SELECTION_PRIMARY) ) {
m_EdnBuf.GetSelectionText(SELECTION_PRIMARY, mVect); //m_EdnBuf.GetSelectionText(SELECTION_PRIMARY, mVect);
EDN_TODO("Remove for now ...");
} }
// copy data in the click board : // copy data in the click board :
ClipBoard::Set(clipboardID, mVect); //ClipBoard::Set(clipboardID, mVect);
EDN_TODO("Remove for now ...");
} }
@@ -1316,7 +1359,10 @@ void BufferText::Cut(int8_t clipboardID)
*/ */
void BufferText::Paste(int8_t clipboardID) void BufferText::Paste(int8_t clipboardID)
{ {
etk::VectorType<int8_t> mVect; etk::VectorType<uniChar_t> mVect;
EDN_TODO("Remove for now ...");
/*
// copy data from the click board : // copy data from the click board :
ClipBoard::Get(clipboardID, mVect); ClipBoard::Get(clipboardID, mVect);
@@ -1333,7 +1379,7 @@ void BufferText::Paste(int8_t clipboardID)
m_EdnBuf.Insert(m_cursorPos, mVect); m_EdnBuf.Insert(m_cursorPos, mVect);
m_cursorPos += mVect.Size(); m_cursorPos += mVect.Size();
} }
*/
UpdateWindowsPosition(); UpdateWindowsPosition();
ForceReDraw(true); ForceReDraw(true);
SetModify(true); SetModify(true);

View File

@@ -46,9 +46,15 @@ class BufferText : public Buffer {
void GetInfo(infoStatBuffer_ts &infoToUpdate); void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber); void SetLineDisplay(uint32_t lineNumber);
int32_t Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY);
void ForceReDraw(bool allElement); void ForceReDraw(bool allElement);
void AddChar(char * UTF8data); void AddChar(uniChar_t unicodeData);
void cursorMove(ewol::eventKbMoveType_te moveTypeEvent); void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
void MouseSelectFromCursorTo(int32_t width, int32_t height); void MouseSelectFromCursorTo(int32_t width, int32_t height);
void MouseEvent(int32_t width, int32_t height); void MouseEvent(int32_t width, int32_t height);
@@ -61,9 +67,9 @@ class BufferText : public Buffer {
void Cut(int8_t clipboardID); void Cut(int8_t clipboardID);
void Paste(int8_t clipboardID); void Paste(int8_t clipboardID);
void Search(etk::String &data, bool back, bool caseSensitive, bool wrap, bool regExp); void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp);
void Replace(etk::String &data); void Replace(etk::UString &data);
int32_t FindLine(etk::String &data); int32_t FindLine(etk::UString &data);
void JumpAtLine(int32_t newLine); void JumpAtLine(int32_t newLine);
int32_t GetCurrentLine(void); int32_t GetCurrentLine(void);
@@ -73,6 +79,7 @@ class BufferText : public Buffer {
void Undo(void); void Undo(void);
void Redo(void); void Redo(void);
void SetCharset(unicode::charset_te newCharset); void SetCharset(unicode::charset_te newCharset);
int32_t GetNumberOfLine(void);
protected: protected:
void NameChange(void); void NameChange(void);
@@ -94,8 +101,6 @@ class BufferText : public Buffer {
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ... int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
displayHLData_ts m_displayLocalSyntax; //!< for the display of the local elements (display HL mode)
// internal function // internal function
void BasicInit(void); void BasicInit(void);
void UpdateWindowsPosition(bool centerPage = false); void UpdateWindowsPosition(bool centerPage = false);

View File

@@ -32,7 +32,7 @@
#define __class__ "Colorize" #define __class__ "Colorize"
Colorize::Colorize( etk::String &newColorName) Colorize::Colorize( etk::UString &newColorName)
{ {
m_colorFG.red=0; m_colorFG.red=0;
@@ -85,14 +85,14 @@ void Colorize::SetName(const char *newColorName)
ColorName = newColorName; ColorName = newColorName;
} }
void Colorize::SetName(etk::String &newColorName) void Colorize::SetName(etk::UString &newColorName)
{ {
//EDN_INFO("color change name : \"%s\" ==> \"%s\"",ColorName.c_str(), newColorName.c_str()); //EDN_INFO("color change name : \"%s\" ==> \"%s\"",ColorName.c_str(), newColorName.c_str());
ColorName = newColorName; ColorName = newColorName;
} }
etk::String Colorize::GetName(void) etk::UString Colorize::GetName(void)
{ {
return ColorName; return ColorName;
} }

View File

@@ -31,12 +31,12 @@ class Colorize {
public: public:
// Constructeur // Constructeur
Colorize(void); Colorize(void);
Colorize(etk::String &newColorName); Colorize(etk::UString &newColorName);
~Colorize(void); ~Colorize(void);
void SetName(etk::String &newColorName); void SetName(etk::UString &newColorName);
void SetName(const char *newColorName); void SetName(const char *newColorName);
etk::String GetName(void); etk::UString GetName(void);
void SetFgColor(const char *myColor); void SetFgColor(const char *myColor);
void SetBgColor(const char *myColor); void SetBgColor(const char *myColor);
@@ -50,10 +50,10 @@ class Colorize {
bool GetItalic(void); bool GetItalic(void);
bool GetBold(void); bool GetBold(void);
void Display(int32_t i) { EDN_INFO(" " << i << " : \"" << ColorName.c_str() << "\"" << " fg="<< m_colorFG.red <<","<< m_colorFG.green <<","<< m_colorFG.blue <<","<< m_colorFG.alpha /*<<" bg="<< m_colorBG.red <<","<< m_colorBG.green <<","<< m_colorBG.blue*/ ); }; void Display(int32_t i) { EDN_INFO(" " << i << " : \"" << ColorName << "\"" << " fg="<< m_colorFG.red <<","<< m_colorFG.green <<","<< m_colorFG.blue <<","<< m_colorFG.alpha /*<<" bg="<< m_colorBG.red <<","<< m_colorBG.green <<","<< m_colorBG.blue*/ ); };
private: private:
etk::String ColorName; //!< curent color Name etk::UString ColorName; //!< curent color Name
color_ts m_colorFG; color_ts m_colorFG;
color_ts m_colorBG; color_ts m_colorBG;

View File

@@ -33,7 +33,7 @@
ColorizeManager::ColorizeManager(void) ColorizeManager::ColorizeManager(void)
{ {
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgReloadColorFile); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiChangeColor);
} }
ColorizeManager::~ColorizeManager(void) ColorizeManager::~ColorizeManager(void)
@@ -61,9 +61,9 @@ bool ColorizeManager::OnEventAreaExternal(int32_t widgetID, const char * generat
case EDN_MSG__RELOAD_COLOR_FILE: case EDN_MSG__RELOAD_COLOR_FILE:
{ {
// Reaload File // Reaload File
// TODO : Check this : Pb in the recopy etk::String element // TODO : Check this : Pb in the recopy etk::UString element
etk::String plop = m_fileColor; etk::UString plop = m_fileColor;
LoadFile(plop.c_str()); LoadFile(plop);
} }
break; break;
} }
@@ -72,11 +72,13 @@ bool ColorizeManager::OnEventAreaExternal(int32_t widgetID, const char * generat
} }
void ColorizeManager::LoadFile(etk::String &xmlFilename) void ColorizeManager::LoadFile(etk::UString &xmlFilename)
{ {
LoadFile(xmlFilename.c_str()); // TODO : Remove this
LoadFile(xmlFilename.Utf8Data());
} }
// TODO : Remove this ...
void ColorizeManager::LoadFile(const char * xmlFilename) void ColorizeManager::LoadFile(const char * xmlFilename)
{ {
// Remove all old color : // Remove all old color :
@@ -115,11 +117,12 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
return; return;
} }
// allocate data // allocate data
char * fileBuffer = new char[fileSize]; char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) { if (NULL == fileBuffer) {
EWOL_ERROR("Error Memory allocation size=" << fileSize); EWOL_ERROR("Error Memory allocation size=" << fileSize);
return; return;
} }
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file : // load data from the file :
fileName.fRead(fileBuffer, 1, fileSize); fileName.fRead(fileBuffer, 1, fileSize);
// close the file: // close the file:
@@ -272,11 +275,12 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
//SendMessage(EDN_MSG__USER_DISPLAY_CHANGE); //SendMessage(EDN_MSG__USER_DISPLAY_CHANGE);
} }
// TODO : Remove this ...
Colorize *ColorizeManager::Get(const char *colorName) Colorize *ColorizeManager::Get(const char *colorName)
{ {
int32_t i; int32_t i;
for (i=0; i<listMyColor.Size(); i++) { for (i=0; i<listMyColor.Size(); i++) {
etk::String elementName = listMyColor[i]->GetName(); etk::UString elementName = listMyColor[i]->GetName();
if (elementName == colorName) { if (elementName == colorName) {
return listMyColor[i]; return listMyColor[i];
} }
@@ -286,9 +290,10 @@ Colorize *ColorizeManager::Get(const char *colorName)
return errorColor; return errorColor;
} }
Colorize *ColorizeManager::Get(etk::String &colorName) Colorize *ColorizeManager::Get(etk::UString &colorName)
{ {
return Get(colorName.c_str()); // TODO : Remove this
return Get(colorName.Utf8Data());
} }
color_ts & ColorizeManager::Get(basicColor_te myColor) color_ts & ColorizeManager::Get(basicColor_te myColor)
@@ -301,20 +306,23 @@ color_ts & ColorizeManager::Get(basicColor_te myColor)
} }
// TODO : Remove this ...
bool ColorizeManager::Exist(const char *colorName) bool ColorizeManager::Exist(const char *colorName)
{ {
int32_t i; int32_t i;
for (i=0; i<listMyColor.Size(); i++) { for (i=0; i<listMyColor.Size(); i++) {
etk::String elementName = listMyColor[i]->GetName(); etk::UString elementName = listMyColor[i]->GetName();
if (elementName == colorName) { if (elementName == colorName) {
return true; return true;
} }
} }
return false; return false;
} }
bool ColorizeManager::Exist(etk::String &colorName)
bool ColorizeManager::Exist(etk::UString &colorName)
{ {
return Exist(colorName.c_str()); // TODO : Remove this
return Exist(colorName.Utf8Data());
} }
void ColorizeManager::DisplayListOfColor(void) void ColorizeManager::DisplayListOfColor(void)
@@ -322,7 +330,7 @@ void ColorizeManager::DisplayListOfColor(void)
int32_t i; int32_t i;
EDN_INFO(PFX"List of ALL COLOR : "); EDN_INFO(PFX"List of ALL COLOR : ");
for (i=0; i<listMyColor.Size(); i++) { for (i=0; i<listMyColor.Size(); i++) {
//etk::String elementName = listMyColor[i]->GetName(); //etk::UString elementName = listMyColor[i]->GetName();
//EDN_INFO(i << " : \"" << elementName.c_str() << "\"" ); //EDN_INFO(i << " : \"" << elementName.c_str() << "\"" );
listMyColor[i]->Display(i); listMyColor[i]->Display(i);
} }

View File

@@ -61,17 +61,17 @@ class ColorizeManager: public etk::Singleton<ColorizeManager>, public ewol::Widg
public: public:
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y); bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
public: public:
void LoadFile(etk::String &xmlFilename); void LoadFile(etk::UString &xmlFilename);
void LoadFile(const char * xmlFilename); void LoadFile(const char * xmlFilename);
Colorize * Get(const char *colorName); Colorize * Get(const char *colorName);
Colorize * Get(etk::String &colorName); Colorize * Get(etk::UString &colorName);
color_ts & Get(basicColor_te myColor); color_ts & Get(basicColor_te myColor);
bool Exist(etk::String &colorName); bool Exist(etk::UString &colorName);
bool Exist(const char *colorName); bool Exist(const char *colorName);
void DisplayListOfColor(void); void DisplayListOfColor(void);
private: private:
etk::String m_fileColor; etk::UString m_fileColor;
etk::VectorType<Colorize*> listMyColor; //!< List of ALL Color etk::VectorType<Colorize*> listMyColor; //!< List of ALL Color
Colorize * errorColor; Colorize * errorColor;
color_ts basicColors[COLOR_NUMBER_MAX]; color_ts basicColors[COLOR_NUMBER_MAX];

View File

@@ -37,46 +37,13 @@
BufferView::BufferView(void) BufferView::BufferView(void)
{ {
m_shawableAreaX = 0;
m_shawableAreaY = 0;
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerNewFile);
// Init link with the buffer Manager // Init link with the buffer Manager
//m_bufferManager = BufferManager::Get(); m_bufferManager = BufferManager::getInstance();
//m_colorManager = ColorizeManager::Get(); m_colorManager = ColorizeManager::getInstance();
#if 0 SetCanHaveFocus(true);
m_widget = gtk_drawing_area_new(); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferListChange);
gtk_widget_set_size_request( m_widget, 250, 100); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferState);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferId);
gtk_widget_add_events( m_widget,
GDK_KEY_PRESS_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK);
# ifdef USE_GTK_VERSION_3_0
g_object_set(m_widget,"can-focus", TRUE, NULL);
# elif defined( USE_GTK_VERSION_2_0 )
GTK_WIDGET_SET_FLAGS(m_widget, GTK_CAN_FOCUS);
# endif
// Focus Event
g_signal_connect( G_OBJECT(m_widget), "focus_in_event", G_CALLBACK(CB_focusGet), this);
g_signal_connect( G_OBJECT(m_widget), "focus_out_event", G_CALLBACK(CB_focusLost), this);
// Keyboard Event
g_signal_connect_after( G_OBJECT(m_widget), "key_press_event", G_CALLBACK(CB_keyboardEvent), this);
g_signal_connect_after( G_OBJECT(m_widget), "key_release_event", G_CALLBACK(CB_keyboardEvent), this);
// Mouse Event
g_signal_connect( G_OBJECT(m_widget), "button_press_event", G_CALLBACK(CB_mouseButtonEvent), this);
g_signal_connect( G_OBJECT(m_widget), "button_release_event", G_CALLBACK(CB_mouseButtonEvent), this);
g_signal_connect( G_OBJECT(m_widget), "motion_notify_event", G_CALLBACK(CB_mouseMotionEvent), this);
// Display Event
g_signal_connect( G_OBJECT(m_widget), "realize", G_CALLBACK(CB_displayInit), this);
# ifdef USE_GTK_VERSION_3_0
g_signal_connect( G_OBJECT(m_widget), "draw", G_CALLBACK(CB_displayDraw), this);
# elif defined( USE_GTK_VERSION_2_0 )
g_signal_connect( G_OBJECT(m_widget), "expose_event", G_CALLBACK(CB_displayDraw), this);
# endif
#endif
m_selectedID = -1; m_selectedID = -1;
} }
@@ -93,25 +60,103 @@ GtkWidget * BufferView::GetMainWidget(void)
*/ */
bool BufferView::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y) bool BufferView::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y)
{ {
/* if (generateEventId == ednMsgBufferListChange) {
switch (id) MarkToReedraw();
{ }else if (generateEventId == ednMsgBufferId) {
case EDN_MSG__BUFFER_CHANGE_CURRENT: MarkToReedraw();
m_selectedID = dataID; }else if (generateEventId == ednMsgBufferState) {
case EDN_MSG__BUFFER_CHANGE_STATE: MarkToReedraw();
case EDN_MSG__BUFFER_CHANGE_NAME:
case EDN_MSG__BUFFER_CHANGE_MODIFY:
// change Title :
//gtk_widget_queue_draw(m_widget);
break;
case EDN_MSG__USER_DISPLAY_CHANGE:
// Redraw all the display ...
//gtk_widget_queue_draw(m_widget);
break;
} }
*/
return false; return false;
} }
color_ts BufferView::GetBasicBG(void)
{
return m_colorManager->Get(COLOR_LIST_BG_1);
}
uint32_t BufferView::GetNuberOfColomn(void)
{
return 1;
}
bool BufferView::GetTitle(int32_t colomn, etk::UString &myTitle, color_ts &fg, color_ts &bg)
{
myTitle = "Buffers : ";
return true;
}
uint32_t BufferView::GetNuberOfRaw(void)
{
if (NULL != m_bufferManager) {
return m_bufferManager->SizeOpen();
}
return 0;
}
bool BufferView::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg)
{
etk::File name;
bool isModify;
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
basicColor_te selectBG = COLOR_LIST_BG_1;
// transforme the ID in the real value ...
int32_t realID = m_bufferManager->WitchBuffer(raw+1);
if (m_bufferManager->Exist(realID)) {
isModify = m_bufferManager->Get(realID)->IsModify();
name = m_bufferManager->Get(realID)->GetFileName();
char *tmpModify = (char*)" ";
if (true == isModify) {
tmpModify = (char*)"M";
}
myTextToWrite = "[";
myTextToWrite += realID;
myTextToWrite += "](";
myTextToWrite += tmpModify;
myTextToWrite += ") ";
myTextToWrite += name.GetShortFilename();
if (true == isModify) {
selectFG = COLOR_LIST_TEXT_MODIFY;
} else {
selectFG = COLOR_LIST_TEXT_NORMAL;
}
if (raw%2==0) {
selectBG = COLOR_LIST_BG_1;
} else {
selectBG = COLOR_LIST_BG_2;
}
if (m_selectedID == raw) {
selectBG = COLOR_LIST_BG_SELECTED;
}
} else {
myTextToWrite = "ERROR";
}
fg = m_colorManager->Get(selectFG);
bg = m_colorManager->Get(selectBG);
return true;
}
bool BufferView::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y)
{
if (typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
EDN_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
int32_t selectBuf = m_bufferManager->WitchBuffer(raw+1);
if ( 0 <= selectBuf) {
m_selectedID = raw;
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, selectBuf);
}
}
MarkToReedraw();
return false;
}
#if 0 #if 0
gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data) gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data)
@@ -191,7 +236,6 @@ gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, g
monDrawer.Flush(); monDrawer.Flush();
lineID ++; lineID ++;
} }
} }
return TRUE; return TRUE;

View File

@@ -30,45 +30,30 @@
#include <BufferManager.h> #include <BufferManager.h>
#include <Display.h> #include <Display.h>
#include <MsgBroadcast.h> #include <MsgBroadcast.h>
#include <ewol/widget/List.h>
class BufferView : public ewol::Widget class BufferView : public ewol::List
{ {
public: public:
// Constructeur // Constructeur
BufferView(void); BufferView(void);
~BufferView(void); ~BufferView(void);
//GtkWidget *GetMainWidget(void);
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y); bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
/* protected:
// sur : GTK+ callback : // function call to display the list :
static gboolean CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data); virtual color_ts GetBasicBG(void);
static gboolean CB_displayInit( GtkWidget *widget, gpointer data); virtual uint32_t GetNuberOfColomn(void);
static gint CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data); virtual bool GetTitle(int32_t colomn, etk::UString &myTitle, color_ts &fg, color_ts &bg);
static gint CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data); virtual uint32_t GetNuberOfRaw(void);
static gint CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpointer data); virtual bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg);
static gint CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data); virtual bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y);
static gint CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data);
static void CB_EventOnBufferManager(gpointer data);
static void OnPopupEventShow(GtkWidget *menuitem, gpointer data);
static void OnPopupEventClose(GtkWidget *menuitem, gpointer data);
static void OnPopupEventSave(GtkWidget *menuitem, gpointer data);
static void OnPopupEventSaveAs(GtkWidget *menuitem, gpointer data);
*/
private: private:
//void ViewPopupMenu(GtkWidget *parrent, GdkEventButton *event, int32_t BufferID);
// main windows widget :
//GtkWidget * m_widget;
// r<>cup<75>ration des proprieter g<>n<EFBFBD>ral... // r<>cup<75>ration des proprieter g<>n<EFBFBD>ral...
BufferManager * m_bufferManager; BufferManager * m_bufferManager;
ColorizeManager * m_colorManager; ColorizeManager * m_colorManager;
int32_t m_shawableAreaX;
int32_t m_shawableAreaY;
int32_t m_selectedID; int32_t m_selectedID;
int32_t m_contectMenuSelectID;
}; };

View File

@@ -46,6 +46,12 @@
CodeView::CodeView(void) CodeView::CodeView(void)
{ {
m_label = "CodeView is disable ..."; m_label = "CodeView is disable ...";
m_fontNormal = -1;
m_fontBold = -1;
m_fontItalic = -1;
m_fontBoldItalic = -1;
m_fontSize = 15;
m_bufferID = -1; m_bufferID = -1;
m_buttunOneSelected = false; m_buttunOneSelected = false;
@@ -63,25 +69,7 @@ CodeView::CodeView(void)
m_textColorBg.blue = 0.0; m_textColorBg.blue = 0.0;
m_textColorBg.alpha = 0.25; m_textColorBg.alpha = 0.25;
SetCanHaveFocus(true); SetCanHaveFocus(true);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentChangeBufferId); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferId);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentSave);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentSaveAs);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentSelectAll);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentRemoveLine);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentUnSelect);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentCopy);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentCut);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentPaste);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentFindPrevious);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentFindNext);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentFindOldNext);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentReplace);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentReplaceAll);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentClose);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentUndo);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentRedo);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentGotoLine);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewCurrentSetCharset);
} }
CodeView::~CodeView(void) CodeView::~CodeView(void)
@@ -96,51 +84,54 @@ bool CodeView::CalculateMinSize(void)
return true; return true;
} }
void CodeView::CalculateMaxSize(void)
{
m_maxSize.x = 2048;
int32_t letterHeight = ewol::GetHeight(m_fontNormal);
m_maxSize.y = m_bufferManager->Get(m_bufferID)->GetNumberOfLine() * letterHeight;
}
void CodeView::OnRegenerateDisplay(void) void CodeView::OnRegenerateDisplay(void)
{ {
// create tmp object : if (true == NeedRedraw()) {
ewol::OObject2DTextColored* myOObjectText = new ewol::OObject2DTextColored("", -1); // For the scrooling windows
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored(); CalculateMaxSize();
// generate the objects : // create tmp object :
//m_bufferID = 0; ewol::OObject2DTextColored* myOObjectTextNormal = new ewol::OObject2DTextColored(m_fontNormal);
m_bufferManager->Get(m_bufferID)->Display(myOObjectText, myOObjectsColored, m_size.x, m_size.y); ewol::OObject2DTextColored* myOObjectTextBold = new ewol::OObject2DTextColored(m_fontBold);
ewol::OObject2DTextColored* myOObjectTextItalic = new ewol::OObject2DTextColored(m_fontItalic);
ewol::OObject2DTextColored* myOObjectTextBoldItalic = new ewol::OObject2DTextColored(m_fontBoldItalic);
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored();
// clean the object list ... // generate the objects :
ClearOObjectList(); //m_bufferID = 0;
// add generated element m_bufferManager->Get(m_bufferID)->Display(myOObjectTextNormal, myOObjectTextBold, myOObjectTextItalic, myOObjectTextBoldItalic, myOObjectsColored,
AddOObject(myOObjectsColored, "CodeViewBackground"); m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
AddOObject(myOObjectText, "CodeViewText");
}
bool CodeView::OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y) // clean the object list ...
{ ClearOObjectList();
/* // add generated element
//bool eventIsOK = false; AddOObject(myOObjectsColored, "CodeViewBackground");
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\""); AddOObject(myOObjectTextNormal, "CodeViewTextNormal");
if(ewolEventButtonPressed == generateEventId) { AddOObject(myOObjectTextBold, "CodeViewTextBold");
EWOL_INFO("BT pressed ... " << m_label); AddOObject(myOObjectTextItalic, "CodeViewTextItalic");
//eventIsOK = true; AddOObject(myOObjectTextBoldItalic, "CodeViewTextBoldItalic");
ewol::widgetManager::FocusKeep(this);
} else if(ewolEventButtonEnter == generateEventId) { // call the herited class...
OnRegenerateDisplay(); WidgetScrooled::OnRegenerateDisplay();
} }
//return eventIsOK;
*/
// in every case this not stop the propagation of the event
return false;
// if overwrited... you can ...
} }
bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]) bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData)
{ {
//EDN_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent); //EDN_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) { if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
m_bufferManager->Get(m_bufferID)->AddChar(UTF8_data); m_bufferManager->Get(m_bufferID)->AddChar(unicodeData);
OnRegenerateDisplay(); MarkToReedraw();
} }
return true; return true;
} }
@@ -150,7 +141,7 @@ bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveTy
{ {
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) { if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
m_bufferManager->Get(m_bufferID)->cursorMove(moveTypeEvent); m_bufferManager->Get(m_bufferID)->cursorMove(moveTypeEvent);
OnRegenerateDisplay(); MarkToReedraw();
} }
return true; return true;
} }
@@ -159,62 +150,44 @@ bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveTy
bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y) bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
{ {
if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, x, y)) {
ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widet ...
return true;
}
x -= m_origin.x; x -= m_origin.x;
y -= m_origin.y; y -= m_origin.y;
/*
etk::String type = (int)typeEvent;
switch (typeEvent)
{
case ewol::EVENT_INPUT_TYPE_DOWN:
type = "EVENT_INPUT_TYPE_DOWN";
break;
case ewol::EVENT_INPUT_TYPE_MOVE:
type = "EVENT_INPUT_TYPE_MOVE";
break;
case ewol::EVENT_INPUT_TYPE_SINGLE:
type = "EVENT_INPUT_TYPE_SINGLE";
break;
case ewol::EVENT_INPUT_TYPE_DOUBLE:
type = "EVENT_INPUT_TYPE_DOUBLE";
break;
case ewol::EVENT_INPUT_TYPE_TRIPLE:
type = "EVENT_INPUT_TYPE_TRIPLE";
break;
case ewol::EVENT_INPUT_TYPE_UP:
type = "EVENT_INPUT_TYPE_UP";
break;
case ewol::EVENT_INPUT_TYPE_ENTER:
type = "EVENT_INPUT_TYPE_ENTER";
break;
case ewol::EVENT_INPUT_TYPE_LEAVE:
type = "EVENT_INPUT_TYPE_LEAVE";
break;
default:
break;
};
EDN_DEBUG("Event : " << IdInput << " type : " << type << " position(" << x << "," << y << ")");
*/
if (1 == IdInput) { if (1 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { #ifndef __MODE__Touch
m_buttunOneSelected = true; if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
ewol::widgetManager::FocusKeep(this); m_buttunOneSelected = true;
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { ewol::widgetManager::FocusKeep(this);
m_buttunOneSelected = false; //EDN_INFO("mouse-event BT1 ==> One Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
m_bufferManager->Get(m_bufferID)->Copy(COPY_MIDDLE_BUTTON); m_bufferManager->Get(m_bufferID)->MouseEvent(x, y);
OnRegenerateDisplay(); MarkToReedraw();
} else if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
//EDN_INFO("mouse-event BT1 ==> One Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y); m_buttunOneSelected = false;
m_bufferManager->Get(m_bufferID)->MouseEvent(x, y); m_bufferManager->Get(m_bufferID)->Copy(COPY_MIDDLE_BUTTON);
OnRegenerateDisplay(); MarkToReedraw();
} else
#endif
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
#ifdef __MODE__Touch
ewol::widgetManager::FocusKeep(this);
//EDN_INFO("mouse-event BT1 ==> One Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
m_bufferManager->Get(m_bufferID)->MouseEvent(x, y);
MarkToReedraw();
#else
// nothing to do ...
#endif
} else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) { } else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) {
//EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y); //EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
m_bufferManager->Get(m_bufferID)->MouseEventDouble(); m_bufferManager->Get(m_bufferID)->MouseEventDouble();
OnRegenerateDisplay(); MarkToReedraw();
} else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) { } else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
//EDN_INFO("mouse-event BT1 ==> Triple Clicked"); //EDN_INFO("mouse-event BT1 ==> Triple Clicked");
m_bufferManager->Get(m_bufferID)->MouseEventTriple(); m_bufferManager->Get(m_bufferID)->MouseEventTriple();
OnRegenerateDisplay(); MarkToReedraw();
} else if (ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { } else if (ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
if (true == m_buttunOneSelected) { if (true == m_buttunOneSelected) {
int xxx, yyy; int xxx, yyy;
@@ -228,49 +201,51 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent,
} }
//EDN_INFO("mouse-motion BT1 %d, %d", xxx, yyy); //EDN_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
m_bufferManager->Get(m_bufferID)->MouseSelectFromCursorTo(xxx, yyy); m_bufferManager->Get(m_bufferID)->MouseSelectFromCursorTo(xxx, yyy);
OnRegenerateDisplay(); MarkToReedraw();
} }
} }
} else if (2 == IdInput) { } else if (2 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
m_bufferManager->Get(m_bufferID)->MouseEvent(x, y); m_bufferManager->Get(m_bufferID)->MouseEvent(x, y);
m_bufferManager->Get(m_bufferID)->Paste(COPY_MIDDLE_BUTTON); m_bufferManager->Get(m_bufferID)->Paste(COPY_MIDDLE_BUTTON);
OnRegenerateDisplay(); MarkToReedraw();
ewol::widgetManager::FocusKeep(this); ewol::widgetManager::FocusKeep(this);
} }
} }
if (4 == IdInput && ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent)
{
//EDN_INFO("mouse-event GDK_SCROLL_UP");
m_bufferManager->Get(m_bufferID)->ScrollUp();
OnRegenerateDisplay();
ewol::widgetManager::FocusKeep(this);
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent)
{
//EDN_INFO("mouse-event GDK_SCROLL_DOWN");
m_bufferManager->Get(m_bufferID)->ScrollDown();
OnRegenerateDisplay();
ewol::widgetManager::FocusKeep(this);
}
return true; return true;
} }
bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y) bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
{ {
EDN_DEBUG("Extern Event : " << widgetID << " type : " << generateEventId << " position(" << x << "," << y << ")"); EDN_DEBUG("Extern Event : " << widgetID << " type : " << generateEventId << " position(" << x << "," << y << ")");
if( ednMsgCodeViewCurrentChangeBufferId == generateEventId) {
if( ednMsgBufferId == generateEventId) {
int32_t bufferID = 0; int32_t bufferID = 0;
sscanf(eventExternId, "%d", &bufferID); sscanf(data, "%d", &bufferID);
EDN_INFO("Select a new Buffer ... " << bufferID);
m_bufferID = bufferID;
m_bufferManager->Get(m_bufferID)->ForceReDraw(true);
// TODO : need to update the state of the file and the filenames ...
}
// old
/*
else if( ednMsgCodeViewCurrentChangeBufferId == generateEventId) {
int32_t bufferID = 0;
sscanf(data, "%d", &bufferID);
EDN_INFO("Select a new Buffer ... " << bufferID); EDN_INFO("Select a new Buffer ... " << bufferID);
m_bufferID = bufferID; m_bufferID = bufferID;
m_bufferManager->Get(m_bufferID)->ForceReDraw(true); m_bufferManager->Get(m_bufferID)->ForceReDraw(true);
// request the display of the curent Editor // request the display of the curent Editor
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferChangeCurrent, (char*)eventExternId); ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferChangeCurrent, (char*)data);
} else if (ednMsgCodeViewCurrentSave == generateEventId) { }
*/
/*
else if (ednMsgCodeViewCurrentSave == generateEventId) {
} else if (ednMsgCodeViewCurrentSaveAs == generateEventId) { } else if (ednMsgCodeViewCurrentSaveAs == generateEventId) {
@@ -306,7 +281,9 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI
} else if (ednMsgCodeViewCurrentSetCharset == generateEventId) { } else if (ednMsgCodeViewCurrentSetCharset == generateEventId) {
} else { }
*/
else {
} }
@@ -355,21 +332,21 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI
break; break;
case EDN_MSG__CURRENT_FIND_PREVIOUS: case EDN_MSG__CURRENT_FIND_PREVIOUS:
{ {
etk::String myDataString; etk::UString myDataString;
SearchData::GetSearch(myDataString); SearchData::GetSearch(myDataString);
m_bufferManager->Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() ); m_bufferManager->Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
} }
break; break;
case EDN_MSG__CURRENT_FIND_NEXT: case EDN_MSG__CURRENT_FIND_NEXT:
{ {
etk::String myDataString; etk::UString myDataString;
SearchData::GetSearch(myDataString); SearchData::GetSearch(myDataString);
m_bufferManager->Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() ); m_bufferManager->Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
} }
break; break;
case EDN_MSG__CURRENT_REPLACE: case EDN_MSG__CURRENT_REPLACE:
{ {
etk::String myDataString; etk::UString myDataString;
SearchData::GetReplace(myDataString); SearchData::GetReplace(myDataString);
m_bufferManager->Get(m_bufferID)->Replace(myDataString); m_bufferManager->Get(m_bufferID)->Replace(myDataString);
} }
@@ -402,22 +379,58 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI
} }
*/ */
// Force redraw of the widget // Force redraw of the widget
OnRegenerateDisplay(); MarkToReedraw();
return true; return true;
} }
void CodeView::OnGetFocus(void) void CodeView::OnGetFocus(void)
{ {
//SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID); ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_bufferID);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferChangeCurrent); ewol::KeyboardShow(ewol::KEYBOARD_MODE_CODE);
EDN_INFO("Focus - In"); EDN_INFO("Focus - In");
} }
void CodeView::OnLostFocus(void) void CodeView::OnLostFocus(void)
{ {
ewol::KeyboardHide();
EDN_INFO("Focus - out"); EDN_INFO("Focus - out");
} }
void CodeView::SetFontSize(int32_t size)
{
m_fontSize = size;
}
void CodeView::SetFontNameNormal(etk::UString fontName)
{
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
if (fontID >= 0) {
m_fontNormal = fontID;
}
}
void CodeView::SetFontNameBold(etk::UString fontName)
{
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
if (fontID >= 0) {
m_fontBold = fontID;
}
}
void CodeView::SetFontNameItalic(etk::UString fontName)
{
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
if (fontID >= 0) {
m_fontItalic = fontID;
}
}
void CodeView::SetFontNameBoldItalic(etk::UString fontName)
{
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
if (fontID >= 0) {
m_fontBoldItalic = fontID;
}
}

View File

@@ -33,18 +33,18 @@
#include <MsgBroadcast.h> #include <MsgBroadcast.h>
#include <etk/Types.h> #include <etk/Types.h>
#include <ewol/Widget.h> #include <ewol/widget/WidgetScrolled.h>
class CodeView :public ewol::Widget class CodeView :public ewol::WidgetScrooled
{ {
public: public:
CodeView(void); CodeView(void);
virtual ~CodeView(void); virtual ~CodeView(void);
virtual bool CalculateMinSize(void); virtual bool CalculateMinSize(void);
private: private:
etk::String m_label; etk::UString m_label;
color_ts m_textColorFg; //!< Text color color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color color_ts m_textColorBg; //!< Background color
BufferManager * m_bufferManager; BufferManager * m_bufferManager;
ColorizeManager * m_colorManager; ColorizeManager * m_colorManager;
int32_t m_bufferID; int32_t m_bufferID;
@@ -54,50 +54,25 @@ class CodeView :public ewol::Widget
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y); bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
public: public:
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y); virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y); virtual bool OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData);
virtual bool OnEventKb(ewol::eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
virtual bool OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent); virtual bool OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent);
virtual void OnGetFocus(void); virtual void OnGetFocus(void);
virtual void OnLostFocus(void); virtual void OnLostFocus(void);
};
#if 0
class CodeView : public MsgBroadcast
{
public:
// Constructeur
CodeView(void);
~CodeView(void);
void OnMessage(int32_t id, int32_t dataID);
/*
GtkWidget *GetMainWidget(void);
// sur : GTK+ callback :
static gboolean CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data);
static gboolean CB_displayInit( GtkWidget *widget, gpointer data);
static gint CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data);
static gint CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data);
static gint CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpointer data);
static gint CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data);
static gint CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data);
static gint CB_mouseScrollEvent( GtkWidget *widget, GdkEventScroll *event, gpointer data);
*/
private: private:
// main windows widget : int32_t m_fontSize;
//GtkWidget * m_widget; int32_t m_fontNormal;
// récupération des proprieter général... int32_t m_fontBold;
BufferManager * m_bufferManager; int32_t m_fontItalic;
ColorizeManager * m_colorManager; int32_t m_fontBoldItalic;
int32_t m_shawableAreaX; public:
int32_t m_shawableAreaY; void SetFontSize(int32_t size);
int32_t m_bufferID; void SetFontNameNormal(etk::UString fontName);
bool m_buttunOneSelected; void SetFontNameBold(etk::UString fontName);
void SetFontNameItalic(etk::UString fontName);
void SetFontNameBoldItalic(etk::UString fontName);
private:
void CalculateMaxSize(void);
}; };
#endif #endif
#endif

View File

@@ -49,12 +49,14 @@
#define __class__ "MainWindows" #define __class__ "MainWindows"
const char * const ednEventNewFile = "edn-New-File";
const char * const ednEventOpenFile = "edn-Open-File"; const char * const ednEventOpenFile = "edn-Open-File";
const char * const ednEventCloseFile = "edn-Close-File"; const char * const ednEventCloseFile = "edn-Close-File";
const char * const ednEventSaveFile = "edn-Save-File"; const char * const ednEventSaveFile = "edn-Save-File";
const char * const ednEventSaveAsFile = "edn-SaveAs-File"; const char * const ednEventSaveAsFile = "edn-SaveAs-File";
const char * const ednEventPopUpClose = "edn-PopUp-Close"; const char * const ednEventPopUpClose = "edn-PopUp-Close";
const char * const ednEventPopUpFileSelected = "edn-PopUp-FileSelected"; const char * const ednEventPopUpFileSelected = "edn-PopUp-FileSelected";
const char * const ednEventPopUpFileSaveAs = "edn-PopUp-FileSaveAs";
MainWindows::MainWindows(void) MainWindows::MainWindows(void)
{ {
@@ -64,6 +66,7 @@ MainWindows::MainWindows(void)
ewol::Button * myButton = NULL; ewol::Button * myButton = NULL;
ewol::Label * myLabel = NULL; ewol::Label * myLabel = NULL;
CodeView * myCodeView = NULL; CodeView * myCodeView = NULL;
BufferView * myBufferView = NULL;
mySizerVert = new ewol::SizerVert(); mySizerVert = new ewol::SizerVert();
SetSubWidget(mySizerVert); SetSubWidget(mySizerVert);
@@ -71,6 +74,12 @@ MainWindows::MainWindows(void)
mySizerHori = new ewol::SizerHori(); mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori); mySizerVert->SubWidgetAdd(mySizerHori);
myButton = new ewol::Button("New");
mySizerHori->SubWidgetAdd(myButton);
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventNewFile) ) {
EDN_CRITICAL("link with an entry event");
}
myButton = new ewol::Button("Open"); myButton = new ewol::Button("Open");
mySizerHori->SubWidgetAdd(myButton); mySizerHori->SubWidgetAdd(myButton);
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventOpenFile) ) { if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventOpenFile) ) {
@@ -103,13 +112,34 @@ MainWindows::MainWindows(void)
mySizerHori = new ewol::SizerHori(); mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori); mySizerVert->SubWidgetAdd(mySizerHori);
myBufferView = new BufferView();
myBufferView->SetExpendX(false);
myBufferView->SetExpendY(true);
myBufferView->SetFillX(true);
myBufferView->SetFillY(true);
mySizerHori->SubWidgetAdd(myBufferView);
myCodeView = new CodeView(); myCodeView = new CodeView();
myCodeView->SetExpendX(true); myCodeView->SetExpendX(true);
myCodeView->SetExpendY(true); myCodeView->SetExpendY(true);
myCodeView->SetFillX(true); myCodeView->SetFillX(true);
myCodeView->SetFillY(true); myCodeView->SetFillY(true);
myCodeView->SetFontSize(11);
myCodeView->SetFontNameNormal( "freefont/FreeMono.ttf");
myCodeView->SetFontNameBold( "freefont/FreeMonoBold.ttf");
myCodeView->SetFontNameItalic( "freefont/FreeMonoOblique.ttf");
myCodeView->SetFontNameBoldItalic("freefont/FreeMonoBoldOblique.ttf");
/*
myCodeView->SetFontSize(11);
myCodeView->SetFontNameNormal( "ubuntu/UbuntuMono-R.ttf");
myCodeView->SetFontNameBold( "ubuntu/UbuntuMono-B.ttf");
myCodeView->SetFontNameItalic( "ubuntu/UbuntuMono-RI.ttf");
myCodeView->SetFontNameBoldItalic("ubuntu/UbuntuMono-BI.ttf");
*/
mySizerHori->SubWidgetAdd(myCodeView); mySizerHori->SubWidgetAdd(myCodeView);
// Generic event ...
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiSaveAs);
} }
@@ -122,12 +152,30 @@ MainWindows::~MainWindows(void)
bool MainWindows::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y) bool MainWindows::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
{ {
EDN_INFO("Receive Event from the main windows ... : widgetid=" << widgetID << "\"" << generateEventId << "\" ==> data=\"" << data << "\"" ); if (true == ewol::Windows::OnEventAreaExternal(widgetID, generateEventId, data, x, y) ) {
if (generateEventId == ednEventOpenFile) { return true;
}
//EDN_INFO("Receive Event from the main windows ... : widgetid=" << widgetID << "\"" << generateEventId << "\" ==> data=\"" << data << "\"" );
// newFile section ...
if (generateEventId == ednEventNewFile) {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiNew);
}
else if (generateEventId == ednEventCloseFile) {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiClose, "current");
}
else if (generateEventId == ednEventSaveFile) {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSave, "current");
}
else if (generateEventId == ednEventSaveAsFile) {
OnEventAreaExternal(GetWidgetId(), ednMsgGuiSaveAs, "current", x, y);
}
// Open file Section ...
else if (generateEventId == ednEventOpenFile) {
ewol::FileChooser* tmpWidget = new ewol::FileChooser(); ewol::FileChooser* tmpWidget = new ewol::FileChooser();
tmpWidget->SetTitle("Open Files ..."); tmpWidget->SetTitle("Open Files ...");
tmpWidget->SetValidateLabel("Open"); tmpWidget->SetValidateLabel("Open");
tmpWidget->SetFolder("/"); // TODO : Set the good folder ...
//tmpWidget->SetFolder("/");
PopUpWidgetPush(tmpWidget); PopUpWidgetPush(tmpWidget);
if (false == tmpWidget->ExternLinkOnEvent(ewolEventFileChooserCancel, GetWidgetId(), ednEventPopUpClose) ) { if (false == tmpWidget->ExternLinkOnEvent(ewolEventFileChooserCancel, GetWidgetId(), ednEventPopUpClose) ) {
EDN_CRITICAL("link with an entry event"); EDN_CRITICAL("link with an entry event");
@@ -136,6 +184,7 @@ bool MainWindows::OnEventAreaExternal(int32_t widgetID, const char * generateEve
EDN_CRITICAL("link with an entry event"); EDN_CRITICAL("link with an entry event");
} }
} else if (generateEventId == ednEventPopUpClose) { } else if (generateEventId == ednEventPopUpClose) {
// TODO : Set this in the upper windows ...
PopUpWidgetPop(); PopUpWidgetPop();
} else if (generateEventId == ednEventPopUpFileSelected) { } else if (generateEventId == ednEventPopUpFileSelected) {
// get widget: // get widget:
@@ -146,16 +195,65 @@ bool MainWindows::OnEventAreaExternal(int32_t widgetID, const char * generateEve
return false; return false;
} }
// get the filename : // get the filename :
etk::String tmpData = tmpWidget->GetCompleateFileName(); etk::UString tmpData = tmpWidget->GetCompleateFileName();
etk::File myfilename = tmpData;
BufferManager *myBufferManager = BufferManager::getInstance();
if (false == myBufferManager->Exist(myfilename) ) {
int32_t openID = myBufferManager->Open(myfilename);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgCodeViewCurrentChangeBufferId, openID);
} else {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgCodeViewCurrentChangeBufferId, myBufferManager->GetId(myfilename));
}
EDN_DEBUG("Request opening the file : " << tmpData); EDN_DEBUG("Request opening the file : " << tmpData);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgOpenFile, tmpData);
PopUpWidgetPop();
} else if (generateEventId == ednMsgGuiSaveAs) {
if (NULL == data) {
EDN_ERROR("Null data for Save As file ... ");
} else {
BufferManager * myMng = BufferManager::getInstance();
m_currentSavingAsIdBuffer = -1;
if (0 == strcmp(data , "current")) {
m_currentSavingAsIdBuffer = myMng->GetSelected();
} else {
sscanf(data, "%d", &m_currentSavingAsIdBuffer);
}
if (false == myMng->Exist(m_currentSavingAsIdBuffer)) {
EDN_ERROR("Request saveAs on non existant Buffer ID=" << m_currentSavingAsIdBuffer);
} else {
Buffer * myBuffer = myMng->Get(m_currentSavingAsIdBuffer);
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
tmpWidget->SetTitle("Save Files As...");
tmpWidget->SetValidateLabel("Save");
etk::UString folder = "/home/";
etk::UString fileName = "";
if (true == myBuffer->HaveName()) {
etk::File tmpName = myBuffer->GetFileName();
folder = tmpName.GetFolder();
fileName = tmpName.GetShortFilename();
}
tmpWidget->SetFolder(folder);
tmpWidget->SetFileName(fileName);
PopUpWidgetPush(tmpWidget);
if (false == tmpWidget->ExternLinkOnEvent(ewolEventFileChooserCancel, GetWidgetId(), ednEventPopUpClose) ) {
EDN_CRITICAL("link with an entry event");
}
if (false == tmpWidget->ExternLinkOnEvent(ewolEventFileChooserValidate, GetWidgetId(), ednEventPopUpFileSaveAs) ) {
EDN_CRITICAL("link with an entry event");
}
}
}
} else if (generateEventId == ednEventPopUpFileSaveAs) {
// get widget:
ewol::FileChooser * tmpWidget = (ewol::FileChooser*)ewol::widgetManager::Get(widgetID);
if (NULL == tmpWidget) {
EDN_ERROR("impossible to get pop_upWidget " << widgetID);
PopUpWidgetPop();
return false;
}
// get the filename :
etk::UString tmpData = tmpWidget->GetCompleateFileName();
EDN_DEBUG("Request Saving As file : " << tmpData);
BufferManager * myMng = BufferManager::getInstance();
myMng->Get(m_currentSavingAsIdBuffer)->SetFileName(tmpData);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSave, m_currentSavingAsIdBuffer);
//ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgOpenFile, tmpData);
PopUpWidgetPop(); PopUpWidgetPop();
} }
return true; return true;
@@ -180,7 +278,7 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
// select the program icone // select the program icone
GError *err = NULL; GError *err = NULL;
etk::String iconeFile; etk::UString iconeFile;
iconeFile = "/usr/share/edn/images/icone.png"; iconeFile = "/usr/share/edn/images/icone.png";
GdkPixbuf * icone = gdk_pixbuf_new_from_file(iconeFile.c_str(), &err); GdkPixbuf * icone = gdk_pixbuf_new_from_file(iconeFile.c_str(), &err);
@@ -205,7 +303,7 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
GtkWidget *hboxMenu = gtk_hbox_new (FALSE, 0); GtkWidget *hboxMenu = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start( GTK_BOX (vbox), hboxMenu, FALSE, FALSE, 0); gtk_box_pack_start( GTK_BOX (vbox), hboxMenu, FALSE, FALSE, 0);
// Add Exit boutton // Add Exit boutton
etk::String ExitIconeFile; etk::UString ExitIconeFile;
ExitIconeFile = "/usr/share/edn/images/delete-24px.png"; ExitIconeFile = "/usr/share/edn/images/delete-24px.png";
// TODO : find a good way to change the size of an image // TODO : find a good way to change the size of an image
GtkWidget *myImageQuit = gtk_image_new_from_file(ExitIconeFile.c_str()); GtkWidget *myImageQuit = gtk_image_new_from_file(ExitIconeFile.c_str());
@@ -259,7 +357,7 @@ MainWindows::~MainWindows(void)
void MainWindows::SetTitle(etk::File &fileName, bool isModify) void MainWindows::SetTitle(etk::File &fileName, bool isModify)
{ {
etk::String tmp = ""; etk::UString tmp = "";
if (fileName.GetShortFilename() != "") { if (fileName.GetShortFilename() != "") {
tmp += fileName.GetShortFilename(); tmp += fileName.GetShortFilename();
tmp += " - "; tmp += " - ";
@@ -283,7 +381,7 @@ void MainWindows::SetTitle(etk::File &fileName, bool isModify)
void MainWindows::SetNoTitle(void) void MainWindows::SetNoTitle(void)
{ {
etk::String tmp = "Edn"; etk::UString tmp = "Edn";
//gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str()); //gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
//gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str()); //gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str());
} }

View File

@@ -70,6 +70,8 @@ class MainWindows: public etk::Singleton<MainWindows>, public MsgBroadcast
#endif #endif
class MainWindows : public ewol::Windows class MainWindows : public ewol::Windows
{ {
private:
int32_t m_currentSavingAsIdBuffer;
public: public:
// Constructeur // Constructeur
MainWindows(void); MainWindows(void);

View File

@@ -79,7 +79,7 @@ static void CB_menuInternal(GtkMenuItem *menu_item, gpointer data)
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_UTF8); GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_UTF8);
} else if (myPointer == MSG_LoadColorWhite) { } else if (myPointer == MSG_LoadColorWhite) {
ColorizeManager * myColorSystem = ColorizeManager::getInstance(); ColorizeManager * myColorSystem = ColorizeManager::getInstance();
etk::String homedir; etk::UString homedir;
# ifdef NDEBUG # ifdef NDEBUG
homedir = "/usr/share/edn/"; homedir = "/usr/share/edn/";
# else # else
@@ -89,7 +89,7 @@ static void CB_menuInternal(GtkMenuItem *menu_item, gpointer data)
myColorSystem->LoadFile(homedir); myColorSystem->LoadFile(homedir);
} else if (myPointer == MSG_LoadColorBlack) { } else if (myPointer == MSG_LoadColorBlack) {
ColorizeManager * myColorSystem = ColorizeManager::getInstance(); ColorizeManager * myColorSystem = ColorizeManager::getInstance();
etk::String homedir; etk::UString homedir;
# ifdef NDEBUG # ifdef NDEBUG
homedir = "/usr/share/edn/"; homedir = "/usr/share/edn/";
# else # else

View File

@@ -195,7 +195,7 @@ void Search::Display(GtkWindow *parent)
gtk_widget_set_sensitive(m_CkMatchCase, true); gtk_widget_set_sensitive(m_CkMatchCase, true);
} }
// Remove data form the search // Remove data form the search
etk::String myDataString = ""; etk::UString myDataString = "";
SearchData::SetSearch(myDataString); SearchData::SetSearch(myDataString);
gtk_entry_set_text(GTK_ENTRY(m_searchEntry), myDataString.c_str()); gtk_entry_set_text(GTK_ENTRY(m_searchEntry), myDataString.c_str());
if (0 == strlen(myDataString.c_str())) { if (0 == strlen(myDataString.c_str())) {
@@ -321,7 +321,7 @@ void Search::OnEntrySearchChange(GtkWidget *widget, gpointer data)
// update research data // update research data
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget)); const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
if (NULL != testData) { if (NULL != testData) {
etk::String myDataString = testData; etk::UString myDataString = testData;
SearchData::SetSearch(myDataString); SearchData::SetSearch(myDataString);
if (0 == strlen(testData)) { if (0 == strlen(testData)) {
self->m_haveSearchData = false; self->m_haveSearchData = false;
@@ -347,7 +347,7 @@ void Search::OnEntryReplaceChange(GtkWidget *widget, gpointer data)
// update replace data // update replace data
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget)); const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
if (NULL != testData) { if (NULL != testData) {
etk::String myDataString = testData; etk::UString myDataString = testData;
SearchData::SetReplace(myDataString); SearchData::SetReplace(myDataString);
if (0 == strlen(testData)) { if (0 == strlen(testData)) {
self->m_haveReplaceData = false; self->m_haveReplaceData = false;

View File

@@ -31,13 +31,13 @@
#define __class__ "SearchData" #define __class__ "SearchData"
static etk::String m_findRequest = ""; static etk::UString m_findRequest = "";
void SearchData::SetSearch(etk::String &myData) void SearchData::SetSearch(etk::UString &myData)
{ {
m_findRequest = myData; m_findRequest = myData;
} }
void SearchData::GetSearch(etk::String &myData) void SearchData::GetSearch(etk::UString &myData)
{ {
myData = m_findRequest; myData = m_findRequest;
} }
@@ -49,12 +49,12 @@ bool SearchData::IsSearchEmpty(void)
return true; return true;
} }
static etk::String m_replaceRequest = ""; static etk::UString m_replaceRequest = "";
void SearchData::SetReplace(etk::String &myData) void SearchData::SetReplace(etk::UString &myData)
{ {
m_replaceRequest = myData; m_replaceRequest = myData;
} }
void SearchData::GetReplace(etk::String &myData) void SearchData::GetReplace(etk::UString &myData)
{ {
myData = m_replaceRequest; myData = m_replaceRequest;
} }

View File

@@ -30,11 +30,11 @@
namespace SearchData namespace SearchData
{ {
void SetSearch(etk::String &myData); void SetSearch(etk::UString &myData);
void GetSearch(etk::String &myData); void GetSearch(etk::UString &myData);
bool IsSearchEmpty(void); bool IsSearchEmpty(void);
void SetReplace(etk::String &myData); void SetReplace(etk::UString &myData);
void GetReplace(etk::String &myData); void GetReplace(etk::UString &myData);
bool IsReplaceEmpty(void); bool IsReplaceEmpty(void);
void SetCase(bool value); void SetCase(bool value);
bool GetCase(void); bool GetCase(void);

View File

@@ -131,7 +131,7 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
idSelected = dataID; idSelected = dataID;
} }
Buffer *myBuffer = BufferManager::getInstance()->Get(idSelected); Buffer *myBuffer = BufferManager::getInstance()->Get(idSelected);
etk::String tmpString = "Save as file : "; etk::UString tmpString = "Save as file : ";
tmpString += myBuffer->GetFileName().GetShortFilename().c_str(); tmpString += myBuffer->GetFileName().GetShortFilename().c_str();
GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL, GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL,
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_FILE_CHOOSER_ACTION_SAVE,
@@ -142,7 +142,7 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
gtk_window_set_skip_pager_hint(GTK_WINDOW(dialog), TRUE); gtk_window_set_skip_pager_hint(GTK_WINDOW(dialog), TRUE);
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{ {
etk::String myfilename; etk::UString myfilename;
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog)); myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
myBuffer->SetFileName(myfilename); myBuffer->SetFileName(myfilename);

View File

@@ -45,7 +45,7 @@ void Highlight::ParseRules(TiXmlNode *child, etk::VectorType<HighlightPattern*>
Highlight::Highlight(etk::String &xmlFilename) Highlight::Highlight(etk::UString &xmlFilename)
{ {
TiXmlDocument XmlDocument; TiXmlDocument XmlDocument;
@@ -64,11 +64,12 @@ Highlight::Highlight(etk::String &xmlFilename)
return; return;
} }
// allocate data // allocate data
char * fileBuffer = new char[fileSize]; char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) { if (NULL == fileBuffer) {
EWOL_ERROR("Error Memory allocation size=" << fileSize); EWOL_ERROR("Error Memory allocation size=" << fileSize);
return; return;
} }
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file : // load data from the file :
fileName.fRead(fileBuffer, 1, fileSize); fileName.fRead(fileBuffer, 1, fileSize);
// close the file: // close the file:
@@ -98,7 +99,7 @@ Highlight::Highlight(etk::String &xmlFilename)
const char *myData = child->ToElement()->GetText(); const char *myData = child->ToElement()->GetText();
if (NULL != myData) { if (NULL != myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData); //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
etk::String * myEdnData = new etk::String(myData); etk::UString * myEdnData = new etk::UString(myData);
m_listExtentions.PushBack(myEdnData); m_listExtentions.PushBack(myEdnData);
} }
} else if (!strcmp(child->Value(), "pass1")) { } else if (!strcmp(child->Value(), "pass1")) {
@@ -179,7 +180,7 @@ void Highlight::ReloadColor(void)
} }
} }
bool Highlight::HasExtention(etk::String &ext) bool Highlight::HasExtention(etk::UString &ext)
{ {
int32_t i; int32_t i;
for (i=0; i<m_listExtentions.Size(); i++) { for (i=0; i<m_listExtentions.Size(); i++) {
@@ -193,7 +194,7 @@ bool Highlight::HasExtention(etk::String &ext)
bool Highlight::FileNameCompatible(etk::File &fileName) bool Highlight::FileNameCompatible(etk::File &fileName)
{ {
int32_t i; int32_t i;
etk::String extention; etk::UString extention;
if (true == fileName.HasExtention() ) { if (true == fileName.HasExtention() ) {
extention = "*."; extention = "*.";
extention += fileName.GetExtention(); extention += fileName.GetExtention();

View File

@@ -50,9 +50,9 @@ extern "C" {
class Highlight { class Highlight {
public: public:
// Constructeur // Constructeur
Highlight(etk::String &xmlFilename); Highlight(etk::UString &xmlFilename);
~Highlight(void); ~Highlight(void);
bool HasExtention(etk::String &ext); bool HasExtention(etk::UString &ext);
bool FileNameCompatible(etk::File &fileName); bool FileNameCompatible(etk::File &fileName);
void Display(void); void Display(void);
void ReloadColor(void); void ReloadColor(void);
@@ -67,8 +67,8 @@ class Highlight {
EdnVectorBuf &buffer); EdnVectorBuf &buffer);
private: private:
void ParseRules(TiXmlNode *child, etk::VectorType<HighlightPattern*> &mListPatern, int32_t level); void ParseRules(TiXmlNode *child, etk::VectorType<HighlightPattern*> &mListPatern, int32_t level);
etk::String m_styleName; //!< curent style name (like "c++" or "c" or "script Bash") etk::UString m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
etk::VectorType<etk::String*> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" etk::VectorType<etk::UString*> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
etk::VectorType<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer) etk::VectorType<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer)
etk::VectorType<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) ) etk::VectorType<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) )
}; };

View File

@@ -33,7 +33,7 @@
HighlightManager::HighlightManager(void) HighlightManager::HighlightManager(void)
{ {
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgColorHasChange); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferColor);
} }
HighlightManager::~HighlightManager(void) HighlightManager::~HighlightManager(void)
@@ -91,7 +91,7 @@ bool HighlightManager::Exist(etk::File &fileName)
void HighlightManager::loadLanguages(void) void HighlightManager::loadLanguages(void)
{ {
etk::String xmlFilename = "lang_c.xml"; etk::UString xmlFilename = "lang_c.xml";
Highlight *myHightline = new Highlight(xmlFilename); Highlight *myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline); listHighlight.PushBack(myHightline);

View File

@@ -29,6 +29,7 @@
class HighlightManager; class HighlightManager;
#include <etk/Singleton.h> #include <etk/Singleton.h>
#include <etk/UString.h>
#include <MsgBroadcast.h> #include <MsgBroadcast.h>
#include <Highlight.h> #include <Highlight.h>
#include <ewol/Widget.h> #include <ewol/Widget.h>

View File

@@ -50,12 +50,12 @@ HighlightPattern::~HighlightPattern(void)
delete(m_regExpStop); delete(m_regExpStop);
} }
void HighlightPattern::SetPaternStart(etk::String &regExp) void HighlightPattern::SetPaternStart(etk::UString &regExp)
{ {
m_regExpStart->SetRegExp(regExp); m_regExpStart->SetRegExp(regExp);
} }
void HighlightPattern::SetPaternStop(etk::String &regExp) void HighlightPattern::SetPaternStop(etk::UString &regExp)
{ {
if (regExp.Size() != 0) { if (regExp.Size() != 0) {
m_regExpStop->SetRegExp(regExp); m_regExpStop->SetRegExp(regExp);
@@ -65,17 +65,17 @@ void HighlightPattern::SetPaternStop(etk::String &regExp)
} }
} }
void HighlightPattern::SetEscapeChar(etk::String &EscapeChar) void HighlightPattern::SetEscapeChar(etk::UString &EscapeChar)
{ {
if (EscapeChar.Size()>0) { if (EscapeChar.Size()>0) {
m_escapeChar = EscapeChar.c_str()[0]; m_escapeChar = EscapeChar[0];
} else { } else {
m_escapeChar = 0; m_escapeChar = 0;
} }
} }
void HighlightPattern::SetColor(etk::String &colorName) void HighlightPattern::SetColor(etk::UString &colorName)
{ {
m_colorName = colorName; m_colorName = colorName;
ColorizeManager *myColorManager = ColorizeManager::getInstance(); ColorizeManager *myColorManager = ColorizeManager::getInstance();
@@ -140,7 +140,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
// process attribute // process attribute
const char *highLightName = child->ToElement()->Attribute("name"); const char *highLightName = child->ToElement()->Attribute("name");
etk::String myEdnDataTmp = "???"; etk::UString myEdnDataTmp = "???";
if (NULL != highLightName) { if (NULL != highLightName) {
myEdnDataTmp = highLightName; myEdnDataTmp = highLightName;
} }
@@ -152,7 +152,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
const char *myData = xChild->GetText(); const char *myData = xChild->GetText();
if (myData) { if (myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::String myEdnData = myData; etk::UString myEdnData = myData;
SetColor(myEdnData); SetColor(myEdnData);
} }
} }
@@ -161,7 +161,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
const char *myData = xChild->GetText(); const char *myData = xChild->GetText();
if (myData) { if (myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::String myEdnData = myData; etk::UString myEdnData = myData;
SetPaternStart(myEdnData); SetPaternStart(myEdnData);
} }
} }
@@ -170,7 +170,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
const char *myData = xChild->GetText(); const char *myData = xChild->GetText();
if (myData) { if (myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::String myEdnData = myData; etk::UString myEdnData = myData;
SetPaternStop(myEdnData); SetPaternStop(myEdnData);
} }
} }
@@ -179,7 +179,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
const char *myData = xChild->GetText(); const char *myData = xChild->GetText();
if (myData) { if (myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::String myEdnData = myData; etk::UString myEdnData = myData;
SetEscapeChar(myEdnData); SetEscapeChar(myEdnData);
} }
} }

View File

@@ -51,13 +51,13 @@ class HighlightPattern {
HighlightPattern(void); HighlightPattern(void);
~HighlightPattern(void); ~HighlightPattern(void);
void SetName(etk::String &name) { m_paternName = name;}; void SetName(etk::UString &name) { m_paternName = name;};
etk::String GetName(void) { return m_paternName;}; etk::UString GetName(void) { return m_paternName;};
void SetPaternStart(etk::String &regExp); void SetPaternStart(etk::UString &regExp);
void SetPaternStop(etk::String &regExp); void SetPaternStop(etk::UString &regExp);
void SetColor(etk::String &colorName); void SetColor(etk::UString &colorName);
void SetEscapeChar(etk::String &EscapeChar); void SetEscapeChar(etk::UString &EscapeChar);
void SetMultiline(bool enable) { m_multiline = enable; }; void SetMultiline(bool enable) { m_multiline = enable; };
void SetLevel(int32_t newLevel) { m_level = newLevel; }; void SetLevel(int32_t newLevel) { m_level = newLevel; };
@@ -73,14 +73,14 @@ class HighlightPattern {
private: private:
int32_t m_level; //!< Level of the pattern ==> this is to overwrite next pattern when we create an higher .... int32_t m_level; //!< Level of the pattern ==> this is to overwrite next pattern when we create an higher ....
etk::String m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
etk::String m_colorName; //!< Current color name etk::UString m_colorName; //!< Current color name
Colorize * m_color; //!< Link to the color manager Colorize * m_color; //!< Link to the color manager
etk::RegExp<EdnVectorBuf> * m_regExpStart; //!< Start of Regular expression etk::RegExp<EdnVectorBuf> * m_regExpStart; //!< Start of Regular expression
etk::RegExp<EdnVectorBuf> * m_regExpStop; //!< Stop of Regular Expression etk::RegExp<EdnVectorBuf> * m_regExpStop; //!< Stop of Regular Expression
bool m_haveStopPatern; //!< Stop patern presence bool m_haveStopPatern; //!< Stop patern presence
bool m_multiline; //!< The patern is multiline bool m_multiline; //!< The patern is multiline
char m_escapeChar; //!< Escape char to prevent exeit of patern .... uniChar_t m_escapeChar; //!< Escape char to prevent exeit of patern ....
etk::VectorType<HighlightPattern *> m_subPatern; //!< Under patern of this one etk::VectorType<HighlightPattern *> m_subPatern; //!< Under patern of this one
// etk::VectorType<HighlightPattern *> m_subColor; //!< Under Color in the start RegExp ... // etk::VectorType<HighlightPattern *> m_subColor; //!< Under Color in the start RegExp ...
}; };

View File

@@ -49,10 +49,7 @@ CTagsManager::CTagsManager(void)
m_tagFolderBase = ""; m_tagFolderBase = "";
m_ctagFile = NULL; m_ctagFile = NULL;
m_historyPos = 0; m_historyPos = 0;
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCtagsOpen); ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiCtags);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCtagsReload);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCtagsJumpCurrentSelection);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCtagsJumpBack);
} }
/** /**
@@ -75,7 +72,7 @@ CTagsManager::~CTagsManager(void)
*/ */
} }
etk::String CTagsManager::GetFolder(etk::String &inputString) etk::UString CTagsManager::GetFolder(etk::UString &inputString)
{ {
/* /*
char tmpVal[4096]; char tmpVal[4096];
@@ -85,7 +82,7 @@ etk::String CTagsManager::GetFolder(etk::String &inputString)
if (NULL == ptr) { if (NULL == ptr) {
ptr = strrchr(tmpVal, '\\'); ptr = strrchr(tmpVal, '\\');
} }
etk::String out = "./"; etk::UString out = "./";
if (NULL != ptr) { if (NULL != ptr) {
*ptr = '\0'; *ptr = '\0';
out = tmpVal; out = tmpVal;
@@ -93,7 +90,7 @@ etk::String CTagsManager::GetFolder(etk::String &inputString)
} }
return out; return out;
*/ */
etk::String out = "./"; etk::UString out = "./";
return out; return out;
} }
@@ -363,7 +360,7 @@ void CTagsManager::JumpTo(void)
// For all tags : Save in an internal Structure : // For all tags : Save in an internal Structure :
do { do {
etk::String destinationFilename = m_tagFolderBase; etk::UString destinationFilename = m_tagFolderBase;
destinationFilename += entry.file; destinationFilename += entry.file;
etk::File myfile = destinationFilename; etk::File myfile = destinationFilename;
TagListFind_ts myStruct; TagListFind_ts myStruct;

View File

@@ -58,9 +58,9 @@ class CTagsManager: public etk::Singleton<CTagsManager>, public ewol::Widget
int32_t MultipleJump(void); int32_t MultipleJump(void);
void JumpTo(void); void JumpTo(void);
void PrintTag(const tagEntry *entry, bool small); void PrintTag(const tagEntry *entry, bool small);
etk::String GetFolder(etk::String &inputString); etk::UString GetFolder(etk::UString &inputString);
etk::String m_tagFolderBase; etk::UString m_tagFolderBase;
etk::String m_tagFilename; etk::UString m_tagFilename;
tagFile * m_ctagFile; tagFile * m_ctagFile;
// history system // history system
void AddToHistory(int32_t bufferID); void AddToHistory(int32_t bufferID);

View File

@@ -31,12 +31,12 @@
#include <ColorizeManager.h> #include <ColorizeManager.h>
#include <HighlightManager.h> #include <HighlightManager.h>
#include <ClipBoard.h> #include <ClipBoard.h>
#include <etk/String.h>
#include <WindowsManager.h> #include <WindowsManager.h>
#include <Search.h> #include <Search.h>
#include <unistd.h> #include <unistd.h>
#include <readtags.h> #include <readtags.h>
#include <CTagsManager.h> #include <CTagsManager.h>
#include <etk/UString.h>
#include <ewol/WidgetMessageMultiCast.h> #include <ewol/WidgetMessageMultiCast.h>
MainWindows * basicWindows = NULL; MainWindows * basicWindows = NULL;
@@ -47,12 +47,28 @@ MainWindows * basicWindows = NULL;
*/ */
void APP_Init(void) void APP_Init(void)
{ {
EDN_INFO("Start Edn"); etk::UString myTmpString("test <20>l<EFBFBD>mentaire...");
EDN_CRITICAL("essay de UString : " << myTmpString);
myTmpString = "TT...SDFSDFSDFQAEZqsdgfqsdfqskdj";
EDN_CRITICAL("essay de UString : " << myTmpString);
myTmpString += "19";
EDN_CRITICAL("essay de UString : " << myTmpString);
EDN_INFO("==> Init Edn (START)");
ewol::ChangeSize(800, 600); ewol::ChangeSize(800, 600);
// set the default Path of the application : // set the default Path of the application :
#ifdef PLATFORM_Linux #ifdef PLATFORM_Linux
etk::String homedir; etk::UString homedir;
#ifdef NDEBUG #ifdef NDEBUG
homedir = "/usr/share/"PROJECT_NAME"/"; homedir = "/usr/share/"PROJECT_NAME"/";
#else #else
@@ -65,7 +81,8 @@ void APP_Init(void)
homedir += "/assets/"; homedir += "/assets/";
} }
#endif #endif
SetBaseFolderData(homedir.c_str()); // TODO : Remove the Utf8Data
SetBaseFolderData(homedir.Utf8Data());
SetBaseFolderDataUser("~/."PROJECT_NAME"/"); SetBaseFolderDataUser("~/."PROJECT_NAME"/");
SetBaseFolderCache("/tmp/"PROJECT_NAME"/"); SetBaseFolderCache("/tmp/"PROJECT_NAME"/");
#endif #endif
@@ -87,13 +104,13 @@ void APP_Init(void)
// init ALL Singleton : // init ALL Singleton :
(void)WindowsManager::getInstance(); (void)WindowsManager::getInstance();
(void)CTagsManager::getInstance(); (void)CTagsManager::getInstance();
BufferManager *myBufferManager = BufferManager::getInstance(); (void)BufferManager::getInstance();
// set color and other trucs... // set color and other trucs...
ColorizeManager *myColorManager = NULL; ColorizeManager *myColorManager = NULL;
myColorManager = ColorizeManager::getInstance(); myColorManager = ColorizeManager::getInstance();
etk::String homedir = "color_white.xml"; etk::UString homedir = "color_white.xml";
myColorManager->LoadFile( homedir.c_str() ); myColorManager->LoadFile( homedir.Utf8Data() );
myColorManager->DisplayListOfColor(); myColorManager->DisplayListOfColor();
HighlightManager *myHighlightManager = NULL; HighlightManager *myHighlightManager = NULL;
@@ -124,15 +141,10 @@ void APP_Init(void)
for( int32_t iii=0 ; iii<ewol::CmdLineNb(); iii++) { for( int32_t iii=0 ; iii<ewol::CmdLineNb(); iii++) {
EDN_INFO("need load file : \"" << ewol::CmdLineGet(iii) << "\"" ); EDN_INFO("need load file : \"" << ewol::CmdLineGet(iii) << "\"" );
etk::String tmpString = ewol::CmdLineGet(iii); etk::UString tmpppp = ewol::CmdLineGet(iii);
etk::File myfile(tmpString, etk::FILE_TYPE_DIRECT); ewol::widgetMessageMultiCast::Send(-1, ednMsgOpenFile, tmpppp);
if (false == myBufferManager->Exist(myfile) ) {
int32_t idBuffOpened = myBufferManager->Open(myfile);
if (1==iii) {
ewol::widgetMessageMultiCast::Send(-1, ednMsgCodeViewCurrentChangeBufferId, idBuffOpened);
}
}
} }
EDN_INFO("==> Init Edn (END)");
} }
@@ -141,6 +153,7 @@ void APP_Init(void)
*/ */
void APP_UnInit(void) void APP_UnInit(void)
{ {
EDN_INFO("==> Un-Init Edn (START)");
// Remove windows : // Remove windows :
ewol::DisplayWindows(NULL); ewol::DisplayWindows(NULL);
@@ -157,6 +170,7 @@ void APP_UnInit(void)
if (NULL != basicWindows) { if (NULL != basicWindows) {
delete(basicWindows); delete(basicWindows);
} }
EDN_INFO("Stop Edn"); basicWindows = NULL;
EDN_INFO("==> Un-Init Edn (END)");
} }

View File

@@ -78,7 +78,6 @@ EdnBuf::EdnBuf(void)
// basicly no HL system ... // basicly no HL system ...
m_Highlight = NULL; m_Highlight = NULL;
m_nbLine = 1; m_nbLine = 1;
m_HLDataSequence = 0;
} }
/** /**

View File

@@ -68,7 +68,6 @@ typedef enum{
typedef struct { typedef struct {
etk::VectorType<colorInformation_ts> HLData; etk::VectorType<colorInformation_ts> HLData;
int32_t idSequence;
int32_t posHLPass1; int32_t posHLPass1;
int32_t posHLPass2; int32_t posHLPass2;
}displayHLData_ts; }displayHLData_ts;
@@ -159,7 +158,6 @@ class EdnBuf {
private: private:
Highlight * m_Highlight; //!< internal link with the Highlight system Highlight * m_Highlight; //!< internal link with the Highlight system
etk::VectorType<colorInformation_ts> m_HLDataPass1; //!< colorisation position in the current buffer pass 1 etk::VectorType<colorInformation_ts> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
int32_t m_HLDataSequence; //!< position of the start of line requested by the screen viewer
void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded); void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded);
void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0); void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0);
void CleanHighLight(void); void CleanHighLight(void);

View File

@@ -46,9 +46,6 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
//GTimeVal timeStart; //GTimeVal timeStart;
//g_get_current_time(&timeStart); //g_get_current_time(&timeStart);
// remove display HL...
m_HLDataSequence++;
// prevent ERROR... // prevent ERROR...
if (NULL == m_Highlight) { if (NULL == m_Highlight) {
return; return;
@@ -64,7 +61,7 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
int32_t i; int32_t i;
/* /*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) { for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::String ploppp; etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) { if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName(); ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
} }
@@ -108,7 +105,7 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
//EDN_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1); //EDN_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1);
/* /*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) { for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::String ploppp; etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) { if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName(); ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
} }
@@ -151,7 +148,7 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
} }
/* /*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) { for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::String ploppp; etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) { if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName(); ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
} }
@@ -287,7 +284,6 @@ colorInformation_ts *EdnBuf::GetElementColorAtPosition(int32_t pos, int32_t &sta
} }
void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines) void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines)
{ {
MData.posHLPass1 = 0; MData.posHLPass1 = 0;
@@ -295,65 +291,62 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
if (NULL == m_Highlight) { if (NULL == m_Highlight) {
return; return;
} }
if (MData.idSequence != m_HLDataSequence) { //GTimeVal timeStart;
//GTimeVal timeStart; //g_get_current_time(&timeStart);
//g_get_current_time(&timeStart); HLStart = StartOfLine(HLStart);
MData.idSequence = m_HLDataSequence; MData.HLData.Clear();
HLStart = StartOfLine(HLStart); int32_t HLStop = CountForwardNLines(HLStart, nbLines);
MData.HLData.Clear(); int32_t startId, stopId;
int32_t HLStop = CountForwardNLines(HLStart, nbLines); // find element previous
int32_t startId, stopId; FindMainHighLightPosition(HLStart, HLStop, startId, stopId, true);
// find element previous
FindMainHighLightPosition(HLStart, HLStop, startId, stopId, true);
int32_t k; int32_t k;
//EDN_DEBUG("List of section between : "<< startId << " & " << stopId); //EDN_DEBUG("List of section between : "<< startId << " & " << stopId);
int32_t endSearch = stopId+1; int32_t endSearch = stopId+1;
if (-1 == stopId) { if (-1 == stopId) {
endSearch = m_HLDataPass1.Size(); endSearch = m_HLDataPass1.Size();
} }
for (k=edn_max(startId, 0); k<endSearch; k++) { for (k=edn_max(startId, 0); k<endSearch; k++) {
// empty section : // empty section :
if (0==k) { if (0==k) {
if (HLStart < m_HLDataPass1[k].beginStart) { if (HLStart < m_HLDataPass1[k].beginStart) {
//EDN_DEBUG(" ==> (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart ); //EDN_DEBUG(" ==> (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart );
m_Highlight->Parse2(HLStart, m_Highlight->Parse2(HLStart,
m_HLDataPass1[k].beginStart,
MData.HLData,
m_data);
} // else : nothing to do ...
} else {
//EDN_DEBUG(" ==> (empty section 2 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<m_HLDataPass1[k].beginStart );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
m_HLDataPass1[k].beginStart, m_HLDataPass1[k].beginStart,
MData.HLData, MData.HLData,
m_data); m_data);
} } // else : nothing to do ...
// under section : } else {
//EDN_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999); //EDN_DEBUG(" ==> (empty section 2 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<m_HLDataPass1[k].beginStart );
// TODO : ... m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
m_HLDataPass1[k].beginStart,
MData.HLData,
m_data);
} }
if (endSearch == (int32_t)m_HLDataPass1.Size() ){ // under section :
//if( k < (int32_t)m_HLDataPass1.Size()) { //EDN_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999);
if (m_HLDataPass1.Size() != 0) { // TODO : ...
//EDN_DEBUG(" ==> (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
HLStop,
MData.HLData,
m_data);
} else {
//EDN_DEBUG(" ==> (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
m_Highlight->Parse2(0,
HLStop,
MData.HLData,
m_data);
}
}
//GTimeVal timeStop;
//g_get_current_time(&timeStop);
//EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
} }
if (endSearch == (int32_t)m_HLDataPass1.Size() ){
//if( k < (int32_t)m_HLDataPass1.Size()) {
if (m_HLDataPass1.Size() != 0) {
//EDN_DEBUG(" ==> (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
HLStop,
MData.HLData,
m_data);
} else {
//EDN_DEBUG(" ==> (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
m_Highlight->Parse2(0,
HLStop,
MData.HLData,
m_data);
}
}
//GTimeVal timeStop;
//g_get_current_time(&timeStop);
//EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
} }

View File

@@ -28,53 +28,50 @@
#include <MsgBroadcast.h> #include <MsgBroadcast.h>
// new list of edn event generic :
////////////////////////////////////////////////////////////////////////
// Event of the gui request something :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgGuiNew = "edn-Msg-Gui-New";
extern const char* const ednMsgGuiOpen = "edn-Msg-Gui-Open";
extern const char* const ednMsgGuiClose = "edn-Msg-Gui-Close";
extern const char* const ednMsgGuiSave = "edn-Msg-Gui-Save";
extern const char* const ednMsgGuiSaveAs = "edn-Msg-Gui-SaveAs";
extern const char* const ednMsgBufferChangeCurrent = "edn-Msg-Buffer-Change-Current"; extern const char* const ednMsgGuiUndo = "edn-Msg-Gui-Undo";
extern const char* const ednMsgUserDisplayChange = "edn-Msg-User-Display-Change"; extern const char* const ednMsgGuiRedo = "edn-Msg-Gui-Redo";
extern const char* const ednMsgGuiCopy = "edn-Msg-Gui-Copy";
extern const char* const ednMsgGuiCut = "edn-Msg-Gui-Cut";
extern const char* const ednMsgGuiPaste = "edn-Msg-Gui-Paste";
extern const char* const ednMsgGuiRm = "edn-Msg-Gui-Rm";
extern const char* const ednMsgGuiSelect = "edn-Msg-Gui-Select";
extern const char* const ednMsgGuiGotoLine = "edn-Msg-Gui-GotoLine";
extern const char* const ednMsgBufferRemove = "edn-Msg-Buffer-Remove"; extern const char* const ednMsgGuiSearch = "edn-Msg-Gui-Search";
extern const char* const ednMsgBufferRemoveAll = "edn-Msg-Buffer-Remove-All"; extern const char* const ednMsgGuiReplace = "edn-Msg-Gui-Replace";
extern const char* const ednMsgBufferAdd = "edn-Msg-Buffer-Add"; extern const char* const ednMsgGuiFind = "edn-Msg-Gui-Find";
extern const char* const ednMsgBufferChangeState = "edn-Msg-Buffer-Change-State";
extern const char* const ednMsgBufferChangeName = "edn-Msg-Buffer-Change-Name";
extern const char* const ednMsgBufferModify = "edn-Msg-Buffer-Modify";
extern const char* const ednMsgBufferHasHistory = "edn-Msg-Buffer-Has-History";
extern const char* const ednMsgBufferHasNotHistory = "edn-Msg-Buffer-Has-Not-History";
extern const char* const ednMsgBufferHasFutureHistory = "edn-Msg-Buffer-Has-Future-History";
extern const char* const ednMsgBufferHasNotFutureHistory = "edn-Msg-Buffer-Has-Not-Future-History";
extern const char* const ednMsgBufferManagerNewFile = "edn-Msg-Buffer-Manager-New-File"; extern const char* const ednMsgGuiChangeColor = "edn-Msg-Gui-ChangeColor";
extern const char* const ednMsgBufferManagerSaveAll = "edn-Msg-Buffer-Manager-Save-All"; extern const char* const ednMsgGuiChangeCharset = "edn-Msg-Gui-ChangeCharset";
extern const char* const ednMsgBufferManagerCloseAll = "edn-Msg-Buffer-Manager-Close-All"; extern const char* const ednMsgGuiShowSpaces = "edn-Msg-Gui-ShowSpaces";
extern const char* const ednMsgBufferManagerClose = "edn-Msg-Buffer-Manager-Close"; extern const char* const ednMsgGuiShowEndOfLine = "edn-Msg-Gui-ShowEndOfLine";
extern const char* const ednMsgBufferManagerSave = "edn-Msg-Buffer-Manager-Save";
extern const char* const ednMsgCodeViewCurrentChangeBufferId = "edn-Msg-CodeView-Current-Change-Buffer-Id"; extern const char* const ednMsgGuiCtags = "edn-Msg-Gui-CTags";
extern const char* const ednMsgCodeViewCurrentSave = "edn-Msg-CodeView-Current-Save";
extern const char* const ednMsgCodeViewCurrentSaveAs = "edn-Msg-CodeView-Current-Save-As";
extern const char* const ednMsgCodeViewCurrentSelectAll = "edn-Msg-CodeView-Current-Select-All";
extern const char* const ednMsgCodeViewCurrentRemoveLine = "edn-Msg-CodeView-Current-Remove-Line";
extern const char* const ednMsgCodeViewCurrentUnSelect = "edn-Msg-CodeView-Current-Un-Select";
extern const char* const ednMsgCodeViewCurrentCopy = "edn-Msg-CodeView-Current-Copy";
extern const char* const ednMsgCodeViewCurrentCut = "edn-Msg-CodeView-Current-Cut";
extern const char* const ednMsgCodeViewCurrentPaste = "edn-Msg-CodeView-Current-Paste";
extern const char* const ednMsgCodeViewCurrentFindPrevious = "edn-Msg-CodeView-Current-Find-Previous";
extern const char* const ednMsgCodeViewCurrentFindNext = "edn-Msg-CodeView-Current-Find-Next";
extern const char* const ednMsgCodeViewCurrentFindOldNext = "edn-Msg-CodeView-Current-Find-Old-Next";
extern const char* const ednMsgCodeViewCurrentReplace = "edn-Msg-CodeView-Current-Replace";
extern const char* const ednMsgCodeViewCurrentReplaceAll = "edn-Msg-CodeView-Current-Replace-All";
extern const char* const ednMsgCodeViewCurrentClose = "edn-Msg-CodeView-Current-Close";
extern const char* const ednMsgCodeViewCurrentUndo = "edn-Msg-CodeView-Current-Undo";
extern const char* const ednMsgCodeViewCurrentRedo = "edn-Msg-CodeView-Current-Redo";
extern const char* const ednMsgCodeViewCurrentGotoLine = "edn-Msg-CodeView-Current-Goto-Line";
extern const char* const ednMsgCodeViewCurrentSetCharset = "edn-Msg-CodeView-Current-Set-Charset";
extern const char* const ednMsgCtagsOpen = "edn-Msg-Ctags-Open"; extern const char* const ednMsgGuiAbout = "edn-Msg-Gui-About";
extern const char* const ednMsgCtagsReload = "edn-Msg-Ctags-Reload";
extern const char* const ednMsgCtagsJumpCurrentSelection = "edn-Msg-Ctags-Jump-Current-Selection";
extern const char* const ednMsgCtagsJumpBack = "edn-Msg-Ctags-Jump-Back";
extern const char* const ednMsgColorHasChange = "edn-Msg-Color-Has-Change";
extern const char* const ednMsgReloadColorFile = "edn-Msg-Reload-Color-File"; ////////////////////////////////////////////////////////////////////////
// Event internal :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgBufferState = "edn-Msg-Buffer-State";
extern const char* const ednMsgBufferName = "edn-Msg-Buffer-Name";
extern const char* const ednMsgBufferId = "edn-Msg-Buffer-Id";
extern const char* const ednMsgCodeViewSelectedId = "edn-Msg-CodeView-Select-Id";
extern const char* const ednMsgOpenFile = "edn-Msg-OpenFile";
extern const char* const ednMsgBufferListChange = "edn-Msg-BufferListChange";
extern const char* const ednMsgBufferColor = "edn-Msg-Buffer-Color";

View File

@@ -27,57 +27,54 @@
#define __MSG_BROADCAST_H__ #define __MSG_BROADCAST_H__
#include <tools_debug.h> #include <tools_debug.h>
#include <etk/String.h> #include <etk/UString.h>
extern const char* const ednMsgBufferChangeCurrent; // set the new current BUFFER ... // new list of edn event generic :
extern const char* const ednMsgUserDisplayChange; // User change the display ==> need to reload all the display depending on color internal ////////////////////////////////////////////////////////////////////////
// Event of the gui request something :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgGuiNew; // data : ""
extern const char* const ednMsgGuiOpen; // data : ""
extern const char* const ednMsgGuiClose; // data : "current" "All"
extern const char* const ednMsgGuiSave; // data : ""
extern const char* const ednMsgGuiSaveAs; // data : ""
extern const char* const ednMsgBufferRemove; extern const char* const ednMsgGuiUndo; // data : ""
extern const char* const ednMsgBufferRemoveAll; extern const char* const ednMsgGuiRedo; // data : ""
extern const char* const ednMsgBufferAdd; extern const char* const ednMsgGuiCopy; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgBufferChangeState; extern const char* const ednMsgGuiCut; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgBufferChangeName; extern const char* const ednMsgGuiPaste; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgBufferModify; extern const char* const ednMsgGuiRm; // data : "Word" "Line" "Paragraph"
extern const char* const ednMsgBufferHasHistory; extern const char* const ednMsgGuiSelect; // data : "ALL" "NONE"
extern const char* const ednMsgBufferHasNotHistory; extern const char* const ednMsgGuiGotoLine; // data : "???" / "1" ... "999999999999"
extern const char* const ednMsgBufferHasFutureHistory;
extern const char* const ednMsgBufferHasNotFutureHistory;
extern const char* const ednMsgBufferManagerNewFile; extern const char* const ednMsgGuiSearch; // data : ""
extern const char* const ednMsgBufferManagerSaveAll; extern const char* const ednMsgGuiReplace; // data : ""
extern const char* const ednMsgBufferManagerCloseAll; extern const char* const ednMsgGuiFind; // data : "Next" "Previous"
extern const char* const ednMsgBufferManagerClose;
extern const char* const ednMsgBufferManagerSave;
extern const char* const ednMsgCodeViewCurrentChangeBufferId; extern const char* const ednMsgGuiChangeColor; // data : "Black" "White"
extern const char* const ednMsgCodeViewCurrentSave; extern const char* const ednMsgGuiChangeCharset; // data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
extern const char* const ednMsgCodeViewCurrentSaveAs; extern const char* const ednMsgGuiShowSpaces; // data : "enable" "disable"
extern const char* const ednMsgCodeViewCurrentSelectAll; extern const char* const ednMsgGuiShowEndOfLine; // data : "enable" "disable"
extern const char* const ednMsgCodeViewCurrentRemoveLine;
extern const char* const ednMsgCodeViewCurrentUnSelect;
extern const char* const ednMsgCodeViewCurrentCopy;
extern const char* const ednMsgCodeViewCurrentCut;
extern const char* const ednMsgCodeViewCurrentPaste;
extern const char* const ednMsgCodeViewCurrentFindPrevious;
extern const char* const ednMsgCodeViewCurrentFindNext;
extern const char* const ednMsgCodeViewCurrentFindOldNext;
extern const char* const ednMsgCodeViewCurrentReplace;
extern const char* const ednMsgCodeViewCurrentReplaceAll;
extern const char* const ednMsgCodeViewCurrentClose;
extern const char* const ednMsgCodeViewCurrentUndo;
extern const char* const ednMsgCodeViewCurrentRedo;
extern const char* const ednMsgCodeViewCurrentGotoLine;
extern const char* const ednMsgCodeViewCurrentSetCharset;
extern const char* const ednMsgCtagsOpen; extern const char* const ednMsgGuiCtags; // data : "Load" "ReLoad" "Jump" "Back"
extern const char* const ednMsgCtagsReload;
extern const char* const ednMsgCtagsJumpCurrentSelection;
extern const char* const ednMsgCtagsJumpBack;
extern const char* const ednMsgColorHasChange; extern const char* const ednMsgGuiAbout; // data : ""
extern const char* const ednMsgReloadColorFile;
////////////////////////////////////////////////////////////////////////
// Event internal :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory"
extern const char* const ednMsgBufferName; // data : "filename"
extern const char* const ednMsgBufferId; // data : "0" ... "99999999999"
extern const char* const ednMsgCodeViewSelectedId; // data : "0" ... "99999999999"
extern const char* const ednMsgOpenFile; // data : "/Compleate/file/name.xx"
extern const char* const ednMsgBufferListChange; // data : ""
extern const char* const ednMsgBufferColor; // data : "new"
#endif #endif

View File

@@ -59,7 +59,7 @@ extern const char * ednLog;
# define EDN_VERBOSE(data) do {}while(0) # define EDN_VERBOSE(data) do {}while(0)
#endif #endif
#define EDN_TODO(data) DRAW_WARNING("TODO : " << data) #define EDN_TODO(data) ETK_WARNING(ednLog, "TODO : " << data)
#define EDN_ASSERT(cond, data) ETK_ASSERT(ednLog, cond, data) #define EDN_ASSERT(cond, data) ETK_ASSERT(ednLog, cond, data)

View File

@@ -55,7 +55,7 @@ void globals::SetDisplayEndOfLine(bool newVal)
{ {
EDN_INFO("Set EndOfLine " << newVal); EDN_INFO("Set EndOfLine " << newVal);
displayEOL = newVal; displayEOL = newVal;
ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange); //ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
} }
// ----------------------------------------------------------- // -----------------------------------------------------------
@@ -69,7 +69,7 @@ void globals::SetDisplaySpaceChar(bool newVal)
{ {
EDN_INFO("Set SpaceChar " << newVal); EDN_INFO("Set SpaceChar " << newVal);
displaySpaceChar = newVal; displaySpaceChar = newVal;
ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange); //ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
} }