[DEV] work on highlight

This commit is contained in:
Edouard DUPIN 2013-10-25 22:12:34 +02:00
parent 6f4a67b47b
commit 8eb4aff266
14 changed files with 249 additions and 512 deletions

View File

@ -0,0 +1,9 @@
{
"ednColor": [
{ name="LIST_backgroung1", foreground="#202020" },
{ name="LIST_backgroung2", foreground="#000000" },
{ name="LIST_backgroungSelected", foreground="#2f0ba4" },
{ name="LIST_textNormal", foreground="#EEEEEE" },
{ name="LIST_textModify", foreground="#FF0000" },
]
}

View File

@ -5,12 +5,6 @@
{ name="CODE_tabulation", foreground="#444444" }, { name="CODE_tabulation", foreground="#444444" },
{ name="CODE_cursor", foreground="#eadd05" }, { name="CODE_cursor", foreground="#eadd05" },
{ name="CODE_lineNumber", foreground="#fff725" }, { name="CODE_lineNumber", foreground="#fff725" },
{ name="LIST_backgroung1", foreground="#202020" },
{ name="LIST_backgroung2", foreground="#000000" },
{ name="LIST_backgroungSelected", foreground="#2f0ba4" },
{ name="LIST_textNormal", foreground="#EEEEEE" },
{ name="LIST_textModify", foreground="#FF0000" },
{ name="normal", foreground="#EEEEEE"}, { name="normal", foreground="#EEEEEE"},
{ name="SelectedText", foreground="#AAAAAA", background="#225a09"}, { name="SelectedText", foreground="#AAAAAA", background="#225a09"},
{ name="error", foreground="#FF0000"}, { name="error", foreground="#FF0000"},

View File

@ -10,7 +10,7 @@
#include <appl/global.h> #include <appl/global.h>
#include <BufferView.h> #include <BufferView.h>
#include <BufferManager.h> #include <BufferManager.h>
#include <ColorizeManager.h> //#include <ColorizeManager.h>
#include <MainWindows.h> #include <MainWindows.h>
#include <ewol/renderer/EObject.h> #include <ewol/renderer/EObject.h>

View File

@ -10,7 +10,7 @@
#include <appl/global.h> #include <appl/global.h>
#include <TextViewer.h> #include <TextViewer.h>
#include <BufferManager.h> #include <BufferManager.h>
#include <ColorizeManager.h> //#include <ColorizeManager.h>
#include <ewol/clipBoard.h> #include <ewol/clipBoard.h>
#include <SearchData.h> #include <SearchData.h>

View File

