- if (tui.mode == 'chat') {
- if (event.key.length === 1) {
- tui.add_to_input(event.key);
- tui.full_refresh();
- } else if (event.key == 'Backspace') {
- tui.shorten_input();
- tui.full_refresh();
- } else if (event.key == 'Enter') {
- let [tokens, token_starts] = parser.tokenize(tui.input);
- if (tokens.length > 0 && tokens[0].length > 0) {
- if (tokens[0][0] == ':') {
- if (tokens[0] == ':play' || tokens[0] == ':p') {
- tui.switch_mode('play');
- } else if (tokens[0] == ':study' || tokens[0] == ':s') {
- tui.switch_mode('study');
- } else if (tokens[0] == ':help') {
- tui.log_help();
- tui.refresh();
- } else if (tokens[0] == ':login') {
- if (tokens.length > 1) {
- server.send(['LOGIN', tokens[1]]);
- } else {
- tui.log_msg('? need login name');
- }
- } else if (tokens[0] == ':msg') {
- if (tokens.length > 2) {
- let msg = tui.input.slice(token_starts[2]);
- server.send(['QUERY', tokens[1], msg]);
- } else {
- tui.log_msg('? need message target and message');
- }
+ if (tui.mode.has_input_prompt && event.key.length === 1) {
+ tui.add_to_input(event.key);
+ tui.full_refresh();
+ } else if (tui.mode.has_input_prompt && event.key == 'Backspace') {
+ tui.shorten_input();
+ tui.full_refresh();
+ } else if (tui.mode == mode_annotate && event.key == 'Enter') {
+ explorer.annotate(tui.input);
+ tui.switch_mode(mode_study, true);
+ } else if (tui.mode == mode_chat && event.key == 'Enter') {
+ let [tokens, token_starts] = parser.tokenize(tui.input);
+ if (tokens.length > 0 && tokens[0].length > 0) {
+ if (tokens[0][0] == ':') {
+ if (tokens[0] == ':play' || tokens[0] == ':p') {
+ tui.switch_mode(mode_play);
+ } else if (tokens[0] == ':study' || tokens[0] == ':s') {
+ tui.switch_mode(mode_study);
+ } else if (tokens[0] == ':help') {
+ tui.log_help();
+ tui.refresh();
+ } else if (tokens[0] == ':login') {
+ if (tokens.length > 1) {
+ server.send(['LOGIN', tokens[1]]);