Re: [PATCH] Highlight keyboard shortcuts in git-add--interactive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



El 1/12/2007, a las 3:36, Junio C Hamano escribió:

When list_and_choose() function is letting you choose more than one
items, its prompt becomes ">> ", instead of "> " that is used for a
singleton choice. To that prompt, you can say "3-7" (Add these 5 items to the choice), "*" (I want all of them), "-2-4" (exclude 2 and 3 and 4
from the set I have chosen so far).  These are also "hidden", and need
to be documented, but that would be a separate patch.

I was just about to prepare some documentation for this when I saw that it is already documented, and by none other than you, Junio! (see 6a5ad23d).

Unless by "documentation" you meant to somehow expose these in the interface at runtime... something like this? (applied on top of the patch I just sent to the list):

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 32fb9ea..e7b07ee 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -237,7 +237,8 @@ sub is_valid_prefix {
 	    !($prefix =~ /[\s,]/) && # separators
 	    !($prefix =~ /^-/) &&    # deselection
 	    !($prefix =~ /^\d+/) &&  # selection
-	    ($prefix ne '*');        # "all" wildcard
+	    ($prefix ne '*') &&      # "all" wildcard
+	    ($prefix ne '?');        # prompt help
 }

# given a prefix/remainder tuple return a string with the prefix highlighted
@@ -308,7 +309,7 @@ sub list_and_choose {
 			print "> ";
 		}
 		else {
-			print ">> ";
+			print " (?)>> ";
 		}
 		my $line = <STDIN>;
 		if (!$line) {
@@ -318,6 +319,10 @@ sub list_and_choose {
 		}
 		chomp $line;
 		last if $line eq '';
+		if ($line eq '?' && !$opts->{SINGLETON}) {
+			prompt_help_cmd();
+			next TOPLOOP;
+		}
 		for my $choice (split(/[\s,]+/, $line)) {
 			my $choose = 1;
 			my ($bottom, $top);
@@ -363,6 +368,19 @@ sub list_and_choose {
 	return @return;
 }

+sub prompt_help_cmd {
+	print <<\EOF ;
+Prompt help:
+1          - select a single item
+3-5        - select a range of items
+2-3,6-9    - select multiple ranges
+foo        - select item based on unique prefix
+-...       - unselect specified items
+*          - choose all items
+           - (empty) finish selecting
+EOF
+}
+
 sub status_cmd {
 	list_and_choose({ LIST_ONLY => 1, HEADER => $status_head },
 			list_modified());


Cheers,
Wincent



-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux