Skip to content

Commit 7205c9a

Browse files
committed
generate the layout id allocation list
1 parent 285d76a commit 7205c9a

File tree

3 files changed

+304
-4
lines changed

3 files changed

+304
-4
lines changed
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
<!-- Generated file, do not edit. -->
2+
3+
# Layout Id Allocation List
4+
5+
- `0x10`: English/United States
6+
- `0x11`: English/United Kingdom
7+
- `0x12`: English/Japan
8+
- `0x13`:
9+
- `0x14`:
10+
- `0x15`: English/Dvorak (Programmers)
11+
- `0x16`: English/Colemak-DH (ISO)
12+
- `0x17`: English/Colemak-DH Wide (ISO)
13+
- `0x18`: English/Dvorak
14+
- `0x19`: English/Colemak
15+
- `0x1a`: English/Workman
16+
- `0x1b`: English/Colemak-DH (ANSI)
17+
- `0x1c`: English/Colemak-DH (matrix)
18+
- `0x1d`: English/Canary (matrix)
19+
- `0x1e`: English/Canary
20+
- `0x1f`: English/Colemak-DH Wide (ANSI)
21+
- `0x20`: German/Germany
22+
- `0x21`: German/Switzerland
23+
- `0x22`: German/Neo 2
24+
- `0x23`: German/Bone
25+
- `0x24`: German/Mine
26+
- `0x25`: German/Noted
27+
- `0x26`: German/CMOS
28+
- `0x27`:
29+
- `0x28`:
30+
- `0x29`:
31+
- `0x2a`:
32+
- `0x2b`:
33+
- `0x2c`:
34+
- `0x2d`:
35+
- `0x2e`:
36+
- `0x2f`:
37+
- `0x30`: French/France
38+
- `0x31`: French/Canada
39+
- `0x32`: French/Switzerland
40+
- `0x33`: French/Bepo
41+
- `0x34`: French/Ergo-L
42+
- `0x35`: French/Optimot Ergo
43+
- `0x36`: French/Erglace
44+
- `0x37`: French/Ergopti
45+
- `0x38`:
46+
- `0x39`:
47+
- `0x3a`:
48+
- `0x3b`:
49+
- `0x3c`:
50+
- `0x3d`:
51+
- `0x3e`:
52+
- `0x3f`:
53+
- `0x40`: Italian/Italy
54+
- `0x41`:
55+
- `0x42`:
56+
- `0x43`:
57+
- `0x44`:
58+
- `0x45`:
59+
- `0x46`:
60+
- `0x47`:
61+
- `0x48`: Lithuanian/Lithuania
62+
- `0x49`: Latvian/Latvia
63+
- `0x4a`: Finnish/Finland
64+
- `0x4b`: Estonian/Estonia
65+
- `0x4c`:
66+
- `0x4d`:
67+
- `0x4e`:
68+
- `0x4f`:
69+
- `0x50`: Spanish/Spain
70+
- `0x51`:
71+
- `0x52`:
72+
- `0x53`:
73+
- `0x54`:
74+
- `0x55`:
75+
- `0x56`:
76+
- `0x57`:
77+
- `0x58`: Polish/Poland
78+
- `0x59`:
79+
- `0x5a`:
80+
- `0x5b`:
81+
- `0x5c`:
82+
- `0x5d`:
83+
- `0x5e`:
84+
- `0x5f`:
85+
- `0x60`: Portuguese/Brazil (ABNT2)
86+
- `0x61`:
87+
- `0x62`: Portuguese/Portugal
88+
- `0x63`:
89+
- `0x64`:
90+
- `0x65`:
91+
- `0x66`:
92+
- `0x67`:
93+
- `0x68`:
94+
- `0x69`:
95+
- `0x6a`:
96+
- `0x6b`:
97+
- `0x6c`:
98+
- `0x6d`:
99+
- `0x6e`:
100+
- `0x6f`:
101+
- `0x70`: Russian/Russia
102+
- `0x71`:
103+
- `0x72`:
104+
- `0x73`:
105+
- `0x74`: Belarusian/Belarus
106+
- `0x75`:
107+
- `0x76`:
108+
- `0x77`:
109+
- `0x78`: Ukrainian/Ukraine
110+
- `0x79`:
111+
- `0x7a`:
112+
- `0x7b`:
113+
- `0x7c`:
114+
- `0x7d`:
115+
- `0x7e`:
116+
- `0x7f`:
117+
- `0x80`: Swedish/Sweden
118+
- `0x81`: Czech/Czechia
119+
- `0x82`: Slovenian/Slovenia
120+
- `0x83`: Greek/Greece
121+
- `0x84`: Hebrew/Israel (מסורתי)
122+
- `0x85`: Dutch/Netherlands
123+
- `0x86`: Dutch/Belgium
124+
- `0x87`: Hungarian/Hungary
125+
- `0x88`: Norwegian Bokmål/Norway
126+
- `0x89`: Turkish/Türkiye Q
127+
- `0x8a`: Turkish/Türkiye F
128+
- `0x8b`: English/Norman
129+
- `0x8c`: English/Halmak
130+
- `0x8d`: Arabic/Saudi Arabia (101)
131+
- `0x8e`: Arabic/Saudi Arabia (102)
132+
- `0x8f`: Persian/Persian Legacy «پیش فرض فارسی»
133+
- `0x90`: Hebrew/Israel (ארקן)
134+
- `0x91`: Persian/Persian Standard «استاندارد فارسی»
135+
- `0x92`: English/Engram
136+
- `0x93`: English/Nerps
137+
- `0x94`: English/Nerps (matrix)
138+
- `0x95`: English/Hands Down Neu
139+
- `0x96`: English/Sturdy
140+
- `0x97`: Spanish/Mexico
141+
- `0x98`: Polish/FWYR
142+
- `0x99`: English/Graphite
143+
- `0x9a`: Thai/Thai Kedmanee
144+
- `0x9b`: Thai/Thai Pattachote
145+
- `0x9c`: Thai/Thai Manoonchai V1
146+
- `0x9d`: Norwegian Bokmål/Kvikk
147+
- `0x9e`: Norwegian Bokmål/Skarp
148+
- `0x9f`: Norwegian Bokmål/Dvorak
149+
- `0xa0`: Romanian/Romania
150+
- `0xa1`: English/Gallium
151+
- `0xa2`: English/Gallium (matrix)
152+
- `0xa3`: English/Hands Down Promethium (Matrix)
153+
- `0xa4`: English/APTv3
154+
- `0xa5`: English/Focal
155+
- `0xa6`: German/AdNW BuT-XCV
156+
- `0xa7`: Danish/Denmark
157+
- `0xa8`: English/Enthium V6 (Matrix)
158+
- `0xa9`: English/Night (matrix)
159+
- `0xaa`: English/MTGAP
160+
- `0xab`: Spanish/Dvorak
161+
- `0xac`: Spanish/Dvorak (Latin American)
162+
- `0xad`:
163+
- `0xae`:
164+
- `0xaf`:
165+
- `0xb0`:
166+
- `0xb1`:
167+
- `0xb2`:
168+
- `0xb3`:
169+
- `0xb4`:
170+
- `0xb5`:
171+
- `0xb6`:
172+
- `0xb7`:
173+
- `0xb8`: English/Enthium V10 (Matrix)
174+
- `0xb9`:
175+
- `0xba`:
176+
- `0xbb`:
177+
- `0xbc`:
178+
- `0xbd`:
179+
- `0xbe`:
180+
- `0xbf`:
181+
- `0xc0`:
182+
- `0xc1`:
183+
- `0xc2`:
184+
- `0xc3`:
185+
- `0xc4`:
186+
- `0xc5`:
187+
- `0xc6`:
188+
- `0xc7`:
189+
- `0xc8`:
190+
- `0xc9`:
191+
- `0xca`:
192+
- `0xcb`:
193+
- `0xcc`:
194+
- `0xcd`:
195+
- `0xce`:
196+
- `0xcf`:
197+
- `0xd0`:
198+
- `0xd1`:
199+
- `0xd2`:
200+
- `0xd3`:
201+
- `0xd4`:
202+
- `0xd5`:
203+
- `0xd6`:
204+
- `0xd7`:
205+
- `0xd8`:
206+
- `0xd9`:
207+
- `0xda`:
208+
- `0xdb`:
209+
- `0xdc`:
210+
- `0xdd`:
211+
- `0xde`:
212+
- `0xdf`:
213+
- `0xe0`:
214+
- `0xe1`:
215+
- `0xe2`:
216+
- `0xe3`:
217+
- `0xe4`:
218+
- `0xe5`:
219+
- `0xe6`:
220+
- `0xe7`:
221+
- `0xe8`:
222+
- `0xe9`:
223+
- `0xea`:
224+
- `0xeb`:
225+
- `0xec`:
226+
- `0xed`:
227+
- `0xee`:
228+
- `0xef`:
229+
- `0xf0`:
230+
- `0xf1`:
231+
- `0xf2`:
232+
- `0xf3`:
233+
- `0xf4`:
234+
- `0xf5`:
235+
- `0xf6`:
236+
- `0xf7`:
237+
- `0xf8`:
238+
- `0xf9`:
239+
- `0xfa`:
240+
- `0xfb`:
241+
- `0xfc`:
242+
- `0xfd`:
243+
- `0xfe`:
244+
- `0xff`:
245+
246+
87 allocated identifiers
247+
248+
153 free identifiers
249+

