interface name consistency

This commit is contained in:
Niklas Kapelle 2024-03-13 10:39:22 +01:00
parent 2ab5a38894
commit 4ab3d868c1
Signed by: niklas
GPG Key ID: 4EB651B36D841D16
37 changed files with 94 additions and 94 deletions

View File

@ -1,10 +1,10 @@
package bin;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
@:build(macros.Binstore.includeBin("ID", ["id"]))
class ID implements Process {
class ID implements IProcess {
public function new() {}
public function run(handle:ProcessHandle) {

View File

@ -1,7 +1,7 @@
package bin;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
import lib.Color;
import lib.MathI;
import kernel.log.Log;
@ -11,7 +11,7 @@ import lib.ui.UIApp;
using tink.CoreApi;
@:build(macros.Binstore.includeBin("Log", ["log"]))
class KernelLog implements Process {
class KernelLog implements IProcess {
private var handle:ProcessHandle;
private var ctx:WindowContext;

View File

@ -2,10 +2,10 @@ package bin;
import kernel.ps.ProcessManager;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
@:build(macros.Binstore.includeBin("LSPS", ["lsps"]))
class LSPS implements Process {
class LSPS implements IProcess {
public function new() {}
public function run(handle:ProcessHandle) {

View File

@ -4,7 +4,7 @@ import kernel.EndOfLoop;
import lua.NativeStringTools;
import kernel.binstore.BinStore;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
import kernel.ps.ProcessManager;
import lib.Color;
import kernel.ui.WindowContext;
@ -12,7 +12,7 @@ import kernel.ui.WindowContext;
using tink.CoreApi;
@:build(macros.Binstore.includeBin("Terminal", ["terminal"]))
class Terminal implements Process {
class Terminal implements IProcess {
private static inline final MAX_BACKLOG:Int = 100;
private var handle:ProcessHandle;

View File

@ -3,7 +3,7 @@ package bin.debug;
import kernel.log.Log;
import lib.turtle.InvManager;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
/**
Use this to test whatever you are working on. It will also print debug statements.
@ -12,7 +12,7 @@ import kernel.ps.Process;
#if debug
@:build(macros.Binstore.includeBin("Debug", ["dbg", "debug"]))
#end
class Debug implements Process {
class Debug implements IProcess {
public function new() {}
public function run(handle:ProcessHandle) {

View File

@ -3,12 +3,12 @@ package bin.debug;
import bin.debug.DebugRPC.DebugRPCImpl;
import macros.rpc.RPC;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
#if debug
@:build(macros.Binstore.includeBin("Debug SRV", ["dbg-srv", "debug-srv"]))
#end
class DebugService implements Process implements DebugRPC {
class DebugService implements IProcess implements DebugRPC {
private var handle:ProcessHandle;
public function new() {}

View File

@ -1,14 +1,14 @@
package bin.pathfinder;
import lib.Pos3;
import lib.ui.elements.UIElement;
import lib.ui.elements.IUIElement;
import lib.ui.elements.TextElement;
import lib.ui.elements.RootElement;
import kernel.ui.WindowContext;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
class PFClient implements Process {
class PFClient implements IProcess {
private var handle:ProcessHandle;
private var ctx:WindowContext;
@ -38,7 +38,7 @@ class PFClient implements Process {
var acc = kernel.gps.GPS.getAccuracy();
var pos:Pos3 = kernel.gps.GPS.getPosition() ?? {x: 0, y: 0, z: 0};
var childre:Array<UIElement> = [
var childre:Array<IUIElement> = [
new TextElement('Acc: ${acc}'),
new TextElement('Pos: X:${pos.x} Y:${pos.y} Z:${pos.z}'),
new TextElement('UPDATE', {

View File

@ -2,9 +2,9 @@ package bin.turtle;
import kernel.turtle.TurtleMutex;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
class Patrol implements Process {
class Patrol implements IProcess {
private var handle:ProcessHandle;
public function new() {}

View File

@ -1,7 +1,7 @@
package kernel;
import lib.Pos;
import kernel.ui.TermWriteable;
import kernel.ui.ITermWriteable;
import cc.Term;
import lib.Vec.Vec2;
import lib.Color;
@ -11,7 +11,7 @@ using tink.CoreApi;
/**
Represents the main computer screen.
**/
class MainTerm implements TermWriteable {
class MainTerm implements ITermWriteable {
/**
Depends on: KernelEvents,
**/

View File

@ -1,12 +1,12 @@
package kernel.binstore;
import kernel.ps.Process;
import kernel.ps.IProcess;
/**
Represents a callable program.
**/
typedef Bin = {
c:Void->Process,
c:Void->IProcess,
name:String,
aliases:Array<String>,
}

View File

@ -1,6 +1,6 @@
package kernel.binstore;
import kernel.ps.Process;
import kernel.ps.IProcess;
import macros.Binstore;
class BinStore {
@ -13,7 +13,7 @@ class BinStore {
return bins;
}
public static function instantiate(alias:String):Null<Process> {
public static function instantiate(alias:String):Null<IProcess> {
for (bin in bins) {
for (a in bin.aliases) {
if (a == alias) {

View File

@ -3,13 +3,13 @@ package kernel.peripherals;
import cc.Peripheral;
import lib.Pos;
import cc.Term.TerminalSize;
import kernel.ui.TermWriteable;
import kernel.ui.ITermWriteable;
import lib.Vec.Vec2;
import lib.Color;
using tink.CoreApi;
class Screen implements TermWriteable implements IPeripheral {
class Screen implements ITermWriteable implements IPeripheral {
public static inline final TYPE_NAME:String = "monitor";
private final nativ:cc.periphs.Monitor.Monitor;

View File

@ -3,6 +3,6 @@ package kernel.ps;
/**
Defines an independent process that can be run by the kernel.
**/
interface Process {
interface IProcess {
public function run(handle:ProcessHandle):Void;
}

View File

@ -10,7 +10,7 @@ typedef PID = Int;
class ProcessManager {
private static final processList = new Map<PID, ProcessHandle>();
public static function run(process:Process, config:HandleConfig):PID {
public static function run(process:IProcess, config:HandleConfig):PID {
var pid = createPID();
var handle = new ProcessHandle(config, pid);

View File

@ -1,6 +1,6 @@
package kernel.service;
import kernel.ps.Process;
import kernel.ps.IProcess;
import kernel.ps.ProcessManager;
import kernel.binstore.BinStore;
@ -11,7 +11,7 @@ class Service {
public final name:String;
public final args:Array<String>;
public var pid:PID;
public var ps:Process;
public var ps:IProcess;
@:allow(kernel.service.ServiceManager)
private function new(binName:String, name:String, ?args:Array<String>) {

View File

@ -3,7 +3,7 @@ package kernel.ui;
import lib.Pos;
import lib.Vec.Vec2;
import lib.Color;
import kernel.ui.TermWriteable;
import kernel.ui.ITermWriteable;
using tink.CoreApi;
@ -11,15 +11,15 @@ 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
**/
class BufferedVirtualTermWriter implements VirtualTermWriter extends TermBuffer {
class BufferedVirtualTermWriter implements IVirtualTermWriter extends TermBuffer {
private static final defaultSize:Vec2<Int> = {x: 50, y: 50};
private var target:TermWriteable;
private var target:ITermWriteable;
private var enabled:Bool = false;
private var onResizeLink:CallbackLink;
@:allow(kernel.ui)
private function new(?target:TermWriteable) {
private function new(?target:ITermWriteable) {
setTarget(target);
if (enabled) {
@ -44,7 +44,7 @@ class BufferedVirtualTermWriter implements VirtualTermWriter extends TermBuffer
return enabled;
}
public function setTarget(newTarget:TermWriteable) {
public function setTarget(newTarget:ITermWriteable) {
if (newTarget != null) {
super.setSize(newTarget.getSize());

View File

@ -9,7 +9,7 @@ using tink.CoreApi;
/**
Interface describing a terminal. E.g. the main computer screen or a external screen.
**/
interface TermWriteable {
interface ITermWriteable {
public var onResize(default, null):Signal<Vec2<Int>>;
public function write(text:String):Void;

View File

@ -4,9 +4,9 @@ package kernel.ui;
A VirtualTermWriter is a TermWriteable that can be enabled or disabled.
When disabled, it will not write to its target. When enabled, it will.
**/
interface VirtualTermWriter extends TermWriteable {
interface IVirtualTermWriter extends ITermWriteable {
public function enable():Void;
public function disable():Void;
public function isEnabled():Bool;
public function setTarget(newTarget:TermWriteable):Void;
public function setTarget(newTarget:ITermWriteable):Void;
}

View File

@ -13,18 +13,18 @@ using tink.CoreApi;
The render function is only called when needed.
You can also request a re-render by calling `requestRender`.
**/
class StatelessVirtualTermWriter implements VirtualTermWriter {
class StatelessVirtualTermWriter implements IVirtualTermWriter {
public var onResize(default, null):Signal<Vec2<Int>>;
private var onResizeTrigger:SignalTrigger<Vec2<Int>> = Signal.trigger();
private var target:TermWriteable;
private var target:ITermWriteable;
private var enabled:Bool = false;
private var renderFunc:Null<Void->Void> = null;
private var renderRequested:Bool = false;
private var onResizeLink:CallbackLink;
@:allow(kernel.ui)
private function new(?target:TermWriteable) {
private function new(?target:ITermWriteable) {
onResize = onResizeTrigger.asSignal();
setTarget(target);
}
@ -70,7 +70,7 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
enabled = false;
}
public function setTarget(newTarget:TermWriteable) {
public function setTarget(newTarget:ITermWriteable) {
if (newTarget == null) {
return;
}

View File

@ -3,7 +3,7 @@ package kernel.ui;
import lib.Pos;
import lib.Vec.Vec2;
import lib.Color;
import kernel.ui.TermWriteable;
import kernel.ui.ITermWriteable;
using tink.CoreApi;
@ -12,7 +12,7 @@ using tink.CoreApi;
even if its not displayed right now. When the GUI gets displayed again
this buffer will be written to the screen.
**/
class TermBuffer implements TermWriteable {
class TermBuffer implements ITermWriteable {
/**
format [y][x]. First index is the line. Second index the char in the line.
**/
@ -60,7 +60,7 @@ class TermBuffer implements TermWriteable {
}
}
private function copyBufferToTarget(target:TermWriteable) {
private function copyBufferToTarget(target:ITermWriteable) {
target.setCursorPos(0, 0);
target.setBackgroundColor(Black);
target.setTextColor(White);

View File

@ -1,21 +1,21 @@
package kernel.ui;
import lib.ui.rendere.UIEventDelegate;
import lib.ui.rendere.IUIEventDelegate;
import lib.Pos;
import lib.Color;
import kernel.ButtonType;
import lib.Vec.Vec2;
import kernel.ui.TermWriteable;
import kernel.ui.ITermWriteable;
using tink.CoreApi;
/**
The main object you interact with when writing anything to the screen.
**/
class WindowContext implements TermWriteable {
private final writer:VirtualTermWriter;
class WindowContext implements ITermWriteable {
private final writer:IVirtualTermWriter;
@:allow(kernel.ui.WindowManager) private var eventDelegate:Null<UIEventDelegate>;
@:allow(kernel.ui.WindowManager) private var eventDelegate:Null<IUIEventDelegate>;
public var onClick(default, null):Signal<{button:ButtonType, pos:Pos}>;
public var onKey(default, null):Signal<{keyCode:Int, isHeld:Bool}>;
@ -36,7 +36,7 @@ class WindowContext implements TermWriteable {
@:allow(kernel.ui.WindowManager) private final onCharTrigger:SignalTrigger<String>;
@:allow(kernel.ui.WindowManager)
private function new(writer:VirtualTermWriter) {
private function new(writer:IVirtualTermWriter) {
this.writer = writer;
this.onResize = writer.onResize;
@ -62,7 +62,7 @@ class WindowContext implements TermWriteable {
public var onResize(default, null):Signal<Vec2<Int>>;
@:allow(kernel.ui)
private inline function setTarget(target:TermWriteable) {
private inline function setTarget(target:ITermWriteable) {
writer.setTarget(target);
}
@ -145,7 +145,7 @@ class WindowContext implements TermWriteable {
Delegate events to an UIEventDelegate.
Set to null to stop delegating events.
**/
public inline function delegateEvents(delegate:Null<UIEventDelegate>) {
public inline function delegateEvents(delegate:Null<IUIEventDelegate>) {
this.eventDelegate = delegate;
}
}

View File

@ -3,7 +3,7 @@ package kernel.ui;
import kernel.ps.ProcessManager;
import kernel.ps.ProcessManager.PID;
import haxe.ds.ReadOnlyArray;
import kernel.ui.TermWriteable;
import kernel.ui.ITermWriteable;
import kernel.peripherals.Peripherals.Peripheral;
/**
@ -143,7 +143,7 @@ class WindowManager {
Move context to output. If output is "main", context will be moved to main screen.
**/
public static function focusContextToOutput(context:WindowContext, output:String) {
var target:TermWriteable;
var target:ITermWriteable;
if (output == "main") {
target = MainTerm.instance;
currentMainContext = context;

View File

@ -1,11 +1,11 @@
package lib;
import kernel.ps.Process;
import kernel.ps.IProcess;
import kernel.ps.ProcessHandle;
using tink.CoreApi;
abstract class CLIAppBase implements Process {
abstract class CLIAppBase implements IProcess {
private var handle:ProcessHandle;
private final _subcommandsSync:Map<String, (Array<String>) -> Bool> = [];

View File

@ -4,10 +4,10 @@ import kernel.log.Log;
import kernel.binstore.BinStore;
import kernel.peripherals.Screen;
import kernel.peripherals.Peripherals.Peripheral;
import kernel.ps.Process;
import kernel.ps.IProcess;
import kernel.ps.ProcessManager;
import bin.KernelLog;
import lib.ui.elements.UIElement;
import lib.ui.elements.IUIElement;
import lib.ui.elements.TextElement;
import lib.ui.elements.RootElement;
import kernel.KernelEvents;
@ -148,7 +148,7 @@ class HomeContext {
var workspaceIDs:Array<Int> = [for (k => v in workspaces) k];
workspaceIDs.sort((a, b) -> a - b);
var children:Array<UIElement> = [
var children:Array<IUIElement> = [
for (i in workspaceIDs)
new TextElement('Switch to ${i + 1}', {uiEvents: {onClick: this.handleSelectContext.bind(i)}})
];

View File

@ -2,7 +2,7 @@ package lib.observable;
using tink.CoreApi;
class DummyObservable<T> implements Observable<T> {
class DummyObservable<T> implements IObservable<T> {
private var value:T;
private function new(value:T) {
@ -21,7 +21,7 @@ class DummyObservable<T> implements Observable<T> {
return null;
}
public static function dummy<T>(value:T):Observable<T> {
public static function dummy<T>(value:T):IObservable<T> {
return new DummyObservable<T>(value);
}
}

View File

@ -2,7 +2,7 @@ package lib.observable;
using tink.CoreApi;
interface Observable<T> {
interface IObservable<T> {
public function set(value:T):Void;
public function get():T;
public function subscribe(callback:Callback<T>):CallbackLink;

View File

@ -2,7 +2,7 @@ package lib.observable;
using tink.CoreApi;
class ObservableValue<T> implements Observable<T> {
class ObservableValue<T> implements IObservable<T> {
private var value:T;
private var callbacks:CallbackList<T> = new CallbackList();

View File

@ -2,9 +2,9 @@ package lib.turtle;
import kernel.turtle.TurtleMutex;
import kernel.ps.ProcessHandle;
import kernel.ps.Process;
import kernel.ps.IProcess;
abstract class TurtleAppBase implements Process {
abstract class TurtleAppBase implements IProcess {
private var handle:ProcessHandle;
private var _initFunc:Void->Void;

View File

@ -1,21 +1,21 @@
package lib.ui.elements;
import lib.ui.rendere.UIEventDelegate;
import lib.ui.rendere.IUIEventDelegate;
/**
Find the responsable UIElement to handle the event based on position. Element can be layerd.
Elements added first are lower in the layer.
**/
abstract EventMap(Array<{bound:Rect, delegate:UIEventDelegate}>) {
inline public function new(?i:Array<{bound:Rect, delegate:UIEventDelegate}>) {
abstract EventMap(Array<{bound:Rect, delegate:IUIEventDelegate}>) {
inline public function new(?i:Array<{bound:Rect, delegate:IUIEventDelegate}>) {
if (i == null) {
this = new Array<{bound:Rect, delegate:UIEventDelegate}>();
this = new Array<{bound:Rect, delegate:IUIEventDelegate}>();
} else {
this = i;
}
}
public function findResponseableDelegate(pos:Pos):UIEventDelegate {
public function findResponseableDelegate(pos:Pos):IUIEventDelegate {
for (i in 0...this.length) {
var newi = (this.length - 1) - i;
var element = this[newi];
@ -26,7 +26,7 @@ abstract EventMap(Array<{bound:Rect, delegate:UIEventDelegate}>) {
return null;
}
public inline function addElement(element:UIEventDelegate, bound:Rect) {
public inline function addElement(element:IUIEventDelegate, bound:Rect) {
this.push({bound: bound, delegate: element});
}
}

View File

@ -0,0 +1,7 @@
package lib.ui.elements;
import lib.ui.rendere.IUIEventDelegate;
interface IUIElement extends IUIEventDelegate {
public function render(bounds:Pos):Canvas;
}

View File

@ -1,14 +1,14 @@
package lib.ui.elements;
class LayerdRootElement implements UIElement {
private var children:Array<{element:UIElement, offset:Pos}>;
class LayerdRootElement implements IUIElement {
private var children:Array<{element:IUIElement, offset:Pos}>;
private final eventManager:UIEventManager = new UIEventManager();
public function new(?children:Array<{element:UIElement, offset:Pos}>) {
public function new(?children:Array<{element:IUIElement, offset:Pos}>) {
this.children = children == null ? [] : children;
}
public function setChildren(children:Array<{element:UIElement, offset:Pos}>) {
public function setChildren(children:Array<{element:IUIElement, offset:Pos}>) {
this.children = children;
}

View File

@ -1,11 +1,11 @@
package lib.ui.elements;
class RootElement implements UIElement {
private var children:Array<UIElement>;
class RootElement implements IUIElement {
private var children:Array<IUIElement>;
private final eventManager:UIEventManager = new UIEventManager();
private var title:String = "";
public function new(?children:Array<UIElement>) {
public function new(?children:Array<IUIElement>) {
if (children == null) {
children = [];
} else {
@ -17,7 +17,7 @@ class RootElement implements UIElement {
return eventManager.getEventHandlers();
}
public function setChildren(children:Array<UIElement>) {
public function setChildren(children:Array<IUIElement>) {
this.children = children;
}

View File

@ -1,8 +1,8 @@
package lib.ui.elements;
import lib.ui.elements.UIElement;
import lib.ui.elements.IUIElement;
class TextElement implements UIElement {
class TextElement implements IUIElement {
public var text:String;
private final uiEvents:UIEvents;

View File

@ -1,7 +0,0 @@
package lib.ui.elements;
import lib.ui.rendere.UIEventDelegate;
interface UIElement extends UIEventDelegate {
public function render(bounds:Pos):Canvas;
}

View File

@ -2,9 +2,9 @@ package lib.ui.elements;
import kernel.log.Log;
import kernel.ButtonType;
import lib.ui.rendere.UIEventDelegate;
import lib.ui.rendere.IUIEventDelegate;
class UIEventManager implements UIEventDelegate {
class UIEventManager implements IUIEventDelegate {
private var map:EventMap = new EventMap();
public function new() {}
@ -13,7 +13,7 @@ class UIEventManager implements UIEventDelegate {
this.map = new EventMap();
}
public function addMapElement(element:UIEventDelegate, bound:Rect) {
public function addMapElement(element:IUIEventDelegate, bound:Rect) {
this.map.addElement(element, bound);
}

View File

@ -1,5 +1,5 @@
package lib.ui.rendere;
interface UIEventDelegate {
interface IUIEventDelegate {
public function getEventHandlers():UIEvents;
}

View File

@ -1,6 +1,6 @@
package lib.ui.rendere;
class List implements UIEventDelegate {
class List implements IUIEventDelegate {
private final onElementClick:Null<Int->Void>;
public function new(?onElementClick:Int->Void) {