}/* stream_read_key */ /* * stream_read_input * * Read a line of input from the current input stream. * */ internal static zword stream_read_input(int max, zword[] buf,// zword* buf, zword timeout, zword routine, bool hot_keys, bool no_scripting) { zword key = CharCodes.ZC_BAD; bool no_scrollback = no_scripting; if (main.h_version == ZMachine.V6 && main.story_id == Story.UNKNOWN && !main.ostream_script) { no_scrollback = false; } Buffer.flush_buffer(); /* Remove initial input from the transscript file or from the screen */ if (main.ostream_script && main.enable_scripting && !no_scripting) { Files.script_erase_input(buf); } if (main.enable_scripting && !no_scrollback) { Stream.scrollback_erase_input(buf); } if (main.istream_replay) { Screen.screen_erase_input(buf); } /* Read input line from current input stream */ continue_input: do { if (main.istream_replay) { key = Files.replay_read_input(buf); } else { key = Screen.console_read_input(max, buf, timeout, key != CharCodes.ZC_BAD); } } while (key == CharCodes.ZC_BAD); /* Verify mouse clicks */ if (key == CharCodes.ZC_SINGLE_CLICK || key == CharCodes.ZC_DOUBLE_CLICK) { if (!Screen.validate_click()) { goto continue_input; } } /* Copy input line to the command file */ if (main.ostream_record && !main.istream_replay) { Files.record_write_input(buf, key); } /* Handle timeouts */ if (key == CharCodes.ZC_TIME_OUT) { if (Process.direct_call(routine) == 0) { goto continue_input; } } /* Handle hot keys */ if (hot_keys && key >= CharCodes.ZC_HKEY_MIN && key <= CharCodes.ZC_HKEY_MAX) { if (!Hotkey.handle_hot_key(key)) { goto continue_input; } return(CharCodes.ZC_BAD); } /* Copy input line to transscript file or to the screen */ if (main.ostream_script && main.enable_scripting && !no_scripting) { Files.script_write_input(buf, key); } if (main.enable_scripting && !no_scrollback) { scrollback_write_input(buf, key); } if (main.istream_replay) { Screen.screen_write_input(buf, key); } /* Return terminating key */ return(key); }/* stream_read_input */
}/* z_input_stream */ /* * stream_read_key * * Read a single keystroke from the current input stream. * */ internal static zword stream_read_key(zword timeout, zword routine, bool hot_keys) { zword key = CharCodes.ZC_BAD; Buffer.flush_buffer(); /* Read key from current input stream */ continue_input: do { if (main.istream_replay) { key = Files.replay_read_key(); } else { key = Screen.console_read_key(timeout); } } while (key == CharCodes.ZC_BAD); /* Verify mouse clicks */ if (key == CharCodes.ZC_SINGLE_CLICK || key == CharCodes.ZC_DOUBLE_CLICK) { if (!Screen.validate_click()) { goto continue_input; } } /* Copy key to the command file */ if (main.ostream_record && !main.istream_replay) { Files.record_write_key(key); } /* Handle timeouts */ if (key == CharCodes.ZC_TIME_OUT) { if (Process.direct_call(routine) == 0) { goto continue_input; } } /* Handle hot keys */ if (hot_keys && key >= CharCodes.ZC_HKEY_MIN && key <= CharCodes.ZC_HKEY_MAX) { if (main.h_version == ZMachine.V4 && key == CharCodes.ZC_HKEY_UNDO) { goto continue_input; } if (!Hotkey.handle_hot_key(key)) { goto continue_input; } } /* Return key */ return(key); }/* stream_read_key */