[PATCH 5/5] keyboard input: when an unknown sequence is seen, purge all buffered input

2012-10-22 Thread Denys Vlasenko
When we see an unknown sequence, it is not enough to drop already received part - there can be more of it coming over e.g. a serial line. To prevent interpreting it as a random garbage, eat and discard all chars that follow. Small, but non-zero timeout is needed to reconnect escape sequence split

[PATCH 2/5] keyboard input: add commented-out debugging logging mechanism.

2012-10-22 Thread Denys Vlasenko
Figuring out what exactly happens in get_key_code() when user uses various function keys is not trivial. While working on some fixes, I added a debugging code which records a log in /tmp/mc_key.log; I would like to save future developers from doing this again. This patch adds my debugging code, di

[PATCH 3/5] keyboard input: remove unreachable code

2012-10-22 Thread Denys Vlasenko
With the recently rearranged code, it's easy to see that "this == NULL" can't be true here: note -> if (!this->child) { ... return correct_key_code (code); } if (!push_char (c)) { ... goto pend_send;

[PATCH 4/5] keyboard input: treat only ESC or as valid

2012-10-22 Thread Denys Vlasenko
This change prevents misinterpreting an unknown ESC sequence's tail as a garbage input. To reproduce, run "sleep 3" and hold down Down_Arrow key until sleep runs. With debugging log enabled, the following can be seen: entered get_key_code(no_delay:0) c=tty_lowlevel_getch()=27 push_char(27) !0 c

[PATCH 1/5] keyboard input: simplify code, no logic changes

2012-10-22 Thread Denys Vlasenko
This change slightly simplifies and rearranges the code in get_key_code(), reduces indentation levels there, adds a few comments. The logic remains the same. This is a preparatory patch for subsequent changes. Signed-off-by: Denys Vlasenko --- lib/tty/key.c | 126 --

[PATCH 0/5] keyboard input: stop generating garbage input from unknown ESC sequences

2012-10-22 Thread Denys Vlasenko
I got tired of seeing garbage when I press function key MC doesn't know. This changeset attempts to eradicate this problem. Denys Vlasenko (5): keyboard input: simplify code, no logic changes keyboard input: add commented-out debugging logging mechanism. keyboard input: remove unreachable co