Skip to content

Commit

Permalink
Fixed issue where new style variables and old style section variables…
Browse files Browse the repository at this point in the history
… could not replace an entire bang sequence.

Fixes issue with 99a11be.

Small backwards compatibility issue if attempting to send a command to Windows that has the same name as a section. In Rainmeter versions prior to r2874, the below code would open the command prompt, not notepad. Now it will open notepad.
Example:
[cmd]
Measure=String
String=[notepad]
[Meter]
Meter=...
LeftMouseUpAction=[cmd]
  • Loading branch information
brianferguson committed Oct 4, 2017
1 parent cf0f31f commit 8c01d9f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Library/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,24 @@ void CommandHandler::ExecuteCommand(const WCHAR* command, Skin* skin, bool multi
std::wstring tmpSz = command;
if (skin)
{
// If the command is a section variable or a new style variable,
// surround the command with brackets and replace it with the variable.
// This allows for section variables to completely replace a bang sequence.
// ex. LeftMouseUpAction=[SomeMeasureName] or LeftMouseUpAction=[#NewStyleVar]
if (ConfigParser::IsVariableKey(tmpSz[0]) || skin->GetMeasure(tmpSz))
{
tmpSz.insert(0, L"[");
tmpSz.append(L"]");

skin->GetParser().ReplaceMeasures(tmpSz);

ExecuteCommand(tmpSz.c_str(), skin, true);
return;
}

skin->GetParser().ReplaceMeasures(tmpSz);
}

RunCommand(tmpSz);
}
}
Expand Down
1 change: 1 addition & 0 deletions Library/ConfigParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class ConfigParser

static void ClearMultiMonitorVariables() { c_MonitorVariables.clear(); }
static void UpdateWorkareaVariables() { SetMultiMonitorVariables(false); }
static bool IsVariableKey(const WCHAR ch) { for (auto& k : c_VariableMap) { if (k.second == ch) return true; } return false; }

private:
void SetBuiltInVariables(const std::wstring& filename, const std::wstring* resourcePath, Skin* skin);
Expand Down

0 comments on commit 8c01d9f

Please sign in to comment.