Reorganise the internal data of this repository

This commit is contained in:
2012-08-15 23:11:44 +02:00
parent d3e963749b
commit 04c86769d6
188 changed files with 45 additions and 2194 deletions

View File

@@ -0,0 +1,332 @@
/**
*******************************************************************************
* @file Highlight.c
* @brief Editeur De N'ours : Hightlightning Specific
* @author Edouard DUPIN
* @date 14/12/2010
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <Highlight.h>
#include <tinyXML/tinyxml.h>
#undef __class__
#define __class__ "Highlight"
void Highlight::ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level)
{
// Create the patern ...
HighlightPattern *myPattern = new HighlightPattern();
// parse under Element
myPattern->ParseRules(child, level);
// add element in the list
mListPatern.PushBack(myPattern);
}
Highlight::Highlight(etk::UString &xmlFilename)
{
TiXmlDocument XmlDocument;
etk::File fileName(xmlFilename, etk::FILE_TYPE_DATA);
if (false == fileName.Exist()) {
APPL_ERROR("File Does not exist : " << fileName);
return;
}
int32_t fileSize = fileName.Size();
if (0==fileSize) {
APPL_ERROR("This file is empty : " << fileName);
return;
}
if (false == fileName.fOpenRead()) {
APPL_ERROR("Can not open the file : " << fileName);
return;
}
// allocate data
char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) {
APPL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
fileName.fRead(fileBuffer, 1, fileSize);
// close the file:
fileName.fClose();
// load the XML from the memory
bool loadError = XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
if (false == loadError) {
APPL_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename << "\"");
return;
}
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" );
if (NULL == root) {
APPL_ERROR( "can not load Hightlight XML: main node not find: \"EdnLang\"");
return;
}
int32_t level1 = 0;
int32_t level2 = 0;
TiXmlNode * child = root->FirstChild();
while(NULL != child)
{
if (child->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(child->Value(), "ext")) {
const char *myData = child->ToElement()->GetText();
if (NULL != myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
etk::UString * myEdnData = new etk::UString(myData);
m_listExtentions.PushBack(myEdnData);
}
} else if (!strcmp(child->Value(), "pass1")) {
// Get sub Nodes ...
TiXmlNode *passChild = child->FirstChild();
while (NULL != passChild) {
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(passChild->Value(), "rule")) {
ParseRules(passChild, m_listHighlightPass1, level1++);
} else {
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
}
// get the next node element :
passChild = passChild->NextSibling();
}
} else if (!strcmp(child->Value(), "pass2")) {
// Get sub Nodes ...
TiXmlNode *passChild = child->FirstChild();
while (NULL != passChild) {
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(passChild->Value(), "rule")) {
ParseRules(passChild, m_listHighlightPass2, level2++);
} else {
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
}
// get the next node element :
passChild = passChild->NextSibling();
}
} else {
APPL_ERROR("(l "<< child->Row() << ") node not suported : \""<< child->Value() << "\" must be [ext,pass1,pass2]" );
}
// get the next node element :
child = child->NextSibling();
}
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
}
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;
}
}
// clear the compleate list
m_listHighlightPass1.Clear();
// clean all Element
for (i=0; i< m_listExtentions.Size(); i++) {
if (NULL != m_listExtentions[i]) {
delete(m_listExtentions[i]);
m_listExtentions[i] = NULL;
}
}
// clear the compleate list
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(etk::UString &ext)
{
int32_t i;
for (i=0; i<m_listExtentions.Size(); i++) {
if (ext == *m_listExtentions[i] ) {
return true;
}
}
return false;
}
bool Highlight::FileNameCompatible(etk::File &fileName)
{
int32_t i;
etk::UString extention;
if (true == fileName.HasExtention() ) {
extention = "*.";
extention += fileName.GetExtention();
} else {
extention = fileName.GetShortFilename();
}
APPL_DEBUG(" try to find : in \"" << fileName << "\" extention:\"" << extention << "\" ");
for (i=0; i<m_listExtentions.Size(); i++) {
if (extention == *m_listExtentions[i] ) {
return true;
}
}
return false;
}
void Highlight::Display(void)
{
int32_t i;
APPL_INFO("List of ALL Highlight : ");
for (i=0; i< m_listExtentions.Size(); i++) {
APPL_INFO(" Extention : " << i << " : " << *m_listExtentions[i] );
}
// Display all elements
for (i=0; i< m_listHighlightPass1.Size(); i++) {
APPL_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName() );
//m_listHighlightPass1[i]->Display();
}
// Display all elements
for (i=0; i< m_listHighlightPass2.Size(); i++) {
APPL_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName() );
//m_listHighlightPass2[i]->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<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,
int32_t addingPos,
EdnVectorBuf &buffer)
{
if (0 > addingPos) {
addingPos = 0;
}
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.Size() << " ==> position search: (" << start << "," << stop << ")" );
int32_t elementStart = start;
int32_t elementStop = stop;
colorInformation_ts resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
for (int32_t jjj=0; jjj<m_listHighlightPass1.Size(); jjj++){
resultFind_te ret = HLP_FIND_OK;
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
// Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass1[jjj]->Find(elementStart, buffer.Size(), resultat, buffer);
if (HLP_FIND_ERROR != ret) {
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// Remove element in the current List where the current Element have a end inside the next...
int32_t kkk=addingPos;
while(kkk < metaData.Size() ) {
if (metaData[kkk].beginStart <= resultat.endStop) {
// Remove element
//APPL_INFO("Erase element=" << kkk);
metaData.EraseLen(kkk, kkk+1);
// Increase the end of search
if (kkk < metaData.Size()) {
// just befor the end of the next element
elementStop = metaData[kkk].beginStart-1;
} else {
// end of the buffer
elementStop = buffer.Size();
}
} else {
// Not find ==> exit the cycle :
break;
}
}
// Add curent element in the list ...
metaData.Insert(addingPos, resultat);
//APPL_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
// Update the current research starting element: (Set position at the end of the current element
elementStart = resultat.endStop-1;
// increment the position of insertion:
addingPos++;
// We find a pattern ==> Stop search for the current element
break;
}
}
// Go to the next element (and search again ...).
elementStart++;
}
}
/**
* @brief second pass of the hightlight
*
*/
void Highlight::Parse2(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
EdnVectorBuf &buffer)
{
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " ==> position search: (" << start << "," << stop << ")" );
int32_t elementStart = start;
int32_t elementStop = stop;
colorInformation_ts resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
int32_t jjj;
for (jjj=0; jjj<m_listHighlightPass2.Size(); jjj++){
resultFind_te ret = HLP_FIND_OK;
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
// Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass2[jjj]->Find(elementStart, elementStop, resultat, buffer);
if (HLP_FIND_ERROR != ret) {
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// Add curent element in the list ...
metaData.PushBack(resultat);
elementStart = resultat.endStop-1;
// Exit current cycle
break;
}
}
// Go to the next element (and search again ...).
elementStart++;
}
}

