Skip to content

feat: add KLE/Vial <-> [layout] converter and terminal preview - #14

Open
HaoboGu wants to merge 1 commit into
feat/rmk-0.9-apifrom
feat/layout-tools
Open

feat: add KLE/Vial <-> [layout] converter and terminal preview#14
HaoboGu wants to merge 1 commit into
feat/rmk-0.9-apifrom
feat/layout-tools

Conversation

@HaoboGu

@HaoboGu HaoboGu commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Stack 2/3 — base #13, review that one first. The diff shown here is only this layer.

The RMK docs already point at rmkit layout for turning an existing KLE or Vial layout into a keyboard.toml's [layout] section. The conversion engine lives upstream in the rynk-kle crate (which round-trips its output through RMK's own layout builder, so the result is guaranteed to build); this PR is the CLI over it.

rmkit layout convert path/to/vial.json -o layout.toml   # vial.json → [layout]
rmkit layout convert path/to/kle_export.json            # raw KLE "Download JSON" export too
rmkit layout convert --to-vial keyboard.toml            # reverse: [layout] → vial.json
rmkit layout show keyboard.toml                         # render it in the terminal

show accepts a keyboard.toml, a vial.json, or a raw KLE export (converted on the fly), and --variant picks one [[layout.variant]]. The renderer draws every box edge into a per-cell direction bitmask, so shared borders merge into proper junctions, two-rect ISO / big-ass Enter keys draw as their union silhouette, and encoders get rounded corners. A character grid cannot draw rotation, so rotated keys render axis-aligned with the angle printed inside.

Tests: unit snapshots for the renderer plus CLI integration tests against golden fixtures (corne, BAlice65, ANSI60 split backspace, and raw KLE exports with and without row,col legends). Regenerate the goldens with the loop in the comment above converted_toml_fixtures_are_up_to_date.

rynk-kle is git-pinned to the same commit as rmk-config; both need publishing before rmkit can be released.

The RMK docs already point at 'rmkit layout' for turning an existing KLE or
Vial layout into a keyboard.toml's [layout] section. The conversion engine
lives upstream in the rynk-kle crate (which round-trips its output through
RMK's own layout builder, so the result is guaranteed to build); this adds
the CLI over it:

- 'rmkit layout convert <kle|vial.json>' emits the [layout] section, with
  -o to write a file and --to-vial for the reverse direction
- 'rmkit layout show <keyboard.toml|vial.json|kle>' renders the physical
  layout as box-drawing art: shared borders merge into junctions, two-rect
  ISO/big-ass Enter keys draw as their union silhouette, encoders get
  rounded corners, and --variant picks one [[layout.variant]]
- CLI tests with golden fixtures (corne, BAlice65, ANSI60 split backspace,
  raw KLE exports with and without row,col legends)

A character grid cannot draw rotation, so rotated keys render axis-aligned
with the angle printed inside.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant