Revert "Revert "Prevent runaway scrolling in Visual when using arrow keys ##visual""

This reverts commit 6c1d31c841315c2667dd866213b72013954ffcc3.
This commit is contained in:
Khairul Kasmiran 2019-01-25 22:51:05 +08:00
parent 6c1d31c841
commit 0412beb08c

View File

@ -4054,6 +4054,21 @@ dodo:
#ifndef __WINDOWS__
if (IS_PRINTABLE (ch) || ch == '\t' || ch == '\n') {
tcflush (STDIN_FILENO, TCIFLUSH);
} else if (ch == 0x1b) {
char chrs[2];
chrs[0] = r_cons_readchar ();
if (chrs[0] == '[') {
chrs[1] = r_cons_readchar ();
if (chrs[1] >= 'A' && chrs[1] <= 'D') { // arrow keys
tcflush (STDIN_FILENO, TCIFLUSH);
// Following seems to fix an issue where scrolling slows
// down to a crawl after some time mashing the up and down
// arrow keys
r_cons_set_raw (false);
r_cons_set_raw (true);
}
}
(void)r_cons_readpush (chrs, R_ARRAY_SIZE (chrs));
}
#endif
if (r_cons_is_breaked()) {