From 5ea04c04a2b38b31b5e20055f2397eb3bb89ca15 Mon Sep 17 00:00:00 2001 From: Fabien Cazenave Date: Fri, 8 Mar 2024 22:16:44 +0100 Subject: [PATCH] [keylayout] bugfix: unique action IDs --- kalamine/template.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/kalamine/template.py b/kalamine/template.py index b6712c0..ce23f19 100644 --- a/kalamine/template.py +++ b/kalamine/template.py @@ -613,8 +613,10 @@ def has_dead_keys(letter: str) -> bool: char = f"code=\"{SCAN_CODES['osx'][key_name]}\"".ljust(10) if final_key: action = f'output="{symbol}"' - else: + elif symbol.startswith("dead_"): action = f'action="{xml_proof_id(symbol)}"' + else: + action = f'action="{key_name}_{xml_proof_id(symbol)}"' output.append(f"") ret_str.append(output) @@ -636,8 +638,8 @@ def when(state: str, action: str) -> str: action_attr = f'output="{xml_proof(action)}"' return f" " - def append_actions(symbol: str, actions: List[Tuple[str, str]]) -> None: - ret_actions.append(f'') + def append_actions(key: str, symbol: str, actions: List[Tuple[str, str]]) -> None: + ret_actions.append(f'') ret_actions.append(when("none", symbol)) for state, out in actions: ret_actions.append(when(state, out)) @@ -662,7 +664,7 @@ def append_actions(symbol: str, actions: List[Tuple[str, str]]) -> None: ret_actions.append(f"") continue - for i in [Layer.BASE, Layer.SHIFT]: + for i in [Layer.BASE, Layer.SHIFT, Layer.ALTGR, Layer.ALTGR_SHIFT]: if key_name == "spce" or key_name not in layout.layers[i]: continue @@ -678,16 +680,16 @@ def append_actions(symbol: str, actions: List[Tuple[str, str]]) -> None: if key in layout.dead_keys[k]: actions.append((DK_INDEX[k].name, layout.dead_keys[k][key])) if actions: - append_actions(xml_proof(key), actions) + append_actions(key_name, xml_proof(key), actions) # spacebar actions actions = [] for k in DK_INDEX: if k in layout.dead_keys: actions.append((DK_INDEX[k].name, layout.dead_keys[k][" "])) - append_actions(" ", actions) # space - append_actions(" ", actions) # no-break space - append_actions(" ", actions) # fine no-break space + append_actions("spce", " ", actions) # space + append_actions("spce", " ", actions) # no-break space + append_actions("spce", " ", actions) # fine no-break space return ret_actions