diff --git a/sources/appl/Colorize/Colorize.cpp b/sources/appl/Colorize/Colorize.cpp index e7f6a13..b681e93 100644 --- a/sources/appl/Colorize/Colorize.cpp +++ b/sources/appl/Colorize/Colorize.cpp @@ -15,108 +15,35 @@ #define __class__ "Colorize" -Colorize::Colorize( etk::UString &newColorName) +Colorize::Colorize(const etk::UString &_newColorName) : + m_colorName(_newColorName), + m_colorFG(draw::color::black), + m_colorBG(draw::color::none), + m_italic(false), + m_bold(false) { - - m_colorFG = draw::color::black; - m_colorBG = draw::color::none; - - italic = false; - bold = false; - SetName(newColorName); APPL_VERBOSE("New(Colorise)"); } -Colorize::Colorize(void) +void Colorize::SetItalic(bool _enable) { - ColorName = "no_name"; - - m_colorFG = draw::color::black; - m_colorBG = draw::color::none; - - italic = false; - bold = false; - - APPL_VERBOSE("New(Colorise)"); -} - -Colorize::~Colorize(void) -{ - // nothing to do ... -} - - -void Colorize::SetName(const char *newColorName) -{ - APPL_VERBOSE("color change name : \"" << ColorName << "\" ==> \"" << newColorName << "\""); - ColorName = newColorName; -} - -void Colorize::SetName(etk::UString &newColorName) -{ - APPL_VERBOSE("color change name : \"" << ColorName << "\" ==> \"" << newColorName << "\""); - ColorName = newColorName; -} - - -etk::UString Colorize::GetName(void) -{ - return ColorName; -} - - -void Colorize::SetFgColor(const char *myColor) -{ - m_colorFG = myColor; - APPL_VERBOSE(myColor << " ==> "<< m_colorFG ); -} - -void Colorize::SetBgColor(const char *myColor) -{ - m_colorBG = myColor; - APPL_VERBOSE(myColor << " ==> "<< m_colorBG ); -} - -bool Colorize::HaveBg(void) -{ - return m_colorBG.a!=0; -} - - -void Colorize::SetItalic(bool enable) -{ - italic = enable; - if (true == enable) { - APPL_VERBOSE("color : \"" << ColorName << "\" enable italic"); + m_italic = _enable; + if (true == _enable) { + APPL_VERBOSE("color : \"" << m_colorName << "\" enable italic"); } else { - APPL_VERBOSE("color : \"" << ColorName << "\" disable italic"); + APPL_VERBOSE("color : \"" << m_colorName << "\" disable italic"); } } -bool Colorize::GetItalic(void) +void Colorize::SetBold(bool _enable) { - return italic; -} - - -void Colorize::SetBold(bool enable) -{ - bold = enable; - if (true == enable) { - APPL_VERBOSE("color : \"" << ColorName << "\" enable bold"); + m_bold = _enable; + if (true == _enable) { + APPL_VERBOSE("color : \"" << m_colorName << "\" enable bold"); } else { - APPL_VERBOSE("color : \"" << ColorName << "\" disable bold"); + APPL_VERBOSE("color : \"" << m_colorName << "\" disable bold"); } } -bool Colorize::GetBold(void) -{ - return bold; -} - - - - - diff --git a/sources/appl/Colorize/Colorize.h b/sources/appl/Colorize/Colorize.h index fb3120c..e18f051 100644 --- a/sources/appl/Colorize/Colorize.h +++ b/sources/appl/Colorize/Colorize.h @@ -14,36 +14,38 @@ class Colorize { public: // Constructeur - Colorize(void); - Colorize(etk::UString &newColorName); - ~Colorize(void); + Colorize(const etk::UString& _newColorName="no_name"); + ~Colorize(void) { }; - void SetName(etk::UString &newColorName); - void SetName(const char *newColorName); - etk::UString GetName(void); - void SetFgColor(const char *myColor); - void SetBgColor(const char *myColor); - - draw::Color & GetFG(void) { return m_colorFG; }; - draw::Color & GetBG(void) { return m_colorBG; }; - - bool HaveBg(void); - - void SetItalic(bool enable); - void SetBold(bool enable); - bool GetItalic(void); - bool GetBold(void); - - void Display(int32_t i) { APPL_INFO(" " << i << " : \"" << ColorName << "\"" << " fg="<< m_colorFG); }; - private: - etk::UString ColorName; //!< curent color Name - draw::Color m_colorFG; - draw::Color m_colorBG; + etk::UString m_colorName; //!< curent color Name + public: + void SetName(const etk::UString& _newColorName) { m_colorName = _newColorName; }; + const etk::UString& GetName(void) { return m_colorName; }; - bool italic; - bool bold; - + private: + draw::Color m_colorFG; + public: + void SetFgColor(const etk::UString& _myColor) { m_colorFG=_myColor.c_str(); }; + const draw::Color& GetFG(void) { return m_colorFG; }; + bool HaveFg(void) { return m_colorFG.a!=0; }; + private: + draw::Color m_colorBG; + public: + void SetBgColor(const etk::UString& _myColor) { m_colorBG=_myColor.c_str(); }; + const draw::Color& GetBG(void) { return m_colorBG; }; + bool HaveBg(void) { return m_colorBG.a!=0; }; + private: + bool m_italic; + public: + void SetItalic(bool _enable); + bool GetItalic(void) { return m_italic; }; + private: + bool m_bold; + public: + void SetBold(bool _enable); + bool GetBold(void) { return m_bold; }; + void Display(int32_t _i) { APPL_INFO(" " << _i << " : fg="<< m_colorFG << " bold=" << m_italic << " bold=" << m_italic << "\"" << m_colorName << "\""); }; }; #endif diff --git a/sources/appl/Colorize/ColorizeManager.cpp b/sources/appl/Colorize/ColorizeManager.cpp index fa0dc2e..a691ce1 100644 --- a/sources/appl/Colorize/ColorizeManager.cpp +++ b/sources/appl/Colorize/ColorizeManager.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -18,315 +18,235 @@ class classColorManager: public ewol::EObject { + private: + etk::UString m_fileColor; + etk::Vector listMyColor; //!< List of ALL Color + Colorize * errorColor; + draw::Color basicColors[COLOR_NUMBER_MAX]; + public: // Constructeur - classColorManager(void); - ~classColorManager(void); + classColorManager(void) + { + //ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiChangeColor); + } + ~classColorManager(void) + { + delete(errorColor); + + int32_t i; + // clean all Element + for (i=0; i< listMyColor.Size(); i++) { + if (NULL != listMyColor[i]) { + delete(listMyColor[i]); + listMyColor[i] = NULL; + } + } + // clear the compleate list + listMyColor.Clear(); + } const char * const GetObjectType(void) { - return "ApplColorManager"; + return "Appl::ColorManager"; + } + void OnReceiveMessage(const ewol::EMessage& _msg) + { + /* + switch (id) + { + case APPL_MSG__RELOAD_COLOR_FILE: + { + // Reaload File + // TODO : Check this : Pb in the recopy etk::UString element + etk::UString plop = m_fileColor; + LoadFile(plop); + } + break; + } + */ } - virtual void OnReceiveMessage(const ewol::EMessage& _msg); public: - void LoadFile(etk::UString &xmlFilename); - void LoadFile(const char * xmlFilename); - Colorize * Get(const char *colorName); - Colorize * Get(etk::UString &colorName); - draw::Color& Get(basicColor_te myColor); - bool Exist(etk::UString &colorName); - bool Exist(const char *colorName); - void DisplayListOfColor(void); - - private: - etk::UString m_fileColor; - etk::Vector listMyColor; //!< List of ALL Color - Colorize * errorColor; - draw::Color basicColors[COLOR_NUMBER_MAX]; + void LoadFile(const etk::UString& _xmlFilename); + Colorize* Get(const etk::UString& _colorName) + { + int32_t i; + for (i=0; iGetName() == _colorName) { + return listMyColor[i]; + } + } + APPL_ERROR(PFX"Color does not Existed ["<< _colorName<<"]" ); + // an error + return errorColor; + } + draw::Color& Get(basicColor_te _myColor) + { + if (_myColor < COLOR_NUMBER_MAX) { + return basicColors[_myColor]; + } else { + return basicColors[0]; + } + } + bool Exist(const etk::UString& _colorName) + { + int32_t i; + for (i=0; iGetName() == _colorName) { + return true; + } + } + return false; + } + void DisplayListOfColor(void) + { + int32_t i; + APPL_INFO(PFX"List of ALL COLOR : "); + for (i=0; iGetName(); + //APPL_INFO(i << " : \"" << elementName.c_str() << "\"" ); + listMyColor[i]->Display(i); + } + } }; - -classColorManager::classColorManager(void) -{ - //ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiChangeColor); -} - -classColorManager::~classColorManager(void) -{ - delete(errorColor); - - int32_t i; - // clean all Element - for (i=0; i< listMyColor.Size(); i++) { - if (NULL != listMyColor[i]) { - delete(listMyColor[i]); - listMyColor[i] = NULL; - } - } - // clear the compleate list - listMyColor.Clear(); -} - -void classColorManager::OnReceiveMessage(const ewol::EMessage& _msg) -{ - /* - switch (id) - { - case APPL_MSG__RELOAD_COLOR_FILE: - { - // Reaload File - // TODO : Check this : Pb in the recopy etk::UString element - etk::UString plop = m_fileColor; - LoadFile(plop); - } - break; - } - */ -} - - -void classColorManager::LoadFile(etk::UString &xmlFilename) -{ - // TODO : Remove this - LoadFile(xmlFilename.c_str()); -} - -// TODO : Remove this ... -void classColorManager::LoadFile(const char * xmlFilename) +void classColorManager::LoadFile(const etk::UString& _xmlFilename) { // Remove all old color : - int32_t i; - // clean all Element - for (i=0; i< listMyColor.Size(); i++) { - if (NULL != listMyColor[i]) { - delete(listMyColor[i]); - listMyColor[i] = NULL; + for (int32_t iii=0; iii< listMyColor.Size(); iii++) { + if (NULL != listMyColor[iii]) { + delete(listMyColor[iii]); + listMyColor[iii] = NULL; } } // clear the compleate list listMyColor.Clear(); - m_fileColor = xmlFilename; - APPL_DEBUG("open file (COLOR) \"" << xmlFilename << "\" ? = \"" << m_fileColor << "\""); + m_fileColor = _xmlFilename; + APPL_DEBUG("open file (COLOR) \"" << _xmlFilename << "\" ? = \"" << m_fileColor << "\""); errorColor = new Colorize(); errorColor->SetBgColor("#00FF00FF"); errorColor->SetFgColor("#FF00FFFF"); - // allocate the document in the stack - TiXmlDocument XmlDocument; // open the curent File - etk::FSNode fileName(etk::UString("DATA:color/") + xmlFilename + etk::UString(".xml")); - if (false == fileName.Exist()) { - APPL_ERROR("File Does not exist : " << fileName); + etk::UString fileName(etk::UString("DATA:color/") + _xmlFilename + etk::UString(".xml")); + exml::Document doc; + if (doc.Load(fileName)==false) { + APPL_ERROR(" can not load file XML : " << fileName); return; } - int32_t fileSize = fileName.FileSize(); - if (0==fileSize) { - APPL_ERROR("This file is empty : " << fileName); - return; - } - if (false == fileName.FileOpenRead()) { - APPL_ERROR("Can not open the file : " << fileName); - return; - } - // allocate data - char * fileBuffer = new char[fileSize+5]; - if (NULL == fileBuffer) { - APPL_ERROR("Error Memory allocation size=" << fileSize); - return; - } - memset(fileBuffer, 0, (fileSize+5)*sizeof(char)); - // load data from the file : - fileName.FileRead(fileBuffer, 1, fileSize); - // close the file: - fileName.FileClose(); - // load the XML from the memory - XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8); - - TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" ); + exml::Element* root = (exml::Element*)doc.GetNamed("EdnColor"); if (NULL == root ) { - APPL_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\""); + APPL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"EdnColor\" ..."); return; - } else { - TiXmlNode * pNode = root->FirstChild(); - while(NULL != pNode) { - if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { - // nothing to do, just proceed to next step - } else if (!strcmp(pNode->Value(), "gui")) { - TiXmlNode * pGuiNode = pNode->FirstChild(); - while(NULL != pGuiNode) { - if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) { - // nothing to do, just proceed to next step - } else if (!strcmp(pGuiNode->Value(), "color")) { - //-------------------------------------------------------------------------------------------- - // - //-------------------------------------------------------------------------------------------- - const char *colorName = pGuiNode->ToElement()->Attribute("name"); - int32_t id = 0; - if (NULL == colorName) { - APPL_ERROR("(l "<< pGuiNode->Row() <<") node with no name"); - // get next node element - pGuiNode = pGuiNode->NextSibling(); - continue; - } - if (!strcmp(colorName, "CODE_space")) { - id = COLOR_CODE_SPACE; - } else if (!strcmp(colorName, "CODE_tabulation")) { - id = COLOR_CODE_TAB; - } else if (!strcmp(colorName, "CODE_basicBackgroung")) { - id = COLOR_CODE_BASIC_BG; - } else if (!strcmp(colorName, "CODE_cursor")) { - id = COLOR_CODE_CURSOR; - } else if (!strcmp(colorName, "CODE_lineNumber")) { - id = COLOR_CODE_LINE_NUMBER; - } else if (!strcmp(colorName, "LIST_backgroung1")) { - id = COLOR_LIST_BG_1; - } else if (!strcmp(colorName, "LIST_backgroung2")) { - id = COLOR_LIST_BG_2; - } else if (!strcmp(colorName, "LIST_backgroungSelected")) { - id = COLOR_LIST_BG_SELECTED; - } else if (!strcmp(colorName, "LIST_textNormal")) { - id = COLOR_LIST_TEXT_NORMAL; - } else if (!strcmp(colorName, "LIST_textModify")) { - id = COLOR_LIST_TEXT_MODIFY; - } else { - APPL_ERROR("(l "<Row()<<") Unknown basic gui color : \"" << colorName << "\"" ); - // get next node element - pGuiNode = pGuiNode->NextSibling(); - continue; - } - const char *color = pGuiNode->ToElement()->Attribute("val"); - if (NULL != color) { - basicColors[id] = color; - } - } else { - APPL_ERROR("(l "<Row()<<") node not suported : \""<Value()<<"\" must be [color]"); - } - // get next node element - pGuiNode = pGuiNode->NextSibling(); - } - } else if (!strcmp(pNode->Value(), "syntax")) { - TiXmlNode * pGuiNode = pNode->FirstChild(); - while(NULL != pGuiNode) - { - if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) { - // nothing to do, just proceed to next step - } else if (!strcmp(pGuiNode->Value(), "color")) { - Colorize *myNewColor = new Colorize(); - //-------------------------------------------------------------------------------------------- - // - //-------------------------------------------------------------------------------------------- - // get the name of the Chaine - const char *colorName = pGuiNode->ToElement()->Attribute("name"); - if (NULL == colorName) { - APPL_ERROR(PFX"(l "<< pGuiNode->Row() <<") node with no name"); - // get next node element - pGuiNode = pGuiNode->NextSibling(); - continue; - } else { - myNewColor->SetName(colorName); - //APPL_INFO(PFX"Add a new color in the panel : \"%s\"", colorName); - } - const char *colorBG = pGuiNode->ToElement()->Attribute("BG"); - if (NULL != colorBG) { - myNewColor->SetBgColor(colorBG); - } - const char *colorFG = pGuiNode->ToElement()->Attribute("FG"); - if (NULL != colorFG) { - myNewColor->SetFgColor(colorFG); - } - const char *bold = pGuiNode->ToElement()->Attribute("bold"); - if (NULL != bold) { - if(0 == strcmp(bold, "yes") ) { - myNewColor->SetBold(true); - } - } - const char *italic = pGuiNode->ToElement()->Attribute("italic"); - if (NULL != italic) { - if(0 == strcmp(italic, "yes") ) { - myNewColor->SetItalic(true); - } - } - listMyColor.PushBack(myNewColor); - } else { - APPL_ERROR(PFX"(l "<Row()<<") node not suported : \""<Value()<<"\" must be [color]"); - } - pGuiNode = pGuiNode->NextSibling(); - } - } else { - APPL_ERROR(PFX"(l "<Row()<<") node not suported : \""<Value()<<"\" must be [gui,syntax]"); - } - // get next node element - pNode = pNode->NextSibling(); - } } - if (NULL != fileBuffer) { - delete[] fileBuffer; + + + // parse all the elements : + for(int32_t iii=0; iii< root->Size(); iii++) { + exml::Element* pNode = root->GetElement(iii); + if (pNode==NULL) { + // trash here all that is not element. + continue; + } + if (pNode->GetValue()=="gui") { + for(int32_t iii=0; iii< pNode->Size(); iii++) { + exml::Element* pGuiNode = pNode->GetElement(iii); + if (pGuiNode==NULL) { + // trash here all that is not element. + continue; + } + if (pGuiNode->GetValue()!="color") { + APPL_ERROR("(l "<Pos()<<") node not suported : \""<GetValue()<<"\" must be [color]"); + continue; + } + //-------------------------------------------------------------------------------------------- + // + //-------------------------------------------------------------------------------------------- + etk::UString colorName = pGuiNode->GetAttribute("name"); + if (colorName.Size()==0) { + APPL_ERROR("(l "<< pGuiNode->Pos() <<") node with no name"); + continue; + } + int32_t id = 0; + if (colorName=="CODE_space") { + id = COLOR_CODE_SPACE; + } else if (colorName=="CODE_tabulation") { + id = COLOR_CODE_TAB; + } else if (colorName=="CODE_basicBackgroung") { + id = COLOR_CODE_BASIC_BG; + } else if (colorName=="CODE_cursor") { + id = COLOR_CODE_CURSOR; + } else if (colorName=="CODE_lineNumber") { + id = COLOR_CODE_LINE_NUMBER; + } else if (colorName=="LIST_backgroung1") { + id = COLOR_LIST_BG_1; + } else if (colorName=="LIST_backgroung2") { + id = COLOR_LIST_BG_2; + } else if (colorName=="LIST_backgroungSelected") { + id = COLOR_LIST_BG_SELECTED; + } else if (colorName=="LIST_textNormal") { + id = COLOR_LIST_TEXT_NORMAL; + } else if (colorName=="LIST_textModify") { + id = COLOR_LIST_TEXT_MODIFY; + } else { + APPL_ERROR("(l "<Pos()<<") Unknown basic gui color : \"" << colorName << "\"" ); + continue; + } + etk::UString color = pGuiNode->GetAttribute("val"); + if (color.Size()!=0) { + basicColors[id] = color.c_str(); + } + } + } else if (pNode->GetValue()=="syntax") { + for(int32_t iii=0; iii< pNode->Size(); iii++) { + exml::Element* pGuiNode = pNode->GetElement(iii); + if (pGuiNode==NULL) { + continue; + } + if (pGuiNode->GetValue()!="color") { + APPL_ERROR(PFX"(l "<Pos()<<") node not suported : \""<GetValue()<<"\" must be [color]"); + continue; + } + //-------------------------------------------------------------------------------------------- + // + //-------------------------------------------------------------------------------------------- + // get the name of the Chaine + etk::UString colorName = pGuiNode->GetAttribute("name"); + if (colorName.Size()==0) { + APPL_ERROR(PFX"(l "<< pGuiNode->Pos() <<") node with no name"); + continue; + } + Colorize* myNewColor = new Colorize(); + if (NULL==myNewColor) { + APPL_ERROR(PFX"(l "<< pGuiNode->Pos() <<") ==> allocation error"); + continue; + } + myNewColor->SetName(colorName); + etk::UString colorBG = pGuiNode->GetAttribute("BG"); + if (colorBG.Size()!=0) { + myNewColor->SetBgColor(colorBG); + } + etk::UString colorFG = pGuiNode->GetAttribute("FG"); + if (colorFG.Size()!=0) { + myNewColor->SetFgColor(colorFG); + } + etk::UString bold = pGuiNode->GetAttribute("bold"); + if (bold.Size()!=0) { + myNewColor->SetBold(bold.ToBool()); + } + etk::UString italic = pGuiNode->GetAttribute("italic"); + if (italic.Size()!=0) { + myNewColor->SetItalic(italic.ToBool()); + } + listMyColor.PushBack(myNewColor); + } + } } //SendMessage(APPL_MSG__COLOR_HAS_CHANGE); //SendMessage(APPL_MSG__USER_DISPLAY_CHANGE); } -// TODO : Remove this ... -Colorize *classColorManager::Get(const char *colorName) -{ - int32_t i; - for (i=0; iGetName(); - if (elementName == colorName) { - return listMyColor[i]; - } - } - APPL_ERROR(PFX"Color does not Existed ["<< colorName<<"]" ); - // an error - return errorColor; -} - -Colorize *classColorManager::Get(etk::UString &colorName) -{ - // TODO : Remove this - return Get(colorName.c_str()); -} - -draw::Color & classColorManager::Get(basicColor_te myColor) -{ - if (myColor < COLOR_NUMBER_MAX) { - return basicColors[myColor]; - } else { - return basicColors[0]; - } -} - - -// TODO : Remove this ... -bool classColorManager::Exist(const char *colorName) -{ - int32_t i; - for (i=0; iGetName(); - if (elementName == colorName) { - return true; - } - } - return false; -} - -bool classColorManager::Exist(etk::UString &colorName) -{ - // TODO : Remove this - return Exist(colorName.c_str()); -} - -void classColorManager::DisplayListOfColor(void) -{ - int32_t i; - APPL_INFO(PFX"List of ALL COLOR : "); - for (i=0; iGetName(); - //APPL_INFO(i << " : \"" << elementName.c_str() << "\"" ); - listMyColor[i]->Display(i); - } -} @@ -356,63 +276,38 @@ void ColorizeManager::UnInit(void) localManager = NULL; } -void ColorizeManager::LoadFile(etk::UString &xmlFilename) +void ColorizeManager::LoadFile(const etk::UString& _xmlFilename) { if (NULL == localManager) { return; } - localManager->LoadFile(xmlFilename); + localManager->LoadFile(_xmlFilename); } - -void ColorizeManager::LoadFile(const char * xmlFilename) -{ - if (NULL == localManager) { - return; - } - localManager->LoadFile(xmlFilename); -} - -Colorize* ColorizeManager::Get(const char *colorName) +Colorize* ColorizeManager::Get(const etk::UString& _colorName) { if (NULL == localManager) { return NULL; } - return localManager->Get(colorName); -} - -Colorize* ColorizeManager::Get(etk::UString &colorName) -{ - if (NULL == localManager) { - return NULL; - } - return localManager->Get(colorName); + return localManager->Get(_colorName); } draw::Color errorColor; -draw::Color& ColorizeManager::Get(basicColor_te myColor) +draw::Color& ColorizeManager::Get(basicColor_te _myColor) { if (NULL == localManager) { return errorColor; } - return localManager->Get(myColor); + return localManager->Get(_myColor); } -bool ColorizeManager::Exist(etk::UString &colorName) +bool ColorizeManager::Exist(const etk::UString& _colorName) { if (NULL == localManager) { return false; } - return localManager->Exist(colorName); -} - -bool ColorizeManager::Exist(const char *colorName) -{ - if (NULL == localManager) { - return false; - } - return localManager->Exist(colorName); + return localManager->Exist(_colorName); } void ColorizeManager::DisplayListOfColor(void) diff --git a/sources/appl/Colorize/ColorizeManager.h b/sources/appl/Colorize/ColorizeManager.h index c58a635..2cbc51d 100644 --- a/sources/appl/Colorize/ColorizeManager.h +++ b/sources/appl/Colorize/ColorizeManager.h @@ -37,13 +37,10 @@ namespace ColorizeManager { void Init(void); void UnInit(void); - void LoadFile(etk::UString &xmlFilename); - void LoadFile(const char * xmlFilename); - Colorize * Get(const char *colorName); - Colorize * Get(etk::UString &colorName); - draw::Color& Get(basicColor_te myColor); - bool Exist(etk::UString &colorName); - bool Exist(const char *colorName); + void LoadFile(const etk::UString& _xmlFilename); + Colorize * Get(const etk::UString& _colorName); + draw::Color& Get(basicColor_te _myColor); + bool Exist(const etk::UString& _colorName); void DisplayListOfColor(void); }; diff --git a/sources/appl/Highlight/Highlight.cpp b/sources/appl/Highlight/Highlight.cpp index df8f51d..34ff5f4 100644 --- a/sources/appl/Highlight/Highlight.cpp +++ b/sources/appl/Highlight/Highlight.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #undef __class__ @@ -31,34 +31,34 @@ void Highlight::ParseRules(exml::Element* child, etk::Vector Highlight::Highlight(const etk::UString& _xmlFilename) { exml::Document doc; - if (doc.Load(_fileName)==false) { - EWOL_ERROR(" can not load file XML : " << _fileName); - return false; + if (doc.Load(_xmlFilename)==false) { + APPL_ERROR(" can not load file XML : " << _xmlFilename); + return; } exml::Element* root = (exml::Element*)doc.GetNamed("EdnLang"); if (NULL == root ) { - EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ..."); - return false; + APPL_ERROR("(l ?) main node not find: \"EdnLang\" ..."); + return; } int32_t level1 = 0; int32_t level2 = 0; // parse all the elements : - for(int32_t iii=0; iii< _node->Size(); iii++) { - exml::Element* child = (exml::Element*)_node->Get(iii); + for(int32_t iii=0; iii< root->Size(); iii++) { + exml::Element* child = root->GetElement(iii); if (child==NULL) { + // trash here all that is not element ... continue; } if (child->GetValue() == "ext") { - const char *myData = child->GetText(); - if (NULL != myData) { + etk::UString myData = child->GetText(); + if (myData.Size()!=0) { //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData); - etk::UString * myEdnData = new etk::UString(myData); - m_listExtentions.PushBack(myEdnData); + m_listExtentions.PushBack(myData); } } else if (child->GetValue()=="pass1") { // Get sub Nodes ... for(int32_t jjj=0; jjj< child->Size(); jjj++) { - exml::Element* passChild = (exml::Element*)child->Get(jjj); + exml::Element* passChild = child->GetElement(jjj); if (passChild==NULL) { continue; } @@ -71,7 +71,7 @@ Highlight::Highlight(const etk::UString& _xmlFilename) } else if (child->GetValue() == "pass2") { // Get sub Nodes ... for(int32_t jjj=0; jjj< child->Size(); jjj++) { - exml::Element* passChild = (exml::Element*)child->Get(jjj); + exml::Element* passChild = child->GetElement(jjj); if (passChild==NULL) { continue; } @@ -99,14 +99,6 @@ Highlight::~Highlight(void) } // clear the compleate list m_listHighlightPass1.Clear(); - - // clean all Element - for (i=0; i< m_listExtentions.Size(); i++) { - if (NULL != m_listExtentions[i]) { - delete(m_listExtentions[i]); - m_listExtentions[i] = NULL; - } - } // clear the compleate list m_listExtentions.Clear(); } @@ -126,31 +118,29 @@ void Highlight::ReloadColor(void) } } -bool Highlight::HasExtention(etk::UString &ext) +bool Highlight::HasExtention(const etk::UString& _ext) { - int32_t i; - for (i=0; iGetName() ); + for (int32_t iii=0; iii< m_listHighlightPass1.Size(); iii++) { + APPL_INFO(" " << iii << " Pass 1 : " << m_listHighlightPass1[iii]->GetName() ); //m_listHighlightPass1[i]->Display(); } // Display all elements - for (i=0; i< m_listHighlightPass2.Size(); i++) { - APPL_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName() ); + for (int32_t iii=0; iii< m_listHighlightPass2.Size(); iii++) { + APPL_INFO(" " << iii << " Pass 2 : " << m_listHighlightPass2[iii]->GetName() ); //m_listHighlightPass2[i]->Display(); } } diff --git a/sources/appl/Highlight/Highlight.h b/sources/appl/Highlight/Highlight.h index b7b5b0f..1b7187f 100644 --- a/sources/appl/Highlight/Highlight.h +++ b/sources/appl/Highlight/Highlight.h @@ -36,8 +36,8 @@ class Highlight { // Constructeur Highlight(const etk::UString& _xmlFilename); ~Highlight(void); - bool HasExtention(etk::UString &ext); - bool FileNameCompatible(etk::FSNode &fileName); + bool HasExtention(const etk::UString& _ext); + bool FileNameCompatible(etk::FSNode &_fileName); void Display(void); void ReloadColor(void); void Parse(int32_t start, @@ -50,11 +50,11 @@ class Highlight { etk::Vector &metaData, etk::Buffer &buffer); private: - void ParseRules(exml::Element* child, etk::Vector &mListPatern, int32_t level); - etk::UString m_styleName; //!< curent style name (like "c++" or "c" or "script Bash") - etk::Vector m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" - etk::Vector m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer) - etk::Vector m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) ) + void ParseRules(exml::Element* child, etk::Vector &mListPatern, int32_t level); + etk::UString m_styleName; //!< curent style name (like "c++" or "c" or "script Bash") + etk::Vector m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" + etk::Vector m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer) + etk::Vector m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) ) };