[DEV] aupdate at exml api ==> tested and validate

This commit is contained in:
Edouard DUPIN 2013-06-26 23:48:23 +02:00
parent 24bb4f515c
commit 6422d91883
6 changed files with 293 additions and 483 deletions

View File

@ -15,108 +15,35 @@
#define __class__ "Colorize" #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)"); APPL_VERBOSE("New(Colorise)");
} }
Colorize::Colorize(void) void Colorize::SetItalic(bool _enable)
{ {
ColorName = "no_name"; m_italic = _enable;
if (true == _enable) {
m_colorFG = draw::color::black; APPL_VERBOSE("color : \"" << m_colorName << "\" enable italic");
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");
} else { } 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; m_bold = _enable;
} if (true == _enable) {
APPL_VERBOSE("color : \"" << m_colorName << "\" enable bold");
void Colorize::SetBold(bool enable)
{
bold = enable;
if (true == enable) {
APPL_VERBOSE("color : \"" << ColorName << "\" enable bold");
} else { } else {
APPL_VERBOSE("color : \"" << ColorName << "\" disable bold"); APPL_VERBOSE("color : \"" << m_colorName << "\" disable bold");
} }
} }
bool Colorize::GetBold(void)
{
return bold;
}

View File

@ -14,36 +14,38 @@
class Colorize { class Colorize {
public: public:
// Constructeur // Constructeur
Colorize(void); Colorize(const etk::UString& _newColorName="no_name");
Colorize(etk::UString &newColorName); ~Colorize(void) { };
~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: private:
etk::UString ColorName; //!< curent color Name etk::UString m_colorName; //!< curent color Name
draw::Color m_colorFG; public:
draw::Color m_colorBG; void SetName(const etk::UString& _newColorName) { m_colorName = _newColorName; };
const etk::UString& GetName(void) { return m_colorName; };
bool italic; private:
bool bold; 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 #endif

View File

@ -9,7 +9,7 @@
#include <appl/Debug.h> #include <appl/Debug.h>
#include <appl/global.h> #include <appl/global.h>
#include <ColorizeManager.h> #include <ColorizeManager.h>
#include <tinyXML/tinyxml.h> #include <exml/exml.h>
#include <ewol/eObject/EObject.h> #include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h> #include <ewol/eObject/EObjectManager.h>
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
@ -18,315 +18,235 @@
class classColorManager: public ewol::EObject class classColorManager: public ewol::EObject
{ {
private:
etk::UString m_fileColor;
etk::Vector<Colorize*> listMyColor; //!< List of ALL Color
Colorize * errorColor;
draw::Color basicColors[COLOR_NUMBER_MAX];
public: public:
// Constructeur // 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) 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: public:
void LoadFile(etk::UString &xmlFilename); void LoadFile(const etk::UString& _xmlFilename);
void LoadFile(const char * xmlFilename); Colorize* Get(const etk::UString& _colorName)
Colorize * Get(const char *colorName); {
Colorize * Get(etk::UString &colorName); int32_t i;
draw::Color& Get(basicColor_te myColor); for (i=0; i<listMyColor.Size(); i++) {
bool Exist(etk::UString &colorName); if (listMyColor[i]->GetName() == _colorName) {
bool Exist(const char *colorName); return listMyColor[i];
void DisplayListOfColor(void); }
}
private: APPL_ERROR(PFX"Color does not Existed ["<< _colorName<<"]" );
etk::UString m_fileColor; // an error
etk::Vector<Colorize*> listMyColor; //!< List of ALL Color return errorColor;
Colorize * errorColor; }
draw::Color basicColors[COLOR_NUMBER_MAX]; 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; i<listMyColor.Size(); i++) {
if (listMyColor[i]->GetName() == _colorName) {
return true;
}
}
return false;
}
void DisplayListOfColor(void)
{
int32_t i;
APPL_INFO(PFX"List of ALL COLOR : ");
for (i=0; i<listMyColor.Size(); i++) {
//etk::UString elementName = listMyColor[i]->GetName();
//APPL_INFO(i << " : \"" << elementName.c_str() << "\"" );
listMyColor[i]->Display(i);
}
}
}; };
void classColorManager::LoadFile(const etk::UString& _xmlFilename)
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)
{ {
// Remove all old color : // Remove all old color :
int32_t i; for (int32_t iii=0; iii< listMyColor.Size(); iii++) {
// clean all Element if (NULL != listMyColor[iii]) {
for (i=0; i< listMyColor.Size(); i++) { delete(listMyColor[iii]);
if (NULL != listMyColor[i]) { listMyColor[iii] = NULL;
delete(listMyColor[i]);
listMyColor[i] = NULL;
} }
} }
// clear the compleate list // clear the compleate list
listMyColor.Clear(); listMyColor.Clear();
m_fileColor = xmlFilename; m_fileColor = _xmlFilename;
APPL_DEBUG("open file (COLOR) \"" << xmlFilename << "\" ? = \"" << m_fileColor << "\""); APPL_DEBUG("open file (COLOR) \"" << _xmlFilename << "\" ? = \"" << m_fileColor << "\"");
errorColor = new Colorize(); errorColor = new Colorize();
errorColor->SetBgColor("#00FF00FF"); errorColor->SetBgColor("#00FF00FF");
errorColor->SetFgColor("#FF00FFFF"); errorColor->SetFgColor("#FF00FFFF");
// allocate the document in the stack
TiXmlDocument XmlDocument;
// open the curent File // open the curent File
etk::FSNode fileName(etk::UString("DATA:color/") + xmlFilename + etk::UString(".xml")); etk::UString fileName(etk::UString("DATA:color/") + _xmlFilename + etk::UString(".xml"));
if (false == fileName.Exist()) { exml::Document doc;
APPL_ERROR("File Does not exist : " << fileName); if (doc.Load(fileName)==false) {
APPL_ERROR(" can not load file XML : " << fileName);
return; return;
} }
int32_t fileSize = fileName.FileSize(); exml::Element* root = (exml::Element*)doc.GetNamed("EdnColor");
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" );
if (NULL == root ) { 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; 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")) {
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" val="#000000"/>
//--------------------------------------------------------------------------------------------
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 "<<pGuiNode->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 "<<pGuiNode->Row()<<") node not suported : \""<<pGuiNode->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();
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" FG="#000000" BG="#000000" bold="no" italic="no"/>
//--------------------------------------------------------------------------------------------
// 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 "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [color]");
}
pGuiNode = pGuiNode->NextSibling();
}
} else {
APPL_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->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 "<<pGuiNode->Pos()<<") node not suported : \""<<pGuiNode->GetValue()<<"\" must be [color]");
continue;
}
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" val="#000000"/>
//--------------------------------------------------------------------------------------------
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 "<<pGuiNode->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 "<<pGuiNode->Pos()<<") node not suported : \""<<pGuiNode->GetValue()<<"\" must be [color]");
continue;
}
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" FG="#000000" BG="#000000" bold="no" italic="no"/>
//--------------------------------------------------------------------------------------------
// 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__COLOR_HAS_CHANGE);
//SendMessage(APPL_MSG__USER_DISPLAY_CHANGE); //SendMessage(APPL_MSG__USER_DISPLAY_CHANGE);
} }
// TODO : Remove this ...
Colorize *classColorManager::Get(const char *colorName)
{
int32_t i;
for (i=0; i<listMyColor.Size(); i++) {
etk::UString elementName = listMyColor[i]->GetName();
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; i<listMyColor.Size(); i++) {
etk::UString elementName = listMyColor[i]->GetName();
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; i<listMyColor.Size(); i++) {
//etk::UString elementName = listMyColor[i]->GetName();
//APPL_INFO(i << " : \"" << elementName.c_str() << "\"" );
listMyColor[i]->Display(i);
}
}
@ -356,63 +276,38 @@ void ColorizeManager::UnInit(void)
localManager = NULL; localManager = NULL;
} }
void ColorizeManager::LoadFile(etk::UString &xmlFilename) void ColorizeManager::LoadFile(const etk::UString& _xmlFilename)
{ {
if (NULL == localManager) { if (NULL == localManager) {
return; return;
} }
localManager->LoadFile(xmlFilename); localManager->LoadFile(_xmlFilename);
} }
Colorize* ColorizeManager::Get(const etk::UString& _colorName)
void ColorizeManager::LoadFile(const char * xmlFilename)
{
if (NULL == localManager) {
return;
}
localManager->LoadFile(xmlFilename);
}
Colorize* ColorizeManager::Get(const char *colorName)
{ {
if (NULL == localManager) { if (NULL == localManager) {
return NULL; return NULL;
} }
return localManager->Get(colorName); return localManager->Get(_colorName);
}
Colorize* ColorizeManager::Get(etk::UString &colorName)
{
if (NULL == localManager) {
return NULL;
}
return localManager->Get(colorName);
} }
draw::Color errorColor; draw::Color errorColor;
draw::Color& ColorizeManager::Get(basicColor_te myColor) draw::Color& ColorizeManager::Get(basicColor_te _myColor)
{ {
if (NULL == localManager) { if (NULL == localManager) {
return errorColor; 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) { if (NULL == localManager) {
return false; return false;
} }
return localManager->Exist(colorName); return localManager->Exist(_colorName);
}
bool ColorizeManager::Exist(const char *colorName)
{
if (NULL == localManager) {
return false;
}
return localManager->Exist(colorName);
} }
void ColorizeManager::DisplayListOfColor(void) void ColorizeManager::DisplayListOfColor(void)

View File

@ -37,13 +37,10 @@ namespace ColorizeManager
{ {
void Init(void); void Init(void);
void UnInit(void); void UnInit(void);
void LoadFile(etk::UString &xmlFilename); void LoadFile(const etk::UString& _xmlFilename);
void LoadFile(const char * xmlFilename); Colorize * Get(const etk::UString& _colorName);
Colorize * Get(const char *colorName); draw::Color& Get(basicColor_te _myColor);
Colorize * Get(etk::UString &colorName); bool Exist(const etk::UString& _colorName);
draw::Color& Get(basicColor_te myColor);
bool Exist(etk::UString &colorName);
bool Exist(const char *colorName);
void DisplayListOfColor(void); void DisplayListOfColor(void);
}; };

View File

@ -9,7 +9,7 @@
#include <appl/Debug.h> #include <appl/Debug.h>
#include <appl/global.h> #include <appl/global.h>
#include <Highlight.h> #include <Highlight.h>
#include <tinyXML/tinyxml.h> #include <exml/exml.h>
#undef __class__ #undef __class__
@ -31,34 +31,34 @@ void Highlight::ParseRules(exml::Element* child, etk::Vector<HighlightPattern*>
Highlight::Highlight(const etk::UString& _xmlFilename) Highlight::Highlight(const etk::UString& _xmlFilename)
{ {
exml::Document doc; exml::Document doc;
if (doc.Load(_fileName)==false) { if (doc.Load(_xmlFilename)==false) {
EWOL_ERROR(" can not load file XML : " << _fileName); APPL_ERROR(" can not load file XML : " << _xmlFilename);
return false; return;
} }
exml::Element* root = (exml::Element*)doc.GetNamed("EdnLang"); exml::Element* root = (exml::Element*)doc.GetNamed("EdnLang");
if (NULL == root ) { if (NULL == root ) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ..."); APPL_ERROR("(l ?) main node not find: \"EdnLang\" ...");
return false; return;
} }
int32_t level1 = 0; int32_t level1 = 0;
int32_t level2 = 0; int32_t level2 = 0;
// parse all the elements : // parse all the elements :
for(int32_t iii=0; iii< _node->Size(); iii++) { for(int32_t iii=0; iii< root->Size(); iii++) {
exml::Element* child = (exml::Element*)_node->Get(iii); exml::Element* child = root->GetElement(iii);
if (child==NULL) { if (child==NULL) {
// trash here all that is not element ...
continue; continue;
} }
if (child->GetValue() == "ext") { if (child->GetValue() == "ext") {
const char *myData = child->GetText(); etk::UString myData = child->GetText();
if (NULL != myData) { if (myData.Size()!=0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData); //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
etk::UString * myEdnData = new etk::UString(myData); m_listExtentions.PushBack(myData);
m_listExtentions.PushBack(myEdnData);
} }
} else if (child->GetValue()=="pass1") { } else if (child->GetValue()=="pass1") {
// Get sub Nodes ... // Get sub Nodes ...
for(int32_t jjj=0; jjj< child->Size(); jjj++) { 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) { if (passChild==NULL) {
continue; continue;
} }
@ -71,7 +71,7 @@ Highlight::Highlight(const etk::UString& _xmlFilename)
} else if (child->GetValue() == "pass2") { } else if (child->GetValue() == "pass2") {
// Get sub Nodes ... // Get sub Nodes ...
for(int32_t jjj=0; jjj< child->Size(); jjj++) { 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) { if (passChild==NULL) {
continue; continue;
} }
@ -99,14 +99,6 @@ Highlight::~Highlight(void)
} }
// clear the compleate list // clear the compleate list
m_listHighlightPass1.Clear(); 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 // clear the compleate list
m_listExtentions.Clear(); 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 (int32_t iii=0; iii<m_listExtentions.Size(); iii++) {
for (i=0; i<m_listExtentions.Size(); i++) { if (_ext == m_listExtentions[iii] ) {
if (ext == *m_listExtentions[i] ) {
return true; return true;
} }
} }
return false; return false;
} }
bool Highlight::FileNameCompatible(etk::FSNode &fileName) bool Highlight::FileNameCompatible(etk::FSNode &_fileName)
{ {
int32_t i;
etk::UString extention; etk::UString extention;
if (true == fileName.FileHasExtention() ) { if (true == _fileName.FileHasExtention() ) {
extention = "*."; extention = "*.";
extention += fileName.FileGetExtention(); extention += _fileName.FileGetExtention();
} else { } else {
extention = fileName.GetNameFile(); extention = _fileName.GetNameFile();
} }
APPL_DEBUG(" try to find : in \"" << fileName << "\" extention:\"" << extention << "\" "); APPL_DEBUG(" try to find : in \"" << _fileName << "\" extention:\"" << extention << "\" ");
for (i=0; i<m_listExtentions.Size(); i++) { for (int32_t iii=0; iii<m_listExtentions.Size(); iii++) {
if (extention == *m_listExtentions[i] ) { if (extention == m_listExtentions[iii] ) {
return true; return true;
} }
} }
@ -160,19 +150,18 @@ bool Highlight::FileNameCompatible(etk::FSNode &fileName)
void Highlight::Display(void) void Highlight::Display(void)
{ {
int32_t i;
APPL_INFO("List of ALL Highlight : "); APPL_INFO("List of ALL Highlight : ");
for (i=0; i< m_listExtentions.Size(); i++) { for (int32_t iii=0; iii< m_listExtentions.Size(); iii++) {
APPL_INFO(" Extention : " << i << " : " << *m_listExtentions[i] ); APPL_INFO(" Extention : " << iii << " : " << m_listExtentions[iii] );
} }
// Display all elements // Display all elements
for (i=0; i< m_listHighlightPass1.Size(); i++) { for (int32_t iii=0; iii< m_listHighlightPass1.Size(); iii++) {
APPL_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName() ); APPL_INFO(" " << iii << " Pass 1 : " << m_listHighlightPass1[iii]->GetName() );
//m_listHighlightPass1[i]->Display(); //m_listHighlightPass1[i]->Display();
} }
// Display all elements // Display all elements
for (i=0; i< m_listHighlightPass2.Size(); i++) { for (int32_t iii=0; iii< m_listHighlightPass2.Size(); iii++) {
APPL_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName() ); APPL_INFO(" " << iii << " Pass 2 : " << m_listHighlightPass2[iii]->GetName() );
//m_listHighlightPass2[i]->Display(); //m_listHighlightPass2[i]->Display();
} }
} }

View File

@ -36,8 +36,8 @@ class Highlight {
// Constructeur // Constructeur
Highlight(const etk::UString& _xmlFilename); Highlight(const etk::UString& _xmlFilename);
~Highlight(void); ~Highlight(void);
bool HasExtention(etk::UString &ext); bool HasExtention(const etk::UString& _ext);
bool FileNameCompatible(etk::FSNode &fileName); bool FileNameCompatible(etk::FSNode &_fileName);
void Display(void); void Display(void);
void ReloadColor(void); void ReloadColor(void);
void Parse(int32_t start, void Parse(int32_t start,
@ -50,11 +50,11 @@ class Highlight {
etk::Vector<colorInformation_ts> &metaData, etk::Vector<colorInformation_ts> &metaData,
etk::Buffer &buffer); etk::Buffer &buffer);
private: private:
void ParseRules(exml::Element* child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level); void ParseRules(exml::Element* child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level);
etk::UString 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::Vector<etk::UString*> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" etk::Vector<etk::UString> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
etk::Vector<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer) etk::Vector<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer)
etk::Vector<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) ) etk::Vector<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) )
}; };