From: Ian Jackson Date: Fri, 2 Oct 2020 22:43:48 +0000 (+0100) Subject: signal wresting X-Git-Tag: otter-0.2.0~798 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d2368f9f826354e98dcf55f999be10e470eca136;p=otter.git signal wresting Signed-off-by: Ian Jackson --- diff --git a/templates/script.ts b/templates/script.ts index f0c929f4..a64081df 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -96,7 +96,7 @@ var gen = 0; var cseq : ClientSeq = 0; var ctoken : string; var uo_map : { [k: string]: UoRecord | null } = Object.create(null); -var keyops_pieces : { [opname: string]: (uo: UoRecord) => void } = Object(); +var keyops_local : { [opname: string]: (uo: UoRecord) => void } = Object(); var svg_ns : string; var space : SVGGraphicsElement; @@ -105,6 +105,7 @@ var defs_marker : SVGGraphicsElement; var logdiv : HTMLElement; var status_node : HTMLElement; var uos_node : HTMLElement; +var wresting: boolean; const uo_kind_prec : { [kind: string]: number } = { 'GlobalExtra' : 50, @@ -257,7 +258,7 @@ function recompute_keybindings() { def_key: 'W', kind: 'ClientExtra', opname: 'wrest', - desc: 'Enter wresting mode', + desc: wresting ? 'Exit wresting mode' : 'Enter wresting mode', wrc: 'Predictable', }); var uo_keys = Object.keys(uo_map); @@ -292,7 +293,7 @@ function some_keydown(e: KeyboardEvent) { console.log('KEY UO', e, uo); if (uo.kind == 'Client' || uo.kind == 'ClientExtra') { - let f = keyops_pieces[uo.opname]; + let f = keyops_local[uo.opname]; // xxx 'wrest' // xxx 'lower' f(uo); @@ -313,6 +314,13 @@ function some_keydown(e: KeyboardEvent) { } } +keyops_local['wrest'] = function (uo: UoRecord) { + wresting = !wresting; + document.getElementById('wresting-warning')!.innerHTML = !wresting ? "" : + " (wresting mode!)"; + recompute_keybindings(); +} + // ----- clicking/dragging pieces ----- type DragInfo = { diff --git a/templates/session.tera b/templates/session.tera index 3857a4d0..69f27f19 100644 --- a/templates/session.tera +++ b/templates/session.tera @@ -16,7 +16,7 @@ margin-top: auto; } -

Hi {{nick | escape}}!

+

Hi {{nick | escape}}


 

nothing