From: Christian Heller Date: Thu, 29 Oct 2020 04:20:52 +0000 (+0100) Subject: Fix line wrapping on terminal resizing. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/blog?a=commitdiff_plain;h=3f81e293dc23f238cd11a20b48ce51763c558ccc;p=plomrogue2-experiments Fix line wrapping on terminal resizing. --- diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index fc5e24c..6aa17ee 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -267,9 +267,8 @@ let tui = { return lines; }, log_msg: function(msg) { - let lines = this.msg_into_lines_of_width(msg, this.window_width); - this.log = this.log.concat(lines); - while (this.log.length > terminal.rows) { + this.log.push(msg); + while (this.log.length > terminal.rows * 4) { this.log.shift(); }; this.full_refresh(); @@ -337,14 +336,15 @@ let tui = { terminal.write(1, this.window_width, 'TURN: ' + game.turn); }, draw_history: function() { - if (terminal.rows <= this.height_header + this.height_input) { - return; - } + let log_display_lines = []; + for (let line of this.log) { + log_display_lines = log_display_lines.concat(this.msg_into_lines_of_width(line, this.window_width)); + }; for (let y = terminal.rows - 1 - this.height_input, - i = this.log.length - 1; + i = log_display_lines.length - 1; y >= this.height_header && i >= 0; y--, i--) { - terminal.write(y, this.window_width, this.log[i]); + terminal.write(y, this.window_width, log_display_lines[i]); } }, draw_info: function() {