diff --git a/Sources/Buffer/Buffer.h b/Sources/Buffer/Buffer.h index f25402d..b17b26e 100644 --- a/Sources/Buffer/Buffer.h +++ b/Sources/Buffer/Buffer.h @@ -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); diff --git a/Sources/Buffer/BufferText.cpp b/Sources/Buffer/BufferText.cpp index f68fafb..0aa8dd8 100644 --- a/Sources/Buffer/BufferText.cpp +++ b/Sources/Buffer/BufferText.cpp @@ -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 diff --git a/Sources/Buffer/BufferText.h b/Sources/Buffer/BufferText.h index 159b6c0..2fc3ae5 100644 --- a/Sources/Buffer/BufferText.h +++ b/Sources/Buffer/BufferText.h @@ -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 diff --git a/Sources/Highlight/Highlight.cpp b/Sources/Highlight/Highlight.cpp index 9be05ca..ef52e7b 100644 --- a/Sources/Highlight/Highlight.cpp +++ b/Sources/Highlight/Highlight.cpp @@ -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; iGetName().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(); } } diff --git a/Sources/Highlight/Highlight.h b/Sources/Highlight/Highlight.h index 2752c8d..50b8fd7 100644 --- a/Sources/Highlight/Highlight.h +++ b/Sources/Highlight/Highlight.h @@ -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 &metaData, int32_t &addingPos, EdnVectorBuf &buffer, int32_t elementID=0); void Parse2(int32_t start, int32_t stop, std::vector &metaData, EdnVectorBuf &buffer, int32_t elementID=0); diff --git a/Sources/Highlight/HighlightManager.cpp b/Sources/Highlight/HighlightManager.cpp index 711ad75..0153a63 100644 --- a/Sources/Highlight/HighlightManager.cpp +++ b/Sources/Highlight/HighlightManager.cpp @@ -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; iFileNameCompatible(fileName) ) { - return true; - } + if (NULL != Get(fileName) ) { + return true; } return false; } diff --git a/Sources/Highlight/HighlightManager.h b/Sources/Highlight/HighlightManager.h index af42ae2..c9f6c82 100644 --- a/Sources/Highlight/HighlightManager.h +++ b/Sources/Highlight/HighlightManager.h @@ -45,8 +45,8 @@ class HighlightManager: public Singleton 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 listHighlight; //!< List of ALL hightlight modules diff --git a/Sources/Highlight/HighlightPattern.cpp b/Sources/Highlight/HighlightPattern.cpp index df0d3e5..0bfe163 100644 --- a/Sources/Highlight/HighlightPattern.cpp +++ b/Sources/Highlight/HighlightPattern.cpp @@ -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(); } } diff --git a/Sources/tools/NameSpaceEdn/File.cpp b/Sources/tools/NameSpaceEdn/File.cpp index f7e2681..3831d17 100644 --- a/Sources/tools/NameSpaceEdn/File.cpp +++ b/Sources/tools/NameSpaceEdn/File.cpp @@ -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; +} diff --git a/Sources/tools/NameSpaceEdn/File.h b/Sources/tools/NameSpaceEdn/File.h index 0fade51..38e11ad 100644 --- a/Sources/tools/NameSpaceEdn/File.h +++ b/Sources/tools/NameSpaceEdn/File.h @@ -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); diff --git a/data/lang_Makefile.xml b/data/lang_Makefile.xml index 1b7e296..3ff0c9e 100644 --- a/data/lang_Makefile.xml +++ b/data/lang_Makefile.xml @@ -1,7 +1,8 @@ Makefile - .mk + *.mk + *.global preprocesseur diff --git a/data/lang_asm.xml b/data/lang_asm.xml index 909ad6e..4a231e4 100644 --- a/data/lang_asm.xml +++ b/data/lang_asm.xml @@ -1,8 +1,8 @@ - .s - .S - .asm + *.s + *.S + *.asm commentDoxygen diff --git a/data/lang_boo.xml b/data/lang_boo.xml index 441aacc..9b52cb0 100644 --- a/data/lang_boo.xml +++ b/data/lang_boo.xml @@ -1,6 +1,6 @@ - .boo + *.boo diff --git a/data/lang_c.xml b/data/lang_c.xml index a2f6064..f7652e0 100644 --- a/data/lang_c.xml +++ b/data/lang_c.xml @@ -1,9 +1,9 @@ - .c - .cpp - .h - .hpp + *.c + *.cpp + *.h + *.hpp commentDoxygen diff --git a/data/lang_php.xml b/data/lang_php.xml index 7f2a8f9..1d5acbe 100644 --- a/data/lang_php.xml +++ b/data/lang_php.xml @@ -1,9 +1,9 @@ - .php - .php3 - .php4 - .phtml + *.php + *.php3 + *.php4 + *.phtml comment diff --git a/data/lang_xml.xml b/data/lang_xml.xml index 6d884f5..485dd7f 100644 --- a/data/lang_xml.xml +++ b/data/lang_xml.xml @@ -1,6 +1,6 @@ - .xml + *.xml comment