error whith the Highlight detection
This commit is contained in:
@@ -57,12 +57,14 @@ class Buffer {
|
||||
{
|
||||
m_fileName = newName;
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
|
||||
void SetFileName(Edn::String &newName)
|
||||
{
|
||||
m_fileName.SetCompleateName(newName);
|
||||
m_haveName = true;
|
||||
NameChange();
|
||||
};
|
||||
|
||||
bool HaveName(void)
|
||||
@@ -74,6 +76,7 @@ class Buffer {
|
||||
bool IsModify(void);
|
||||
protected:
|
||||
void SetModify(bool status);
|
||||
virtual void NameChange(void) { /*EDN_DEBUG("check name change ==> no HL change possible");*/};
|
||||
public:
|
||||
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate);
|
||||
virtual void SetLineDisplay(uint32_t lineNumber);
|
||||
|
@@ -74,6 +74,29 @@ void BufferText::BasicInit(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::NameChange(void)
|
||||
{
|
||||
// Find HL system
|
||||
//EDN_DEBUG("check name change");
|
||||
if (true == HighlightManager::getInstance()->Exist(m_fileName)) {
|
||||
Highlight * myHL = HighlightManager::getInstance()->Get(m_fileName);
|
||||
// Set the new HL
|
||||
if (NULL != myHL) {
|
||||
m_EdnBuf.SetHLSystem(myHL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@@ -101,6 +124,7 @@ BufferText::BufferText()
|
||||
BufferText::BufferText(Edn::File &fileName) : Buffer(fileName)
|
||||
{
|
||||
BasicInit();
|
||||
NameChange();
|
||||
EDN_INFO("Add Data from file(" << GetFileName() << ")");
|
||||
FILE * myFile = NULL;
|
||||
// try to open the file. if not existed, new file
|
||||
|
@@ -73,6 +73,8 @@ class BufferText : public Buffer {
|
||||
void Undo(void);
|
||||
void Redo(void);
|
||||
void SetCharset(charset_te newCharset);
|
||||
protected:
|
||||
void NameChange(void);
|
||||
|
||||
private:
|
||||
// Display
|
||||
|
@@ -52,7 +52,7 @@ Highlight::Highlight(Edn::String &xmlFilename)
|
||||
// open the curent File
|
||||
bool loadError = XmlDocument.LoadFile(xmlFilename.c_str());
|
||||
if (false == loadError) {
|
||||
EDN_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename.c_str() << "\"");
|
||||
EDN_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename << "\"");
|
||||
return;
|
||||
}
|
||||
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" );
|
||||
@@ -134,24 +134,17 @@ bool Highlight::HasExtention(Edn::String &ext)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Highlight::FileNameCompatible(Edn::String &fileName)
|
||||
bool Highlight::FileNameCompatible(Edn::File &fileName)
|
||||
{
|
||||
uint32_t i;
|
||||
int32_t posCopy = fileName.FindBack('/');
|
||||
Edn::String shortFilename;
|
||||
if (-1 != posCopy) {
|
||||
shortFilename = fileName.Extract(posCopy+1);
|
||||
} else {
|
||||
shortFilename = fileName;
|
||||
}
|
||||
posCopy = shortFilename.FindBack('.');
|
||||
Edn::String extention;
|
||||
if (-1 != posCopy) {
|
||||
extention = shortFilename.Extract(posCopy);
|
||||
if (true == fileName.HasExtention() ) {
|
||||
extention = "*.";
|
||||
extention += fileName.GetExtention();
|
||||
} else {
|
||||
extention = shortFilename;
|
||||
extention = fileName.GetShortFilename();
|
||||
}
|
||||
EDN_DEBUG(" try to find : in \"" << fileName.c_str() << "\" shortfilename\"" << shortFilename.c_str() << "\" extention:\"" << extention.c_str() << "\" ");
|
||||
EDN_DEBUG(" try to find : in \"" << fileName << "\" extention:\"" << extention << "\" ");
|
||||
|
||||
for (i=0; i<m_listExtentions.size(); i++) {
|
||||
if (extention == m_listExtentions[i] ) {
|
||||
@@ -167,16 +160,16 @@ void Highlight::Display(void)
|
||||
uint32_t i;
|
||||
EDN_INFO("List of ALL Highlight : ");
|
||||
for (i=0; i< m_listExtentions.size(); i++) {
|
||||
EDN_INFO(" Extention : " << i << " : " << m_listExtentions[i].c_str() );
|
||||
EDN_INFO(" Extention : " << i << " : " << m_listExtentions[i] );
|
||||
}
|
||||
// Display all elements
|
||||
for (i=0; i< m_listHighlightPass1.size(); i++) {
|
||||
EDN_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName().c_str() );
|
||||
EDN_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName() );
|
||||
//m_listHighlightPass1[i]->Display();
|
||||
}
|
||||
// Display all elements
|
||||
for (i=0; i< m_listHighlightPass2.size(); i++) {
|
||||
EDN_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName().c_str() );
|
||||
EDN_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName() );
|
||||
//m_listHighlightPass2[i]->Display();
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ class Highlight {
|
||||
Highlight(Edn::String &xmlFilename);
|
||||
~Highlight(void);
|
||||
bool HasExtention(Edn::String &ext);
|
||||
bool FileNameCompatible(Edn::String &fileName);
|
||||
bool FileNameCompatible(Edn::File &fileName);
|
||||
void Display(void);
|
||||
void Parse( int32_t start, int32_t stop, std::vector<colorInformation_ts> &metaData, int32_t &addingPos, EdnVectorBuf &buffer, int32_t elementID=0);
|
||||
void Parse2(int32_t start, int32_t stop, std::vector<colorInformation_ts> &metaData, EdnVectorBuf &buffer, int32_t elementID=0);
|
||||
|
@@ -41,7 +41,7 @@ HighlightManager::~HighlightManager(void)
|
||||
}
|
||||
|
||||
|
||||
Highlight *HighlightManager::Get(Edn::String &fileName)
|
||||
Highlight *HighlightManager::Get(Edn::File &fileName)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i=0; i<listHighlight.size(); i++) {
|
||||
@@ -52,13 +52,10 @@ Highlight *HighlightManager::Get(Edn::String &fileName)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool HighlightManager::Exist(Edn::String &fileName)
|
||||
bool HighlightManager::Exist(Edn::File &fileName)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i=0; i<listHighlight.size(); i++) {
|
||||
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
|
||||
return true;
|
||||
}
|
||||
if (NULL != Get(fileName) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -45,8 +45,8 @@ class HighlightManager: public Singleton<HighlightManager>
|
||||
|
||||
public:
|
||||
void loadLanguages(void);
|
||||
Highlight * Get(Edn::String &fileName);
|
||||
bool Exist(Edn::String &fileName);
|
||||
Highlight * Get(Edn::File &fileName);
|
||||
bool Exist(Edn::File &fileName);
|
||||
|
||||
private:
|
||||
std::vector<Highlight*> listHighlight; //!< List of ALL hightlight modules
|
||||
|
@@ -98,10 +98,10 @@ bool HighlightPattern::IsEnable(void)
|
||||
void HighlightPattern::Display(void)
|
||||
{
|
||||
/*
|
||||
EDN_INFO("patern : \"" << m_paternName.c_str() << "\" level=" << m_level );
|
||||
EDN_INFO(" ==> colorName \"" << m_colorName.c_str() << "\"");
|
||||
EDN_INFO(" ==> regExpStart \"" << m_regExpStart->GetRegExp().c_str() << "\"");
|
||||
EDN_INFO(" ==> regExpStop \"" << m_regExpStop->GetRegExp().c_str() << "\"");
|
||||
EDN_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
|
||||
EDN_INFO(" ==> colorName \"" << m_colorName << "\"");
|
||||
EDN_INFO(" ==> regExpStart \"" << m_regExpStart->GetRegExp() << "\"");
|
||||
EDN_INFO(" ==> regExpStop \"" << m_regExpStop->GetRegExp() << "\"");
|
||||
if (true == m_haveStopPatern) {
|
||||
EDN_INFO(" ==> stop pattern: YES");
|
||||
} else {
|
||||
@@ -115,7 +115,7 @@ void HighlightPattern::Display(void)
|
||||
*/
|
||||
// Display all elements
|
||||
for (int32_t i=0; i< m_subPatern.Size(); i++) {
|
||||
EDN_INFO(" " << i << " SubPattern : " << m_subPatern[i]->GetName().c_str() );
|
||||
EDN_INFO(" " << i << " SubPattern : " << m_subPatern[i]->GetName() );
|
||||
m_subPatern[i]->Display();
|
||||
}
|
||||
}
|
||||
|
@@ -213,3 +213,31 @@ int32_t Edn::File::GetLineNumber(void)
|
||||
return m_lineNumberOpen;
|
||||
}
|
||||
|
||||
|
||||
bool Edn::File::HasExtention(void)
|
||||
{
|
||||
int32_t lastPos = m_shortFilename.FindBack('.');
|
||||
if( -1 != lastPos // not find the .
|
||||
&& 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file
|
||||
&& m_shortFilename.Size() != lastPos ) // Remove file ended with .
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Edn::String Edn::File::GetExtention(void)
|
||||
{
|
||||
Edn::String tmpExt = "";
|
||||
int32_t lastPos = m_shortFilename.FindBack('.');
|
||||
if( -1 != lastPos // not find the .
|
||||
&& 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file
|
||||
&& m_shortFilename.Size() != lastPos ) // Remove file ended with .
|
||||
{
|
||||
// Get the FileName
|
||||
tmpExt = m_shortFilename.Extract(lastPos+1);
|
||||
}
|
||||
return tmpExt;
|
||||
}
|
||||
|
@@ -39,6 +39,8 @@ namespace Edn
|
||||
Edn::String GetFolder(void) const;
|
||||
Edn::String GetShortFilename(void) const;
|
||||
Edn::String GetCompleateName(void) const;
|
||||
bool HasExtention(void);
|
||||
Edn::String GetExtention(void);
|
||||
int32_t GetLineNumber(void);
|
||||
void SetCompleateName(Edn::String &newFilename);
|
||||
|
||||
|
Reference in New Issue
Block a user