aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorXander <xander@icth.xyz>2023-07-03 15:27:49 +0200
committerXander <xander@icth.xyz>2023-07-03 15:27:49 +0200
commit5adc7cf997d481a6afb3ed95573d6eff44cbdd5b (patch)
tree08d1c1749d3ee16d1b7e2ee6ee0b820d3f351b0d /kernel
parent4c7934102bea39f002f637ebf12863bf99dd99a7 (diff)
downloadats-os-5adc7cf997d481a6afb3ed95573d6eff44cbdd5b.tar.xz
ats-os-5adc7cf997d481a6afb3ed95573d6eff44cbdd5b.zip
Added clear screen function
Diffstat (limited to 'kernel')
-rw-r--r--kernel/main.dats3
-rw-r--r--kernel/writer.dats17
-rw-r--r--kernel/writer.sats1
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