Skip to content

Commit

Permalink
Allow to override keys with aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
houmain committed Sep 7, 2024
1 parent a9627cd commit 6dd0b1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/config/ParseConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,6 @@ KeySequence ParseConfig::parse_output(It it, It end) {
}

void ParseConfig::parse_macro(std::string name, It it, It end) {
if (*get_key_by_name(name))
error("Invalid macro name '" + name + "'");
if (m_system_filter_matched)
m_macros[std::move(name)] = preprocess(it, end, false);
}
Expand Down
17 changes: 14 additions & 3 deletions src/test/test1_ParseConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,22 @@ TEST_CASE("Macros", "[ParseConfig]") {
CHECK(format_sequence(config.contexts[0].outputs[0]) ==
"+E -E +F -F !Any +A -A +B -B +E -E +F -F");

// not allowed macro name
// allow to override key names
string = R"(
Space = Enter
Alt{A} >> X
Alt = AltRight
Alt{B} >> Y
)";
CHECK_THROWS(parse_config(string));
REQUIRE_NOTHROW(config = parse_config(string));
REQUIRE(config.contexts[0].inputs.size() == 3);
REQUIRE(config.contexts[0].outputs.size() == 2);
REQUIRE(config.contexts[0].command_outputs.size() == 0);
CHECK(format_sequence(config.contexts[0].inputs[0].input) == "+AltLeft +A ~A ~AltLeft");
CHECK(format_sequence(config.contexts[0].inputs[1].input) == "+AltRight +A ~A ~AltRight");
CHECK(format_sequence(config.contexts[0].inputs[2].input) == "+AltRight +B ~B ~AltRight");
CHECK(format_sequence(config.contexts[0].outputs[0]) == "+X");
CHECK(format_sequence(config.contexts[0].outputs[1]) == "+Y");
}

//--------------------------------------------------------------------
Expand Down

0 comments on commit 6dd0b1a

Please sign in to comment.