From 8eb4aff266d0033e1d78c739992b2dd87ba9b444 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 25 Oct 2013 22:12:34 +0200 Subject: [PATCH] [DEV] work on highlight --- data/theme/default/color/bufferList.json | 9 + .../default/color/textViewer.json} | 6 - sources/appl/Gui/BufferView.cpp | 2 +- sources/appl/Gui/TextViewer.cpp | 2 +- sources/appl/Highlight/Highlight.cpp | 100 +++--- sources/appl/Highlight/Highlight.h | 37 +- sources/appl/Highlight/HighlightManager.cpp | 29 +- sources/appl/Highlight/HighlightPattern.cpp | 187 +++++----- sources/appl/Highlight/HighlightPattern.h | 30 +- sources/appl/global.cpp | 2 +- .../appl/glyphDecoration/GlyphPainting.cpp | 322 +----------------- sources/appl/glyphDecoration/GlyphPainting.h | 12 +- sources/appl/init.cpp | 13 +- sources/lutin_edn.py | 10 +- 14 files changed, 249 insertions(+), 512 deletions(-) create mode 100644 data/theme/default/color/bufferList.json rename data/{color/black.xml => theme/default/color/textViewer.json} (83%) diff --git a/data/theme/default/color/bufferList.json b/data/theme/default/color/bufferList.json new file mode 100644 index 0000000..4af8ef8 --- /dev/null +++ b/data/theme/default/color/bufferList.json @@ -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" }, + ] +} diff --git a/data/color/black.xml b/data/theme/default/color/textViewer.json similarity index 83% rename from data/color/black.xml rename to data/theme/default/color/textViewer.json index 7048693..2aabcfe 100644 --- a/data/color/black.xml +++ b/data/theme/default/color/textViewer.json @@ -5,12 +5,6 @@ { name="CODE_tabulation", foreground="#444444" }, { name="CODE_cursor", foreground="#eadd05" }, { 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="SelectedText", foreground="#AAAAAA", background="#225a09"}, { name="error", foreground="#FF0000"}, diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index 8b30d00..2300ac5 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +//#include #include #include diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index 0c9cf86..c4e7d77 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +//#include #include #include diff --git a/sources/appl/Highlight/Highlight.cpp b/sources/appl/Highlight/Highlight.cpp index 6149d62..07079d4 100644 --- a/sources/appl/Highlight/Highlight.cpp +++ b/sources/appl/Highlight/Highlight.cpp @@ -10,28 +10,35 @@ #include #include #include +#include #undef __class__ -#define __class__ "Highlight" +#define __class__ "Highlight" -void Highlight::parseRules(exml::Element* _child, etk::Vector& _mListPatern, int32_t _level) { +void appl::Highlight::parseRules(exml::Element* _child, + etk::Vector& _mListPatern, + int32_t _level) { // Create the patern ... - HighlightPattern *myPattern = new HighlightPattern(); + HighlightPattern *myPattern = new HighlightPattern(m_paintingProperties); // parse under Element myPattern->parseRules(_child, _level); // add element in the list _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; if (doc.load(_xmlFilename) == false) { APPL_ERROR(" can not load file XML : " << _xmlFilename); return; } - exml::Element* root = (exml::Element*)doc.getNamed("EdnLang"); + exml::Element* root = doc.getNamed("EdnLang"); if (NULL == root ) { APPL_ERROR("(l ?) main node not find: \"EdnLang\" ..."); return; @@ -39,7 +46,7 @@ Highlight::Highlight(const etk::UString& _xmlFilename) { int32_t level1 = 0; int32_t level2 = 0; // 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); if (child == NULL) { // 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; // clean all Element - for (i=0; i< m_listHighlightPass1.size(); i++) { - if (NULL != m_listHighlightPass1[i]) { - delete(m_listHighlightPass1[i]); - m_listHighlightPass1[i] = NULL; + for (esize_t iii = 0; iii < m_listHighlightPass1.size(); ++iii) { + if (m_listHighlightPass1[iii] != NULL) { + delete(m_listHighlightPass1[iii]); + m_listHighlightPass1[iii] = NULL; } } // clear the compleate list @@ -98,38 +105,25 @@ Highlight::~Highlight(void) { m_listExtentions.clear(); } -void Highlight::reloadColor(void) { - 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) { +bool appl::Highlight::hasExtention(const etk::UString& _ext) { for (int32_t iii=0; iiigetName() ); - //m_listHighlightPass1[i]->display(); + //m_listHighlightPass1[iii]->display(); } // display all elements for (int32_t iii=0; iii< m_listHighlightPass2.size(); iii++) { 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... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer... -void Highlight::parse(int32_t start, +/* 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... + */ +void appl::Highlight::parse(int32_t start, int32_t stop, etk::Vector &metaData, int32_t addingPos, @@ -223,7 +217,7 @@ void Highlight::parse(int32_t start, * @brief second pass of the hightlight * */ -void Highlight::parse2(int32_t start, +void appl::Highlight::parse2(int32_t start, int32_t stop, etk::Vector &metaData, 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(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(_object); + getManager().release(object2); + _object = NULL; +} diff --git a/sources/appl/Highlight/Highlight.h b/sources/appl/Highlight/Highlight.h index 73b610e..e127f5f 100644 --- a/sources/appl/Highlight/Highlight.h +++ b/sources/appl/Highlight/Highlight.h @@ -10,11 +10,11 @@ #define __HIGHLIGHT_H__ -class appl { +namespace appl { class Highlight; class HighlightPattern; - class ColorInfo{ + class ColorInfo { public: int32_t beginStart; int32_t beginStop; @@ -27,20 +27,22 @@ class appl { #include #include -#include +#include #include #include -class appl { - class Highlight : public ewol::EObject { - public: +namespace appl { + class Highlight : public ewol::Resource { + private: + appl::GlyphPainting* m_paintingProperties; + protected: // Constructeur - Highlight(const etk::UString& _xmlFilename); + Highlight(const etk::UString& _xmlFilename, const etk::UString& _colorFile); ~Highlight(void); + public: bool hasExtention(const etk::UString& _ext); - bool fileNameCompatible(etk::FSNode &_fileName); + bool fileNameCompatible(const etk::UString& _fileName); void display(void); - void reloadColor(void); void parse(int32_t _start, int32_t _stop, etk::Vector &_metaData, @@ -58,6 +60,23 @@ class appl { 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)) ) + 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 ... + }; }; }; diff --git a/sources/appl/Highlight/HighlightManager.cpp b/sources/appl/Highlight/HighlightManager.cpp index 5b8c9e8..e5cf267 100644 --- a/sources/appl/Highlight/HighlightManager.cpp +++ b/sources/appl/Highlight/HighlightManager.cpp @@ -15,14 +15,14 @@ #undef __class__ #define __class__ "highlightManager" -static etk::Vector& s_list(void) { - static etk::Vector list; +static etk::Vector& s_list(void) { + static etk::Vector list; return list; } void appl::highlightManager::init(void) { - etk::Vector& hlList = s_list(); + etk::Vector& hlList = s_list(); if (hlList.size() != 0) { APPL_ERROR("HighlightManager == > already exist, just unlink the previous ..."); hlList.clear(); @@ -30,9 +30,7 @@ void appl::highlightManager::init(void) { etk::FSNode myFile("DATA:languages/"); // get the subfolder list : etk::Vector list = myFile.folderGetSubList(false, true, false,false); - for (esize_t iii=0; - iiigetName() + "/highlight.xml"; APPL_DEBUG("Load xml name : " << filename); - appl::Highlight *myHightline = appl::Highlight::keep(filename); - hlList.pushBack(myHightline); + appl::Highlight *myHightLine = appl::Highlight::keep(filename); + 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(); return; } - for (esize_t iii = 0; - iii < hlList.size(); - ++iii ) { + for (esize_t iii = 0; iii < hlList.size(); ++iii) { if (hlList[iii] == NULL) { continue; } diff --git a/sources/appl/Highlight/HighlightPattern.cpp b/sources/appl/Highlight/HighlightPattern.cpp index 221f77b..2b7f0e8 100644 --- a/sources/appl/Highlight/HighlightPattern.cpp +++ b/sources/appl/Highlight/HighlightPattern.cpp @@ -9,79 +9,79 @@ #include #include #include -#include #undef __class__ #define __class__ "HighlightPattern" -HighlightPattern::HighlightPattern(void) { - m_haveStopPatern = false; - m_multiline = false; - m_color = ColorizeManager::get("normal"); +appl::HighlightPattern::HighlightPattern(appl::GlyphPainting*& _glyphPainting) : + m_glyphPainting(_glyphPainting), + m_paternName(""), + m_regExpStart(NULL), + m_regExpStop(NULL), + m_colorName(""), + m_escapeChar(etk::UChar::Null), + m_multiline(false), + m_level(0) { m_regExpStart = new etk::RegExp(); - m_regExpStop = new etk::RegExp(); - m_escapeChar = 0; } -HighlightPattern::~HighlightPattern(void) { - delete(m_regExpStart); - delete(m_regExpStop); +appl::HighlightPattern::~HighlightPattern(void) { + if (m_regExpStart != NULL) { + 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); } -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) { - m_regExpStop->setRegExp(_regExp); - m_haveStopPatern = true; - } else { - m_haveStopPatern = false; + m_regExpStop = new etk::RegExp(); + if (m_regExpStop != NULL) { + m_regExpStop->setRegExp(_regExp); + } else { + APPL_ERROR("Allocation error"); + } } } -void HighlightPattern::setEscapeChar(etk::UString& _EscapeChar) { - if (_EscapeChar.size()>0) { - m_escapeChar = _EscapeChar[0]; - } else { - m_escapeChar = 0; - } +void appl::HighlightPattern::setEscapeChar(const etk::UChar& _EscapeChar) { + m_escapeChar = _EscapeChar; } -void HighlightPattern::setColorGlyph(etk::UString& _colorName) { +void appl::HighlightPattern::setColorGlyph(etk::UString& _colorName) { m_colorName = _colorName; - m_color = ColorizeManager::get(m_colorName); + m_colorId = m_glyphPainting->request(m_colorName); } -bool HighlightPattern::isEnable(void) { - return true; -} - -void HighlightPattern::reloadColor(void) { - m_color = ColorizeManager::get(m_colorName); -} - -void HighlightPattern::display(void) { - /* +void appl::HighlightPattern::display(void) { APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level ); APPL_INFO(" == > colorName \"" << m_colorName << "\""); APPL_INFO(" == > regExpStart \"" << m_regExpStart->getRegExp() << "\""); - APPL_INFO(" == > regExpStop \"" << m_regExpStop->getRegExp() << "\""); - if (true == m_haveStopPatern) { - APPL_INFO(" == > stop pattern: YES"); - } else { - APPL_INFO(" == > stop pattern: NO"); + if (m_regExpStop != NULL) { + APPL_INFO(" == > regExpStop \"" << m_regExpStop->getRegExp() << "\""); } - if (true == m_multiline) { + if (m_multiline == true) { APPL_INFO(" == > multiline pattern: YES"); } else { APPL_INFO(" == > multiline pattern: NO"); } - */ } -void HighlightPattern::parseRules(exml::Element *child, int32_t level) { +void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) { //-------------------------------------------------------------------------------------------- /* @@ -93,101 +93,92 @@ void HighlightPattern::parseRules(exml::Element *child, int32_t level) { */ //-------------------------------------------------------------------------------------------- // process attribute - etk::UString highLightName = child->getAttribute("name"); + etk::UString highLightName = _child->getAttribute("name"); etk::UString myEdnDataTmp = "???"; if (highLightName.size()!=0) { myEdnDataTmp = highLightName; } setName(myEdnDataTmp); - setLevel(level); + setLevel(_level); - exml::Element* xChild = (exml::Element*)child->getNamed("color"); + exml::Element* xChild = _child->getNamed("color"); if (NULL != xChild) { 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); etk::UString myEdnData = myData; - setColor(myEdnData); + setColorGlyph(myEdnData); } } - xChild = (exml::Element*)child->getNamed("start"); + xChild = _child->getNamed("start"); if (NULL != xChild) { 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); etk::UString myEdnData = myData; setPaternStart(myEdnData); } } - xChild = (exml::Element*)child->getNamed("end"); + xChild = _child->getNamed("end"); if (NULL != xChild) { 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); etk::UString myEdnData = myData; setPaternStop(myEdnData); } } - xChild = (exml::Element*)child->getNamed("EscapeChar"); + xChild = _child->getNamed("EscapeChar"); if (NULL != xChild) { 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); - etk::UString myEdnData = myData; - setEscapeChar(myEdnData); + setEscapeChar(myData[0]); } } } -/** - * @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 HighlightPattern::find(int32_t start, int32_t stop, colorInformation_ts &resultat, etk::Buffer &buffer) { +resultFind_te appl::HighlightPattern::find(int32_t _start, + int32_t _stop, + appl::ColorInfo& _resultat, + etk::Buffer& _buffer) { //APPL_DEBUG(" try to find the element"); - resultat.beginStart = -1; - resultat.beginStop = -1; - resultat.endStart = -1; - resultat.endStop = -1; - resultat.notEnded = false; - resultat.patern = this; + _resultat.beginStart = -1; + _resultat.beginStop = -1; + _resultat.endStart = -1; + _resultat.endStop = -1; + _resultat.notEnded = false; + _resultat.patern = this; - // when we have only one element : - if (false == m_haveStopPatern) { - if (true == m_regExpStart->processOneElement(buffer, start, stop)) { - resultat.beginStart = m_regExpStart->start(); - resultat.beginStop = m_regExpStart->stop(); - resultat.endStart = m_regExpStart->start(); - resultat.endStop = m_regExpStart->stop(); + // when we have only one element: + if (m_regExpStop == NULL) { + if (true == m_regExpStart->processOneElement(_buffer, _start, _stop)) { + _resultat.beginStart = m_regExpStart->start(); + _resultat.beginStop = m_regExpStart->stop(); + _resultat.endStart = m_regExpStart->start(); + _resultat.endStop = m_regExpStart->stop(); return HLP_FIND_OK; } //APPL_DEBUG("NOT find hightlightpatern ..."); - } else { - // 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 ..."); + return HLP_FIND_ERROR; } + // 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; } diff --git a/sources/appl/Highlight/HighlightPattern.h b/sources/appl/Highlight/HighlightPattern.h index 1732607..c49f64a 100644 --- a/sources/appl/Highlight/HighlightPattern.h +++ b/sources/appl/Highlight/HighlightPattern.h @@ -15,7 +15,7 @@ class HighlightPattern; #include -#include +#include #include #include #include @@ -28,9 +28,11 @@ typedef enum { namespace appl { class HighlightPattern { + private: + appl::GlyphPainting*& m_glyphPainting; public: // Constructeur - HighlightPattern(void); + HighlightPattern(appl::GlyphPainting*& _glyphPainting); ~HighlightPattern(void); private: etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") @@ -46,22 +48,21 @@ namespace appl { public: void setPaternStart(etk::UString& _regExp); private: - bool m_haveStopPatern; //!< Stop patern presence etk::RegExp* m_regExpStop; //!< Stop of Regular Expression public: void setPaternStop(etk::UString& _regExp); private: 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: void setColorGlyph(etk::UString& _colorName); - appl::ColorGlyph* getColorGlyph(void) { - return m_color; + const appl::GlyphDecoration& getColorGlyph(void) { + return (*m_glyphPainting)[m_colorId]; }; private: etk::UChar m_escapeChar; //!< Escape char to prevent exeit of patern .... public: - void setEscapeChar(etk::UString& _EscapeChar); + void setEscapeChar(const etk::UChar& _EscapeChar); private: bool m_multiline; //!< The patern is multiline public: @@ -80,16 +81,23 @@ namespace appl { private: public: - bool isEnable(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, int32_t _stop, - colorInformation_ts& _resultat, + appl::ColorInfo& _resultat, etk::Buffer& _buffer); void parseRules(exml::Element* _child, int32_t _level); - - void reloadColor(void); }; }; diff --git a/sources/appl/global.cpp b/sources/appl/global.cpp index 9e735dc..c575414 100644 --- a/sources/appl/global.cpp +++ b/sources/appl/global.cpp @@ -7,7 +7,7 @@ */ #include -#include +//#include #include #include #include diff --git a/sources/appl/glyphDecoration/GlyphPainting.cpp b/sources/appl/glyphDecoration/GlyphPainting.cpp index b929a38..6513bc4 100644 --- a/sources/appl/glyphDecoration/GlyphPainting.cpp +++ b/sources/appl/glyphDecoration/GlyphPainting.cpp @@ -59,7 +59,7 @@ void appl::GlyphPainting::reload(void) { m_list[jjj].setBackground(background); m_list[jjj].setItalic(italic); m_list[jjj].setBold(bold); - findElement == true; + findElement = true; } if (findElement == true) { continue; @@ -76,26 +76,27 @@ void appl::GlyphPainting::reload(void) { esize_t appl::GlyphPainting::request(const etk::UString& _name) { for (esize_t iii=0; iii(getManager().localKeep(_filename)); if (NULL != object) { return object; } // this element create a new one every time .... + EWOL_INFO("CREATE : appl::GlyphPainting : file : \"" << _filename << "\""); object = new appl::GlyphPainting(_filename); if (NULL == object) { - EWOL_ERROR("allocation error of a resource : ??Mesh.obj??"); + EWOL_ERROR("allocation error of a resource : ??GlyphPainting??"); return NULL; } getManager().localAdd(object); @@ -111,314 +112,3 @@ void appl::GlyphPainting::release(appl::GlyphPainting*& _object) { _object = NULL; } - - - - - - - - - - - - - - - - - - - - - - - - - -class classColorManager: public ewol::EObject { - private: - etk::UString m_fileColor; - etk::Vector 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; igetName() == _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; 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); - } - } -}; - -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 "<getPos()<<") node not suported : \""<getValue()<<"\" must be [color]"); - continue; - } - //-------------------------------------------------------------------------------------------- - // - //-------------------------------------------------------------------------------------------- - 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 "<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 "<getPos()<<") 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->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(); -} - - diff --git a/sources/appl/glyphDecoration/GlyphPainting.h b/sources/appl/glyphDecoration/GlyphPainting.h index 4480347..6ae25d1 100644 --- a/sources/appl/glyphDecoration/GlyphPainting.h +++ b/sources/appl/glyphDecoration/GlyphPainting.h @@ -38,11 +38,19 @@ namespace appl { /** * @brief Get Decoration handle. * @param[in] _id Id of the decoration. - * @return pointer on deco. + * @return reference on deco. */ const appl::GlyphDecoration& get(esize_t _id) const { 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: /** * @brief keep the resource pointer. @@ -60,4 +68,4 @@ namespace appl { }; #endif -*/ + diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 71738ea..dc85ea2 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -71,13 +70,7 @@ bool APP_Init(ewol::eContext& _context) //(void)CTagsManager::getInstance(); BufferManager::init(); - // set color and other trucs... - ColorizeManager::init(); - ColorizeManager::loadFile( "white" ); - ColorizeManager::displayListOfColor(); - - HighlightManager::init(); - HighlightManager::loadLanguages(); + appl::highlightManager::init(); cTagsManager::init(); appl::textPluginManager::init(); appl::textPluginManager::addDefaultPlugin(); @@ -144,12 +137,10 @@ void APP_UnInit(ewol::eContext& _context) cTagsManager::unInit(); APPL_INFO("Stop Hightlight"); - HighlightManager::unInit(); + appl::highlightManager::unInit(); //Kill all singleton APPL_INFO("Stop BufferManager"); BufferManager::unInit(); - APPL_INFO("Stop ColorizeManager"); - ColorizeManager::unInit(); APPL_INFO(" == > Un-Init "PROJECT_NAME" (END)"); } diff --git a/sources/lutin_edn.py b/sources/lutin_edn.py index 90a40cd..d76fbad 100755 --- a/sources/lutin_edn.py +++ b/sources/lutin_edn.py @@ -44,10 +44,10 @@ def Create(target): 'appl/glyphDecoration/GlyphPainting.cpp']) # syntax coloration for the text editor - #myModule.AddSrcFile([ - # 'appl/Highlight/HighlightPattern.cpp', - # 'appl/Highlight/Highlight.cpp', - # 'appl/Highlight/HighlightManager.cpp']) + myModule.AddSrcFile([ + 'appl/Highlight/HighlightPattern.cpp', + 'appl/Highlight/Highlight.cpp', + 'appl/Highlight/HighlightManager.cpp']) myModule.AddModuleDepend('ewol') @@ -57,7 +57,7 @@ def Create(target): myModule.CopyFile('../data/icon.png','icon.png') 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/bash/*.xml','languages/bash/') myModule.CopyFolder('../data/languages/boo/*.xml','languages/boo/')