let terminal = {
rows: 24,
cols: 80,
+ foreground: 'white',
+ background: 'black',
initialize: function() {
this.pre_el = document.getElementById("terminal");
+ this.pre_el.style.color = this.foreground;
+ this.pre_el.style.backgroundColor = this.background;
this.content = [];
let line = []
for (let y = 0, x = 0; y <= this.rows; x++) {
line.push(' ');
}
},
+ blink_screen: function() {
+ this.pre_el.style.color = this.background;
+ this.pre_el.style.backgroundColor = this.foreground;
+ setTimeout(() => {
+ this.pre_el.style.color = this.foreground;
+ this.pre_el.style.backgroundColor = this.background;
+ }, 100);
+ },
refresh: function() {
let pre_string = '';
for (let y = 0; y < this.rows; y++) {
this.height_input = this.input_lines.length;
},
shorten_input: function() {
- this.input = tui.input.slice(0, -1);
- this.recalc_input_lines();
+ if (this.input.length == 0) {
+ terminal.blink_screen();
+ } else {
+ this.input = tui.input.slice(0, -1);
+ this.recalc_input_lines();
+ }
},
draw_input: function() {
terminal.drawBox(terminal.rows - this.height_input, this.window_width, this.height_input, this.window_width);
} else if (tokens[0] === 'UNHANDLED_INPUT') {
tui.log_msg('? unknown command');
tui.refresh();
+ } else if (tokens[0] === 'PLAY_ERROR') {
+ terminal.blink_screen();
} else if (tokens[0] === 'ARGUMENT_ERROR') {
tui.log_msg('? syntax error: ' + tokens[1]);
tui.refresh();