Minor tweaks and cosmetics.

This commit is contained in:
spx 2011-07-18 00:32:09 +00:00
parent a639eb7cc1
commit 15eba97cba
7 changed files with 37 additions and 32 deletions

View File

@ -101,28 +101,11 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
SetBuiltInVariable(L"CURRENTPATH", CRainmeter::ExtractPath(m_Filename));
SetBuiltInVariable(L"ADDONSPATH", pRainmeter->GetAddonPath());
SetBuiltInVariable(L"CRLF", L"\n");
if (meterWindow)
{
const std::wstring& config = meterWindow->GetSkinName();
std::wstring path = pRainmeter->GetSkinPath();
std::wstring::size_type loc;
if ((loc = config.find_first_of(L'\\')) != std::wstring::npos)
{
path += config.substr(0, loc + 1);
}
else
{
path += config;
path += L"\\";
}
SetBuiltInVariable(L"ROOTCONFIGPATH", path);
}
}
if (meterWindow)
{
SetBuiltInVariable(L"CURRENTCONFIG", meterWindow->GetSkinName());
SetBuiltInVariable(L"ROOTCONFIGPATH", meterWindow->GetSkinRootPath());
}
}
@ -604,10 +587,8 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT
std::wstring::size_type pos = (*iter).find_first_not_of(L" \t\r\n");
if (pos != std::wstring::npos)
{
std::wstring::size_type lastPos = (*iter).find_last_not_of(L" \t\r\n");
// Trim white-space
std::wstring strSection((*iter), pos, lastPos - pos + 1);
std::wstring strSection((*iter), pos, (*iter).find_last_not_of(L" \t\r\n") - pos + 1);
const std::wstring& strStyle = GetValue(strSection, key, strDefault);

View File

@ -66,10 +66,8 @@ std::wstring CGroup::CreateGroup(const std::wstring& str)
std::wstring::size_type pos = str.find_first_not_of(L" \t\r\n");
if (pos != std::wstring::npos)
{
std::wstring::size_type lastPos = str.find_last_not_of(L" \t\r\n");
// Trim white-space
strTmp.assign(str, pos, lastPos - pos + 1);
strTmp.assign(str, pos, str.find_last_not_of(L" \t\r\n") - pos + 1);
// Convert to lower
std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower);

View File

@ -335,8 +335,9 @@ HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR sz
std::wstring args;
std::wstring command = szCommand;
size_t notwhite = command.find_first_not_of(L" \t\n");
size_t notwhite = command.find_first_not_of(L" \t\r\n");
command.erase(0, notwhite);
if (command.empty()) return NULL;
size_t quotePos = command.find(L"\"");
if (quotePos == 0)

View File

@ -130,7 +130,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
pos = m_PluginName.rfind(L'\\');
if (pos != std::wstring::npos)
{
std::wstring pluginName = Rainmeter->GetPath() + m_PluginName.substr(pos + 1);
std::wstring pluginName = Rainmeter->GetPath();
pluginName.append(m_PluginName, pos + 1, m_PluginName.length() - (pos + 1));
err = 0;
m_Plugin = CSystem::RmLoadLibrary(pluginName.c_str(), &err);

View File

@ -5072,17 +5072,41 @@ void CMeterWindow::SetWindowSizeVariables(int w, int h)
*/
std::wstring CMeterWindow::MakePathAbsolute(const std::wstring& path)
{
std::wstring absolute;
if (path.empty() ||
path.find(L":\\") != std::wstring::npos || path.find(L":/") != std::wstring::npos ||
(path.length() >= 2 && (path[0] == L'\\' || path[0] == L'/') && (path[1] == L'\\' || path[1] == L'/'))) // UNC
{
return path; // It's already absolute path (or it's empty)
absolute = path; // It's already absolute path (or it's empty)
}
else
{
absolute = m_SkinPath;
absolute += m_SkinName;
absolute += L"\\";
absolute += path;
}
std::wstring root = m_SkinPath + m_SkinName;
root += L"\\";
return absolute;
}
return root + path;
std::wstring CMeterWindow::GetSkinRootPath()
{
std::wstring path = m_Rainmeter->GetSkinPath();
std::wstring::size_type loc;
if ((loc = m_SkinName.find_first_of(L'\\')) != std::wstring::npos)
{
path.append(m_SkinName, 0, loc + 1);
}
else
{
path += m_SkinName;
path += L"\\";
}
return path;
}
@ -5096,7 +5120,6 @@ CMeter* CMeterWindow::GetMeter(const std::wstring& meterName)
return (*j);
}
}
return NULL;
}

View File

@ -200,6 +200,7 @@ public:
const std::wstring& GetSkinAuthor() { return m_Author; }
const std::wstring& GetSkinName() { return m_SkinName; }
const std::wstring& GetSkinIniFile() { return m_SkinIniFile; }
std::wstring GetSkinRootPath();
std::list<CMeasure*>& GetMeasures() { return m_Measures; }
std::list<CMeter*>& GetMeters() { return m_Meters; }

View File

@ -3098,7 +3098,7 @@ BOOL CRainmeter::ExecuteBang(const std::wstring& bang, const std::wstring& arg,
std::wstring command = arg.substr(start + 1, end - (start + 1));
// trim leading whitespace
std::wstring::size_type notwhite = command.find_first_not_of(L" \t\n");
std::wstring::size_type notwhite = command.find_first_not_of(L" \t\r\n");
command.erase(0, notwhite);
ExecuteCommand(command.c_str(), meterWindow);
}