/** @file * @author Edouard DUPIN * @copyright 2010, Edouard DUPIN, all right reserved * @license GPL v3 (see license file) */ #include #include #include #include #include // TODO : Review this in a generic unique resource ... static etk::Vector>& s_list() { static etk::Vector> list; return list; } void appl::highlightManager::init() { etk::Vector>& hlList = s_list(); if (hlList.size() != 0) { APPL_ERROR("HighlightManager == > already exist, just unlink the previous ..."); hlList.clear(); } APPL_DEBUG("HighlightManager == > INIT"); etk::FSNode myFile("DATA:languages/"); // get the subfolder list : etk::Vector list = myFile.folderGetSubList(false, true, false,false); for (auto &it : list) { if (it == null) { continue; } if (it->getNodeType() != etk::typeNode_folder) { continue; } etk::String filename = it->getName() + "/highlight.xml"; APPL_DEBUG("Load xml name : " << filename); ememory::SharedPtr myHightLine = appl::Highlight::create(filename); if (myHightLine != null) { // Check if the language name already exist for (auto &it2 : hlList) { if ( it2 != null && it2->getTypeName() == myHightLine->getTypeName() ) { APPL_WARNING("LANGUAGE : replace pattern name: '" << myHightLine->getTypeName() << "' with file '" << filename << "' replace: " << it2->getName()); } } hlList.pushBack(myHightLine); } else { APPL_ERROR("Can not allocate HighLight"); } } // display : for (auto &it : hlList) { if (it == null) { continue; } it->display(); } } void appl::highlightManager::unInit() { etk::Vector>& hlList = s_list(); if (hlList.size() == 0) { APPL_DEBUG("HighlightManager ==> no highlight"); hlList.clear(); return; } hlList.clear(); } etk::String appl::highlightManager::getTypeFile(const etk::String& _fileName) { if (_fileName.size() == 0) { return ""; } APPL_WARNING("Try to find type for extention : '" << _fileName << "' in " << s_list().size() << " types"); etk::Vector>& hlList = s_list(); for (auto &it : hlList) { if (it == null) { continue; } APPL_WARNING(" check : " << it->getTypeName()); if (it->isCompatible(_fileName) == true) { APPL_WARNING("Find type for extention : " << _fileName << " type : " << it->getTypeName()); return it->getTypeName(); } } return ""; } etk::String appl::highlightManager::getFileWithTypeType(const etk::String& _type) { if (_type.size() == 0) { return ""; } for (auto &it : s_list()) { if (it == null) { continue; } if (it->getTypeName() == _type) { return it->getName(); } } return ""; } etk::Vector appl::highlightManager::getTypeList() { etk::Vector ret; return ret; }