View File

@@ -0,0 +1,83 @@
/**
*******************************************************************************
* @file Highlight.h
* @brief Editeur De N'ours : Hightlightning Specific (header)
* @author Edouard DUPIN
* @date 14/12/2010
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __HIGHLIGHT_H__
#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;
}
#include <etk/File.h>
#include <HighlightPattern.h>
#include <Colorize.h>
#include <EdnVectorBuf.h>
#include <tinyXML/tinyxml.h>
class Highlight {
public:
// Constructeur
Highlight(etk::UString &xmlFilename);
~Highlight(void);
bool HasExtention(etk::UString &ext);
bool FileNameCompatible(etk::File &fileName);
void Display(void);
void ReloadColor(void);
void Parse(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
int32_t addingPos,
EdnVectorBuf &buffer);
void Parse2(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
EdnVectorBuf &buffer);
private:
void ParseRules(TiXmlNode *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)) )
};
#endif

View File

@@ -0,0 +1,217 @@
/**
*******************************************************************************
* @file HighlightManager.cpp
* @brief Editeur De N'ours : Hightlining Manager
* @author Edouard DUPIN
* @date 16/12/2010
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <HighlightManager.h>
#include <ewol/EObject.h>
#include <ewol/EObjectManager.h>
#undef __class__
#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();
};
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void)
{
return "ApplHighlightManager";
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
/*
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::File &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::File &fileName)
{
if (NULL != Get(fileName) ) {
return true;
}
return false;
}
void loadLanguages(void)
{
etk::UString xmlFilename = "lang_c.xml";
Highlight *myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_boo.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_Makefile.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_asm.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_xml.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_php.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_bash.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_matlab.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_java.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_lua.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_in.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
//myHightline->Display();
}
};
#define EDN_CAST_HIGHLIGHT_MANAGER(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_HIGHLIGHT_MANAGER,localClassHighlightManager,curentPointer)
static localClassHighlightManager * localManager = NULL;
void HighlightManager::Init(void)
{
if (NULL == localManager) {
APPL_ERROR("HighlightManager ==> already exist, just unlink the previous ...");
localManager = NULL;
}
localManager = new localClassHighlightManager();
if (NULL == localManager) {
APPL_CRITICAL("Allocation of HighlightManager not done ...");
}
}
void HighlightManager::UnInit(void)
{
if (NULL == localManager) {
APPL_ERROR("HighlightManager ==> request UnInit, but does not exist ...");
return;
}
delete(localManager);
localManager = NULL;
}
void HighlightManager::loadLanguages(void)
{
if (NULL == localManager) {
return;
}
localManager->loadLanguages();
}
Highlight* HighlightManager::Get(etk::File &fileName)
{
if (NULL == localManager) {
return NULL;
}
return localManager->Get(fileName);
}
bool HighlightManager::Exist(etk::File &fileName)
{
if (NULL == localManager) {
return false;
}
return localManager->Exist(fileName);
}

View File

@@ -0,0 +1,45 @@
/**
*******************************************************************************
* @file HighlightManager.h
* @brief Editeur De N'ours : Hightlining Manager (header)
* @author Edouard DUPIN
* @date 14/12/2010
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __HIGHLIGHT_MANAGER_H__
#define __HIGHLIGHT_MANAGER_H__
#include <etk/UString.h>
#include <appl/globalMsg.h>
#include <Highlight.h>
#include <ewol/Widget.h>
namespace HighlightManager{
void Init(void);
void UnInit(void);
void loadLanguages(void);
Highlight* Get(etk::File &fileName);
bool Exist(etk::File &fileName);
};
#endif

View File

@@ -0,0 +1,249 @@
/**
*******************************************************************************
* @file HighlightPattern.cpp
* @brief Editeur De N'ours : Hightlight Patern (header)
* @author Edouard DUPIN
* @date 14/12/2010
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <HighlightPattern.h>
#include <ColorizeManager.h>
#undef __class__
#define __class__ "HighlightPattern"
HighlightPattern::HighlightPattern(void)
{
m_haveStopPatern = false;
m_multiline = false;
m_color = ColorizeManager::Get("normal");
m_regExpStart = new etk::RegExp<EdnVectorBuf>();
m_regExpStop = new etk::RegExp<EdnVectorBuf>();
m_escapeChar = 0;
}
HighlightPattern::~HighlightPattern(void)
{
delete(m_regExpStart);
delete(m_regExpStop);
}
void HighlightPattern::SetPaternStart(etk::UString &regExp)
{
m_regExpStart->SetRegExp(regExp);
}
void HighlightPattern::SetPaternStop(etk::UString &regExp)
{
if (regExp.Size() != 0) {
m_regExpStop->SetRegExp(regExp);
m_haveStopPatern = true;
} else {
m_haveStopPatern = false;
}
}
void HighlightPattern::SetEscapeChar(etk::UString &EscapeChar)
{
if (EscapeChar.Size()>0) {
m_escapeChar = EscapeChar[0];
} else {
m_escapeChar = 0;
}
}
void HighlightPattern::SetColor(etk::UString &colorName)
{
m_colorName = colorName;
m_color = ColorizeManager::Get(m_colorName);
}
bool HighlightPattern::IsEnable(void)
{
return true;
}
void HighlightPattern::ReloadColor(void)
{
m_color = ColorizeManager::Get(m_colorName);
}
/**
* @brief
*
* @param[in,out]
*
* @eturn
*
*/
void 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 (true == m_multiline) {
APPL_INFO(" ==> multiline pattern: YES");
} else {
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(TiXmlNode *child, int32_t level)
{
//--------------------------------------------------------------------------------------------
/*
<rule name="my preprocesseur">
<color>preprocesseur</color>
<start>#</start>
<end>$</end>
<multiline>yes</multiline>
</rule>
*/
//--------------------------------------------------------------------------------------------
// process attribute
const char *highLightName = child->ToElement()->Attribute("name");
etk::UString myEdnDataTmp = "???";
if (NULL != highLightName) {
myEdnDataTmp = highLightName;
}
SetName(myEdnDataTmp);
SetLevel(level);
TiXmlElement *xChild = child->FirstChildElement("color");
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetColor(myEdnData);
}
}
xChild = child->FirstChildElement("start");
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetPaternStart(myEdnData);
}
}
xChild = child->FirstChildElement("end");
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetPaternStop(myEdnData);
}
}
xChild = child->FirstChildElement("EscapeChar");
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetEscapeChar(myEdnData);
}
}
xChild = child->FirstChildElement("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++);
*/
}
}
/**
* @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, EdnVectorBuf &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;
// 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();
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;
}

View File

@@ -0,0 +1,90 @@
/**
*******************************************************************************
* @file HighlightPattern.h
* @brief Editeur De N'ours : Hightlight Patern (header)
* @author Edouard DUPIN
* @date 14/12/2010
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <Highlight.h>
#ifndef __HIGHLIGHT_PATTERN_H__
#define __HIGHLIGHT_PATTERN_H__
class HighlightPattern;
#include <etk/RegExp.h>
#include <Colorize.h>
#include <etk/Vector.h>
#include <tinyXML/tinyxml.h>
#include <EdnVectorBuf.h>
typedef enum {
HLP_FIND_ERROR,
HLP_FIND_OK,
HLP_FIND_OK_NO_END,
}resultFind_te;
class HighlightPattern;
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, EdnVectorBuf &buffer);
Colorize * GetColor(void) { return m_color; };
void ParseRules(TiXmlNode *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<EdnVectorBuf> * m_regExpStart; //!< Start of Regular expression
etk::RegExp<EdnVectorBuf> * m_regExpStop; //!< Stop of Regular Expression
bool m_haveStopPatern; //!< Stop patern presence
bool m_multiline; //!< The patern is multiline
uniChar_t 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 ...
};
#endif