From: Ian Jackson Date: Sat, 3 Apr 2021 20:44:38 +0000 (+0100) Subject: special selection: wip key handling X-Git-Tag: otter-0.5.0~224 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e7e2c6c83ff7ba601edccb46d1150bafdc14847e;p=otter.git special selection: wip key handling Signed-off-by: Ian Jackson --- diff --git a/templates/macros.tera b/templates/macros.tera index 854ca7e0..439ff23f 100644 --- a/templates/macros.tera +++ b/templates/macros.tera @@ -70,6 +70,8 @@ Hi {{nick | escape}} {% endmacro errors %} {% macro space() %} +
-
Mouse select/deselect/drag
-
shift multiple selection
+
Mouse select/deselect/drag + shift multiple selection
+
0-9 special selection
Show H this help U players diff --git a/templates/script.ts b/templates/script.ts index a1aa33bf..19193940 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -136,6 +136,7 @@ var zoom_btn : HTMLInputElement; var links_elem : HTMLElement; var wresting: boolean; var occregions: wasm_bindgen.RegionList; +let special_count: number | null; var movehist_gen: number = 0; const MOVEHIST_ENDS = 2.5; @@ -398,6 +399,19 @@ function some_keydown(e: KeyboardEvent) { return pane_switch(pane); } + let special_count_key = parseInt(e.key); + if (isFinite(special_count_key)) { + if (special_count == null) special_count = 0; + special_count *= 10; + special_count += special_count_key; + special_count %= 100; + special_count_reupdate(); + } + if (e.key == ' ') { + special_count = null; + special_count_reupdate(); + } + let uo = uo_map[e.key]; if (uo === undefined || uo === null) return; @@ -436,6 +450,32 @@ function pane_switch(newpane: PaneName) { new_e.removeAttribute('style'); } +function special_count_reupdate() { + let style_elem = document.getElementById("space-cursor-style")!; + let style_text; + if (special_count == null) { + style_text = ''; + } else { + let path = 'stroke-linecap="square" d="M -10 -10 10 10 M 10 -10 -10 10"'; + let svg = +` + + + + ${special_count} + `; + console.log(svg); + let svg_data = btoa(svg); + style_text = +`svg[id=space] { + cursor: url(data:image/svg+xml;base64,${svg_data}) 15 50, text; +}`; + } + style_elem.innerHTML = style_text; +} + keyops_local['left' ] = function (uo: UoRecord) { rotate_targets(uo, +1); } keyops_local['right'] = function (uo: UoRecord) { rotate_targets(uo, -1); }