diff options
Diffstat (limited to 'lib/DATS/writer.dats')
-rw-r--r-- | lib/DATS/writer.dats | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/DATS/writer.dats b/lib/DATS/writer.dats index 9b2fd78..b8625f4 100644 --- a/lib/DATS/writer.dats +++ b/lib/DATS/writer.dats @@ -97,31 +97,27 @@ in in implement put_string (str : string) : void = let - val (vbox pf | p) = ref_get_viewptr(writer_ref) - implement init_exec$fwork<writer_t>(v) = let + implement exec_void$fwork<writer_t>(v) = let implement string_foreach$fwork<writer_t> (c,env) = put_char(c,env) val _ = $effmask_all(string_foreach_env<writer_t> (g1ofg0(str),v)) in end in - init_exec<writer_t>(!p) + $effmask_ref(exec_void<writer_t>(writer_ref)) end implement clear_screen() : void = let - val (vbox pf | p) = ref_get_viewptr(writer_ref) - implement init_exec$fwork<writer_t>(v) = _clear_screen(v) + implement exec_void$fwork<writer_t>(v) = _clear_screen(v) + implement initialize$fwork<writer_t>(v) = + ( + v := @{position = 0, color_code = code_value(White,Black)}; + let prval() = opt_some v in true end + ) in - if p->initialized then - init_exec<writer_t> (!p) - else - let - prval () = opt_unnone p->obj - val () = p->obj := @{position = 0, color_code = code_value(White,Black)} - val () = p->initialized := true - val () = _clear_screen(p->obj) - prval () = opt_some p->obj - in - end + if not writer_ref->initialized then + initialize<writer_t>(writer_ref); + + exec_void<writer_t>(writer_ref) end end |