terminal.write(terminal.rows - 1, terminal.cols / 2, '> ' + this.input_line);
}
},
- log_msg: function(msg) {
- let line_length = (terminal.cols / 2);
+ msg_into_lines_of_width: function(msg, width) {
let chunk = "";
+ let lines = [];
for (let i = 0, x = 0; i < msg.length; i++, x++) {
- if (x >= line_length) {
- this.log.unshift(chunk);
+ if (x >= width) {
+ lines.unshift(chunk);
chunk = "";
x = 0;
};
chunk += msg[i];
}
- this.log.unshift(chunk);
+ lines.unshift(chunk);
+ return lines;
+ },
+ log_msg: function(msg) {
+ let line_length = (terminal.cols / 2);
+ let chunk = "";
+ this.log = this.msg_into_lines_of_width(msg, terminal.cols / 2).concat(this.log);
while (this.log.length > terminal.rows - 2) {
this.log.pop();
};
},
draw_info: function() {
terminal.drawBox(1, terminal.cols / 2, terminal.rows - 2, terminal.cols / 2);
- let lines = explorer.get_info();
+ let lines = this.msg_into_lines_of_width(explorer.get_info(), terminal.cols / 2);
+ lines.reverse();
for (let y = 1, i = 0; y < terminal.rows && i < lines.length; y++, i++) {
terminal.write(y, terminal.cols / 2, lines[i]);
}
},
get_info: function() {
if (this.position in this.info_db) {
- return [this.info_db[this.position]];
+ return this.info_db[this.position];
} else {
- return ['waiting …'];
+ return 'waiting …';
}
},
annotate: function(msg) {