From: Ian Jackson Date: Sat, 3 Oct 2020 00:39:22 +0000 (+0100) Subject: can pin X-Git-Tag: otter-0.2.0~789 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=01a2e0c847b74847234373d801c0d19f4d9ae949;p=otter.git can pin Signed-off-by: Ian Jackson --- diff --git a/src/api.rs b/src/api.rs index 1db1a859..d218421c 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,4 +1,4 @@ -p// Copyright 2020 Ian Jackson +// Copyright 2020 Ian Jackson // SPDX-License-Identifier: AGPL-3.0-or-later // There is NO WARRANTY. @@ -391,6 +391,7 @@ pub fn mount(rocket_instance: Rocket) -> Rocket { api_raise, api_move, api_wrest, + api_pin, api_uo, ]) } diff --git a/src/session.rs b/src/session.rs index cb2203a6..e24bd370 100644 --- a/src/session.rs +++ b/src/session.rs @@ -29,6 +29,7 @@ struct SessionPieceLoadJson<'r> { held : &'r Option, z : ZCoord, zg : Generation, + pinned : bool, uos: &'r [UoDescription], } @@ -105,6 +106,7 @@ fn session(form : Json) -> Result { held : &pr.held, z : pr.zlevel.z, zg : pr.zlevel.zg, + pinned : pr.pinned, uos : &p.ui_operations()?, }; diff --git a/templates/script.ts b/templates/script.ts index fa7ae345..d40ac99e 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -359,6 +359,19 @@ keyops_local['wrest'] = function (uo: UoRecord) { recompute_keybindings(); } +keyops_local['pin' ] = function (uo) { pin_unpin(uo, true ); } +keyops_local['unpin'] = function (uo) { pin_unpin(uo, false); } + +function pin_unpin(uo: UoRecord, newpin: boolean) { + for (let piece of uo.targets!) { + let p = pieces[piece]!; + p.pinned = newpin; + api_piece(api, 'pin', piece,p, newpin); + redisplay_ancillaries(piece,p); + } + recompute_keybindings(); +} + // ----- clicking/dragging pieces ----- type DragInfo = { @@ -491,7 +504,7 @@ function redisplay_ancillaries(piece: PieceId, p: PieceInfo) { } else if (p.last_seen_moved != null) { halo_colour = 'yellow'; } else if (p.held != null && p.pinned) { - halo_colour = 'white'; + halo_colour = '#8cf'; } if (halo_colour != null) { let nelem = ancillary_node(piece, halo_colour);