diff --git a/src/bin/Terminal.hx b/src/bin/Terminal.hx index 6d00df8..d16be44 100644 --- a/src/bin/Terminal.hx +++ b/src/bin/Terminal.hx @@ -1,5 +1,6 @@ package bin; +import lib.MathI; import kernel.EndOfLoop; import lua.NativeStringTools; import kernel.binstore.BinStore; @@ -25,6 +26,8 @@ class Terminal implements IProcess { private var history:Array = []; private var historyIndex:Int = 0; + private var scrollBack = 0; + private var runningPID:PID = -1; public function new() {} @@ -61,6 +64,7 @@ class Terminal implements IProcess { this.backlog.push("> " + this.input); var command = this.input; this.input = ""; + this.scrollBack = 0; this.requestRender(); this.historyIndex = 0; this.invokeCommand(command); @@ -72,6 +76,12 @@ class Terminal implements IProcess { this.input = this.history[this.history.length - this.historyIndex]; this.requestRender(); } + case 266: // PAGE UP + this.scrollBack = MathI.min(scrollBack + 1, this.backlog.length - 1); + this.requestRender(); + case 267: // PAGE DOWN + this.scrollBack = MathI.max(scrollBack - 1, 0); + this.requestRender(); } })); @@ -99,7 +109,8 @@ class Terminal implements IProcess { var size = this.ctx.getSize(); var linesAvailable = size.y - 1; - var start:Int = this.backlog.length - linesAvailable; + var withoutScrollBack = (this.backlog.length - linesAvailable); + var start:Int = withoutScrollBack - scrollBack; for (i in 0...linesAvailable) { var line = this.backlog[start + i];