[DEV] start move to exml
This commit is contained in:
parent
86552172d7
commit
24bb4f515c
@ -16,7 +16,7 @@
|
|||||||
#define __class__ "Highlight"
|
#define __class__ "Highlight"
|
||||||
|
|
||||||
|
|
||||||
void Highlight::ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level)
|
void Highlight::ParseRules(exml::Element* child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level)
|
||||||
{
|
{
|
||||||
// Create the patern ...
|
// Create the patern ...
|
||||||
HighlightPattern *myPattern = new HighlightPattern();
|
HighlightPattern *myPattern = new HighlightPattern();
|
||||||
@ -28,99 +28,62 @@ void Highlight::ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mLi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Highlight::Highlight(etk::UString &xmlFilename)
|
Highlight::Highlight(const etk::UString& _xmlFilename)
|
||||||
{
|
{
|
||||||
TiXmlDocument XmlDocument;
|
exml::Document doc;
|
||||||
|
if (doc.Load(_fileName)==false) {
|
||||||
etk::FSNode fileName(xmlFilename);
|
EWOL_ERROR(" can not load file XML : " << _fileName);
|
||||||
if (false == fileName.Exist()) {
|
return false;
|
||||||
APPL_ERROR("File Does not exist : " << fileName);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
int32_t fileSize = fileName.FileSize();
|
exml::Element* root = (exml::Element*)doc.GetNamed("EdnLang");
|
||||||
if (0==fileSize) {
|
if (NULL == root ) {
|
||||||
APPL_ERROR("This file is empty : " << fileName);
|
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ...");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
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
|
|
||||||
bool loadError = XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
|
|
||||||
if (false == loadError) {
|
|
||||||
APPL_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename << "\"");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" );
|
|
||||||
if (NULL == root) {
|
|
||||||
APPL_ERROR( "can not load Hightlight XML: main node not find: \"EdnLang\"");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t level1 = 0;
|
int32_t level1 = 0;
|
||||||
int32_t level2 = 0;
|
int32_t level2 = 0;
|
||||||
TiXmlNode * child = root->FirstChild();
|
// parse all the elements :
|
||||||
while(NULL != child)
|
for(int32_t iii=0; iii< _node->Size(); iii++) {
|
||||||
{
|
exml::Element* child = (exml::Element*)_node->Get(iii);
|
||||||
if (child->Type()==TiXmlNode::TINYXML_COMMENT) {
|
if (child==NULL) {
|
||||||
// nothing to do ...
|
continue;
|
||||||
} else if (!strcmp(child->Value(), "ext")) {
|
}
|
||||||
const char *myData = child->ToElement()->GetText();
|
if (child->GetValue() == "ext") {
|
||||||
|
const char *myData = child->GetText();
|
||||||
if (NULL != myData) {
|
if (NULL != myData) {
|
||||||
//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);
|
etk::UString * myEdnData = new etk::UString(myData);
|
||||||
m_listExtentions.PushBack(myEdnData);
|
m_listExtentions.PushBack(myEdnData);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(child->Value(), "pass1")) {
|
} else if (child->GetValue()=="pass1") {
|
||||||
// Get sub Nodes ...
|
// Get sub Nodes ...
|
||||||
TiXmlNode *passChild = child->FirstChild();
|
for(int32_t jjj=0; jjj< child->Size(); jjj++) {
|
||||||
while (NULL != passChild) {
|
exml::Element* passChild = (exml::Element*)child->Get(jjj);
|
||||||
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
|
if (passChild==NULL) {
|
||||||
// nothing to do ...
|
continue;
|
||||||
} else if (!strcmp(passChild->Value(), "rule")) {
|
|
||||||
ParseRules(passChild, m_listHighlightPass1, level1++);
|
|
||||||
} else {
|
|
||||||
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
|
|
||||||
}
|
}
|
||||||
// get the next node element :
|
if (passChild->GetValue() != "rule") {
|
||||||
passChild = passChild->NextSibling();
|
APPL_ERROR("(l "<< passChild->Pos() << ") node not suported : \""<< passChild->GetValue() << "\" must be [rule]" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ParseRules(passChild, m_listHighlightPass1, level1++);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(child->Value(), "pass2")) {
|
} else if (child->GetValue() == "pass2") {
|
||||||
// Get sub Nodes ...
|
// Get sub Nodes ...
|
||||||
TiXmlNode *passChild = child->FirstChild();
|
for(int32_t jjj=0; jjj< child->Size(); jjj++) {
|
||||||
while (NULL != passChild) {
|
exml::Element* passChild = (exml::Element*)child->Get(jjj);
|
||||||
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
|
if (passChild==NULL) {
|
||||||
// nothing to do ...
|
continue;
|
||||||
} else if (!strcmp(passChild->Value(), "rule")) {
|
|
||||||
ParseRules(passChild, m_listHighlightPass2, level2++);
|
|
||||||
} else {
|
|
||||||
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
|
|
||||||
}
|
}
|
||||||
// get the next node element :
|
if (passChild->GetValue() != "rule") {
|
||||||
passChild = passChild->NextSibling();
|
APPL_ERROR("(l "<< passChild->Pos() << ") node not suported : \""<< passChild->GetValue() << "\" must be [rule]" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ParseRules(passChild, m_listHighlightPass2, level2++);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
APPL_ERROR("(l "<< child->Row() << ") node not suported : \""<< child->Value() << "\" must be [ext,pass1,pass2]" );
|
APPL_ERROR("(l "<< child->Pos() << ") node not suported : \""<< child->GetValue() << "\" must be [ext,pass1,pass2]" );
|
||||||
}
|
}
|
||||||
// get the next node element :
|
|
||||||
child = child->NextSibling();
|
|
||||||
}
|
|
||||||
if (NULL != fileBuffer) {
|
|
||||||
delete[] fileBuffer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,12 +29,12 @@ extern "C" {
|
|||||||
#include <HighlightPattern.h>
|
#include <HighlightPattern.h>
|
||||||
#include <Colorize.h>
|
#include <Colorize.h>
|
||||||
#include <etk/Buffer.h>
|
#include <etk/Buffer.h>
|
||||||
#include <tinyXML/tinyxml.h>
|
#include <exml/exml.h>
|
||||||
|
|
||||||
class Highlight {
|
class Highlight {
|
||||||
public:
|
public:
|
||||||
// Constructeur
|
// Constructeur
|
||||||
Highlight(etk::UString &xmlFilename);
|
Highlight(const etk::UString& _xmlFilename);
|
||||||
~Highlight(void);
|
~Highlight(void);
|
||||||
bool HasExtention(etk::UString &ext);
|
bool HasExtention(etk::UString &ext);
|
||||||
bool FileNameCompatible(etk::FSNode &fileName);
|
bool FileNameCompatible(etk::FSNode &fileName);
|
||||||
@ -50,7 +50,7 @@ class Highlight {
|
|||||||
etk::Vector<colorInformation_ts> &metaData,
|
etk::Vector<colorInformation_ts> &metaData,
|
||||||
etk::Buffer &buffer);
|
etk::Buffer &buffer);
|
||||||
private:
|
private:
|
||||||
void ParseRules(TiXmlNode *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)
|
||||||
|
@ -107,7 +107,7 @@ void HighlightPattern::Display(void)
|
|||||||
m_subPatern[i]->Display();
|
m_subPatern[i]->Display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
|
void HighlightPattern::ParseRules(exml::Element *child, int32_t level)
|
||||||
{
|
{
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
/*
|
/*
|
||||||
@ -120,51 +120,51 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
|
|||||||
*/
|
*/
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
// process attribute
|
// process attribute
|
||||||
const char *highLightName = child->ToElement()->Attribute("name");
|
etk::UString highLightName = child->GetAttribute("name");
|
||||||
etk::UString myEdnDataTmp = "???";
|
etk::UString myEdnDataTmp = "???";
|
||||||
if (NULL != highLightName) {
|
if (highLightName.Size()!=0) {
|
||||||
myEdnDataTmp = highLightName;
|
myEdnDataTmp = highLightName;
|
||||||
}
|
}
|
||||||
SetName(myEdnDataTmp);
|
SetName(myEdnDataTmp);
|
||||||
SetLevel(level);
|
SetLevel(level);
|
||||||
|
|
||||||
TiXmlElement *xChild = child->FirstChildElement("color");
|
exml::Element* xChild = (exml::Element*)child->GetNamed("color");
|
||||||
if (NULL != xChild) {
|
if (NULL != xChild) {
|
||||||
const char *myData = xChild->GetText();
|
etk::UString myData = xChild->GetText();
|
||||||
if (myData) {
|
if (myData.Size()!=0) {
|
||||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||||
etk::UString myEdnData = myData;
|
etk::UString myEdnData = myData;
|
||||||
SetColor(myEdnData);
|
SetColor(myEdnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xChild = child->FirstChildElement("start");
|
xChild = (exml::Element*)child->GetNamed("start");
|
||||||
if (NULL != xChild) {
|
if (NULL != xChild) {
|
||||||
const char *myData = xChild->GetText();
|
etk::UString myData = xChild->GetText();
|
||||||
if (myData) {
|
if (myData.Size()!=0) {
|
||||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||||
etk::UString myEdnData = myData;
|
etk::UString myEdnData = myData;
|
||||||
SetPaternStart(myEdnData);
|
SetPaternStart(myEdnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xChild = child->FirstChildElement("end");
|
xChild = (exml::Element*)child->GetNamed("end");
|
||||||
if (NULL != xChild) {
|
if (NULL != xChild) {
|
||||||
const char *myData = xChild->GetText();
|
etk::UString myData = xChild->GetText();
|
||||||
if (myData) {
|
if (myData.Size()!=0) {
|
||||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||||
etk::UString myEdnData = myData;
|
etk::UString myEdnData = myData;
|
||||||
SetPaternStop(myEdnData);
|
SetPaternStop(myEdnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xChild = child->FirstChildElement("EscapeChar");
|
xChild = (exml::Element*)child->GetNamed("EscapeChar");
|
||||||
if (NULL != xChild) {
|
if (NULL != xChild) {
|
||||||
const char *myData = xChild->GetText();
|
etk::UString myData = xChild->GetText();
|
||||||
if (myData) {
|
if (myData.Size()!=0) {
|
||||||
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
|
||||||
etk::UString myEdnData = myData;
|
etk::UString myEdnData = myData;
|
||||||
SetEscapeChar(myEdnData);
|
SetEscapeChar(myEdnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xChild = child->FirstChildElement("rule");
|
xChild = (exml::Element*)child->GetNamed("rule");
|
||||||
if (NULL != xChild) {
|
if (NULL != xChild) {
|
||||||
/*
|
/*
|
||||||
// Create the patern ...
|
// Create the patern ...
|
||||||
|
@ -17,7 +17,7 @@ class HighlightPattern;
|
|||||||
#include <etk/RegExp.h>
|
#include <etk/RegExp.h>
|
||||||
#include <Colorize.h>
|
#include <Colorize.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
#include <tinyXML/tinyxml.h>
|
#include <exml/exml.h>
|
||||||
#include <etk/Buffer.h>
|
#include <etk/Buffer.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -50,7 +50,7 @@ class HighlightPattern {
|
|||||||
void Display(void);
|
void Display(void);
|
||||||
resultFind_te Find(int32_t start, int32_t stop, colorInformation_ts &resultat, etk::Buffer &buffer);
|
resultFind_te Find(int32_t start, int32_t stop, colorInformation_ts &resultat, etk::Buffer &buffer);
|
||||||
Colorize * GetColor(void) { return m_color; };
|
Colorize * GetColor(void) { return m_color; };
|
||||||
void ParseRules(TiXmlNode *child, int32_t level);
|
void ParseRules(exml::Element *child, int32_t level);
|
||||||
|
|
||||||
void ReloadColor(void);
|
void ReloadColor(void);
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@ void APP_Init(void)
|
|||||||
// set the application icon ...
|
// set the application icon ...
|
||||||
ewol::SetIcon("DATA:icon.png");
|
ewol::SetIcon("DATA:icon.png");
|
||||||
|
|
||||||
|
|
||||||
// init ALL Singleton :
|
// init ALL Singleton :
|
||||||
//(void)CTagsManager::getInstance();
|
//(void)CTagsManager::getInstance();
|
||||||
BufferManager::Init();
|
BufferManager::Init();
|
||||||
@ -137,7 +136,7 @@ void APP_Init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
APPL_INFO("==> Init Edn (END)");
|
APPL_INFO("==> Init "PROJECT_NAME" (END)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -146,7 +145,7 @@ void APP_Init(void)
|
|||||||
*/
|
*/
|
||||||
void APP_UnInit(void)
|
void APP_UnInit(void)
|
||||||
{
|
{
|
||||||
APPL_INFO("==> Un-Init Edn (START)");
|
APPL_INFO("==> Un-Init "PROJECT_NAME" (START)");
|
||||||
|
|
||||||
if (NULL != basicWindows) {
|
if (NULL != basicWindows) {
|
||||||
delete(basicWindows);
|
delete(basicWindows);
|
||||||
@ -162,6 +161,6 @@ void APP_UnInit(void)
|
|||||||
BufferManager::UnInit();
|
BufferManager::UnInit();
|
||||||
APPL_INFO("Stop ColorizeManager");
|
APPL_INFO("Stop ColorizeManager");
|
||||||
ColorizeManager::UnInit();
|
ColorizeManager::UnInit();
|
||||||
APPL_INFO("==> Un-Init Edn (END)");
|
APPL_INFO("==> Un-Init "PROJECT_NAME" (END)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user