[DEV] start rework color and highlight

This commit is contained in:
2013-10-23 21:19:30 +02:00
parent c8fd4183cd
commit 8c57b28d73
16 changed files with 487 additions and 388 deletions

View File

@@ -162,7 +162,7 @@ void Highlight::display(void) {
// TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas tr<74>grave... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
void Highlight::parse(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
etk::Vector<appl::ColorInfo> &metaData,
int32_t addingPos,
etk::Buffer &buffer) {
if (0 > addingPos) {
@@ -171,7 +171,7 @@ void Highlight::parse(int32_t start,
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.size() << " == > position search: (" << start << "," << stop << ")" );
int32_t elementStart = start;
int32_t elementStop = stop;
colorInformation_ts resultat;
appl::ColorInfo resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
@@ -225,12 +225,12 @@ void Highlight::parse(int32_t start,
*/
void Highlight::parse2(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
etk::Vector<appl::ColorInfo> &metaData,
etk::Buffer &buffer) {
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " == > position search: (" << start << "," << stop << ")" );
int32_t elementStart = start;
int32_t elementStop = stop;
colorInformation_ts resultat;
appl::ColorInfo resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have

View File

@@ -10,19 +10,20 @@
#define __HIGHLIGHT_H__
class Highlight;
class HighlightPattern;
extern "C" {
typedef struct {
int32_t beginStart;
int32_t beginStop;
int32_t endStart;
int32_t endStop;
bool notEnded;
HighlightPattern* patern; // pointer on class :
} colorInformation_ts;
}
class appl {
class Highlight;
class HighlightPattern;
class ColorInfo{
public:
int32_t beginStart;
int32_t beginStop;
int32_t endStart;
int32_t endStop;
bool notEnded;
appl::HighlightPattern* patern; // pointer on class :
};
};
#include <etk/os/FSNode.h>
#include <HighlightPattern.h>
@@ -30,30 +31,34 @@ extern "C" {
#include <etk/Buffer.h>
#include <exml/exml.h>
class Highlight {
public:
// Constructeur
Highlight(const etk::UString& _xmlFilename);
~Highlight(void);
bool hasExtention(const etk::UString& _ext);
bool fileNameCompatible(etk::FSNode &_fileName);
void display(void);
void reloadColor(void);
void parse(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
int32_t addingPos,
etk::Buffer &buffer);
void parse2(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
etk::Buffer &buffer);
private:
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::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_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) )
class appl {
class Highlight : public ewol::EObject {
public:
// Constructeur
Highlight(const etk::UString& _xmlFilename);
~Highlight(void);
bool hasExtention(const etk::UString& _ext);
bool fileNameCompatible(etk::FSNode &_fileName);
void display(void);
void reloadColor(void);
void parse(int32_t _start,
int32_t _stop,
etk::Vector<appl::ColorInfo> &_metaData,
int32_t _addingPos,
etk::Buffer &_buffer);
void parse2(int32_t _start,
int32_t _stop,
etk::Vector<appl::ColorInfo> &_metaData,
etk::Buffer &_buffer);
private:
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::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_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) )
};
};

View File

@@ -13,130 +13,65 @@
#include <ewol/renderer/EObjectManager.h>
#undef __class__
#define __class__ "HighlightManager"
#define __class__ "highlightManager"
class localClassHighlightManager: public ewol::EObject {
private:
etk::Vector<Highlight*> listHighlight; //!< List of ALL hightlight modules
public:
// Constructeur
localClassHighlightManager(void) {
//ewol::widgetMessageMultiCast::add(getWidgetId(), ednMsgBufferColor);
};
~localClassHighlightManager(void) {
int32_t i;
// clean all Element
for (i=0; i< listHighlight.size(); i++) {
if (NULL != listHighlight[i]) {
delete(listHighlight[i]);
listHighlight[i] = NULL;
}
}
// clear the compleate list
listHighlight.clear();
};
// herited function
const char * const getObjectType(void) {
return "ApplHighlightManager";
}
// herited function
virtual void onReceiveMessage(const ewol::EMessage& _msg) {
/*
switch (id)
{
case APPL_MSG__COLOR_HAS_CHANGE:
APPL_INFO("UPDATE the color pointer on the HL");
for (int32_t i=0; i<listHighlight.size(); i++) {
if (NULL != listHighlight[i]) {
listHighlight[i]->ReloadColor();
}
}
break;
}
*/
}
Highlight* get(etk::FSNode& _fileName) {
int32_t i;
for (i=0; i<listHighlight.size(); ++i) {
if (true == listHighlight[i]->fileNameCompatible(_fileName) ) {
return listHighlight[i];
}
}
return NULL;
}
bool exist(etk::FSNode& _fileName) {
if (NULL != get(_fileName) ) {
return true;
}
return false;
}
void loadLanguages(void) {
etk::FSNode myFile("DATA:languages/");
// get the subfolder list :
etk::Vector<etk::FSNode *> list = myFile.folderGetSubList(false, true, false,false);
for ( int32_t iii=0 ; iii<list.size() ; iii++ ) {
if (NULL!=list[iii]) {
if (list[iii]->getNodeType() == etk::FSN_FOLDER) {
etk::UString filename = list[iii]->getName() + "/highlight.xml";
APPL_DEBUG("Load xml name : " << filename);
Highlight *myHightline = new Highlight(filename);
listHighlight.pushBack(myHightline);
}
}
}
//myHightline->display();
}
};
static localClassHighlightManager * localManager = NULL;
static etk::Vector<Highlight*>& s_list(void) {
static etk::Vector<Highlight*> list;
return list;
}
void HighlightManager::init(void) {
if (NULL != localManager) {
void appl::highlightManager::init(void) {
etk::Vector<Highlight*>& hlList = s_list();
if (hlList.size() != 0) {
APPL_ERROR("HighlightManager == > already exist, just unlink the previous ...");
localManager = NULL;
hlList.clear();
}
localManager = new localClassHighlightManager();
if (NULL == localManager) {
APPL_CRITICAL("Allocation of HighlightManager not done ...");
etk::FSNode myFile("DATA:languages/");
// get the subfolder list :
etk::Vector<etk::FSNode *> list = myFile.folderGetSubList(false, true, false,false);
for (esize_t iii=0;
iii<list.size();
++iii ) {
if (list[iii] == NULL) {
continue;
}
if (list[iii]->getNodeType() != etk::FSN_FOLDER) {
continue;
}
etk::UString filename = list[iii]->getName() + "/highlight.xml";
APPL_DEBUG("Load xml name : " << filename);
appl::Highlight *myHightline = appl::Highlight::keep(filename);
hlList.pushBack(myHightline);
}
}
void HighlightManager::unInit(void) {
if (NULL == localManager) {
APPL_ERROR("HighlightManager == > request UnInit, but does not exist ...");
void appl::highlightManager::unInit(void) {
etk::Vector<Highlight*>& hlList = s_list();
if (hlList.size() == 0) {
APPL_DEBUG("HighlightManager ==> no highlight");
hlList.clear();
return;
}
delete(localManager);
localManager = NULL;
}
void HighlightManager::loadLanguages(void) {
if (NULL == localManager) {
return;
for (esize_t iii = 0;
iii < hlList.size();
++iii ) {
if (hlList[iii] == NULL) {
continue;
}
appl::Highlight::release(hlList[iii]);
hlList[iii] = NULL;
}
localManager->loadLanguages();
hlList.clear();
}
Highlight* HighlightManager::get(etk::FSNode& _fileName) {
if (NULL == localManager) {
return NULL;
}
return localManager->get(_fileName);
etk::UString appl::highlightManager::getTypeExtention(const etk::UString& _extention) {
return "";
}
bool HighlightManager::exist(etk::FSNode& _fileName) {
if (NULL == localManager) {
return false;
}
return localManager->exist(_fileName);
etk::Vector<etk::UString> appl::highlightManager::getTypeList(void) {
etk::Vector<etk::UString> ret;
return ret;
}

View File

@@ -15,12 +15,28 @@
#include <Highlight.h>
#include <ewol/widget/Widget.h>
namespace HighlightManager{
void init(void);
void unInit(void);
void loadLanguages(void);
Highlight* get(etk::FSNode &fileName);
bool exist(etk::FSNode &fileName);
namespace appl {
namespace highlightManager {
/**
* @brief Init the Highlight manager
*/
void init(void);
/**
* @brief Un-Init the Highlight manager
*/
void unInit(void);
/**
* @brief Un-Init the Highlight manager
* @param[in] extention of the file
* @return type of highlight
*/
etk::UString getTypeExtention(const etk::UString& _extention);
/**
* @brief Get the list of extention type
* @return the requested list.
*/
etk::Vector<etk::UString> getTypeList(void);
};
};

View File

@@ -49,7 +49,7 @@ void HighlightPattern::setEscapeChar(etk::UString& _EscapeChar) {
}
}
void HighlightPattern::setColor(etk::UString& _colorName) {
void HighlightPattern::setColorGlyph(etk::UString& _colorName) {
m_colorName = _colorName;
m_color = ColorizeManager::get(m_colorName);
}
@@ -79,11 +79,6 @@ void HighlightPattern::display(void) {
APPL_INFO(" == > multiline pattern: NO");
}
*/
// display all elements
for (int32_t i=0; i< m_subPatern.size(); i++) {
APPL_INFO(" " << i << " subPattern : " << m_subPatern[i]->getName() );
m_subPatern[i]->display();
}
}
void HighlightPattern::parseRules(exml::Element *child, int32_t level) {
@@ -142,18 +137,6 @@ void HighlightPattern::parseRules(exml::Element *child, int32_t level) {
setEscapeChar(myEdnData);
}
}
xChild = (exml::Element*)child->getNamed("rule");
if (NULL != xChild) {
/*
// Create the patern ...
HighlightPattern *myPattern = new HighlightPattern();
// parse under Element
myPattern->ParseRules(ruleChild, level+1);
// add element in the list
m_subPatern.pushBack(myPattern);
//ParseRules(passChild, m_listHighlightPass1, level1++);
*/
}
}

View File

@@ -26,57 +26,71 @@ typedef enum {
HLP_FIND_OK_NO_END,
}resultFind_te;
class HighlightPattern {
public:
// Constructeur
HighlightPattern(void);
~HighlightPattern(void);
void setName(etk::UString& _name) {
m_paternName = _name;
};
etk::UString getName(void) {
return m_paternName;
};
void setPaternStart(etk::UString& _regExp);
void setPaternStop(etk::UString& _regExp);
void setColor(etk::UString& _colorName);
void setEscapeChar(etk::UString& _EscapeChar);
void setMultiline(bool _enable) {
m_multiline = _enable;
};
void setLevel(int32_t _newLevel) {
m_level = _newLevel;
};
int32_t getLevel(void) {
return m_level;
};
bool isEnable(void);
void display(void);
resultFind_te find(int32_t _start, int32_t _stop, colorInformation_ts& _resultat, etk::Buffer& _buffer);
Colorize* getColor(void) {
return m_color;
};
void parseRules(exml::Element* _child, int32_t _level);
void reloadColor(void);
private:
int32_t m_level; //!< Level of the pattern == > this is to overwrite next pattern when we create an higher ....
etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
etk::UString m_colorName; //!< Current color name
Colorize* m_color; //!< Link to the color manager
etk::RegExp<etk::Buffer>* m_regExpStart; //!< Start of Regular expression
etk::RegExp<etk::Buffer>* m_regExpStop; //!< Stop of Regular Expression
bool m_haveStopPatern; //!< Stop patern presence
bool m_multiline; //!< The patern is multiline
etk::UChar m_escapeChar; //!< Escape char to prevent exeit of patern ....
etk::Vector<HighlightPattern*> m_subPatern; //!< Under patern of this one
// etk::Vector<HighlightPattern*> m_subColor; //!< Under Color in the start RegExp ...
namespace appl {
class HighlightPattern {
public:
// Constructeur
HighlightPattern(void);
~HighlightPattern(void);
private:
etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
public:
void setName(etk::UString& _name) {
m_paternName = _name;
};
etk::UString getName(void) {
return m_paternName;
};
private:
etk::RegExp<etk::Buffer>* m_regExpStart; //!< Start of Regular expression
public:
void setPaternStart(etk::UString& _regExp);
private:
bool m_haveStopPatern; //!< Stop patern presence
etk::RegExp<etk::Buffer>* 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
public:
void setColorGlyph(etk::UString& _colorName);
appl::ColorGlyph* getColorGlyph(void) {
return m_color;
};
private:
etk::UChar m_escapeChar; //!< Escape char to prevent exeit of patern ....
public:
void setEscapeChar(etk::UString& _EscapeChar);
private:
bool m_multiline; //!< The patern is multiline
public:
void setMultiline(bool _enable) {
m_multiline = _enable;
};
private:
int32_t m_level; //!< Level of the pattern == > this is to overwrite next pattern when we create an higher ....
public:
void setLevel(int32_t _newLevel) {
m_level = _newLevel;
};
int32_t getLevel(void) {
return m_level;
};
private:
public:
bool isEnable(void);
void display(void);
resultFind_te find(int32_t _start,
int32_t _stop,
colorInformation_ts& _resultat,
etk::Buffer& _buffer);
void parseRules(exml::Element* _child, int32_t _level);
void reloadColor(void);
};
};
#endif