mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
(get_key_code): yet another refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
78b01cdf87
commit
dff8ee2981
@ -1765,13 +1765,14 @@ get_key_code (int no_delay)
|
||||
|
||||
while (getch_with_timeout (old_esc_mode_timeout) >= 0 && --paranoia != 0)
|
||||
;
|
||||
goto nodelay_try_again;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c > 127 && c < 256 && use_8th_bit_as_meta)
|
||||
c = ALT (c & 0x7f);
|
||||
|
||||
if (c > 127 && c < 256 && use_8th_bit_as_meta)
|
||||
c = ALT (c & 0x7f);
|
||||
|
||||
goto done;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
nodelay_try_again:
|
||||
@ -1789,30 +1790,27 @@ get_key_code (int no_delay)
|
||||
tty_nodelay (FALSE);
|
||||
if (c == -1)
|
||||
{
|
||||
if (this != NULL && parent != NULL && parent->action == MCKEY_ESCAPE && old_esc_mode)
|
||||
struct timeval current, time_out;
|
||||
|
||||
if (this == NULL || parent == NULL || parent->action != MCKEY_ESCAPE || !old_esc_mode ||
|
||||
esctime.tv_sec == -1)
|
||||
return -1;
|
||||
|
||||
GET_TIME (current);
|
||||
time_out.tv_sec = old_esc_mode_timeout / 1000000 + esctime.tv_sec;
|
||||
time_out.tv_usec = old_esc_mode_timeout % 1000000 + esctime.tv_usec;
|
||||
if (time_out.tv_usec > 1000000)
|
||||
{
|
||||
struct timeval current, time_out;
|
||||
|
||||
if (esctime.tv_sec == -1)
|
||||
return -1;
|
||||
|
||||
GET_TIME (current);
|
||||
time_out.tv_sec = old_esc_mode_timeout / 1000000 + esctime.tv_sec;
|
||||
time_out.tv_usec = old_esc_mode_timeout % 1000000 + esctime.tv_usec;
|
||||
if (time_out.tv_usec > 1000000)
|
||||
{
|
||||
time_out.tv_usec -= 1000000;
|
||||
time_out.tv_sec++;
|
||||
}
|
||||
if (current.tv_sec < time_out.tv_sec ||
|
||||
(current.tv_sec == time_out.tv_sec && current.tv_usec < time_out.tv_usec))
|
||||
return -1;
|
||||
this = NULL;
|
||||
pending_keys = seq_append = NULL;
|
||||
return ESC_CHAR;
|
||||
time_out.tv_usec -= 1000000;
|
||||
time_out.tv_sec++;
|
||||
}
|
||||
if (current.tv_sec < time_out.tv_sec ||
|
||||
(current.tv_sec == time_out.tv_sec && current.tv_usec < time_out.tv_usec))
|
||||
return -1;
|
||||
|
||||
return -1;
|
||||
this = NULL;
|
||||
pending_keys = seq_append = NULL;
|
||||
return ESC_CHAR;
|
||||
}
|
||||
}
|
||||
else if (c == -1)
|
||||
@ -1820,13 +1818,14 @@ get_key_code (int no_delay)
|
||||
/* Maybe we got an incomplete match.
|
||||
This we do only in delay mode, since otherwise
|
||||
tty_lowlevel_getch can return -1 at any time. */
|
||||
if (seq_append != NULL)
|
||||
if (seq_append == NULL)
|
||||
{
|
||||
pending_keys = seq_buffer;
|
||||
goto pend_send;
|
||||
this = NULL;
|
||||
return -1;
|
||||
}
|
||||
this = NULL;
|
||||
return -1;
|
||||
|
||||
pending_keys = seq_buffer;
|
||||
goto pend_send;
|
||||
}
|
||||
|
||||
/* Search the key on the root */
|
||||
@ -1876,13 +1875,12 @@ get_key_code (int no_delay)
|
||||
|
||||
esctime.tv_sec = -1;
|
||||
c = getch_with_timeout (old_esc_mode_timeout);
|
||||
if (c == -1)
|
||||
{
|
||||
pending_keys = seq_append = NULL;
|
||||
this = NULL;
|
||||
return ESC_CHAR;
|
||||
}
|
||||
continue;
|
||||
if (c != -1)
|
||||
continue;
|
||||
|
||||
pending_keys = seq_append = NULL;
|
||||
this = NULL;
|
||||
return ESC_CHAR;
|
||||
}
|
||||
|
||||
if (no_delay != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user