Exemplo n.º 1
0
zchar console_read_input (int max, zchar *buf, zword timeout, bool continued)
{
    zchar key;
    int i;

    /* Make sure there is some space for input */

    if (cwin == 0 && units_left () + os_string_width (buf) < 10 * font_width)
        screen_new_line ();

    /* Make sure the input line is visible */

    if (continued && input_redraw)
        screen_write_input (buf, -1);

    input_window = cwin;
    input_redraw = FALSE;

    /* Get input line from IO interface */

    cwp->x_cursor -= os_string_width (buf);
    key = os_read_line (max, buf, timeout, units_left (), continued);
    cwp->x_cursor += os_string_width (buf);

    if (key != ZC_TIME_OUT)
        for (i = 0; i < 8; i++)
            wp[i].line_count = 0;

    /* Add a newline if the input was terminated normally */

    if (key == ZC_RETURN)
        screen_new_line ();

    return key;

}/* console_read_input */
Exemplo n.º 2
0
zchar stream_read_input ( int max, zchar *buf,
			  zword timeout, zword routine,
			  bool hot_keys,
			  bool no_scripting )
{
    zchar key = ZC_BAD;

    flush_buffer ();

    /* Remove initial input from the transscript file or from the screen */

    if (ostream_script && enable_scripting && !no_scripting)
	script_erase_input (buf);
    if (istream_replay)
	screen_erase_input (buf);

    /* Read input line from current input stream */

continue_input:

    do {

	if (istream_replay)
	    key = replay_read_input (buf);
	else
	    key = console_read_input (max, buf, timeout, key != ZC_BAD);

    } while (key == ZC_BAD);

    /* Verify mouse clicks */

    if (key == ZC_SINGLE_CLICK || key == ZC_DOUBLE_CLICK)
	if (!validate_click ())
	    goto continue_input;

    /* Copy input line to the command file */

    if (ostream_record && !istream_replay)
	record_write_input (buf, key);

    /* Handle timeouts */

    if (key == ZC_TIME_OUT)
	if (direct_call (routine) == 0)
	    goto continue_input;

    /* Handle hot keys */

    if (hot_keys && key >= ZC_HKEY_MIN && key <= ZC_HKEY_MAX) {

	if (!handle_hot_key (key))
	    goto continue_input;

	return ZC_BAD;

    }

    /* Copy input line to transscript file or to the screen */

    if (ostream_script && enable_scripting && !no_scripting)
	script_write_input (buf, key);
    if (istream_replay)
	screen_write_input (buf, key);

    /* Return terminating key */

    return key;

}/* stream_read_input */