Git development
 help / color / mirror / Atom feed
From: "Suraj N. Kurapati" <sunaku@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH/RFC v2] git-add--interactive.perl: Answer questions with a single keypress
Date: Tue, 4 Nov 2008 22:31:19 -0800	[thread overview]
Message-ID: <200811042231.19124.sunaku@gmail.com> (raw)
In-Reply-To: <200811042215.31147.sunaku@gmail.com>

Allows the user to answer 'Stage this hunk' questions with a
single keypress, just like in Darcs.  Previously, the user was
forced to press the Return key after every choice they made.
This quickly becomes tiring, burdensome work for the fingers.

Signed-off-by: Suraj N. Kurapati <sunaku@gmail.com>
---
 git-add--interactive.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index b0223c3..a824984 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -877,6 +877,8 @@ sub patch_update_file {
 	$num = scalar @hunk;
 	$ix = 0;
 
+	require Term::ReadKey;
+	Term::ReadKey::ReadMode('raw');
 	while (1) {
 		my ($prev, $next, $other, $undecided, $i);
 		$other = '';
@@ -920,7 +922,7 @@ sub patch_update_file {
 			print;
 		}
 		print colored $prompt_color, "Stage this hunk [y/n/a/d$other/?]? ";
-		my $line = <STDIN>;
+		my $line = Term::ReadKey::ReadKey(0);
 		if ($line) {
 			if ($line =~ /^y/i) {
 				$hunk[$ix]{USE} = 1;
@@ -998,6 +1000,7 @@ sub patch_update_file {
 			}
 		}
 	}
+	Term::ReadKey::ReadMode('restore');
 
 	my $n_lofs = 0;
 	my @result = ();
-- 
1.6.0.3

\0

  reply	other threads:[~2008-11-05  6:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-05  6:15 [PATCH/RFC] git-add--interactive.perl: Answer questions with a single keypress Suraj N. Kurapati
2008-11-05  6:31 ` Suraj N. Kurapati [this message]
2008-11-05 17:59 ` [PATCH/RFC v3] git add -i: " Suraj N. Kurapati
2008-11-06  8:42   ` Jeff King
2008-11-06 16:15     ` Suraj N. Kurapati
2008-11-06 17:06       ` Junio C Hamano
2008-11-07 19:19         ` Jeff King
2008-11-07 19:19       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200811042231.19124.sunaku@gmail.com \
    --to=sunaku@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox