From 466e0b82189352ee931916b22494f638fabc9aa3 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 27 Feb 2025 23:53:42 +0100 Subject: KeyValue: Don't wrap keys into a macro when possible Many kind of KeyValues don't need to be wrapped into a Macro to show a specific symbol. This is especially useful as Macro keys are not affected by modifiers. The parser is changed to have a fast-path when a key value is not a macro. --- test/juloo.keyboard2/KeyValueParserTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'test/juloo.keyboard2/KeyValueParserTest.java') diff --git a/test/juloo.keyboard2/KeyValueParserTest.java b/test/juloo.keyboard2/KeyValueParserTest.java index a041e8a..7ece1a7 100644 --- a/test/juloo.keyboard2/KeyValueParserTest.java +++ b/test/juloo.keyboard2/KeyValueParserTest.java @@ -54,6 +54,13 @@ public class KeyValueParserTest Utils.expect_error("unexpected_quote:,"); } + @Test + /* Using the [symbol:..] syntax but not resulting in a macro. */ + public void parse_non_macro() throws Exception + { + Utils.parse("a:b", KeyValue.makeCharKey('b', "a", 0)); + } + @Test public void parse_string_key() throws Exception { @@ -87,9 +94,7 @@ public class KeyValueParserTest @Test public void parse_key_event() throws Exception { - Utils.parse("symbol:keyevent:85", KeyValue.makeMacro("symbol", new KeyValue[]{ - KeyValue.keyeventKey("", 85, 0) - }, 0)); + Utils.parse("symbol:keyevent:85", KeyValue.keyeventKey("symbol", 85, 0)); Utils.parse("macro:keyevent:85,abc", KeyValue.makeMacro("macro", new KeyValue[]{ KeyValue.keyeventKey("", 85, 0), KeyValue.makeStringKey("abc") -- cgit v1.2.3