chiark / gitweb /
signal wresting
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 2 Oct 2020 22:43:48 +0000 (23:43 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 2 Oct 2020 22:43:53 +0000 (23:43 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/script.ts
templates/session.tera

index f0c929f41bbd46349e4c5196f9a604631d550b77..a64081df16d84d143adf94d8a44e2d1478ea5e00 100644 (file)
@@ -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 ? "" :
+      " <strong>(wresting mode!)</strong>";
+  recompute_keybindings();
+}
+
 // ----- clicking/dragging pieces -----
 
 type DragInfo = {
index 3857a4d00f42980a5e3601a7d6e754b266a16c8d..69f27f19f7ec91d47860b7caed5c98fd74c06b40 100644 (file)
@@ -16,7 +16,7 @@
     margin-top: auto;
   }
 </style>
-<h1>Hi {{nick | escape}}!</h1>
+<h1>Hi {{nick | escape}}<span id="wresting-warning"></div></h1>
 <pre id="error"></pre>
 <p>
 <div id="status">nothing</div>