@ -10,28 +10,35 @@
#include <appl/global.h> #include <appl/global.h>
#include <Highlight.h> #include <Highlight.h>
#include <exml/exml.h> #include <exml/exml.h>
#include <ewol/resources/ResourceManager.h>
#undef __class__ #undef __class__
#define __class__ "Highlight" #define __class__ "Highlight"
void Highlight::parseRules(exml::Element* _child, etk::Vector<HighlightPattern*>& _mListPatern, int32_t _level) { void appl::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(m_paintingProperties);
// parse under Element // parse under Element
myPattern->parseRules(_child, _level); myPattern->parseRules(_child, _level);
// add element in the list // add element in the list
_mListPatern.pushBack(myPattern); _mListPatern.pushBack(myPattern);
} }
Highlight::Highlight(const etk::UString& _xmlFilename) { appl::Highlight::Highlight(const etk::UString& _xmlFilename, const etk::UString& _colorFile) :
ewol::Resource(_xmlFilename) {
// keep color propertiy file :
m_paintingProperties = appl::GlyphPainting::keep(_colorFile);
exml::Document doc; exml::Document doc;
if (doc.load(_xmlFilename) == false) { if (doc.load(_xmlFilename) == false) {
APPL_ERROR(" can not load file XML : " << _xmlFilename); APPL_ERROR(" can not load file XML : " << _xmlFilename);
return; return;
} }
exml::Element* root = (exml::Element*)doc.getNamed("EdnLang"); exml::Element* root = doc.getNamed("EdnLang");
if (NULL == root ) { if (NULL == root ) {
APPL_ERROR("(l ?) main node not find: \"EdnLang\" ..."); APPL_ERROR("(l ?) main node not find: \"EdnLang\" ...");
return; return;
@ -39,7 +46,7 @@ Highlight::Highlight(const etk::UString& _xmlFilename) {
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< root->size(); iii++) { for(int32_t iii = 0; iii < root->size(); ++iii) {
exml::Element* child = root->getElement(iii); exml::Element* child = root->getElement(iii);
if (child == NULL) { if (child == NULL) {
// trash here all that is not element ... // trash here all that is not element ...
@ -83,13 +90,13 @@ Highlight::Highlight(const etk::UString& _xmlFilename) {
} }
} }
Highlight::~Highlight(void) { appl::Highlight::~Highlight(void) {
int32_t i; int32_t i;
// clean all Element // clean all Element
for (i=0; i< m_listHighlightPass1.size(); i++) { for (esize_t iii = 0; iii < m_listHighlightPass1.size(); ++iii) {
if (NULL != m_listHighlightPass1[i]) { if (m_listHighlightPass1[iii] != NULL) {
delete(m_listHighlightPass1[i]); delete(m_listHighlightPass1[iii]);
m_listHighlightPass1[i] = NULL; m_listHighlightPass1[iii] = NULL;
} }
} }
// clear the compleate list // clear the compleate list
@ -98,38 +105,25 @@ Highlight::~Highlight(void) {
m_listExtentions.clear(); m_listExtentions.clear();
} }
void Highlight::reloadColor(void) { bool appl::Highlight::hasExtention(const etk::UString& _ext) {
int32_t i;
for (i=0; i< m_listHighlightPass1.size(); i++) {
if (NULL != m_listHighlightPass1[i]) {
m_listHighlightPass1[i]->reloadColor();
}
}
for (i=0; i< m_listHighlightPass2.size(); i++) {
if (NULL != m_listHighlightPass2[i]) {
m_listHighlightPass2[i]->reloadColor();
}
}
}
bool Highlight::hasExtention(const etk::UString& _ext) {
for (int32_t iii=0; iii<m_listExtentions.size(); iii++) { for (int32_t iii=0; iii<m_listExtentions.size(); iii++) {
if (_ext == m_listExtentions[iii] ) { if (m_listExtentions[iii] == _ext) {
return true; return true;
} }
} }
return false; return false;
} }
bool Highlight::fileNameCompatible(etk::FSNode &_fileName) { bool appl::Highlight::fileNameCompatible(const etk::UString& _fileName) {
etk::UString extention; etk::UString extention;
if (true == _fileName.fileHasExtention() ) { etk::FSNode file(_fileName);
if (true == file.fileHasExtention() ) {
extention = "*."; extention = "*.";
extention += _fileName.fileGetExtention(); extention += file.fileGetExtention();
} else { } else {
extention = _fileName.getNameFile(); extention = file.getNameFile();
} }
APPL_DEBUG(" try to find : in \"" << _fileName << "\" extention:\"" << extention << "\" "); APPL_DEBUG(" try to find : in \"" << file << "\" extention:\"" << extention << "\" ");
for (int32_t iii=0; iii<m_listExtentions.size(); iii++) { for (int32_t iii=0; iii<m_listExtentions.size(); iii++) {
if (extention == m_listExtentions[iii] ) { if (extention == m_listExtentions[iii] ) {
@ -140,7 +134,7 @@ bool Highlight::fileNameCompatible(etk::FSNode &_fileName) {
} }
void Highlight::display(void) { void appl::Highlight::display(void) {
APPL_INFO("List of ALL Highlight : "); APPL_INFO("List of ALL Highlight : ");
for (int32_t iii=0; iii< m_listExtentions.size(); iii++) { for (int32_t iii=0; iii< m_listExtentions.size(); iii++) {
APPL_INFO(" Extention : " << iii << " : " << m_listExtentions[iii] ); APPL_INFO(" Extention : " << iii << " : " << m_listExtentions[iii] );
@ -148,19 +142,19 @@ void Highlight::display(void) {
// display all elements // display all elements
for (int32_t iii=0; iii< m_listHighlightPass1.size(); iii++) { for (int32_t iii=0; iii< m_listHighlightPass1.size(); iii++) {
APPL_INFO(" " << iii << " Pass 1 : " << m_listHighlightPass1[iii]->getName() ); APPL_INFO(" " << iii << " Pass 1 : " << m_listHighlightPass1[iii]->getName() );
//m_listHighlightPass1[i]->display(); //m_listHighlightPass1[iii]->display();
} }
// display all elements // display all elements
for (int32_t iii=0; iii< m_listHighlightPass2.size(); iii++) { for (int32_t iii=0; iii< m_listHighlightPass2.size(); iii++) {
APPL_INFO(" " << iii << " Pass 2 : " << m_listHighlightPass2[iii]->getName() ); APPL_INFO(" " << iii << " Pass 2 : " << m_listHighlightPass2[iii]->getName() );
//m_listHighlightPass2[i]->display(); //m_listHighlightPass2[iii]->display();
} }
} }
// 13h 46min 22s | (l= 214) Highlight::Parse | [II] find Pattern in the Buffer : (2457,2479)
/* TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas trègrave...
// TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas trègrave... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer... * Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
void Highlight::parse(int32_t start, */
void appl::Highlight::parse(int32_t start,
int32_t stop, int32_t stop,
etk::Vector<appl::ColorInfo> &metaData, etk::Vector<appl::ColorInfo> &metaData,
int32_t addingPos, int32_t addingPos,
@ -223,7 +217,7 @@ void Highlight::parse(int32_t start,
* @brief second pass of the hightlight * @brief second pass of the hightlight
* *
*/ */
void Highlight::parse2(int32_t start, void appl::Highlight::parse2(int32_t start,
int32_t stop, int32_t stop,
etk::Vector<appl::ColorInfo> &metaData, etk::Vector<appl::ColorInfo> &metaData,
etk::Buffer &buffer) { etk::Buffer &buffer) {
@ -254,3 +248,29 @@ void Highlight::parse2(int32_t start,
} }
} }
appl::Highlight* appl::Highlight::keep(const etk::UString& _filename) {
//EWOL_INFO("KEEP : appl::Highlight : file : \"" << _filename << "\"");
appl::Highlight* object = static_cast<appl::Highlight*>(getManager().localKeep(_filename));
if (NULL != object) {
return object;
}
EWOL_INFO("CREATE : appl::Highlight : file : \"" << _filename << "\"");
// this element create a new one every time ....
object = new appl::Highlight(_filename, "THEME:COLOR:textViewer.json");
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Highlight??");
return NULL;
}
getManager().localAdd(object);
return object;
}
void appl::Highlight::release(appl::Highlight*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -10,11 +10,11 @@
#define __HIGHLIGHT_H__ #define __HIGHLIGHT_H__
class appl { namespace appl {
class Highlight; class Highlight;
class HighlightPattern; class HighlightPattern;
class ColorInfo{ class ColorInfo {
public: public:
int32_t beginStart; int32_t beginStart;
int32_t beginStop; int32_t beginStop;
@ -27,20 +27,22 @@ class appl {
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
#include <HighlightPattern.h> #include <HighlightPattern.h>
#include <Colorize.h> #include <appl/glyphDecoration/GlyphPainting.h>
#include <etk/Buffer.h> #include <etk/Buffer.h>
#include <exml/exml.h> #include <exml/exml.h>
class appl { namespace appl {
class Highlight : public ewol::EObject { class Highlight : public ewol::Resource {
public: private:
appl::GlyphPainting* m_paintingProperties;
protected:
// Constructeur // Constructeur
Highlight(const etk::UString& _xmlFilename); Highlight(const etk::UString& _xmlFilename, const etk::UString& _colorFile);
~Highlight(void); ~Highlight(void);
public:
bool hasExtention(const etk::UString& _ext); bool hasExtention(const etk::UString& _ext);
bool fileNameCompatible(etk::FSNode &_fileName); bool fileNameCompatible(const etk::UString& _fileName);
void display(void); void display(void);
void reloadColor(void);
void parse(int32_t _start, void parse(int32_t _start,
int32_t _stop, int32_t _stop,
etk::Vector<appl::ColorInfo> &_metaData, etk::Vector<appl::ColorInfo> &_metaData,
@ -58,6 +60,23 @@ class appl {
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)) )
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @param[in] _filename Name of the configuration file.
* @return pointer on the resource or NULL if an error occured.
*/
static appl::Highlight* keep(const etk::UString& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(appl::Highlight*& _object);
public: // herited function :
virtual void updateContext(void) {
// no upfate to do ...
};
}; };
}; };

View File

@ -15,14 +15,14 @@
#undef __class__ #undef __class__
#define __class__ "highlightManager" #define __class__ "highlightManager"
static etk::Vector<Highlight*>& s_list(void) { static etk::Vector<appl::Highlight*>& s_list(void) {
static etk::Vector<Highlight*> list; static etk::Vector<appl::Highlight*> list;
return list; return list;
} }
void appl::highlightManager::init(void) { void appl::highlightManager::init(void) {
etk::Vector<Highlight*>& hlList = s_list(); etk::Vector<appl::Highlight*>& hlList = s_list();
if (hlList.size() != 0) { if (hlList.size() != 0) {
APPL_ERROR("HighlightManager == > already exist, just unlink the previous ..."); APPL_ERROR("HighlightManager == > already exist, just unlink the previous ...");
hlList.clear(); hlList.clear();
@ -30,9 +30,7 @@ void appl::highlightManager::init(void) {
etk::FSNode myFile("DATA:languages/"); etk::FSNode myFile("DATA:languages/");
// get the subfolder list : // get the subfolder list :
etk::Vector<etk::FSNode *> list = myFile.folderGetSubList(false, true, false,false); etk::Vector<etk::FSNode *> list = myFile.folderGetSubList(false, true, false,false);
for (esize_t iii=0; for (esize_t iii = 0; iii < list.size(); ++iii) {
iii<list.size();
++iii ) {
if (list[iii] == NULL) { if (list[iii] == NULL) {
continue; continue;
} }
@ -41,8 +39,19 @@ void appl::highlightManager::init(void) {
} }
etk::UString filename = list[iii]->getName() + "/highlight.xml"; etk::UString filename = list[iii]->getName() + "/highlight.xml";
APPL_DEBUG("Load xml name : " << filename); APPL_DEBUG("Load xml name : " << filename);
appl::Highlight *myHightline = appl::Highlight::keep(filename); appl::Highlight *myHightLine = appl::Highlight::keep(filename);
hlList.pushBack(myHightline); if (myHightLine != NULL) {
hlList.pushBack(myHightLine);
} else {
APPL_ERROR("Can not allocate HighLight");
}
}
// display :
for (esize_t iii = 0; iii < hlList.size(); ++iii) {
if (hlList[iii] == NULL) {
continue;
}
hlList[iii]->display();
} }
} }
@ -53,9 +62,7 @@ void appl::highlightManager::unInit(void) {
hlList.clear(); hlList.clear();
return; return;
} }
for (esize_t iii = 0; for (esize_t iii = 0; iii < hlList.size(); ++iii) {
iii < hlList.size();
++iii ) {
if (hlList[iii] == NULL) { if (hlList[iii] == NULL) {
continue; continue;
} }

View File

@ -9,79 +9,79 @@
#include <appl/Debug.h> #include <appl/Debug.h>
#include <appl/global.h> #include <appl/global.h>
#include <HighlightPattern.h> #include <HighlightPattern.h>
#include <ColorizeManager.h>
#undef __class__ #undef __class__
#define __class__ "HighlightPattern" #define __class__ "HighlightPattern"
HighlightPattern::HighlightPattern(void) { appl::HighlightPattern::HighlightPattern(appl::GlyphPainting*& _glyphPainting) :
m_haveStopPatern = false; m_glyphPainting(_glyphPainting),
m_multiline = false; m_paternName(""),
m_color = ColorizeManager::get("normal"); m_regExpStart(NULL),
m_regExpStop(NULL),
m_colorName(""),
m_escapeChar(etk::UChar::Null),
m_multiline(false),
m_level(0) {
m_regExpStart = new etk::RegExp<etk::Buffer>(); m_regExpStart = new etk::RegExp<etk::Buffer>();
m_regExpStop = new etk::RegExp<etk::Buffer>();
m_escapeChar = 0;
} }
HighlightPattern::~HighlightPattern(void) { appl::HighlightPattern::~HighlightPattern(void) {
delete(m_regExpStart); if (m_regExpStart != NULL) {
delete(m_regExpStop); delete(m_regExpStart);
m_regExpStart = NULL;
}
if (m_regExpStop != NULL) {
delete(m_regExpStop);
m_regExpStop = NULL;
}
} }
void HighlightPattern::setPaternStart(etk::UString& _regExp) { void appl::HighlightPattern::setPaternStart(etk::UString& _regExp) {
if (m_regExpStart == NULL) {
return;
}
m_regExpStart->setRegExp(_regExp); m_regExpStart->setRegExp(_regExp);
} }
void HighlightPattern::setPaternStop(etk::UString& _regExp) { void appl::HighlightPattern::setPaternStop(etk::UString& _regExp) {
if (m_regExpStop != NULL) {
delete(m_regExpStop);
m_regExpStop = NULL;
}
if (_regExp.size() != 0) { if (_regExp.size() != 0) {
m_regExpStop->setRegExp(_regExp); m_regExpStop = new etk::RegExp<etk::Buffer>();
m_haveStopPatern = true; if (m_regExpStop != NULL) {
} else { m_regExpStop->setRegExp(_regExp);
m_haveStopPatern = false; } else {
APPL_ERROR("Allocation error");
}
} }
} }
void HighlightPattern::setEscapeChar(etk::UString& _EscapeChar) { void appl::HighlightPattern::setEscapeChar(const etk::UChar& _EscapeChar) {
if (_EscapeChar.size()>0) { m_escapeChar = _EscapeChar;
m_escapeChar = _EscapeChar[0];
} else {
m_escapeChar = 0;
}
} }
void HighlightPattern::setColorGlyph(etk::UString& _colorName) { void appl::HighlightPattern::setColorGlyph(etk::UString& _colorName) {
m_colorName = _colorName; m_colorName = _colorName;
m_color = ColorizeManager::get(m_colorName); m_colorId = m_glyphPainting->request(m_colorName);
} }
bool HighlightPattern::isEnable(void) { void appl::HighlightPattern::display(void) {
return true;
}
void HighlightPattern::reloadColor(void) {
m_color = ColorizeManager::get(m_colorName);
}
void HighlightPattern::display(void) {
/*
APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level ); APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
APPL_INFO(" == > colorName \"" << m_colorName << "\""); APPL_INFO(" == > colorName \"" << m_colorName << "\"");
APPL_INFO(" == > regExpStart \"" << m_regExpStart->getRegExp() << "\""); APPL_INFO(" == > regExpStart \"" << m_regExpStart->getRegExp() << "\"");
APPL_INFO(" == > regExpStop \"" << m_regExpStop->getRegExp() << "\""); if (m_regExpStop != NULL) {
if (true == m_haveStopPatern) { APPL_INFO(" == > regExpStop \"" << m_regExpStop->getRegExp() << "\"");
APPL_INFO(" == > stop pattern: YES");
} else {
APPL_INFO(" == > stop pattern: NO");
} }
if (true == m_multiline) { if (m_multiline == true) {
APPL_INFO(" == > multiline pattern: YES"); APPL_INFO(" == > multiline pattern: YES");
} else { } else {
APPL_INFO(" == > multiline pattern: NO"); APPL_INFO(" == > multiline pattern: NO");
} }
*/
} }
void HighlightPattern::parseRules(exml::Element *child, int32_t level) { void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
/* /*
<rule name="my preprocesseur"> <rule name="my preprocesseur">
@ -93,101 +93,92 @@ void HighlightPattern::parseRules(exml::Element *child, int32_t level) {
*/ */
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
// process attribute // process attribute
etk::UString highLightName = child->getAttribute("name"); etk::UString highLightName = _child->getAttribute("name");
etk::UString myEdnDataTmp = "???"; etk::UString myEdnDataTmp = "???";
if (highLightName.size()!=0) { if (highLightName.size()!=0) {
myEdnDataTmp = highLightName; myEdnDataTmp = highLightName;
} }
setName(myEdnDataTmp); setName(myEdnDataTmp);
setLevel(level); setLevel(_level);
exml::Element* xChild = (exml::Element*)child->getNamed("color"); exml::Element* xChild = _child->getNamed("color");
if (NULL != xChild) { if (NULL != xChild) {
etk::UString myData = xChild->getText(); etk::UString myData = xChild->getText();
if (myData.size()!=0) { 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); setColorGlyph(myEdnData);
} }
} }
xChild = (exml::Element*)child->getNamed("start"); xChild = _child->getNamed("start");
if (NULL != xChild) { if (NULL != xChild) {
etk::UString myData = xChild->getText(); etk::UString myData = xChild->getText();
if (myData.size()!=0) { 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 = (exml::Element*)child->getNamed("end"); xChild = _child->getNamed("end");
if (NULL != xChild) { if (NULL != xChild) {
etk::UString myData = xChild->getText(); etk::UString myData = xChild->getText();
if (myData.size()!=0) { 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 = (exml::Element*)child->getNamed("EscapeChar"); xChild = _child->getNamed("EscapeChar");
if (NULL != xChild) { if (NULL != xChild) {
etk::UString myData = xChild->getText(); etk::UString myData = xChild->getText();
if (myData.size()!=0) { 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; setEscapeChar(myData[0]);
setEscapeChar(myEdnData);
} }
} }
} }
/** resultFind_te appl::HighlightPattern::find(int32_t _start,
* @brief find Element only in the specify start characters and find the end with the range done int32_t _stop,
* appl::ColorInfo& _resultat,
* @param[in] start First character to search data (if recognise it start here) etk::Buffer& _buffer) {
* @param[in] stop End of the possibility whe search can continue
* @param[out] resultat Position where find data
* @param[in] buffer : Where to search data
*
* @return HLP_FIND_OK We find a compleate pattern
* @return HLP_FIND_OK_NO_END Xe find a partial pattern (missing end)
* @return HLP_FIND_ERROR Not find the pattern
*/
resultFind_te HighlightPattern::find(int32_t start, int32_t stop, colorInformation_ts &resultat, etk::Buffer &buffer) {
//APPL_DEBUG(" try to find the element"); //APPL_DEBUG(" try to find the element");
resultat.beginStart = -1; _resultat.beginStart = -1;
resultat.beginStop = -1; _resultat.beginStop = -1;
resultat.endStart = -1; _resultat.endStart = -1;
resultat.endStop = -1; _resultat.endStop = -1;
resultat.notEnded = false; _resultat.notEnded = false;
resultat.patern = this; _resultat.patern = this;
// when we have only one element : // when we have only one element:
if (false == m_haveStopPatern) { if (m_regExpStop == NULL) {
if (true == m_regExpStart->processOneElement(buffer, start, stop)) { if (true == m_regExpStart->processOneElement(_buffer, _start, _stop)) {
resultat.beginStart = m_regExpStart->start(); _resultat.beginStart = m_regExpStart->start();
resultat.beginStop = m_regExpStart->stop(); _resultat.beginStop = m_regExpStart->stop();
resultat.endStart = m_regExpStart->start(); _resultat.endStart = m_regExpStart->start();
resultat.endStop = m_regExpStart->stop(); _resultat.endStop = m_regExpStart->stop();
return HLP_FIND_OK; return HLP_FIND_OK;
} }
//APPL_DEBUG("NOT find hightlightpatern ..."); //APPL_DEBUG("NOT find hightlightpatern ...");
} else { return HLP_FIND_ERROR;
// try while we find the first element
if (true == m_regExpStart->processOneElement(buffer, start, stop, m_escapeChar)) {
resultat.beginStart = m_regExpStart->start();
resultat.beginStop = m_regExpStart->stop();
if (true == m_regExpStop->process(buffer, resultat.beginStop, stop, m_escapeChar)) {
resultat.endStart = m_regExpStop->start();
resultat.endStop = m_regExpStop->stop();
return HLP_FIND_OK;
} else {
resultat.endStart = stop+1;
resultat.endStop = stop+1;
resultat.notEnded = true;
return HLP_FIND_OK_NO_END;
}
}
//APPL_DEBUG("NOT find start hightlightpatern ...");
} }
// try while we find the first element
if (m_regExpStart->processOneElement(_buffer, _start, _stop, m_escapeChar) == false) {
return HLP_FIND_ERROR;
}
_resultat.beginStart = m_regExpStart->start();
_resultat.beginStop = m_regExpStart->stop();
if (m_regExpStop->process(_buffer, _resultat.beginStop, _stop, m_escapeChar) == true) {
_resultat.endStart = m_regExpStop->start();
_resultat.endStop = m_regExpStop->stop();
return HLP_FIND_OK;
} else {
_resultat.endStart = _stop+1;
_resultat.endStop = _stop+1;
_resultat.notEnded = true;
return HLP_FIND_OK_NO_END;
}
//APPL_DEBUG("NOT find start hightlightpatern ...");
return HLP_FIND_ERROR; return HLP_FIND_ERROR;
} }

View File

@ -15,7 +15,7 @@ class HighlightPattern;
#include <etk/RegExp.h> #include <etk/RegExp.h>
#include <Colorize.h> #include <glyphDecoration/GlyphPainting.h>
#include <etk/Vector.h> #include <etk/Vector.h>
#include <exml/exml.h> #include <exml/exml.h>
#include <etk/Buffer.h> #include <etk/Buffer.h>
@ -28,9 +28,11 @@ typedef enum {
namespace appl { namespace appl {
class HighlightPattern { class HighlightPattern {
private:
appl::GlyphPainting*& m_glyphPainting;
public: public:
// Constructeur // Constructeur
HighlightPattern(void); HighlightPattern(appl::GlyphPainting*& _glyphPainting);
~HighlightPattern(void); ~HighlightPattern(void);
private: private:
etk::UString 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")
@ -46,22 +48,21 @@ namespace appl {
public: public:
void setPaternStart(etk::UString& _regExp); void setPaternStart(etk::UString& _regExp);
private: private:
bool m_haveStopPatern; //!< Stop patern presence
etk::RegExp<etk::Buffer>* m_regExpStop; //!< Stop of Regular Expression etk::RegExp<etk::Buffer>* m_regExpStop; //!< Stop of Regular Expression
public: public:
void setPaternStop(etk::UString& _regExp); void setPaternStop(etk::UString& _regExp);
private: private:
etk::UString m_colorName; //!< Current color name etk::UString m_colorName; //!< Current color name
appl::ColorGlyph* m_color; //!< Link to the color manager esize_t m_colorId; //!< Id of the the glyph painting
public: public:
void setColorGlyph(etk::UString& _colorName); void setColorGlyph(etk::UString& _colorName);
appl::ColorGlyph* getColorGlyph(void) { const appl::GlyphDecoration& getColorGlyph(void) {
return m_color; return (*m_glyphPainting)[m_colorId];
}; };
private: private:
etk::UChar m_escapeChar; //!< Escape char to prevent exeit of patern .... etk::UChar m_escapeChar; //!< Escape char to prevent exeit of patern ....
public: public:
void setEscapeChar(etk::UString& _EscapeChar); void setEscapeChar(const etk::UChar& _EscapeChar);
private: private:
bool m_multiline; //!< The patern is multiline bool m_multiline; //!< The patern is multiline
public: public:
@ -80,16 +81,23 @@ namespace appl {
private: private:
public: public:
bool isEnable(void);
void display(void); void display(void);
/**
* @brief find Element only in the specify start characters and find the end with the range done
* @param[in] _start First character to search data (if recognise it start here)
* @param[in] _stop End of the possibility whe search can continue
* @param[out] _resultat Position where find data
* @param[in] _buffer : Where to search data
* @return HLP_FIND_OK We find a compleate pattern
* @return HLP_FIND_OK_NO_END Xe find a partial pattern (missing end)
* @return HLP_FIND_ERROR Not find the pattern
*/
resultFind_te find(int32_t _start, resultFind_te find(int32_t _start,
int32_t _stop, int32_t _stop,
colorInformation_ts& _resultat, appl::ColorInfo& _resultat,
etk::Buffer& _buffer); etk::Buffer& _buffer);
void parseRules(exml::Element* _child, int32_t _level); void parseRules(exml::Element* _child, int32_t _level);
void reloadColor(void);
}; };
}; };

View File

@ -7,7 +7,7 @@
*/ */
#include <appl/global.h> #include <appl/global.h>
#include <ColorizeManager.h> //#include <ColorizeManager.h>
#include <appl/globalMsg.h> #include <appl/globalMsg.h>
#include <ewol/renderer/EObject.h> #include <ewol/renderer/EObject.h>
#include <ewol/renderer/eContext.h> #include <ewol/renderer/eContext.h>

View File

@ -59,7 +59,7 @@ void appl::GlyphPainting::reload(void) {
m_list[jjj].setBackground(background); m_list[jjj].setBackground(background);
m_list[jjj].setItalic(italic); m_list[jjj].setItalic(italic);
m_list[jjj].setBold(bold); m_list[jjj].setBold(bold);
findElement == true; findElement = true;
} }
if (findElement == true) { if (findElement == true) {
continue; continue;
@ -76,26 +76,27 @@ void appl::GlyphPainting::reload(void) {
esize_t appl::GlyphPainting::request(const etk::UString& _name) { esize_t appl::GlyphPainting::request(const etk::UString& _name) {
for (esize_t iii=0; iii<m_list.size(); ++iii) { for (esize_t iii=0; iii<m_list.size(); ++iii) {
if (m_list[iii].getName() == name) { if (m_list[iii].getName() == _name) {
return iii; return iii;
} }
} }
// create an empty deco ... // create an empty deco ...
appl::GlyphDecoration tmpDeco(name); appl::GlyphDecoration tmpDeco(_name);
m_list.pushBack(tmpDeco); m_list.pushBack(tmpDeco);
return m_list.size()-1; return m_list.size()-1;
} }
appl::GlyphPainting* appl::GlyphPainting::keep(const etk::UString& _filename) { appl::GlyphPainting* appl::GlyphPainting::keep(const etk::UString& _filename) {
EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\""); //EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\"");
appl::GlyphPainting* object = static_cast<appl::GlyphPainting*>(getManager().localKeep(_filename)); appl::GlyphPainting* object = static_cast<appl::GlyphPainting*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
// this element create a new one every time .... // this element create a new one every time ....
EWOL_INFO("CREATE : appl::GlyphPainting : file : \"" << _filename << "\"");
object = new appl::GlyphPainting(_filename); object = new appl::GlyphPainting(_filename);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Mesh.obj??"); EWOL_ERROR("allocation error of a resource : ??GlyphPainting??");
return NULL; return NULL;
} }
getManager().localAdd(object); getManager().localAdd(object);
@ -111,314 +112,3 @@ void appl::GlyphPainting::release(appl::GlyphPainting*& _object) {
_object = NULL; _object = NULL;
} }
class classColorManager: public ewol::EObject {
private:
etk::UString m_fileColor;
etk::Vector<Colorize*> listMyColor; //!< List of ALL Color
Colorize * errorColor;
etk::Color<> basicColors[COLOR_NUMBER_MAX];
public:
// Constructeur
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 "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;
}
*/
}
public:
void loadFile(const etk::UString& _xmlFilename);
Colorize* get(const etk::UString& _colorName) {
int32_t i;
for (i=0; i<listMyColor.size(); i++) {
if (listMyColor[i]->getName() == _colorName) {
return listMyColor[i];
}
}
APPL_ERROR(PFX"Color does not Existed ["<< _colorName<<"]" );
// an error
return errorColor;
}
etk::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) {
// remove all old color :
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 << "\"");
errorColor = new Colorize();
errorColor->setBgColor("#00FF00FF");
errorColor->setFgColor("#FF00FFFF");
// open the curent file
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;
}
exml::Element* root = (exml::Element*)doc.getNamed("EdnColor");
if (NULL == root ) {
APPL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: \"EdnColor\" ...");
return;
}
// 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->getPos()<<") 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->getPos() <<") 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->getPos()<<") Unknown basic gui color : \"" << colorName << "\"" );
continue;
}
etk::UString color = pGuiNode->getAttribute("val");
if (color.size()!=0) {
basicColors[id] = color;
}
}
} 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->getPos()<<") 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->getPos() <<") node with no name");
continue;
}
Colorize* myNewColor = new Colorize();
if (NULL == myNewColor) {
APPL_ERROR(PFX"(l "<< pGuiNode->getPos() <<") == > 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);
}
static classColorManager * localManager = NULL;
void ColorizeManager::init(void) {
if (NULL != localManager) {
EWOL_ERROR("ColorizeManager == > already exist, just unlink the previous ...");
localManager = NULL;
}
localManager = new classColorManager();
if (NULL == localManager) {
EWOL_CRITICAL("Allocation of HighlightManager not done ...");
}
}
void ColorizeManager::unInit(void) {
if (NULL == localManager) {
EWOL_ERROR("ColorizeManager == > request UnInit, but does not exist ...");
return;
}
delete(localManager);
localManager = NULL;
}
void ColorizeManager::loadFile(const etk::UString& _xmlFilename) {
if (NULL == localManager) {
return;
}
localManager->loadFile(_xmlFilename);
}
Colorize* ColorizeManager::get(const etk::UString& _colorName) {
if (NULL == localManager) {
return NULL;
}
return localManager->get(_colorName);
}
etk::Color<>& ColorizeManager::get(basicColor_te _myColor) {
static etk::Color<> errorColor;
if (NULL == localManager) {
return errorColor;
}
return localManager->get(_myColor);
}
bool ColorizeManager::exist(const etk::UString& _colorName) {
if (NULL == localManager) {
return false;
}
return localManager->exist(_colorName);
}
void ColorizeManager::displayListOfColor(void) {
if (NULL == localManager) {
return;
}
localManager->displayListOfColor();
}

View File

@ -38,11 +38,19 @@ namespace appl {
/** /**
* @brief Get Decoration handle. * @brief Get Decoration handle.
* @param[in] _id Id of the decoration. * @param[in] _id Id of the decoration.
* @return pointer on deco. * @return reference on deco.
*/ */
const appl::GlyphDecoration& get(esize_t _id) const { const appl::GlyphDecoration& get(esize_t _id) const {
return m_list[_id]; return m_list[_id];
}; };
/**
* @brief Operator to get decoration handle.
* @param[in] _pos Id of the decoration.
* @return reference on deco.
*/
const appl::GlyphDecoration& operator[] (esize_t _pos) const {
return m_list[_pos];
}
public: public:
/** /**
* @brief keep the resource pointer. * @brief keep the resource pointer.
@ -60,4 +68,4 @@ namespace appl {
}; };
#endif #endif
*/

View File

@ -18,7 +18,6 @@
#include <etk/tool.h> #include <etk/tool.h>
#include <Gui/MainWindows.h> #include <Gui/MainWindows.h>
#include <BufferManager.h> #include <BufferManager.h>
#include <ColorizeManager.h>
#include <HighlightManager.h> #include <HighlightManager.h>
#include <Gui/Search.h> #include <Gui/Search.h>
#include <unistd.h> #include <unistd.h>
@ -71,13 +70,7 @@ bool APP_Init(ewol::eContext& _context)
//(void)CTagsManager::getInstance(); //(void)CTagsManager::getInstance();
BufferManager::init(); BufferManager::init();
// set color and other trucs... appl::highlightManager::init();
ColorizeManager::init();
ColorizeManager::loadFile( "white" );
ColorizeManager::displayListOfColor();
HighlightManager::init();
HighlightManager::loadLanguages();
cTagsManager::init(); cTagsManager::init();
appl::textPluginManager::init(); appl::textPluginManager::init();
appl::textPluginManager::addDefaultPlugin(); appl::textPluginManager::addDefaultPlugin();
@ -144,12 +137,10 @@ void APP_UnInit(ewol::eContext& _context)
cTagsManager::unInit(); cTagsManager::unInit();
APPL_INFO("Stop Hightlight"); APPL_INFO("Stop Hightlight");
HighlightManager::unInit(); appl::highlightManager::unInit();
//Kill all singleton //Kill all singleton
APPL_INFO("Stop BufferManager"); APPL_INFO("Stop BufferManager");
BufferManager::unInit(); BufferManager::unInit();
APPL_INFO("Stop ColorizeManager");
ColorizeManager::unInit();
APPL_INFO(" == > Un-Init "PROJECT_NAME" (END)"); APPL_INFO(" == > Un-Init "PROJECT_NAME" (END)");
} }

View File

@ -44,10 +44,10 @@ def Create(target):
'appl/glyphDecoration/GlyphPainting.cpp']) 'appl/glyphDecoration/GlyphPainting.cpp'])
# syntax coloration for the text editor # syntax coloration for the text editor
#myModule.AddSrcFile([ myModule.AddSrcFile([
# 'appl/Highlight/HighlightPattern.cpp', 'appl/Highlight/HighlightPattern.cpp',
# 'appl/Highlight/Highlight.cpp', 'appl/Highlight/Highlight.cpp',
# 'appl/Highlight/HighlightManager.cpp']) 'appl/Highlight/HighlightManager.cpp'])
myModule.AddModuleDepend('ewol') myModule.AddModuleDepend('ewol')
@ -57,7 +57,7 @@ def Create(target):
myModule.CopyFile('../data/icon.png','icon.png') myModule.CopyFile('../data/icon.png','icon.png')
myModule.CopyFolder('../data/icon.*','') myModule.CopyFolder('../data/icon.*','')
myModule.CopyFolder('../data/color/*.xml','color/') myModule.CopyFolder('../data/theme/default/color/*.xml','theme/default/color/')
myModule.CopyFolder('../data/languages/asm/*.xml','languages/asm/') myModule.CopyFolder('../data/languages/asm/*.xml','languages/asm/')
myModule.CopyFolder('../data/languages/bash/*.xml','languages/bash/') myModule.CopyFolder('../data/languages/bash/*.xml','languages/bash/')
myModule.CopyFolder('../data/languages/boo/*.xml','languages/boo/') myModule.CopyFolder('../data/languages/boo/*.xml','languages/boo/')