|
#include "stdafx.h"
#include "ProjectItemFinder.h"
#include "Options.h"
ProjectItemFinder::ProjectItemFinder(const Options* pOptions, ProjectItemList* pTarget, CString strMatch)
: m_pOptions(pOptions)
, m_pTarget(pTarget)
, m_strMatch(strMatch)
{
m_strMatch.MakeLower();
}
void ProjectItemFinder::VisitProjectItemFile(CString strName, CString strFileName)
{
ProjectItemData d;
d.m_Name = strName;
d.m_Project = GetCurrentPath();
d.m_Path = strFileName;
if (Match(&d))
{
d.m_Colour = GetColour(&d);
m_pTarget->push_back(d);
}
}
bool ProjectItemFinder::Match(const ProjectItemData* pItem) const
{
if (!MatchString(pItem, m_strMatch))
return false;
for (int i = 0; i < m_pOptions->GetExcludedFileCount(); ++i)
{
if (MatchString(pItem, m_pOptions->GetExcludedFile(i).Filter))
return false;
}
return true;
}
bool ProjectItemFinder::MatchString(const ProjectItemData* pItem, CString strMatch) const
{
CString s(pItem->m_Name);
s.MakeLower();
const CString separators(_T(" ,"));
int i = 0;
CString token = strMatch.Tokenize(separators, i);
while (token != "")
{
if (s.Find(token) == -1)
return false;
token = strMatch.Tokenize(separators, i);
}
return true;
}
COLORREF ProjectItemFinder::GetColour(const ProjectItemData* pItem) const
{
for (int i = 0; i < m_pOptions->GetHighlightedFileCount(); ++i)
{
if (MatchString(pItem, m_pOptions->GetHighlightedFile(i).Filter))
return m_pOptions->GetHighlightedFile(i).Colour;
}
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.