Work in progress v2: Redesign pt-diskstats in Perl.

This commit is contained in:
Brian Fraser
2011-12-13 14:53:05 -03:00
parent 43b29d6374
commit 0fd09e8f6e
25 changed files with 2919 additions and 2721 deletions

View File

@@ -111,6 +111,25 @@ my %modes = (
}
sub readkey {
my $key = '';
cbreak();
sysread(STDIN, $key, 1);
my $timeout = 0.1;
if ( $key eq "\033" ) { # Ugly and broken hack, but good enough for the two minutes it took to write.
{
my $x = '';
STDIN->blocking(0);
sysread(STDIN, $x, 2);
STDIN->blocking(1);
$key .= $x;
redo if $key =~ /\[[0-2](?:[0-9];)?$/
}
}
cooked();
return $key;
}
# As per perlfaq8:
sub _GetTerminalSize {