added scroll back to terminal
This commit is contained in:
parent
dd146d1caf
commit
d89956a626
@ -1,5 +1,6 @@
|
|||||||
package bin;
|
package bin;
|
||||||
|
|
||||||
|
import lib.MathI;
|
||||||
import kernel.EndOfLoop;
|
import kernel.EndOfLoop;
|
||||||
import lua.NativeStringTools;
|
import lua.NativeStringTools;
|
||||||
import kernel.binstore.BinStore;
|
import kernel.binstore.BinStore;
|
||||||
@ -25,6 +26,8 @@ class Terminal implements IProcess {
|
|||||||
private var history:Array<String> = [];
|
private var history:Array<String> = [];
|
||||||
private var historyIndex:Int = 0;
|
private var historyIndex:Int = 0;
|
||||||
|
|
||||||
|
private var scrollBack = 0;
|
||||||
|
|
||||||
private var runningPID:PID = -1;
|
private var runningPID:PID = -1;
|
||||||
|
|
||||||
public function new() {}
|
public function new() {}
|
||||||
@ -61,6 +64,7 @@ class Terminal implements IProcess {
|
|||||||
this.backlog.push("> " + this.input);
|
this.backlog.push("> " + this.input);
|
||||||
var command = this.input;
|
var command = this.input;
|
||||||
this.input = "";
|
this.input = "";
|
||||||
|
this.scrollBack = 0;
|
||||||
this.requestRender();
|
this.requestRender();
|
||||||
this.historyIndex = 0;
|
this.historyIndex = 0;
|
||||||
this.invokeCommand(command);
|
this.invokeCommand(command);
|
||||||
@ -72,6 +76,12 @@ class Terminal implements IProcess {
|
|||||||
this.input = this.history[this.history.length - this.historyIndex];
|
this.input = this.history[this.history.length - this.historyIndex];
|
||||||
this.requestRender();
|
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 size = this.ctx.getSize();
|
||||||
var linesAvailable = size.y - 1;
|
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) {
|
for (i in 0...linesAvailable) {
|
||||||
var line = this.backlog[start + i];
|
var line = this.backlog[start + i];
|
||||||
|
Loading…
Reference in New Issue
Block a user