15 descr: string, |
15 descr: string, |
16 default: string, |
16 default: string, |
17 pgiptype: PgipTypes.pgiptype, |
17 pgiptype: PgipTypes.pgiptype, |
18 get: unit -> string, |
18 get: unit -> string, |
19 set: string -> unit} |
19 set: string -> unit} |
|
20 val options_pref: string -> string -> string -> preference |
20 val generic_pref: ('a -> string) -> (string -> 'a) -> PgipTypes.pgiptype -> |
21 val generic_pref: ('a -> string) -> (string -> 'a) -> PgipTypes.pgiptype -> |
21 'a Unsynchronized.ref -> string -> string -> preference |
22 'a Unsynchronized.ref -> string -> string -> preference |
22 val string_pref: string Unsynchronized.ref -> string -> string -> preference |
23 val string_pref: string Unsynchronized.ref -> string -> string -> preference |
23 val real_pref: real Unsynchronized.ref -> string -> string -> preference |
24 val real_pref: real Unsynchronized.ref -> string -> string -> preference |
24 val int_pref: int Unsynchronized.ref -> string -> string -> preference |
25 val int_pref: int Unsynchronized.ref -> string -> string -> preference |
50 default: string, |
51 default: string, |
51 pgiptype: PgipTypes.pgiptype, |
52 pgiptype: PgipTypes.pgiptype, |
52 get: unit -> string, |
53 get: unit -> string, |
53 set: string -> unit}; |
54 set: string -> unit}; |
54 |
55 |
|
56 |
|
57 (* options as preferences *) |
|
58 |
|
59 fun options_pref option_name pgip_name descr : preference = |
|
60 let |
|
61 val options = Options.default (); |
|
62 val typ = Options.typ options option_name; |
|
63 val pgiptype = |
|
64 if typ = Options.boolT then PgipTypes.Pgipbool |
|
65 else if typ = Options.intT then PgipTypes.Pgipint (NONE, NONE) |
|
66 else if typ = Options.realT then PgipTypes.Pgipreal |
|
67 else PgipTypes.Pgipstring; |
|
68 in |
|
69 {name = pgip_name, |
|
70 descr = descr, |
|
71 default = Options.get_default option_name, |
|
72 pgiptype = pgiptype, |
|
73 get = fn () => Options.get_default option_name, |
|
74 set = Options.put_default option_name} |
|
75 end; |
|
76 |
|
77 |
|
78 (* generic preferences *) |
|
79 |
55 fun mkpref raw_get raw_set typ name descr : preference = |
80 fun mkpref raw_get raw_set typ name descr : preference = |
56 let |
81 let |
57 fun get () = CRITICAL raw_get; |
82 fun get () = CRITICAL raw_get; |
58 fun set x = CRITICAL (fn () => raw_set x); |
83 fun set x = CRITICAL (fn () => raw_set x); |
59 in {name = name, descr = descr, pgiptype = typ, get = get, set = set, default = get ()} end; |
84 in {name = name, descr = descr, pgiptype = typ, get = get, set = set, default = get ()} end; |
60 |
|
61 |
|
62 (* generic preferences *) |
|
63 |
85 |
64 fun generic_pref read write typ r = |
86 fun generic_pref read write typ r = |
65 mkpref (fn () => read (! r)) (fn x => r := write x) typ; |
87 mkpref (fn () => read (! r)) (fn x => r := write x) typ; |
66 |
88 |
67 val string_pref = generic_pref I I PgipTypes.Pgipstring; |
89 val string_pref = generic_pref I I PgipTypes.Pgipstring; |