From a6ed7818da75860c8f2b0ce78104bbc021c75254 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 19 Dec 2022 21:06:23 +0100 Subject: [PATCH] another big refactor --- src/Startup.hx | 2 -- src/bin/HelloWorld.hx | 5 +++-- src/bin/Net.hx | 8 ++++---- src/bin/Terminal.hx | 6 +++--- src/kernel/Init.hx | 2 +- src/kernel/KernelEvents.hx | 4 ++-- src/kernel/Log.hx | 2 +- src/kernel/MainTerm.hx | 10 +++++----- src/kernel/Timer.hx | 4 ++-- src/kernel/net/Net.hx | 5 ++--- src/kernel/net/Routing.hx | 3 +-- src/kernel/peripherals/Drive.hx | 1 - src/kernel/peripherals/Modem.hx | 4 ++-- src/kernel/peripherals/Redstone.hx | 2 +- src/kernel/peripherals/Screen.hx | 7 +++---- src/kernel/ui/Pixel.hx | 2 +- src/kernel/ui/TermBuffer.hx | 7 +++---- src/kernel/ui/TermWriteable.hx | 8 ++++---- src/kernel/ui/VirtualTermWriter.hx | 10 +++++----- src/kernel/ui/WindowContext.hx | 10 +++++----- src/{util => lib}/BuildInfo.hx | 2 +- src/{util => lib}/Color.hx | 2 +- src/{util => lib}/Debug.hx | 2 +- src/{util => lib}/Extender.hx | 2 +- src/{util => lib}/MathI.hx | 2 +- src/{util => lib}/ObjMerge.hx | 2 +- src/{util => lib}/Pos.hx | 4 ++-- src/{util => lib}/Pos3.hx | 4 ++-- src/{util => lib}/Rect.hx | 4 +--- src/lib/TermIO.hx | 2 +- src/{util => lib}/Vec.hx | 2 +- src/lib/{ => cli}/CLIBase.hx | 2 +- src/lib/{ => cli}/TermHandle.hx | 2 +- src/{util => lib/observable}/DummyObservable.hx | 2 +- src/{util => lib/observable}/Observable.hx | 2 +- src/{util => lib/observable}/ObservableArray.hx | 2 +- src/{util => lib/observable}/ObservableValue.hx | 2 +- src/lib/turtle/TurtleExecuter.hx | 5 +++-- src/lib/turtle/TurtleInstructionParser.hx | 1 - src/lib/ui/Canvas.hx | 4 ++-- src/lib/ui/UIEvents.hx | 4 ++-- src/lib/ui/reactive/ListElement.hx | 4 ++-- src/lib/ui/reactive/TextElement.hx | 6 +++--- src/lib/ui/reactive/TurtleController.hx | 8 +++----- src/lib/ui/reactive/UIElement.hx | 6 +++--- 45 files changed, 85 insertions(+), 95 deletions(-) rename src/{util => lib}/BuildInfo.hx (98%) rename src/{util => lib}/Color.hx (97%) rename src/{util => lib}/Debug.hx (98%) rename src/{util => lib}/Extender.hx (98%) rename src/{util => lib}/MathI.hx (94%) rename src/{util => lib}/ObjMerge.hx (96%) rename src/{util => lib}/Pos.hx (95%) rename src/{util => lib}/Pos3.hx (96%) rename src/{util => lib}/Rect.hx (93%) rename src/{util => lib}/Vec.hx (91%) rename src/lib/{ => cli}/CLIBase.hx (89%) rename src/lib/{ => cli}/TermHandle.hx (96%) rename src/{util => lib/observable}/DummyObservable.hx (95%) rename src/{util => lib/observable}/Observable.hx (88%) rename src/{util => lib/observable}/ObservableArray.hx (97%) rename src/{util => lib/observable}/ObservableValue.hx (95%) diff --git a/src/Startup.hx b/src/Startup.hx index ace7ad1..c96b7aa 100644 --- a/src/Startup.hx +++ b/src/Startup.hx @@ -1,7 +1,5 @@ import bin.Terminal; -using util.Extender.LambdaExtender; - class Startup { public static function main() { var terminal = new Terminal(); diff --git a/src/bin/HelloWorld.hx b/src/bin/HelloWorld.hx index 54b8317..716cb41 100644 --- a/src/bin/HelloWorld.hx +++ b/src/bin/HelloWorld.hx @@ -1,8 +1,9 @@ package bin; +import lib.cli.TermHandle; +import lib.cli.CLIBase; + using tink.CoreApi; -import lib.TermHandle; -import lib.CLIBase; class HelloWorld extends CLIBase { public function invoke(handle: TermHandle):Future { diff --git a/src/bin/Net.hx b/src/bin/Net.hx index ea00d47..ebeef33 100644 --- a/src/bin/Net.hx +++ b/src/bin/Net.hx @@ -1,12 +1,12 @@ package bin; -using tink.CoreApi; - import kernel.peripherals.Peripherals.Peripheral; import kernel.net.Routing; import haxe.ds.ReadOnlyArray; -import lib.TermHandle; -import lib.CLIBase; +import lib.cli.TermHandle; +import lib.cli.CLIBase; + +using tink.CoreApi; class Net extends CLIBase { private var handle:TermHandle; diff --git a/src/bin/Terminal.hx b/src/bin/Terminal.hx index d4b5cc3..5ad0150 100644 --- a/src/bin/Terminal.hx +++ b/src/bin/Terminal.hx @@ -1,8 +1,8 @@ package bin; -import lib.TermHandle; -import lib.CLIBase; -import util.Color; +import lib.cli.TermHandle; +import lib.cli.CLIBase; +import lib.Color; import kernel.ui.WindowContext; import kernel.ui.WindowManager; diff --git a/src/kernel/Init.hx b/src/kernel/Init.hx index fe976aa..0f1ce62 100644 --- a/src/kernel/Init.hx +++ b/src/kernel/Init.hx @@ -4,7 +4,7 @@ import kernel.turtle.Turtle; import haxe.MainLoop; import kernel.net.Routing; import cc.OS; -import util.Debug; +import lib.Debug; import kernel.ui.WindowManager; import kernel.peripherals.Peripherals.Peripheral; import kernel.net.Net; diff --git a/src/kernel/KernelEvents.hx b/src/kernel/KernelEvents.hx index 0dfd1bd..7018fa0 100644 --- a/src/kernel/KernelEvents.hx +++ b/src/kernel/KernelEvents.hx @@ -1,10 +1,10 @@ package kernel; -import util.Pos; +import lib.Pos; import cc.HTTP.HTTPResponse; import lua.TableTools; import lua.Coroutine; -import util.Vec.Vec2; +import lib.Vec.Vec2; import haxe.Exception; using tink.CoreApi; diff --git a/src/kernel/Log.hx b/src/kernel/Log.hx index 5017005..8b480d0 100644 --- a/src/kernel/Log.hx +++ b/src/kernel/Log.hx @@ -6,7 +6,7 @@ import kernel.ui.TermWriteable; import lib.TermIO; #if webconsole import kernel.net.Net; -import util.Debug; +import lib.Debug; #end /** diff --git a/src/kernel/MainTerm.hx b/src/kernel/MainTerm.hx index 59c5c14..70282fd 100644 --- a/src/kernel/MainTerm.hx +++ b/src/kernel/MainTerm.hx @@ -1,12 +1,12 @@ package kernel; -import util.Pos; -using tink.CoreApi; - +import lib.Pos; import kernel.ui.TermWriteable; import cc.Term; -import util.Vec.Vec2; -import util.Color; +import lib.Vec.Vec2; +import lib.Color; + +using tink.CoreApi; /** Represents the main computer screen. diff --git a/src/kernel/Timer.hx b/src/kernel/Timer.hx index 9af4d1a..945c789 100644 --- a/src/kernel/Timer.hx +++ b/src/kernel/Timer.hx @@ -1,9 +1,9 @@ package kernel; -using tink.CoreApi; - import cc.OS; +using tink.CoreApi; + /** Wrapper class for using timer. **/ diff --git a/src/kernel/net/Net.hx b/src/kernel/net/Net.hx index 7168689..23aacbe 100644 --- a/src/kernel/net/Net.hx +++ b/src/kernel/net/Net.hx @@ -1,16 +1,15 @@ package kernel.net; import haxe.ds.ReadOnlyArray; -using tink.CoreApi; - import kernel.net.Package.NetworkID; import kernel.peripherals.Peripherals.Peripheral; import kernel.Log; import kernel.Timer; import cc.OS; +using tink.CoreApi; using Lambda; -using util.Extender.LambdaExtender; +using lib.Extender.LambdaExtender; /** Class responsible for everything network related. diff --git a/src/kernel/net/Routing.hx b/src/kernel/net/Routing.hx index 1e4cd9b..c003376 100644 --- a/src/kernel/net/Routing.hx +++ b/src/kernel/net/Routing.hx @@ -2,11 +2,10 @@ package kernel.net; import kernel.peripherals.Peripherals.Peripheral; import kernel.net.INetworkInterface; +import kernel.net.Package.NetworkID; using tink.CoreApi; -import kernel.net.Package.NetworkID; - @:structInit typedef Route = { interf:INetworkInterface, rep: NetworkID, diff --git a/src/kernel/peripherals/Drive.hx b/src/kernel/peripherals/Drive.hx index c8c13b9..726f422 100644 --- a/src/kernel/peripherals/Drive.hx +++ b/src/kernel/peripherals/Drive.hx @@ -1,6 +1,5 @@ package kernel.peripherals; -import kernel.net.Package; using tink.CoreApi; class Drive implements IPeripheral { diff --git a/src/kernel/peripherals/Modem.hx b/src/kernel/peripherals/Modem.hx index 4b1be56..15d637c 100644 --- a/src/kernel/peripherals/Modem.hx +++ b/src/kernel/peripherals/Modem.hx @@ -1,10 +1,10 @@ package kernel.peripherals; -using tink.CoreApi; - import kernel.net.Package; import kernel.net.INetworkInterface; +using tink.CoreApi; + class Modem implements INetworkInterface implements IPeripheral { public final addr:String; public var onMessage(default, null):Signal; diff --git a/src/kernel/peripherals/Redstone.hx b/src/kernel/peripherals/Redstone.hx index 711c5a6..6e0494d 100644 --- a/src/kernel/peripherals/Redstone.hx +++ b/src/kernel/peripherals/Redstone.hx @@ -1,7 +1,7 @@ package kernel.peripherals; import haxe.ds.ReadOnlyArray; -import util.Color; +import lib.Color; using tink.CoreApi; diff --git a/src/kernel/peripherals/Screen.hx b/src/kernel/peripherals/Screen.hx index 7aeb9a8..a487d1b 100644 --- a/src/kernel/peripherals/Screen.hx +++ b/src/kernel/peripherals/Screen.hx @@ -1,11 +1,10 @@ package kernel.peripherals; - -import util.Pos; +import lib.Pos; import cc.Term.TerminalSize; import kernel.ui.TermWriteable; -import util.Vec.Vec2; -import util.Color; +import lib.Vec.Vec2; +import lib.Color; using tink.CoreApi; diff --git a/src/kernel/ui/Pixel.hx b/src/kernel/ui/Pixel.hx index 1e5e78c..8108a2e 100644 --- a/src/kernel/ui/Pixel.hx +++ b/src/kernel/ui/Pixel.hx @@ -1,6 +1,6 @@ package kernel.ui; -import util.Color; +import lib.Color; @:structInit class Pixel { public var char:String; diff --git a/src/kernel/ui/TermBuffer.hx b/src/kernel/ui/TermBuffer.hx index a8797e0..bb2ce05 100644 --- a/src/kernel/ui/TermBuffer.hx +++ b/src/kernel/ui/TermBuffer.hx @@ -1,9 +1,8 @@ package kernel.ui; - -import util.Pos; -import util.Vec.Vec2; -import util.Color; +import lib.Pos; +import lib.Vec.Vec2; +import lib.Color; import kernel.ui.TermWriteable; using tink.CoreApi; diff --git a/src/kernel/ui/TermWriteable.hx b/src/kernel/ui/TermWriteable.hx index 04b311f..098a640 100644 --- a/src/kernel/ui/TermWriteable.hx +++ b/src/kernel/ui/TermWriteable.hx @@ -1,10 +1,10 @@ package kernel.ui; -import util.Pos; -using tink.CoreApi; +import lib.Pos; +import lib.Color; +import lib.Vec.Vec2; -import util.Color; -import util.Vec.Vec2; +using tink.CoreApi; /** Interface describing a terminal. E.g. the main computer screen or a external screen. diff --git a/src/kernel/ui/VirtualTermWriter.hx b/src/kernel/ui/VirtualTermWriter.hx index 970135f..24ee6ef 100644 --- a/src/kernel/ui/VirtualTermWriter.hx +++ b/src/kernel/ui/VirtualTermWriter.hx @@ -1,12 +1,12 @@ package kernel.ui; -import util.Pos; -using tink.CoreApi; - -import util.Vec.Vec2; -import util.Color; +import lib.Pos; +import lib.Vec.Vec2; +import lib.Color; import kernel.ui.TermWriteable; +using tink.CoreApi; + /** A term writer that can switch beetween its internal buffer and another termwriter. The other target is most of the time a real screen diff --git a/src/kernel/ui/WindowContext.hx b/src/kernel/ui/WindowContext.hx index e494034..6f420e1 100644 --- a/src/kernel/ui/WindowContext.hx +++ b/src/kernel/ui/WindowContext.hx @@ -1,13 +1,13 @@ package kernel.ui; -import util.Pos; -using tink.CoreApi; - -import util.Color; +import lib.Pos; +import lib.Color; import kernel.ButtonType; -import util.Vec.Vec2; +import lib.Vec.Vec2; import kernel.ui.TermWriteable; +using tink.CoreApi; + /** The main object you interact with when writing anything to the screen. **/ diff --git a/src/util/BuildInfo.hx b/src/lib/BuildInfo.hx similarity index 98% rename from src/util/BuildInfo.hx rename to src/lib/BuildInfo.hx index a9d38b5..b8f7020 100644 --- a/src/util/BuildInfo.hx +++ b/src/lib/BuildInfo.hx @@ -1,4 +1,4 @@ -package util; +package lib; /** Macros with static information. diff --git a/src/util/Color.hx b/src/lib/Color.hx similarity index 97% rename from src/util/Color.hx rename to src/lib/Color.hx index 8d95af0..8b168b7 100644 --- a/src/util/Color.hx +++ b/src/lib/Color.hx @@ -1,4 +1,4 @@ -package util; +package lib; import kernel.peripherals.Redstone.BundleMask; diff --git a/src/util/Debug.hx b/src/lib/Debug.hx similarity index 98% rename from src/util/Debug.hx rename to src/lib/Debug.hx index 7a564c9..71e822a 100644 --- a/src/util/Debug.hx +++ b/src/lib/Debug.hx @@ -1,4 +1,4 @@ -package util; +package lib; import lua.NativeStringTools; import lib.ui.Canvas; diff --git a/src/util/Extender.hx b/src/lib/Extender.hx similarity index 98% rename from src/util/Extender.hx rename to src/lib/Extender.hx index 0fa7a28..e613c7d 100644 --- a/src/util/Extender.hx +++ b/src/lib/Extender.hx @@ -1,4 +1,4 @@ -package util; +package lib; import haxe.Exception; diff --git a/src/util/MathI.hx b/src/lib/MathI.hx similarity index 94% rename from src/util/MathI.hx rename to src/lib/MathI.hx index e207afa..c727c00 100644 --- a/src/util/MathI.hx +++ b/src/lib/MathI.hx @@ -1,4 +1,4 @@ -package util; +package lib; class MathI { public static function max(a:Int, b:Int):Int { diff --git a/src/util/ObjMerge.hx b/src/lib/ObjMerge.hx similarity index 96% rename from src/util/ObjMerge.hx rename to src/lib/ObjMerge.hx index 52d662a..c36fd95 100644 --- a/src/util/ObjMerge.hx +++ b/src/lib/ObjMerge.hx @@ -1,4 +1,4 @@ -package util; +package lib; class ObjMerge { public static function merge(obj1:T, obj2:T): T { diff --git a/src/util/Pos.hx b/src/lib/Pos.hx similarity index 95% rename from src/util/Pos.hx rename to src/lib/Pos.hx index 99645b7..fb8a09a 100644 --- a/src/util/Pos.hx +++ b/src/lib/Pos.hx @@ -1,6 +1,6 @@ -package util; +package lib; -import util.Vec.Vec2; +import lib.Vec.Vec2; /** Reporesents a Point in a 2D `Int` System. diff --git a/src/util/Pos3.hx b/src/lib/Pos3.hx similarity index 96% rename from src/util/Pos3.hx rename to src/lib/Pos3.hx index bb97e9e..2b50f05 100644 --- a/src/util/Pos3.hx +++ b/src/lib/Pos3.hx @@ -1,6 +1,6 @@ -package util; +package lib; -import util.Vec.Vec3; +import lib.Vec.Vec3; /** Reporesents a Point in a 3D `Int` System. diff --git a/src/util/Rect.hx b/src/lib/Rect.hx similarity index 93% rename from src/util/Rect.hx rename to src/lib/Rect.hx index 20bb491..24ca205 100644 --- a/src/util/Rect.hx +++ b/src/lib/Rect.hx @@ -1,6 +1,4 @@ -package util; - -import util.Vec.Vec2; +package lib; class Rect { diff --git a/src/lib/TermIO.hx b/src/lib/TermIO.hx index 0f9528d..3ba86f8 100644 --- a/src/lib/TermIO.hx +++ b/src/lib/TermIO.hx @@ -1,6 +1,6 @@ package lib; -import util.Color; +import lib.Color; import kernel.ui.TermWriteable; /** diff --git a/src/util/Vec.hx b/src/lib/Vec.hx similarity index 91% rename from src/util/Vec.hx rename to src/lib/Vec.hx index 16a3a61..b67d079 100644 --- a/src/util/Vec.hx +++ b/src/lib/Vec.hx @@ -1,4 +1,4 @@ -package util; +package lib; @:structInit class Vec2 { public final x:T; diff --git a/src/lib/CLIBase.hx b/src/lib/cli/CLIBase.hx similarity index 89% rename from src/lib/CLIBase.hx rename to src/lib/cli/CLIBase.hx index 5fa5725..48cbbe8 100644 --- a/src/lib/CLIBase.hx +++ b/src/lib/cli/CLIBase.hx @@ -1,4 +1,4 @@ -package lib; +package lib.cli; using tink.CoreApi; diff --git a/src/lib/TermHandle.hx b/src/lib/cli/TermHandle.hx similarity index 96% rename from src/lib/TermHandle.hx rename to src/lib/cli/TermHandle.hx index 77970ac..d6c1397 100644 --- a/src/lib/TermHandle.hx +++ b/src/lib/cli/TermHandle.hx @@ -1,4 +1,4 @@ -package lib; +package lib.cli; import haxe.ds.ReadOnlyArray; diff --git a/src/util/DummyObservable.hx b/src/lib/observable/DummyObservable.hx similarity index 95% rename from src/util/DummyObservable.hx rename to src/lib/observable/DummyObservable.hx index d9bdd27..7fb63f0 100644 --- a/src/util/DummyObservable.hx +++ b/src/lib/observable/DummyObservable.hx @@ -1,4 +1,4 @@ -package util; +package lib.observable; using tink.CoreApi; diff --git a/src/util/Observable.hx b/src/lib/observable/Observable.hx similarity index 88% rename from src/util/Observable.hx rename to src/lib/observable/Observable.hx index a284246..072df0c 100644 --- a/src/util/Observable.hx +++ b/src/lib/observable/Observable.hx @@ -1,4 +1,4 @@ -package util; +package lib.observable; using tink.CoreApi; diff --git a/src/util/ObservableArray.hx b/src/lib/observable/ObservableArray.hx similarity index 97% rename from src/util/ObservableArray.hx rename to src/lib/observable/ObservableArray.hx index faa2850..67b5189 100644 --- a/src/util/ObservableArray.hx +++ b/src/lib/observable/ObservableArray.hx @@ -1,4 +1,4 @@ -package util; +package lib.observable; class ObservableArray extends ObservableValue> { public function new(value: Array) { diff --git a/src/util/ObservableValue.hx b/src/lib/observable/ObservableValue.hx similarity index 95% rename from src/util/ObservableValue.hx rename to src/lib/observable/ObservableValue.hx index ea20560..32bcd24 100644 --- a/src/util/ObservableValue.hx +++ b/src/lib/observable/ObservableValue.hx @@ -1,4 +1,4 @@ -package util; +package lib.observable; using tink.CoreApi; diff --git a/src/lib/turtle/TurtleExecuter.hx b/src/lib/turtle/TurtleExecuter.hx index 0da5936..c1a9008 100644 --- a/src/lib/turtle/TurtleExecuter.hx +++ b/src/lib/turtle/TurtleExecuter.hx @@ -1,8 +1,9 @@ package lib.turtle; -import util.Pos; -import util.Pos3; +import lib.Pos; +import lib.Pos3; import kernel.turtle.Turtle; + using tink.CoreApi; class TurtleExecuter { diff --git a/src/lib/turtle/TurtleInstructionParser.hx b/src/lib/turtle/TurtleInstructionParser.hx index c4b0002..6dfebb4 100644 --- a/src/lib/turtle/TurtleInstructionParser.hx +++ b/src/lib/turtle/TurtleInstructionParser.hx @@ -10,7 +10,6 @@ import lua.NativeStringTools; using tink.CoreApi; - /** Save a set of turtle instructions to a string and execute them. **/ diff --git a/src/lib/ui/Canvas.hx b/src/lib/ui/Canvas.hx index 98e20d5..4063bb4 100644 --- a/src/lib/ui/Canvas.hx +++ b/src/lib/ui/Canvas.hx @@ -1,7 +1,7 @@ package lib.ui; -import util.Pos; -import util.Rect; +import lib.Pos; +import lib.Rect; import kernel.ui.Pixel; abstract Canvas(Array>) to Array> from Array>{ diff --git a/src/lib/ui/UIEvents.hx b/src/lib/ui/UIEvents.hx index cf92592..3fe371d 100644 --- a/src/lib/ui/UIEvents.hx +++ b/src/lib/ui/UIEvents.hx @@ -1,8 +1,8 @@ package lib.ui; -import util.Pos; -import util.Vec.Vec2; +import lib.Pos; import kernel.ButtonType; + using tink.CoreApi; typedef UIEvents = { diff --git a/src/lib/ui/reactive/ListElement.hx b/src/lib/ui/reactive/ListElement.hx index ec05bfd..37d1308 100644 --- a/src/lib/ui/reactive/ListElement.hx +++ b/src/lib/ui/reactive/ListElement.hx @@ -1,9 +1,9 @@ package lib.ui.reactive; -import util.Pos; +import lib.Pos; import util.Rect; import util.ObservableArray; -import util.Vec.Vec2; +import lib.Vec.Vec2; class ListElement extends UIElement { diff --git a/src/lib/ui/reactive/TextElement.hx b/src/lib/ui/reactive/TextElement.hx index fae0aba..6bf4673 100644 --- a/src/lib/ui/reactive/TextElement.hx +++ b/src/lib/ui/reactive/TextElement.hx @@ -2,10 +2,10 @@ package lib.ui.reactive; import lib.ui.Dimensions; import util.ObjMerge; -import util.Pos; +import lib.Pos; import util.Observable; -import util.Color; -import util.Vec.Vec2; +import lib.Color; +import lib.Vec.Vec2; using tink.CoreApi; diff --git a/src/lib/ui/reactive/TurtleController.hx b/src/lib/ui/reactive/TurtleController.hx index a3e0ea5..9cda310 100644 --- a/src/lib/ui/reactive/TurtleController.hx +++ b/src/lib/ui/reactive/TurtleController.hx @@ -1,8 +1,8 @@ package lib.ui.reactive; -import util.Debug; -import util.Vec.Vec2; -import util.Pos; +import lib.Debug; +import lib.Vec.Vec2; +import lib.Pos; class TurtleController extends UIElement { @@ -21,8 +21,6 @@ class TurtleController extends UIElement { canvas.combine(addButton("F"),{x:1,y:1}); canvas.combine(addButton("F"),{x:5,y:2}); - Debug.printCanvasToConsole(canvas); - return canvas; } diff --git a/src/lib/ui/reactive/UIElement.hx b/src/lib/ui/reactive/UIElement.hx index f2dd04a..e47fbd9 100644 --- a/src/lib/ui/reactive/UIElement.hx +++ b/src/lib/ui/reactive/UIElement.hx @@ -1,9 +1,9 @@ package lib.ui.reactive; import util.ObjMerge; -import util.Pos; -import util.Rect; -import util.Vec.Vec2; +import lib.Pos; +import lib.Rect; +import lib.Vec.Vec2; using tink.CoreApi;