Skip to content

Commit 4d92340

Browse files
committed
feat: show keymap for editor font
1 parent 66eebc6 commit 4d92340

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

crates/sdo-web/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ wasm-bindgen = "0.2.84"
1212
web-sys = { version = "0.3.68", features = [
1313
"Window",
1414
"Document",
15+
"CssStyleDeclaration",
1516
"HtmlElement",
1617
"HtmlAnchorElement",
1718
"HtmlButtonElement",

crates/sdo-web/src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ impl Handle {
242242
}
243243
}
244244

245-
fn _eset_kb(&self, eset: &ESet<'_>) -> Result<(), JsValue> {
245+
/// Render a keyboard layout for the editor charset
246+
fn eset_kb(&self, eset: &ESet<'_>) -> Result<(), JsValue> {
247+
let container = self.document.create_element("div")?;
246248
let kb_img = KB_DRAW
247249
.to_page(eset)
248250
.or(Err("Failed to draw Keyboard Map"))?;
@@ -254,8 +256,10 @@ impl Handle {
254256
let kb_img_el = blob_image_el(&kb_blob)?;
255257
let np_img_el = blob_image_el(&np_blob)?;
256258

257-
self.output.append_child(&kb_img_el)?;
258-
self.output.append_child(&np_img_el)?;
259+
container.append_child(&kb_img_el)?;
260+
container.append_child(&np_img_el)?;
261+
262+
self.output.append_child(&container)?;
259263
Ok(())
260264
}
261265

@@ -271,6 +275,11 @@ impl Handle {
271275
Ok(pset)
272276
}
273277

278+
fn show_eset(&mut self, eset: &ESet<'_>) -> Result<(), JsValue> {
279+
self.eset_kb(eset)?;
280+
Ok(())
281+
}
282+
274283
fn show_pset(&mut self, pset: &PSet<'_>) -> Result<(), JsValue> {
275284
let h3 = self.document.create_element("h3")?;
276285
h3.set_text_content(Some("Characters"));
@@ -587,7 +596,8 @@ impl Handle {
587596

588597
match font_kind {
589598
FontKind::Editor => {
590-
let _eset = self.parse_eset(&_data)?;
599+
let eset = self.parse_eset(&_data)?;
600+
self.show_eset(&eset)?;
591601
}
592602
FontKind::Printer(_) => {
593603
let pset = self.parse_pset(&_data)?;

0 commit comments

Comments
 (0)