X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/static/gitweb.css?a=blobdiff_plain;f=rogue_chat_nocanvas_monochrome.html;h=d6e8a6ed3798cbf8165ba1333206de5646bec220;hb=4e31e852bd02aa77ce44f0ff8193ee6ca0552f58;hp=7a479d0b0cd85730a941f88d9668b2826210eb61;hpb=6a70ba4e9d6e3ff89b2cdd40ef65e600e6ed6548;p=plomrogue2
diff --git a/rogue_chat_nocanvas_monochrome.html b/rogue_chat_nocanvas_monochrome.html
index 7a479d0..d6e8a6e 100644
--- a/rogue_chat_nocanvas_monochrome.html
+++ b/rogue_chat_nocanvas_monochrome.html
@@ -4,8 +4,8 @@
-terminal rows:
-terminal columns:
+terminal rows:
+terminal columns:
@@ -142,7 +142,6 @@ terminal.initialize();
let parser = {
tokenize: function(str) {
- let token_ends = [];
let tokens = [];
let token = ''
let quoted = false;
@@ -164,7 +163,6 @@ let parser = {
quoted = true
} else if (c === ' ') {
if (token.length > 0) {
- token_ends.push(i);
tokens.push(token);
token = '';
}
@@ -175,11 +173,7 @@ let parser = {
if (token.length > 0) {
tokens.push(token);
}
- let token_starts = [];
- for (let i = 0; i < token_ends.length; i++) {
- token_starts.push(token_ends[i] - tokens[i].length);
- };
- return [tokens, token_starts];
+ return tokens;
},
parse_yx: function(position_string) {
let coordinate_strings = position_string.split(',')
@@ -225,7 +219,7 @@ let server = {
this.websocket.send(unparser.untokenize(tokens));
},
handle_event: function(event) {
- let tokens = parser.tokenize(event.data)[0];
+ let tokens = parser.tokenize(event.data);
if (tokens[0] === 'TURN') {
game.turn_complete = false;
game.things = {};
@@ -285,6 +279,7 @@ let server = {
} else if (tokens[0] === 'UNHANDLED_INPUT') {
tui.log_msg('? unknown command');
} else if (tokens[0] === 'PLAY_ERROR') {
+ tui.log_msg('? ' + tokens[1]);
terminal.blink_screen();
} else if (tokens[0] === 'ARGUMENT_ERROR') {
tui.log_msg('? syntax error: ' + tokens[1]);
@@ -385,6 +380,7 @@ let tui = {
};
},
switch_mode: function(mode) {
+ this.inputEl.focus();
this.show_help = false;
this.map_mode = 'terrain';
if (mode.shows_info && game.player_id in game.things) {
@@ -661,7 +657,6 @@ let tui = {
content += '[' + this.keys.switch_to_play + '] â play mode\n';
} else if (this.mode == mode_chat) {
content += '/nick NAME â re-name yourself to NAME\n';
- //content += '/msg USER TEXT â send TEXT to USER\n';
content += '/' + this.keys.switch_to_play + ' or /play â switch to play mode\n';
content += '/' + this.keys.switch_to_study + ' or /study â switch to study mode\n';
}
@@ -868,7 +863,6 @@ tui.inputEl.addEventListener('input', (event) => {
}
tui.full_refresh();
}, false);
-
tui.inputEl.addEventListener('keydown', (event) => {
tui.show_help = false;
if (event.key == 'Enter') {
@@ -910,13 +904,6 @@ tui.inputEl.addEventListener('keydown', (event) => {
} else {
tui.log_msg('? need new name');
}
- //} else if (tokens[0].slice(1) == 'msg') {
- // if (tokens.length > 2) {
- // let msg = tui.inputEl.value.slice(token_starts[2]);
- // server.send(['QUERY', tokens[1], msg]);
- // } else {
- // tui.log_msg('? need message target and message');
- // }
} else {
tui.log_msg('? unknown command');
}
@@ -981,7 +968,7 @@ tui.inputEl.addEventListener('keydown', (event) => {
}, false);
rows_selector.addEventListener('input', function() {
- if (rows_selector.value % 4 != 0) {
+ if (rows_selector.value % 4 != 0 || rows_selector.value < 24) {
return;
}
window.localStorage.setItem(rows_selector.id, rows_selector.value);
@@ -989,7 +976,7 @@ rows_selector.addEventListener('input', function() {
tui.full_refresh();
}, false);
cols_selector.addEventListener('input', function() {
- if (cols_selector.value % 4 != 0) {
+ if (cols_selector.value % 4 != 0 || cols_selector.value < 80) {
return;
}
window.localStorage.setItem(cols_selector.id, cols_selector.value);
@@ -1003,12 +990,6 @@ for (let key_selector of key_selectors) {
tui.init_keys();
}, false);
}
-window.setInterval(function() {
- if (!(['input', 'n_cols', 'n_rows'].includes(document.activeElement.id)
- || document.activeElement.id.startsWith('key_'))) {
- tui.inputEl.focus();
- }
-}, 100);
window.setInterval(function() {
if (server.connected) {
server.send(['PING']);
@@ -1017,7 +998,9 @@ window.setInterval(function() {
tui.log_msg('@ attempting reconnect â¦')
}
}, 5000);
-
+document.getElementById("terminal").onclick = function() {
+ tui.inputEl.focus();
+};
document.getElementById("help").onclick = function() {
tui.show_help = true;
tui.full_refresh();