12 |
|
|
13 |
val new : unit -> mode |
val new : unit -> mode |
14 |
val set : mode * string * string -> unit |
val set : mode * string * string -> unit |
15 |
|
val cancel : mode * string -> unit |
16 |
|
val reset : mode -> unit |
17 |
|
|
18 |
val configAnchor : mode -> string -> (unit -> string) option |
val configAnchor : mode -> string -> (unit -> string) option |
19 |
|
|
30 |
type mode = string StringMap.map ref |
type mode = string StringMap.map ref |
31 |
|
|
32 |
fun set (m, a, s) = m := StringMap.insert (!m, a, s) |
fun set (m, a, s) = m := StringMap.insert (!m, a, s) |
33 |
|
fun reset m = m := StringMap.empty |
34 |
|
fun cancel (m, a) = (m := #1 (StringMap.remove (!m, a))) |
35 |
|
handle LibBase.NotFound => () |
36 |
|
|
37 |
fun new () = ref (StringMap.empty) |
fun new () = ref StringMap.empty |
38 |
|
|
39 |
fun configAnchor m s = |
fun configAnchor m s = |
40 |
case StringMap.find (!m, s) of |
case StringMap.find (!m, s) of |
48 |
in |
in |
49 |
if line = "" then () |
if line = "" then () |
50 |
else case String.tokens Char.isSpace line of |
else case String.tokens Char.isSpace line of |
51 |
[a, d] => (set (m, a, d); |
[a, d] => (set (m, a, d); loop ()) |
52 |
loop ()) |
| ["-"] => (reset m; loop ()) |
53 |
| _ => (Say.say [f, ": malformed line (ignored)\n"]; |
| [a] => (cancel (m, a); loop ()) |
54 |
loop ()) |
| _ => (Say.say [f, ": malformed line (ignored)\n"]; loop ()) |
55 |
end |
end |
56 |
in |
in |
57 |
loop () |
loop () |