From daff6548678ad6e1ef36dc2ddc00e69fb6631ca9 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Thu, 3 Mar 2022 15:44:32 +0100 Subject: [PATCH] added reset to TermWriteable --- src/kernel/MainTerm.hx | 7 +++++++ src/kernel/peripherals/Screen.hx | 7 +++++++ src/kernel/ui/TermBuffer.hx | 7 +++++++ src/kernel/ui/WindowContext.hx | 4 ++++ src/lib/TermWriteable.hx | 5 +++++ 5 files changed, 30 insertions(+) diff --git a/src/kernel/MainTerm.hx b/src/kernel/MainTerm.hx index 8e677e9..58ac832 100644 --- a/src/kernel/MainTerm.hx +++ b/src/kernel/MainTerm.hx @@ -94,4 +94,11 @@ class MainTerm implements TermWriteable { public function isColor():Bool { return Term.isColor(); } + + public function reset() { + this.setBackgroundColor(Black); + this.setTextColor(White); + this.clear(); + this.setCursorPos(0,0); + } } diff --git a/src/kernel/peripherals/Screen.hx b/src/kernel/peripherals/Screen.hx index 581c695..57de206 100644 --- a/src/kernel/peripherals/Screen.hx +++ b/src/kernel/peripherals/Screen.hx @@ -108,4 +108,11 @@ class Screen implements TermWriteable implements IPeripheral { public function isColor():Bool { return nativ.isColor(); } + + public function reset() { + this.setBackgroundColor(Black); + this.setTextColor(White); + this.clear(); + this.setCursorPos(0,0); + } } diff --git a/src/kernel/ui/TermBuffer.hx b/src/kernel/ui/TermBuffer.hx index 098eea2..d9f882a 100644 --- a/src/kernel/ui/TermBuffer.hx +++ b/src/kernel/ui/TermBuffer.hx @@ -166,4 +166,11 @@ class TermBuffer implements TermWriteable { public function isColor():Bool { throw new haxe.exceptions.NotImplementedException(); } + + public function reset() { + this.setBackgroundColor(Black); + this.setTextColor(White); + this.clear(); + this.setCursorPos(0,0); + } } diff --git a/src/kernel/ui/WindowContext.hx b/src/kernel/ui/WindowContext.hx index ba8b72d..2ed431c 100644 --- a/src/kernel/ui/WindowContext.hx +++ b/src/kernel/ui/WindowContext.hx @@ -124,4 +124,8 @@ class WindowContext implements TermWriteable { public function isColor():Bool { return writer.isColor(); } + + public function reset() { + writer.reset(); + } } diff --git a/src/lib/TermWriteable.hx b/src/lib/TermWriteable.hx index f4fb87f..9705ce1 100644 --- a/src/lib/TermWriteable.hx +++ b/src/lib/TermWriteable.hx @@ -36,4 +36,9 @@ interface TermWriteable { public function isColor():Bool; // setPaletteColor(...) // getPaletteColor(colour) + + /** + Clears the screen, resetes the courser to (0,0) and resetes the color to Black and White. + **/ + public function reset():Void; }