summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-31 19:02:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-31 19:02:04 (GMT)
commit1618297f10c612af3e56187825e3f273e6bbdcdb (patch)
treef85130dc01a26a9fd09803dc936bf03d5f5ef349
parent398dbe536d5e94b7f7263fc4900b5e6f788f495a (diff)
parentb5cc003253c8e1b505d5a2fbbcecb1ffcb409758 (diff)
downloadgit-1618297f10c612af3e56187825e3f273e6bbdcdb.zip
git-1618297f10c612af3e56187825e3f273e6bbdcdb.tar.gz
git-1618297f10c612af3e56187825e3f273e6bbdcdb.tar.bz2
Merge branch 'tr/add-i-no-escape' into maint
* tr/add-i-no-escape: add -i: ignore terminal escape sequences
-rwxr-xr-xgit-add--interactive.perl19
1 files changed, 19 insertions, 0 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 4f08fe7..8f0839d 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -45,6 +45,9 @@ my ($diff_new_color) =
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 @@ if ($repo->config_bool("interactive.singlekey")) {
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;