X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/balance?a=blobdiff_plain;f=new2%2Frogue_chat_nocanvas_monochrome.html;h=ad654611d3249f68751e5163e46e903d96a8d3e4;hb=c28b4f2c784509f2b620e672b6ad0be06de12afc;hp=e8f7873eb3794407c53747938bfe6ec2e1ecd459;hpb=24ccb759c7925aa91e87398280fc50a4e6123612;p=plomrogue2-experiments diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index e8f7873..ad65461 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -11,8 +11,12 @@ let websocket_location = "ws://localhost:8000"; 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++) { @@ -28,6 +32,14 @@ let terminal = { 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++) { @@ -161,6 +173,7 @@ let mode_edit = new Mode('edit', false, false); let tui = { mode: mode_chat, log: [], + input_prompt: '> ', input: '', input_lines: [], window_width: terminal.cols / 2, @@ -177,6 +190,12 @@ let tui = { } this.mode = mode; this.empty_input(); + if (mode == mode_annotate && explorer.position in explorer.info_db) { + let info = explorer.info_db[explorer.position]; + if (info != "(none)") { + this.add_to_input(explorer.info_db[explorer.position]); + } + } this.full_refresh(); }, draw_mode_line: function() { @@ -246,19 +265,23 @@ let tui = { } }, add_to_input: function(str) { - if (this.input.length + str.length > this.window_width * terminal.rows) { + if (this.input_prompt.length + this.input.length + str.length > this.window_width * terminal.rows) { return; } this.input += str; this.recalc_input_lines(); }, recalc_input_lines: function() { - this.input_lines = this.msg_into_lines_of_width("> " + this.input, this.window_width); + this.input_lines = this.msg_into_lines_of_width(this.input_prompt + this.input, this.window_width); 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); @@ -385,6 +408,8 @@ server.websocket.onmessage = function (event) { } 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();