use Pos instead of Vec2<Int>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package kernel;
|
||||
|
||||
import util.Pos;
|
||||
import cc.HTTP.HTTPResponse;
|
||||
import lua.TableTools;
|
||||
import lua.Coroutine;
|
||||
@@ -35,11 +36,11 @@ class KernelEvents {
|
||||
distance:Int
|
||||
}>;
|
||||
public final onMonitorResize:Signal<String>;
|
||||
public final onMonitorTouch:Signal<{addr:String, pos:Vec2<Int>}>;
|
||||
public final onMouseClick:Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public final onMouseDrag:Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public final onMouseScroll:Signal<{dir:Int, pos:Vec2<Int>}>;
|
||||
public final onMouseUp:Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public final onMonitorTouch:Signal<{addr:String, pos:Pos}>;
|
||||
public final onMouseClick:Signal<{button:ButtonType, pos:Pos}>;
|
||||
public final onMouseDrag:Signal<{button:ButtonType, pos:Pos}>;
|
||||
public final onMouseScroll:Signal<{dir:Int, pos:Pos}>;
|
||||
public final onMouseUp:Signal<{button:ButtonType, pos:Pos}>;
|
||||
public final onPaste:Signal<String>;
|
||||
public final onPeripheral:Signal<String>;
|
||||
public final onPeripheralDetach:Signal<String>;
|
||||
@@ -73,11 +74,11 @@ class KernelEvents {
|
||||
distance:Int
|
||||
}> = Signal.trigger();
|
||||
private final onMonitorResizeTrigger:SignalTrigger<String> = Signal.trigger();
|
||||
private final onMonitorTouchTrigger:SignalTrigger<{addr:String, pos:Vec2<Int>}> = Signal.trigger();
|
||||
private final onMouseClickTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}> = Signal.trigger();
|
||||
private final onMouseDragTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}> = Signal.trigger();
|
||||
private final onMouseScrollTrigger:SignalTrigger<{dir:Int, pos:Vec2<Int>}> = Signal.trigger();
|
||||
private final onMouseUpTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}> = Signal.trigger();
|
||||
private final onMonitorTouchTrigger:SignalTrigger<{addr:String, pos:Pos}> = Signal.trigger();
|
||||
private final onMouseClickTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
||||
private final onMouseDragTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
||||
private final onMouseScrollTrigger:SignalTrigger<{dir:Int, pos:Pos}> = Signal.trigger();
|
||||
private final onMouseUpTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
||||
private final onPasteTrigger:SignalTrigger<String> = Signal.trigger();
|
||||
private final onPeripheralTrigger:SignalTrigger<String> = Signal.trigger();
|
||||
private final onPeripheralDetachTrigger:SignalTrigger<String> = Signal.trigger();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kernel;
|
||||
|
||||
import util.Pos;
|
||||
using tink.CoreApi;
|
||||
|
||||
import kernel.ui.TermWriteable;
|
||||
@@ -38,7 +39,7 @@ class MainTerm implements TermWriteable {
|
||||
Term.scroll(y);
|
||||
}
|
||||
|
||||
public function getCursorPos():Vec2<Int> {
|
||||
public function getCursorPos():Pos {
|
||||
var rtn = Term.getCursorPos();
|
||||
return {
|
||||
x: rtn.x - 1,
|
||||
@@ -59,7 +60,7 @@ class MainTerm implements TermWriteable {
|
||||
Term.setCursorBlink(blink);
|
||||
}
|
||||
|
||||
public function getSize():Vec2<Int> {
|
||||
public function getSize():Pos {
|
||||
var rtn = Term.getSize();
|
||||
return {
|
||||
x: rtn.width,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package kernel.peripherals;
|
||||
|
||||
|
||||
import util.Pos;
|
||||
import cc.Term.TerminalSize;
|
||||
import kernel.ui.TermWriteable;
|
||||
import util.Vec.Vec2;
|
||||
@@ -52,7 +53,7 @@ class Screen implements TermWriteable implements IPeripheral {
|
||||
nativ.scroll(y);
|
||||
}
|
||||
|
||||
public function getCursorPos():Vec2<Int> {
|
||||
public function getCursorPos():Pos {
|
||||
var rtn = nativ.getCursorPos();
|
||||
return {
|
||||
x: rtn.x - 1,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package kernel.ui;
|
||||
|
||||
|
||||
import util.Pos;
|
||||
import util.Vec.Vec2;
|
||||
import util.Color;
|
||||
import kernel.ui.TermWriteable;
|
||||
@@ -18,7 +19,7 @@ class TermBuffer implements TermWriteable {
|
||||
**/
|
||||
private var screenBuffer:Array<Array<Pixel>>;
|
||||
|
||||
private var cursorPos:Vec2<Int> = {x: 0, y: 0};
|
||||
private var cursorPos:Pos = {x: 0, y: 0};
|
||||
private var currentTextColor:Color = White;
|
||||
private var currentBgColor:Color = Black;
|
||||
private var cursorBlink: Bool = false;
|
||||
@@ -90,7 +91,7 @@ class TermBuffer implements TermWriteable {
|
||||
target.setBackgroundColor(currentBgColor);
|
||||
}
|
||||
|
||||
private function safeWriteScreenBuffer(pos:Vec2<Int>, char:String) {
|
||||
private function safeWriteScreenBuffer(pos:Pos, char:String) {
|
||||
if (screenBuffer.length > pos.y && screenBuffer[pos.y].length > pos.x) {
|
||||
screenBuffer[pos.y][pos.x].char = char;
|
||||
screenBuffer[pos.y][pos.x].bg = currentBgColor;
|
||||
@@ -120,7 +121,7 @@ class TermBuffer implements TermWriteable {
|
||||
]);
|
||||
}
|
||||
|
||||
public function getCursorPos():Vec2<Int> {
|
||||
public function getCursorPos():Pos {
|
||||
return cursorPos;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kernel.ui;
|
||||
|
||||
import util.Pos;
|
||||
using tink.CoreApi;
|
||||
|
||||
import util.Color;
|
||||
@@ -17,7 +18,7 @@ interface TermWriteable {
|
||||
/**
|
||||
Even though CC is 1 based we use a 0 based index.
|
||||
**/
|
||||
public function getCursorPos():Vec2<Int>;
|
||||
public function getCursorPos():Pos;
|
||||
|
||||
/**
|
||||
Even though CC is 1 based we use a 0 based index.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kernel.ui;
|
||||
|
||||
import util.Pos;
|
||||
using tink.CoreApi;
|
||||
|
||||
import util.Vec.Vec2;
|
||||
@@ -85,7 +86,7 @@ class VirtualTermWriter implements TermWriteable extends TermBuffer {
|
||||
super.scroll(y);
|
||||
}
|
||||
|
||||
public override function getCursorPos():Vec2<Int> {
|
||||
public override function getCursorPos():Pos {
|
||||
if (isEnabled()) {
|
||||
return target.getCursorPos();
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kernel.ui;
|
||||
|
||||
import util.Pos;
|
||||
using tink.CoreApi;
|
||||
|
||||
import util.Color;
|
||||
@@ -13,20 +14,20 @@ import kernel.ui.TermWriteable;
|
||||
class WindowContext implements TermWriteable {
|
||||
private final writer:VirtualTermWriter;
|
||||
|
||||
public var onClick(default, null):Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public var onClick(default, null):Signal<{button:ButtonType, pos:Pos}>;
|
||||
public var onKey(default, null):Signal<{keyCode:Int, isHeld:Bool}>;
|
||||
public var onKeyUp(default, null):Signal<Int>;
|
||||
public var onMouseDrag(default, null):Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public var onMouseScroll(default, null):Signal<{dir:Int, pos:Vec2<Int>}>;
|
||||
public var onMouseUp(default, null):Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public var onMouseDrag(default, null):Signal<{button:ButtonType, pos:Pos}>;
|
||||
public var onMouseScroll(default, null):Signal<{dir:Int, pos:Pos}>;
|
||||
public var onMouseUp(default, null):Signal<{button:ButtonType, pos:Pos}>;
|
||||
public var onPaste(default, null):Signal<String>;
|
||||
|
||||
@:allow(kernel.ui.WindowManager) private final onClickTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onClickTrigger:SignalTrigger<{button:ButtonType, pos:Pos}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onKeyTrigger:SignalTrigger<{keyCode:Int, isHeld:Bool}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onKeyUpTrigger:SignalTrigger<Int>;
|
||||
@:allow(kernel.ui.WindowManager) private final onMouseDragTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onMouseScrollTrigger:SignalTrigger<{dir:Int, pos:Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onMouseUpTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onMouseDragTrigger:SignalTrigger<{button:ButtonType, pos:Pos}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onMouseScrollTrigger:SignalTrigger<{dir:Int, pos:Pos}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onMouseUpTrigger:SignalTrigger<{button:ButtonType, pos:Pos}>;
|
||||
@:allow(kernel.ui.WindowManager) private final onPasteTrigger:SignalTrigger<String>;
|
||||
|
||||
@:allow(kernel.ui.WindowManager)
|
||||
@@ -81,7 +82,7 @@ class WindowContext implements TermWriteable {
|
||||
writer.scroll(y);
|
||||
}
|
||||
|
||||
public function getCursorPos():Vec2<Int> {
|
||||
public function getCursorPos():Pos {
|
||||
return writer.getCursorPos();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user