diff options
author | Xander <xander@icth.xyz> | 2023-07-03 15:27:49 +0200 |
---|---|---|
committer | Xander <xander@icth.xyz> | 2023-07-03 15:27:49 +0200 |
commit | 5adc7cf997d481a6afb3ed95573d6eff44cbdd5b (patch) | |
tree | 08d1c1749d3ee16d1b7e2ee6ee0b820d3f351b0d /kernel/writer.dats | |
parent | 4c7934102bea39f002f637ebf12863bf99dd99a7 (diff) | |
download | ats-os-5adc7cf997d481a6afb3ed95573d6eff44cbdd5b.tar.xz ats-os-5adc7cf997d481a6afb3ed95573d6eff44cbdd5b.zip |
Added clear screen function
Diffstat (limited to 'kernel/writer.dats')
-rw-r--r-- | kernel/writer.dats | 17 |
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 |