From d1464713d69a03131895eafa3a9d7661d4202c1a Mon Sep 17 00:00:00 2001 From: Guillaume Lostis Date: Thu, 18 Apr 2024 14:34:43 +0200 Subject: [PATCH 1/2] =?UTF-8?q?fix=20typo=20altgt=20=E2=86=92=20altgr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 2 +- kalamine/data/user_guide.yaml | 2 +- kalamine/layout.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 32e801b..c3a112e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -83,7 +83,7 @@ Dead keys are preceded by a `*` sign. They can be used in the `base` layer: +-----+ shift = " ---> | "*" | <----- altgr+shift+key = dead diaeresis - base = ' ----> | '*' | <----- altgt+key = dead acute accent + base = ' ----> | '*' | <----- altgr+key = dead acute accent +-----+ diff --git a/kalamine/data/user_guide.yaml b/kalamine/data/user_guide.yaml index 8fa47c2..8684eb8 100644 --- a/kalamine/data/user_guide.yaml +++ b/kalamine/data/user_guide.yaml @@ -44,7 +44,7 @@ Dead_Keys: +-----+ shift = " ---> | "*" | <----- altgr+shift+key = dead diaeresis - base = ' ----> | '*' | <----- altgt+key = dead acute accent + base = ' ----> | '*' | <----- altgr+key = dead acute accent +-----+ Standard_Dead_Keys: | diff --git a/kalamine/layout.py b/kalamine/layout.py index bae0295..bbdde6b 100644 --- a/kalamine/layout.py +++ b/kalamine/layout.py @@ -75,7 +75,7 @@ class MetaDescr: class SpacebarDescr: shift: str = " " altgr: str = " " - altgt_shift: str = " " + altgr_shift: str = " " odk: str = "'" odk_shift: str = "'" # fmt: on From 60021f52a8a43c338a2eda1a6cc3966136ab1d93 Mon Sep 17 00:00:00 2001 From: Guillaume Lostis Date: Thu, 18 Apr 2024 14:35:55 +0200 Subject: [PATCH 2/2] Handle and document all geometries from YAML --- kalamine/cli.py | 23 ++++++++++++++++++----- kalamine/layout.py | 9 ++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/kalamine/cli.py b/kalamine/cli.py index 34c5cd0..190fa8a 100644 --- a/kalamine/cli.py +++ b/kalamine/cli.py @@ -9,7 +9,7 @@ from .generators import ahk, keylayout, klc, web, xkb from .help import create_layout, user_guide -from .layout import KeyboardLayout, load_layout +from .layout import GEOMETRY_NAMES, KeyboardLayout, load_layout from .server import keyboard_server @@ -162,12 +162,25 @@ def build( click.echo(f"... {output_file}") -# TODO: Provide geometry choices @cli.command() @click.argument("output_file", nargs=1, type=click.Path(exists=False, path_type=Path)) -@click.option("--geometry", default="ISO", help="Specify keyboard geometry.") -@click.option("--altgr/--no-altgr", default=False, help="Set an AltGr layer.") -@click.option("--1dk/--no-1dk", "odk", default=False, help="Set a custom dead key.") +@click.option( + "--geometry", + default="ISO", + type=click.Choice(GEOMETRY_NAMES, case_sensitive=False), + help="Specify keyboard geometry (defaults to ISO).", +) +@click.option( + "--altgr/--no-altgr", + default=False, + help="Set an AltGr layer (defaults to --no-altgr).", +) +@click.option( + "--1dk/--no-1dk", + "odk", + default=False, + help="Set a custom dead key (defaults to --no-1dk).", +) def new(output_file: Path, geometry: str, altgr: bool, odk: bool) -> None: """Create a new TOML layout description.""" create_layout(output_file, geometry, altgr, odk) diff --git a/kalamine/layout.py b/kalamine/layout.py index bbdde6b..e483c7c 100644 --- a/kalamine/layout.py +++ b/kalamine/layout.py @@ -121,6 +121,8 @@ def from_dict(cls: Type[T], src: Dict) -> T: key: GeometryDescr.from_dict(val) for key, val in load_data("geometry").items() } +GEOMETRY_NAMES = list(map(str, GEOMETRY.keys())) + ### # Main @@ -375,14 +377,15 @@ def _get_geometry(self, layers: Optional[List[Layer]] = None) -> List[str]: @property def geometry(self) -> str: - """ANSI, ISO, ERGO.""" + """ANSI, ISO, ABNT, JIS, ALT, ERGO.""" return self.meta["geometry"].upper() @geometry.setter def geometry(self, value: str) -> None: - """ANSI, ISO, ERGO.""" + """ANSI, ISO, ABNT, JIS, ALT, ERGO.""" shape = value.upper() - if shape not in ["ANSI", "ISO", "ERGO"]: + if shape not in GEOMETRY_NAMES: + click.echo(f"Unsupported geometry '{shape}', falling back to 'ISO'") shape = "ISO" self.meta["geometry"] = shape