1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-02 07:17:58 +01:00

Merge branch 'tr/add-i-no-escape'

* tr/add-i-no-escape:
  add -i: ignore terminal escape sequences
This commit is contained in:
Junio C Hamano 2011-05-23 10:50:06 -07:00
commit 4961210b17

View file

@ -45,6 +45,9 @@
my $normal_color = $repo->get_color("", "reset");
my $use_readkey = 0;
my $use_termcap = 0;
my %term_escapes;
sub ReadMode;
sub ReadKey;
if ($repo->config_bool("interactive.singlekey")) {
@ -53,6 +56,14 @@
Term::ReadKey->import;
$use_readkey = 1;
};
eval {
require Term::Cap;
my $termcap = Term::Cap->Tgetent;
foreach (values %$termcap) {
$term_escapes{$_} = 1 if /^\e/;
}
$use_termcap = 1;
};
}
sub colored {
@ -1067,6 +1078,14 @@ sub prompt_single_character {
ReadMode 'cbreak';
my $key = ReadKey 0;
ReadMode 'restore';
if ($use_termcap and $key eq "\e") {
while (!defined $term_escapes{$key}) {
my $next = ReadKey 0.5;
last if (!defined $next);
$key .= $next;
}
$key =~ s/\e/^[/;
}
print "$key" if defined $key;
print "\n";
return $key;