git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wincent Colaiuta <win@wincent.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Wincent Colaiuta <win@wincent.com>
Subject: [PATCH] Highlight keyboard shortcuts in git-add--interactive
Date: Wed, 21 Nov 2007 15:27:58 +0100	[thread overview]
Message-ID: <1195655278-19535-1-git-send-email-win@wincent.com> (raw)

The user interface provided by the command loop in git-add--interactive
gives the impression that subcommands can only be launched by entering
an integer identifier from 1 through 8.

A "hidden" feature is that any string can be entered, and an anchored
regex search is used to find the first matching option.

This patch makes this feature a little more obvious by highlighting the
first character of each subcommand (for example "patch" is displayed as
"[p]atch"). The mechanism for doing this is to add an optional third
element to the array defining each subcommand; if present, it will be
used for display purposes, while the actual name of the subcommand (the
first element) is still used for matching purposes.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
---

And another thought: if the colorization for git-add--interactive goes
ahead, we could drop the square brackets used here in favor of underline
or boldface, if people find that more attractive.

 git-add--interactive.perl |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 0317ad9..2b1c55a 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -179,7 +179,7 @@ sub list_and_choose {
 			my $print = $stuff[$i];
 			if (ref $print) {
 				if ((ref $print) eq 'ARRAY') {
-					$print = $print->[0];
+					$print = $print->[2] || $print->[0];
 				}
 				else {
 					$print = $print->{PRINT};
@@ -774,14 +774,14 @@ EOF
 }
 
 sub main_loop {
-	my @cmd = ([ 'status', \&status_cmd, ],
-		   [ 'update', \&update_cmd, ],
-		   [ 'revert', \&revert_cmd, ],
-		   [ 'add untracked', \&add_untracked_cmd, ],
-		   [ 'patch', \&patch_update_cmd, ],
-		   [ 'diff', \&diff_cmd, ],
-		   [ 'quit', \&quit_cmd, ],
-		   [ 'help', \&help_cmd, ],
+	my @cmd = ([ 'status', \&status_cmd, '[s]tatus', ],
+		   [ 'update', \&update_cmd, '[u]date', ],
+		   [ 'revert', \&revert_cmd, '[r]evert', ],
+		   [ 'add untracked', \&add_untracked_cmd, '[a]dd untracked', ],
+		   [ 'patch', \&patch_update_cmd, '[p]atch', ],
+		   [ 'diff', \&diff_cmd, '[d]iff', ],
+		   [ 'quit', \&quit_cmd, '[q]uit', ],
+		   [ 'help', \&help_cmd, '[h]elp', ],
 	);
 	while (1) {
 		my ($it) = list_and_choose({ PROMPT => 'What now',
-- 
1.5.3.6.866.g67e44

             reply	other threads:[~2007-11-21 14:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21 14:27 Wincent Colaiuta [this message]
2007-11-21 14:32 ` [PATCH] Highlight keyboard shortcuts in git-add--interactive Matthieu Moy
2007-11-21 15:28 ` Jeff King
2007-11-21 23:00   ` Dan Zwell
2007-11-28 23:56 ` Junio C Hamano
2007-11-29  1:08   ` Wincent Colaiuta
2007-11-29 12:00   ` Wincent Colaiuta
2007-11-29 14:51     ` Jeff King
2007-12-01  2:36     ` Junio C Hamano
2007-12-01 13:58       ` Wincent Colaiuta
2007-12-01 14:07       ` [PATCH 1/2] " Wincent Colaiuta
2007-12-01 14:07         ` [PATCH 2/2] Teach git-add--interactive to highlight untracked file prefixes Wincent Colaiuta
2007-12-01 14:15         ` [PATCH 1/2] Highlight keyboard shortcuts in git-add--interactive Wincent Colaiuta
2007-12-01 14:29           ` [REPLACEMENT PATCH] " Wincent Colaiuta
2007-12-02 14:11       ` [PATCH] " Wincent Colaiuta
2007-12-02 19:06         ` Junio C Hamano
2007-12-03  8:09           ` Wincent Colaiuta

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=1195655278-19535-1-git-send-email-win@wincent.com \
    --to=win@wincent.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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;
as well as URLs for NNTP newsgroup(s).