[DEV] add highlight parsing file
This commit is contained in:
@@ -29,7 +29,8 @@ void appl::Highlight::parseRules(exml::Element* _child,
|
||||
}
|
||||
|
||||
appl::Highlight::Highlight(const etk::UString& _xmlFilename, const etk::UString& _colorFile) :
|
||||
ewol::Resource(_xmlFilename) {
|
||||
ewol::Resource(_xmlFilename),
|
||||
m_typeName("") {
|
||||
// keep color propertiy file :
|
||||
m_paintingProperties = appl::GlyphPainting::keep(_colorFile);
|
||||
|
||||
@@ -43,6 +44,7 @@ appl::Highlight::Highlight(const etk::UString& _xmlFilename, const etk::UString&
|
||||
APPL_ERROR("(l ?) main node not find: \"EdnLang\" ...");
|
||||
return;
|
||||
}
|
||||
m_typeName = root->getAttribute("lang");
|
||||
int32_t level1 = 0;
|
||||
int32_t level2 = 0;
|
||||
// parse all the elements :
|
||||
@@ -156,7 +158,7 @@ void appl::Highlight::display(void) {
|
||||
*/
|
||||
void appl::Highlight::parse(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<appl::ColorInfo> &metaData,
|
||||
etk::Vector<appl::HighlightInfo> &metaData,
|
||||
int32_t addingPos,
|
||||
etk::Buffer &buffer) {
|
||||
if (0 > addingPos) {
|
||||
@@ -165,7 +167,7 @@ void appl::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;
|
||||
appl::ColorInfo resultat;
|
||||
appl::HighlightInfo resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
@@ -219,12 +221,12 @@ void appl::Highlight::parse(int32_t start,
|
||||
*/
|
||||
void appl::Highlight::parse2(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<appl::ColorInfo> &metaData,
|
||||
etk::Vector<appl::HighlightInfo> &metaData,
|
||||
etk::Buffer &buffer) {
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " == > position search: (" << start << "," << stop << ")" );
|
||||
int32_t elementStart = start;
|
||||
int32_t elementStop = stop;
|
||||
appl::ColorInfo resultat;
|
||||
appl::HighlightInfo resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
|
@@ -14,7 +14,7 @@ namespace appl {
|
||||
class Highlight;
|
||||
class HighlightPattern;
|
||||
|
||||
class ColorInfo {
|
||||
class HighlightInfo {
|
||||
public:
|
||||
int32_t beginStart;
|
||||
int32_t beginStop;
|
||||
@@ -39,18 +39,24 @@ namespace appl {
|
||||
// Constructeur
|
||||
Highlight(const etk::UString& _xmlFilename, const etk::UString& _colorFile);
|
||||
~Highlight(void);
|
||||
private:
|
||||
etk::UString m_typeName; //!< descriptive string type like "C/C++"
|
||||
public:
|
||||
const etk::UString& getTypeName(void) {
|
||||
return m_typeName;
|
||||
}
|
||||
public:
|
||||
bool hasExtention(const etk::UString& _ext);
|
||||
bool fileNameCompatible(const etk::UString& _fileName);
|
||||
void display(void);
|
||||
void parse(int32_t _start,
|
||||
int32_t _stop,
|
||||
etk::Vector<appl::ColorInfo> &_metaData,
|
||||
etk::Vector<appl::HighlightInfo> &_metaData,
|
||||
int32_t _addingPos,
|
||||
etk::Buffer &_buffer);
|
||||
void parse2(int32_t _start,
|
||||
int32_t _stop,
|
||||
etk::Vector<appl::ColorInfo> &_metaData,
|
||||
etk::Vector<appl::HighlightInfo> &_metaData,
|
||||
etk::Buffer &_buffer);
|
||||
private:
|
||||
void parseRules(exml::Element* _child,
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <HighlightManager.h>
|
||||
#include <appl/Highlight/HighlightManager.h>
|
||||
#include <ewol/renderer/EObject.h>
|
||||
#include <ewol/renderer/EObjectManager.h>
|
||||
|
||||
@@ -73,6 +73,34 @@ void appl::highlightManager::unInit(void) {
|
||||
}
|
||||
|
||||
etk::UString appl::highlightManager::getTypeExtention(const etk::UString& _extention) {
|
||||
if (_extention.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
etk::Vector<Highlight*>& hlList = s_list();
|
||||
for (esize_t iii = 0; iii < hlList.size(); ++iii) {
|
||||
if (hlList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (hlList[iii]->hasExtention(_extention) == true) {
|
||||
return hlList[iii]->getTypeName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
etk::UString appl::highlightManager::getFileWithTypeType(const etk::UString& _type) {
|
||||
if (_type.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
etk::Vector<Highlight*>& hlList = s_list();
|
||||
for (esize_t iii = 0; iii < hlList.size(); ++iii) {
|
||||
if (hlList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (hlList[iii]->getTypeName() == _type) {
|
||||
return hlList[iii]->getName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,12 @@ namespace appl {
|
||||
* @return type of highlight
|
||||
*/
|
||||
etk::UString getTypeExtention(const etk::UString& _extention);
|
||||
/**
|
||||
* @brief Get filename with type.
|
||||
* @param[in] _type Type name of the highlight.
|
||||
* @return filename of the highlight.
|
||||
*/
|
||||
etk::UString getFileWithTypeType(const etk::UString& _type);
|
||||
/**
|
||||
* @brief Get the list of extention type
|
||||
* @return the requested list.
|
||||
|
@@ -141,7 +141,7 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
|
||||
|
||||
resultFind_te appl::HighlightPattern::find(int32_t _start,
|
||||
int32_t _stop,
|
||||
appl::ColorInfo& _resultat,
|
||||
appl::HighlightInfo& _resultat,
|
||||
etk::Buffer& _buffer) {
|
||||
//APPL_DEBUG(" try to find the element");
|
||||
_resultat.beginStart = -1;
|
||||
|
@@ -94,7 +94,7 @@ namespace appl {
|
||||
*/
|
||||
resultFind_te find(int32_t _start,
|
||||
int32_t _stop,
|
||||
appl::ColorInfo& _resultat,
|
||||
appl::HighlightInfo& _resultat,
|
||||
etk::Buffer& _buffer);
|
||||
|
||||
void parseRules(exml::Element* _child, int32_t _level);
|
||||
|
Reference in New Issue
Block a user