diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/main.dats | 3 | ||||
-rw-r--r-- | kernel/writer.dats | 17 | ||||
-rw-r--r-- | kernel/writer.sats | 1 |
3 files changed, 18 insertions, 3 deletions
diff --git a/kernel/main.dats b/kernel/main.dats index dfbaa49..bbd201a 100644 --- a/kernel/main.dats +++ b/kernel/main.dats @@ -4,6 +4,7 @@ staload "kernel/writer.sats" dynload "kernel/writer.dats" implement main0 () = ( - put_string(" Hello world\n"); + clear_screen(); + put_string("Hello world\n"); put_string("GOEIENDSG\n"); put_string("GOEIENDSG")) 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 diff --git a/kernel/writer.sats b/kernel/writer.sats index 3ccfd7b..65a2ea9 100644 --- a/kernel/writer.sats +++ b/kernel/writer.sats @@ -29,3 +29,4 @@ typedef writer = @{position = [a:int | a >= 0 && a < N] int (a), color_code = u castfn i2u8 {n: nat} (i: int n): uint8 n fun put_string (str : string) : void +fun clear_screen() : void |