Create InputHandler which performs C0 actions

Part of #459
This commit is contained in:
Daniel Imms
2017-01-08 16:11:35 -08:00
parent 1685cf2d8f
commit 04b1ebf1a7
3 changed files with 73 additions and 16 deletions
+50
View File
@@ -0,0 +1,50 @@
import { IInputHandler, ITerminal } from './Interfaces';
export class InputHandler implements IInputHandler {
// TODO: We want to type _terminal when it's pulled into TS
constructor(private _terminal: any) { }
public bell(): void {
if (!this._terminal.visualBell) {
return;
}
this._terminal.element.style.borderColor = 'white';
setTimeout(() => this._terminal.element.style.borderColor = '', 10);
if (this._terminal.popOnBell) {
this._terminal.focus();
}
}
public lineFeed(): void {
if (this._terminal.convertEol) {
this._terminal.x = 0;
}
this._terminal.y++;
if (this._terminal.y > this._terminal.scrollBottom) {
this._terminal.y--;
this._terminal.scroll();
}
}
public carriageReturn(): void {
this._terminal.x = 0;
}
public backspace(): void {
if (this._terminal.x > 0) {
this._terminal.x--;
}
}
public tab(): void {
this._terminal.x = this._terminal.nextStop();
}
public shiftOut(): void {
this._terminal.setgLevel(1);
}
public shiftIn(): void {
this._terminal.setgLevel(0);
}
}