packages/keybr-keyboard/lib/layout.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { writeFile } from "node:fs/promises";
12
import { test } from "node:test";
23
import { equal, includes, isNotEmpty } from "rich-assert";
34
import { Language } from "./language.ts";
@@ -30,3 +31,55 @@ test("find layouts for all languages", () => {
3031
equal(layout.language.script, language.script);
3132
}
3233
});
34+
35+
await makeIdAllocationReport();
36+
37+
async function makeIdAllocationReport() {
38+
const dnLanguage = new Intl.DisplayNames("en", { type: "language" });
39+
const dnRegion = new Intl.DisplayNames("en", { type: "region" });
40+
41+
function formatLayoutName(layout: Layout): string {
42+
const languageName = dnLanguage.of(layout.language.id)!;
43+
const layoutName = layout.name.replaceAll(/\{[-A-Z]+\}/g, (id) => {
44+
return dnRegion.of(id.substring(1, id.length - 1))!;
45+
});
46+
return `${languageName}/${layoutName}`;
47+
}
48+
49+
const lines = [];
50+
51+
lines.push(`<!-- Generated file, do not edit. -->`);
52+
lines.push(``);
53+
lines.push(`# Layout Id Allocation List`);
54+
lines.push(``);
55+
56+
const layouts = new Map<number, Layout>(
57+
Layout.ALL.map((layout) => [layout.xid, layout]),
58+
);
59+
60+
let numAlloc = 0;
61+
let numFree = 0;
62+
63+
for (let index = 0x10; index <= 0xff; index += 1) {
64+
const layout = layouts.get(index);
65+
const id = `0x${index.toString(16).padStart(2, "0")}`;
66+
if (layout != null) {
67+
lines.push(`- \`${id}\`: ${formatLayoutName(layout)}`);
68+
numAlloc += 1;
69+
} else {
70+
lines.push(`- \`${id}\`:`);
71+
numFree += 1;
72+
}
73+
}
74+
75+
lines.push(``);
76+
lines.push(`${numAlloc} allocated identifiers`);
77+
lines.push(``);
78+
lines.push(`${numFree} free identifiers`);
79+
lines.push(``);
80+
81+
await writeFile(
82+
`${import.meta.dirname}/layout-id.md`,
83+
lines.join("\n") + "\n",
84+
);
85+
}

packages/keybr-keyboard/lib/layout.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export class Layout implements XEnumItem {
290290
);
291291
static readonly FI_FI = new Layout(
292292
/* id= */ "fi-fi",
293-
/* xid= */ 0xa27,
293+
/* xid= */ 0x4a,
294294
/* name= */ "{FI}",
295295
/* family= */ "qwerty",
296296
/* language= */ Language.FI,
@@ -303,7 +303,6 @@ export class Layout implements XEnumItem {
303303
Geometry.MATRIX,
304304
),
305305
);
306-
307306
static readonly FR_FR = new Layout(
308307
/* id= */ "fr-fr",
309308
/* xid= */ 0x30,
@@ -1242,10 +1241,9 @@ export class Layout implements XEnumItem {
12421241
Geometry.MATRIX,
12431242
),
12441243
);
1245-
12461244
static readonly ET_EE = new Layout(
12471245
/* id= */ "et-ee",
1248-
/* xid= */ 0xae,
1246+
/* xid= */ 0x4b,
12491247
/* name= */ "{EE}",
12501248
/* family= */ "qwerty",
12511249
/* language= */ Language.ET,

0 commit comments

Comments
 (0)