format
This commit is contained in:
@@ -13,27 +13,28 @@ import lib.TermWriteable;
|
||||
}
|
||||
|
||||
class TermBuffer implements TermWriteable {
|
||||
|
||||
/**
|
||||
format [y][x]. First index is the line. Second index the char in the line.
|
||||
**/
|
||||
private var screenBuffer: Array<Array<Pixel>>;
|
||||
private var cursorPos: Vec2<Int> = {x: 0, y: 0};
|
||||
private var currentTextColor: Color = White;
|
||||
private var currentBgColor: Color = Black;
|
||||
private var size: Vec2<Int> = {x: 51,y:19}; // Default size set to default size of the main terminal
|
||||
private var screenBuffer:Array<Array<Pixel>>;
|
||||
|
||||
private var cursorPos:Vec2<Int> = {x: 0, y: 0};
|
||||
private var currentTextColor:Color = White;
|
||||
private var currentBgColor:Color = Black;
|
||||
private var size:Vec2<Int> = {x: 51, y: 19}; // Default size set to default size of the main terminal
|
||||
|
||||
public var onResize(default, null):Signal<Vec2<Int>>;
|
||||
|
||||
public var onResize(default,null):Signal<Vec2<Int>>;
|
||||
private final onResizeTrigger:SignalTrigger<Vec2<Int>>;
|
||||
|
||||
|
||||
public function new() {
|
||||
this.onResizeTrigger = Signal.trigger();
|
||||
this.onResize = onResizeTrigger.asSignal();
|
||||
initScreenBuffer(size);
|
||||
}
|
||||
|
||||
private function setSize(size: Vec2<Int>) {
|
||||
if (this.size != size){
|
||||
private function setSize(size:Vec2<Int>) {
|
||||
if (this.size != size) {
|
||||
this.onResizeTrigger.trigger(size);
|
||||
}
|
||||
|
||||
@@ -41,80 +42,82 @@ class TermBuffer implements TermWriteable {
|
||||
updateScreenBufferSize(size);
|
||||
}
|
||||
|
||||
private function updateScreenBufferSize(size: Vec2<Int>) {
|
||||
private function updateScreenBufferSize(size:Vec2<Int>) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
private function initScreenBuffer(size: Vec2<Int>) {
|
||||
private function initScreenBuffer(size:Vec2<Int>) {
|
||||
screenBuffer = new Array();
|
||||
for (y in 0...size.y){
|
||||
for (y in 0...size.y) {
|
||||
screenBuffer[y] = new Array();
|
||||
for (x in 0...size.x){
|
||||
for (x in 0...size.x) {
|
||||
screenBuffer[y][x] = {
|
||||
char: " ",
|
||||
textColor: White,
|
||||
bg: Black,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function copyBufferToTarget(target: TermWriteable) {
|
||||
target.setCursorPos(0,0);
|
||||
private function copyBufferToTarget(target:TermWriteable) {
|
||||
target.setCursorPos(0, 0);
|
||||
target.setBackgroundColor(Black);
|
||||
target.setTextColor(White);
|
||||
|
||||
var tmpFgColor: Color = White;
|
||||
var tmpBgColor: Color = Black;
|
||||
var tmpFgColor:Color = White;
|
||||
var tmpBgColor:Color = Black;
|
||||
|
||||
for (y => line in screenBuffer){
|
||||
for(x => pixel in line){
|
||||
if (tmpFgColor != pixel.textColor){
|
||||
for (y => line in screenBuffer) {
|
||||
for (x => pixel in line) {
|
||||
if (tmpFgColor != pixel.textColor) {
|
||||
tmpFgColor = pixel.textColor;
|
||||
target.setTextColor(pixel.textColor);
|
||||
}
|
||||
|
||||
if (tmpBgColor != pixel.bg){
|
||||
if (tmpBgColor != pixel.bg) {
|
||||
tmpBgColor = pixel.bg;
|
||||
target.setBackgroundColor(pixel.bg);
|
||||
}
|
||||
|
||||
target.setCursorPos(x,y);
|
||||
target.setCursorPos(x, y);
|
||||
target.write(pixel.char);
|
||||
}
|
||||
}
|
||||
|
||||
target.setCursorPos(cursorPos.x,cursorPos.y);
|
||||
target.setCursorPos(cursorPos.x, cursorPos.y);
|
||||
target.setTextColor(currentTextColor);
|
||||
target.setBackgroundColor(currentBgColor);
|
||||
}
|
||||
|
||||
private function safeWriteScreenBuffer(pos: Vec2<Int>,char: String) {
|
||||
if (screenBuffer.length > pos.y && screenBuffer[pos.y].length > pos.x){
|
||||
private function safeWriteScreenBuffer(pos:Vec2<Int>, 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;
|
||||
screenBuffer[pos.y][pos.x].textColor = currentTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// TermWriteable functions
|
||||
//
|
||||
//
|
||||
|
||||
public function write(text:String) {
|
||||
for (i in 0...text.length){
|
||||
safeWriteScreenBuffer({x: cursorPos.x,y: cursorPos.y},text.charAt(i));
|
||||
cursorPos = {y: cursorPos.y,x: cursorPos.x + 1};
|
||||
}
|
||||
for (i in 0...text.length) {
|
||||
safeWriteScreenBuffer({x: cursorPos.x, y: cursorPos.y}, text.charAt(i));
|
||||
cursorPos = {y: cursorPos.y, x: cursorPos.x + 1};
|
||||
}
|
||||
}
|
||||
|
||||
public function scroll(y:Int) {
|
||||
screenBuffer.unshift([for (i in 0...size.x) {
|
||||
char: " ",
|
||||
textColor: White, // TODO: maybe replace with current bg/text color. Check nativ implementation
|
||||
bg: Black
|
||||
}]);
|
||||
screenBuffer.unshift([
|
||||
for (i in 0...size.x)
|
||||
{
|
||||
char: " ",
|
||||
textColor: White, // TODO: maybe replace with current bg/text color. Check nativ implementation
|
||||
bg: Black
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
public function getCursorPos():Vec2<Int> {
|
||||
@@ -145,8 +148,8 @@ class TermBuffer implements TermWriteable {
|
||||
}
|
||||
|
||||
public function clearLine() {
|
||||
if (screenBuffer.length > cursorPos.y){
|
||||
screenBuffer[cursorPos.y] = [for(x in 0...size.x){textColor: White,char: " ",bg: Black}];
|
||||
if (screenBuffer.length > cursorPos.y) {
|
||||
screenBuffer[cursorPos.y] = [for (x in 0...size.x) {textColor: White, char: " ", bg: Black}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,159 +7,159 @@ import util.Color;
|
||||
import lib.TermWriteable;
|
||||
|
||||
class VirtualTermWriter implements TermWriteable extends TermBuffer {
|
||||
private static final defaultSize:Vec2<Int> = {x: 50,y: 50};
|
||||
private static final defaultSize:Vec2<Int> = {x: 50, y: 50};
|
||||
|
||||
private var target: TermWriteable;
|
||||
private var enabled:Bool = false;
|
||||
private var onResizeLink: CallbackLink;
|
||||
private var target:TermWriteable;
|
||||
private var enabled:Bool = false;
|
||||
private var onResizeLink:CallbackLink;
|
||||
|
||||
public function new(?target: TermWriteable) {
|
||||
setTarget(target);
|
||||
public function new(?target:TermWriteable) {
|
||||
setTarget(target);
|
||||
|
||||
if (enabled){
|
||||
enable();
|
||||
}
|
||||
if (enabled) {
|
||||
enable();
|
||||
}
|
||||
|
||||
super();
|
||||
}
|
||||
super();
|
||||
}
|
||||
|
||||
public function enable() {
|
||||
if (target != null){
|
||||
enabled = true;
|
||||
super.copyBufferToTarget(target);
|
||||
}
|
||||
}
|
||||
public function enable() {
|
||||
if (target != null) {
|
||||
enabled = true;
|
||||
super.copyBufferToTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
public function disable() {
|
||||
enabled = false;
|
||||
}
|
||||
public function disable() {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
public inline function isEnabled(): Bool {
|
||||
return enabled;
|
||||
}
|
||||
public inline function isEnabled():Bool {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public function setTarget(newTarget: TermWriteable) {
|
||||
if (newTarget != null){
|
||||
super.setSize(newTarget.getSize());
|
||||
public function setTarget(newTarget:TermWriteable) {
|
||||
if (newTarget != null) {
|
||||
super.setSize(newTarget.getSize());
|
||||
|
||||
// Remove old target event listner
|
||||
if (onResizeLink != null){
|
||||
onResizeLink.cancel();
|
||||
}
|
||||
// Remove old target event listner
|
||||
if (onResizeLink != null) {
|
||||
onResizeLink.cancel();
|
||||
}
|
||||
|
||||
// Add new target event listner
|
||||
onResizeLink = newTarget.onResize.handle(newSize -> {
|
||||
setSuperSize(newSize);
|
||||
});
|
||||
// Add new target event listner
|
||||
onResizeLink = newTarget.onResize.handle(newSize -> {
|
||||
setSuperSize(newSize);
|
||||
});
|
||||
|
||||
target = newTarget;
|
||||
}
|
||||
}
|
||||
target = newTarget;
|
||||
}
|
||||
}
|
||||
|
||||
private function setSuperSize(size: Vec2<Int>) {
|
||||
super.setSize(target.getSize());
|
||||
}
|
||||
|
||||
//
|
||||
// TermWriteable functions.
|
||||
//
|
||||
private function setSuperSize(size:Vec2<Int>) {
|
||||
super.setSize(target.getSize());
|
||||
}
|
||||
|
||||
//
|
||||
// TermWriteable functions.
|
||||
//
|
||||
public override function write(text:String) {
|
||||
if (isEnabled()){
|
||||
target.write(text);
|
||||
}
|
||||
|
||||
super.write(text);
|
||||
}
|
||||
if (isEnabled()) {
|
||||
target.write(text);
|
||||
}
|
||||
|
||||
super.write(text);
|
||||
}
|
||||
|
||||
public override function scroll(y:Int) {
|
||||
if (isEnabled()){
|
||||
target.scroll(y);
|
||||
}
|
||||
super.scroll(y);
|
||||
}
|
||||
if (isEnabled()) {
|
||||
target.scroll(y);
|
||||
}
|
||||
super.scroll(y);
|
||||
}
|
||||
|
||||
public override function getCursorPos():Vec2<Int> {
|
||||
if (isEnabled()){
|
||||
return target.getCursorPos();
|
||||
}else{
|
||||
return super.getCursorPos();
|
||||
}
|
||||
if (isEnabled()) {
|
||||
return target.getCursorPos();
|
||||
} else {
|
||||
return super.getCursorPos();
|
||||
}
|
||||
}
|
||||
|
||||
public override function setCursorPos(x:Int, y:Int) {
|
||||
if (isEnabled()){
|
||||
target.setCursorPos(x,y);
|
||||
}
|
||||
if (isEnabled()) {
|
||||
target.setCursorPos(x, y);
|
||||
}
|
||||
|
||||
super.setCursorPos(x,y);
|
||||
}
|
||||
super.setCursorPos(x, y);
|
||||
}
|
||||
|
||||
public override function getCursorBlink():Bool {
|
||||
throw new haxe.exceptions.NotImplementedException();
|
||||
}
|
||||
|
||||
public override function setCursorBlink(blink:Bool) {
|
||||
// TODO
|
||||
}
|
||||
// TODO
|
||||
}
|
||||
|
||||
public override function getSize():Vec2<Int> {
|
||||
// TODO: make sense ?
|
||||
if (target != null){
|
||||
return target.getSize();
|
||||
}
|
||||
// TODO: make sense ?
|
||||
if (target != null) {
|
||||
return target.getSize();
|
||||
}
|
||||
|
||||
return defaultSize;
|
||||
return defaultSize;
|
||||
}
|
||||
|
||||
public override function clear() {
|
||||
if (isEnabled()){
|
||||
target.clear();
|
||||
}
|
||||
|
||||
super.clear();
|
||||
}
|
||||
if (isEnabled()) {
|
||||
target.clear();
|
||||
}
|
||||
|
||||
super.clear();
|
||||
}
|
||||
|
||||
public override function clearLine() {
|
||||
if (isEnabled()){
|
||||
target.clearLine();
|
||||
}
|
||||
if (isEnabled()) {
|
||||
target.clearLine();
|
||||
}
|
||||
|
||||
super.clearLine();
|
||||
}
|
||||
super.clearLine();
|
||||
}
|
||||
|
||||
public override function getTextColor():Color {
|
||||
if (isEnabled()){
|
||||
return target.getTextColor();
|
||||
}
|
||||
if (isEnabled()) {
|
||||
return target.getTextColor();
|
||||
}
|
||||
|
||||
return super.getTextColor();
|
||||
return super.getTextColor();
|
||||
}
|
||||
|
||||
public override function setTextColor(colour:Color) {
|
||||
if (isEnabled()){
|
||||
target.setTextColor(colour);
|
||||
}
|
||||
if (isEnabled()) {
|
||||
target.setTextColor(colour);
|
||||
}
|
||||
|
||||
super.setTextColor(colour);
|
||||
}
|
||||
super.setTextColor(colour);
|
||||
}
|
||||
|
||||
public override function getBackgroundColor():Color {
|
||||
if (isEnabled()){
|
||||
return target.getBackgroundColor();
|
||||
}
|
||||
if (isEnabled()) {
|
||||
return target.getBackgroundColor();
|
||||
}
|
||||
|
||||
return super.getBackgroundColor();
|
||||
return super.getBackgroundColor();
|
||||
}
|
||||
|
||||
public override function setBackgroundColor(color:Color) {
|
||||
if (isEnabled()){
|
||||
target.setBackgroundColor(color);
|
||||
}
|
||||
if (isEnabled()) {
|
||||
target.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
super.setBackgroundColor(color);
|
||||
}
|
||||
super.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
public override function isColor():Bool {
|
||||
throw new haxe.exceptions.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,120 +8,118 @@ import util.Vec.Vec2;
|
||||
import lib.TermWriteable;
|
||||
|
||||
class WindowContext implements TermWriteable {
|
||||
private final writer:VirtualTermWriter;
|
||||
private final writer:VirtualTermWriter;
|
||||
|
||||
public var clickSignal(default,null):Signal<{button: ButtonType, pos: Vec2<Int>}>;
|
||||
public var keySignal(default,null):Signal<{keyCode: Int, isHeld: Bool}>;
|
||||
public var keyUpSignal(default,null):Signal<Int>;
|
||||
public var mouseDragSignal(default,null):Signal<{button: ButtonType, pos: Vec2<Int>}>;
|
||||
public var mouseScrollSignal(default,null):Signal<{dir: Int,pos: Vec2<Int>}>;
|
||||
public var mouseUpSignal(default,null):Signal<{button: ButtonType,pos: Vec2<Int>}>;
|
||||
public var pasteSignal(default,null):Signal<String> ;
|
||||
public var clickSignal(default, null):Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public var keySignal(default, null):Signal<{keyCode:Int, isHeld:Bool}>;
|
||||
public var keyUpSignal(default, null):Signal<Int>;
|
||||
public var mouseDragSignal(default, null):Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public var mouseScrollSignal(default, null):Signal<{dir:Int, pos:Vec2<Int>}>;
|
||||
public var mouseUpSignal(default, null):Signal<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
public var pasteSignal(default, null):Signal<String>;
|
||||
|
||||
@:allow(kernel.ui.WindowManager) private final clickTrigger:SignalTrigger<{button: ButtonType, pos: Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final keyTrigger:SignalTrigger<{keyCode: Int, isHeld: Bool}>;
|
||||
@:allow(kernel.ui.WindowManager) private final keyUpTrigger:SignalTrigger<Int>;
|
||||
@:allow(kernel.ui.WindowManager) private final mouseDragTrigger:SignalTrigger<{button: ButtonType, pos: Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final mouseScrollTrigger:SignalTrigger<{dir: Int,pos: Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final mouseUpTrigger:SignalTrigger<{button: ButtonType,pos: Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final pasteTrigger:SignalTrigger<String>;
|
||||
@:allow(kernel.ui.WindowManager) private final clickTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final keyTrigger:SignalTrigger<{keyCode:Int, isHeld:Bool}>;
|
||||
@:allow(kernel.ui.WindowManager) private final keyUpTrigger:SignalTrigger<Int>;
|
||||
@:allow(kernel.ui.WindowManager) private final mouseDragTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final mouseScrollTrigger:SignalTrigger<{dir:Int, pos:Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final mouseUpTrigger:SignalTrigger<{button:ButtonType, pos:Vec2<Int>}>;
|
||||
@:allow(kernel.ui.WindowManager) private final pasteTrigger:SignalTrigger<String>;
|
||||
|
||||
public function new(writer:VirtualTermWriter) {
|
||||
this.writer = writer;
|
||||
this.onResize = writer.onResize;
|
||||
|
||||
public function new(writer: VirtualTermWriter) {
|
||||
this.writer = writer;
|
||||
this.onResize = writer.onResize;
|
||||
this.clickTrigger = Signal.trigger();
|
||||
this.keyTrigger = Signal.trigger();
|
||||
this.keyUpTrigger = Signal.trigger();
|
||||
this.mouseDragTrigger = Signal.trigger();
|
||||
this.mouseScrollTrigger = Signal.trigger();
|
||||
this.mouseUpTrigger = Signal.trigger();
|
||||
this.pasteTrigger = Signal.trigger();
|
||||
|
||||
this.clickTrigger = Signal.trigger();
|
||||
this.keyTrigger = Signal.trigger();
|
||||
this.keyUpTrigger = Signal.trigger();
|
||||
this.mouseDragTrigger = Signal.trigger();
|
||||
this.mouseScrollTrigger = Signal.trigger();
|
||||
this.mouseUpTrigger = Signal.trigger();
|
||||
this.pasteTrigger = Signal.trigger();
|
||||
this.clickSignal = clickTrigger.asSignal();
|
||||
this.keySignal = keyTrigger.asSignal();
|
||||
this.keyUpSignal = keyUpTrigger.asSignal();
|
||||
this.mouseDragSignal = mouseDragTrigger.asSignal();
|
||||
this.mouseScrollSignal = mouseScrollTrigger.asSignal();
|
||||
this.mouseUpSignal = mouseUpTrigger.asSignal();
|
||||
this.pasteSignal = pasteTrigger.asSignal();
|
||||
}
|
||||
|
||||
this.clickSignal = clickTrigger.asSignal();
|
||||
this.keySignal = keyTrigger.asSignal();
|
||||
this.keyUpSignal = keyUpTrigger.asSignal();
|
||||
this.mouseDragSignal = mouseDragTrigger.asSignal();
|
||||
this.mouseScrollSignal = mouseScrollTrigger.asSignal();
|
||||
this.mouseUpSignal = mouseUpTrigger.asSignal();
|
||||
this.pasteSignal = pasteTrigger.asSignal();
|
||||
public var onResize(default, null):Signal<Vec2<Int>>;
|
||||
|
||||
}
|
||||
@:allow(kernel.ui)
|
||||
private function setTarget(target:TermWriteable) {
|
||||
writer.setTarget(target);
|
||||
}
|
||||
|
||||
public var onResize(default, null):Signal<Vec2<Int>>;
|
||||
@:allow(kernel.ui)
|
||||
private function enable() {
|
||||
writer.enable();
|
||||
}
|
||||
|
||||
@:allow(kernel.ui)
|
||||
private function setTarget(target: TermWriteable) {
|
||||
writer.setTarget(target);
|
||||
}
|
||||
@:allow(kernel.ui)
|
||||
private function disable() {
|
||||
writer.disable();
|
||||
}
|
||||
|
||||
@:allow(kernel.ui)
|
||||
private function enable() {
|
||||
writer.enable();
|
||||
}
|
||||
|
||||
@:allow(kernel.ui)
|
||||
private function disable() {
|
||||
writer.disable();
|
||||
}
|
||||
|
||||
@:allow(kernel.ui)
|
||||
private function isEnabled() {
|
||||
return writer.isEnabled();
|
||||
}
|
||||
@:allow(kernel.ui)
|
||||
private function isEnabled() {
|
||||
return writer.isEnabled();
|
||||
}
|
||||
|
||||
public function write(text:String) {
|
||||
writer.write(text);
|
||||
}
|
||||
writer.write(text);
|
||||
}
|
||||
|
||||
public function scroll(y:Int) {
|
||||
writer.scroll(y);
|
||||
}
|
||||
writer.scroll(y);
|
||||
}
|
||||
|
||||
public function getCursorPos():Vec2<Int> {
|
||||
return writer.getCursorPos();
|
||||
}
|
||||
|
||||
public function setCursorPos(x:Int, y:Int) {
|
||||
writer.setCursorPos(x,y);
|
||||
}
|
||||
writer.setCursorPos(x, y);
|
||||
}
|
||||
|
||||
public function getCursorBlink():Bool {
|
||||
return writer.getCursorBlink();
|
||||
}
|
||||
|
||||
public function setCursorBlink(blink:Bool) {
|
||||
writer.setCursorBlink(blink);
|
||||
}
|
||||
writer.setCursorBlink(blink);
|
||||
}
|
||||
|
||||
public function getSize():Vec2<Int> {
|
||||
return writer.getSize();
|
||||
}
|
||||
|
||||
public function clear() {
|
||||
writer.clear();
|
||||
}
|
||||
writer.clear();
|
||||
}
|
||||
|
||||
public function clearLine() {
|
||||
writer.clearLine();
|
||||
}
|
||||
writer.clearLine();
|
||||
}
|
||||
|
||||
public function getTextColor():Color {
|
||||
return writer.getTextColor();
|
||||
}
|
||||
|
||||
public function setTextColor(colour:Color) {
|
||||
writer.setTextColor(colour);
|
||||
}
|
||||
writer.setTextColor(colour);
|
||||
}
|
||||
|
||||
public function getBackgroundColor():Color {
|
||||
return writer.getBackgroundColor();
|
||||
}
|
||||
|
||||
public function setBackgroundColor(color:Color) {
|
||||
writer.setBackgroundColor(color);
|
||||
}
|
||||
writer.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
public function isColor():Bool {
|
||||
return writer.isColor();
|
||||
|
||||
@@ -4,102 +4,98 @@ import lib.TermWriteable;
|
||||
import kernel.peripherals.Peripherals.Peripheral;
|
||||
|
||||
class WindowManager {
|
||||
public static var instance:WindowManager;
|
||||
public static var instance:WindowManager;
|
||||
|
||||
@:allow(kernel.Init)
|
||||
private function new() {
|
||||
@:allow(kernel.Init)
|
||||
private function new() {
|
||||
KernelEvents.instance.onKey.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.keyTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onKey.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.keyTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onKeyUp.handle(keyCode -> {
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.keyUpTrigger.trigger(keyCode);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onKeyUp.handle(keyCode -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.keyUpTrigger.trigger(keyCode);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMouseClick.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.clickTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMouseDrag.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseDragTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onMouseClick.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.clickTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMouseScroll.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseScrollTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onMouseDrag.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.mouseDragTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMouseUp.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseUpTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onMouseScroll.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.mouseScrollTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onPaste.handle(text->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.pasteTrigger.trigger(text);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onMouseUp.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.mouseUpTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMonitorTouch.handle(params ->{
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
KernelEvents.instance.onPaste.handle(text -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.pasteTrigger.trigger(text);
|
||||
}
|
||||
});
|
||||
|
||||
private var currentMainContext:WindowContext;
|
||||
private final allContexts:Array<WindowContext> = new Array();
|
||||
private final outputMap:Map<String,WindowContext> = new Map();
|
||||
KernelEvents.instance.onMonitorTouch.handle(params -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
public function createNewContext(): WindowContext {
|
||||
var newContext = new WindowContext(new VirtualTermWriter());
|
||||
private var currentMainContext:WindowContext;
|
||||
private final allContexts:Array<WindowContext> = new Array();
|
||||
private final outputMap:Map<String, WindowContext> = new Map();
|
||||
|
||||
allContexts.push(newContext);
|
||||
public function createNewContext():WindowContext {
|
||||
var newContext = new WindowContext(new VirtualTermWriter());
|
||||
|
||||
// newContext.setTarget(MainTerm.instance);
|
||||
newContext.enable();
|
||||
currentMainContext = newContext;
|
||||
allContexts.push(newContext);
|
||||
|
||||
return newContext;
|
||||
}
|
||||
// newContext.setTarget(MainTerm.instance);
|
||||
newContext.enable();
|
||||
currentMainContext = newContext;
|
||||
|
||||
return newContext;
|
||||
}
|
||||
|
||||
public function getOutputs(): Array<String> {
|
||||
var arr = Peripheral.instance.getScreens().map(screen -> return screen.getAddr());
|
||||
arr.push("main");
|
||||
return arr;
|
||||
}
|
||||
public function getOutputs():Array<String> {
|
||||
var arr = Peripheral.instance.getScreens().map(screen -> return screen.getAddr());
|
||||
arr.push("main");
|
||||
return arr;
|
||||
}
|
||||
|
||||
public function focusContextToOutput(context: WindowContext,output: String) {
|
||||
var target: TermWriteable;
|
||||
if (output == "main"){
|
||||
target = MainTerm.instance;
|
||||
}else{
|
||||
target = Peripheral.instance.getScreen(output);
|
||||
public function focusContextToOutput(context:WindowContext, output:String) {
|
||||
var target:TermWriteable;
|
||||
if (output == "main") {
|
||||
target = MainTerm.instance;
|
||||
} else {
|
||||
target = Peripheral.instance.getScreen(output);
|
||||
|
||||
if (target == null){
|
||||
// output target not found
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
// output target not found
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (outputMap.exists(output)){
|
||||
outputMap[output].disable();
|
||||
}
|
||||
if (outputMap.exists(output)) {
|
||||
outputMap[output].disable();
|
||||
}
|
||||
|
||||
|
||||
outputMap[output] = context;
|
||||
context.setTarget(target);
|
||||
context.enable();
|
||||
}
|
||||
outputMap[output] = context;
|
||||
context.setTarget(target);
|
||||
context.enable();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user