-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathstate_preferences.ml
48 lines (41 loc) · 1.62 KB
/
state_preferences.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(******************************************************************************)
(* _ __ * The Kappa Language *)
(* | |/ / * Copyright 2010-2020 CNRS - Harvard Medical School - INRIA - IRIF *)
(* | ' / *********************************************************************)
(* | . \ * This file is distributed under the terms of the *)
(* |_|\_\ * GNU Lesser General Public License Version 3 *)
(******************************************************************************)
let fontSizeParamId = Js.string "kappappFontSize"
let defaultFontSize = 1.4
let minFontSize = 0.2
let maxFontSize = 3.
let currentFontSize = ref defaultFontSize
let initFromStorage () =
Js.Optdef.case
Dom_html.window##.localStorage
(fun () -> currentFontSize := defaultFontSize)
(fun st ->
currentFontSize :=
Js.Opt.case
(st##getItem fontSizeParamId)
(fun () -> defaultFontSize)
Js.parseFloat)
let set_parameters_as_default () =
let v' = string_of_float !currentFontSize in
Js.Optdef.iter Dom_html.window##.localStorage (fun st ->
st##setItem fontSizeParamId (Js.string v'))
let updateFontSize ~delta =
let () =
currentFontSize :=
max minFontSize (min (!currentFontSize +. delta) maxFontSize)
in
let v' = string_of_float !currentFontSize in
let () =
Dom_html.document##.body##.style##.fontSize := Js.string (v' ^ "em")
in
()
let agent_coloring = Js.Unsafe.obj [||]
let init () : unit Lwt.t =
let () = initFromStorage () in
Lwt.return_unit
let sync () : unit Lwt.t = Lwt.return_unit