feat(extra-keys): add an optional tekl DSL authoring path for extra-keys - #5241
feat(extra-keys): add an optional tekl DSL authoring path for extra-keys#5241poisongod wants to merge 1 commit into
Conversation
|
Let's be realistic: that's can't be accepted. You are introducing a new entity that:
In other words make things more complicated rather than solving Extra Keys Row configuration issue directly.
You provided zero proof on that. Please give a link to one or more tickets under https://github.com/termux/termux-app/issues. If that's you who prefer to use helper scripts - you are only one of many.
If people want a higher-level configuration, they will want something like shown on screenshot below:
|
|
Thanks for the honest feedback, sylirre. Let me address the "middle layer" point precisely, because I think it's a misunderstanding of the proposal. There is no middle layer — On the evidence point (2): I'll gather tickets. Known friction sources: escaping of On "users want a GUI" (3): agree a GUI is the best surface for casual users, and it should generate config — but it needs to generate some text format. JSON is the worst possible GUI-serialization format from a diff/merge standpoint. A GUI in front of tekl gives you both visual editing and a clean, diffable text backing store. These aren't competitors; tekl is the substrate a GUI serializes to/from. Nothing here requires maintainer consensus today — I'm happy to keep this as a working, public reference implementation. Happy to defer the property-discovery question to your guidance. |
What is a companion CLI (termux-extrakey-tekl, with --watch/--reload) then?
I can't get why a custom format is needed when the original issue is to make app configuration user friendly? Custom format needs a dedicated documentation which users need to study first before making adjustments to app config - unless you are proposing to use your npm tool for configuration.
Pay attention that I asked rather about facts that people prefer to use helper scripts to manage extra keys. I well know about escaping
Provided screenshots are from my custom terminal app where everything of that is implemented and work. You as AI user should be able to query your agent for possible implementation variants with end-to-end plans, with all pros and cons for each. Don't look at |
|
Besides that, have a look on what you submitted as pull request: https://github.com/poisongod/termux-app/blob/c0b9a443abbd68b262d7937c70045a853c55a7dc/docs/tekl-dsl-proposal.md No app changes. Just this doc which actually is a draft for pull request description. |
|
1. On the CLI being the middle layer The CLI lives in the reference repo ( 2. On "why a custom format when JSON is cheap" Two different costs: cheap to ship — agreed, that's why On the deeper point — 3. On evidence: "people prefer helper scripts" You asked twice, so let me be exact about what the tracker shows and does not show. It does not show issues titled "I use a script" — users who wrap 4. On "no app changes, just a doc" Correct — deliberately. The PR reviews the design before anyone pays for a Kotlin port; porting the wrong design wastes reviewer time. The reference implementation (tokenizer/parser/compiler, 76 passing tests, CLI+JIT) lives in its own repo so the review is decoupled from it. If the design clears this round, the next commits on this PR are the Kotlin port + tests, scoped exactly as §3.1: pure compiler, |

PR (draft for discussion)
0 TL;DR
This is a proposal with a working reference implementation. It adds an
optional way to author
extra-keys:extra-keys-teklproperty holds tekl source.ExtraKeyButtonmodel — no JSON round-trip.extra-keysJSON path stays exactly as it is; legacy configs keepworking; nothing is migrated or removed.
0.5 It already runs today (MVP)
The language and toolchain are already built and exercised — not a sketch. See
the public repo:
It ships a Node.js implementation of the full pipeline used in this PR's design:
Try it now inside a fresh Termux:
keys.teklexample (the repo's own sample; seeREADME.mdfor the full mapping):While editing
keys.tekl, the--watchmode recompiles and refreshes the keyboardimmediately — the same UX this PR would enable natively in the app.
The PR would port this tested compiler into
termux-shared/Kotlin and connect it to theproperty loader; the grammar, tests and docs all already exist.
1 Background and motivation
1.1
extra-keysis a config surface many users touch, and authoring has frictionJSON was a reasonable choice when
extra-keyslaunched; it is a well-known format andmaps directly to the internal model. Over time, a few friction points have surfaced in
user reports:
termux.propertiesadds its own escaping rules on top of JSON's. Gettingcharacters like
\or quotes right through two escaping layers is a common source ofuser confusion (e.g. issues around
\and quotes inextra-keysvalues).JSONExceptionwithout a line or column, so users must debug the whole string by eye.CTRL+C) needs{"macro":"CTRL C","display":"CTRL C"}; rows of a dozen keys become hard to read,and there is no natural way to add a comment.
None of this is anyone's fault — it is the inherent shape of "JSON inside
.properties". It is also not something this PR tries to "fix away"; it simply offers asecond, friendlier authoring surface next to the existing one.
1.2 Users already build their own authoring tools
Because the JSON path is unforgiving, users in the wild have created helper scripts that
edit
extra-keysintermux.propertiesand reload settings — including setups shared incommunity posts. That is a signal: people want a higher-level, safer way to author their
keyboard. tekl is a formalization of exactly that: a small language with a compiler, so
the "helper script" becomes maintainable and validated.
1.3 Precedent: a keyboard layout is a small language
A layout is a matrix of cells with a small fixed semantics (plain key / combo / label /
popup). Key-binding configs in vim, zsh or ssh chose DSLs over JSON for the same reason:
the format follows the structure of the thing being configured, rather than the other way
around. Termux already treats
extra-keysas a shareable, agnostic component intermux-shared; a DSL authoring path fits that direction.2 What tekl looks like
2.1 Grammar (four productions)
ESC"ESC"CTRL(C){"macro":"CTRL C","display":"CTRL C"}HOME:Start{"key":"HOME","display":"Start"}ESC.F1{"key":"ESC","popup":"F1"}CTRL(C):copy.F5{"macro":"CTRL C","display":"copy","popup":"F5"};All reserved words are existing Termux key names. Keys are identifiers, so the
double-escaping scenarios above cannot occur by construction.
2.2 Authoring benefits
CTRL(Creports line/column with a caret instead of a genericload-time failure.
DRAWER/KEYBOARD.3 Design and footprint
3.1 Integration
extra-keyshandling is untouched; whenextra-keys-teklis absent/empty, behavior isbyte-identical to today.
List<ExtraKeyButton>), no Android API, unittestable in isolation — usable later by plugins or a TUI editor, and by the companion
CLI (
termux-extrakey-tekl, with--watch/--reload), which is part of the samelanguage project.
ExtraKeysView) sees the same model as today; no changes there.3.2 Explicitly out of scope
3.3 Maturity
Covered in §0.5: the compiler, CLI and 59 tests already exist and are publicly
reviewable; the integration part of this PR is a port plus property wiring, not a
greenfield design.
4 Success criteria
termux-reload-settings.CTRL(Cproduces a positioned message instead of a silent failure.5 Open questions (happy to follow maintainer guidance)
extra-keys-teklkey vs value-prefix detection?(leaning dedicated key, but flexible)
Thanks for reading — feedback very welcome.