aboutsummaryrefslogtreecommitdiff
path: root/kernel/writer.dats
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/writer.dats')
-rw-r--r--kernel/writer.dats17
1 files changed, 15 insertions, 2 deletions
diff --git a/kernel/writer.dats b/kernel/writer.dats
index cd6f5d7..3e75a90 100644
--- a/kernel/writer.dats
+++ b/kernel/writer.dats
@@ -51,7 +51,6 @@ staload WRITER = {
end
}
-
fun put_char (c : char, writer: &writer) : void = let
val buf = get_buffer()
val pos = writer.position
@@ -62,12 +61,16 @@ in
in
if (new_pos < N) then
writer.position := new_pos
+ else
+ clear_screen()
end
else (
buf.1->[writer.position] := @{ ascii_character = c, color_code = writer.color_code};
if (pos < N - 1) then
- writer.position := succ(pos));
+ writer.position := succ(pos)
+ else
+ clear_screen());
let prval() = eat_buffer buf in () end
end
@@ -80,3 +83,13 @@ implement put_string (str : string) : void = let
prval() = fpf(pf)
in end
+implement clear_screen() : void = let
+ val (pf, fpf | p_val) = $WRITER.getref()
+ fun loop {n : nat | n < N - 1} .<N-n>. (i : int n, wr : &writer) : void =
+ (put_char('\0', wr); if (i < N - 2) then loop(i+1,wr))
+in
+ !p_val.position := 0;
+ loop(0,!p_val);
+ !p_val.position := 0;
+ let prval() = fpf(pf) in () end
+end