git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Highlight every 5th line for add -i
@ 2010-08-13 12:46 Ciaran McCreesh
  2010-08-14 10:33 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: Ciaran McCreesh @ 2010-08-13 12:46 UTC (permalink / raw)
  To: git; +Cc: Ciaran McCreesh

It's easier to match up numbers to filenames when there's lots of output
that way.
---
 git-add--interactive.perl |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 27fc793..542c29c 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -498,6 +498,7 @@ sub list_and_choose {
 			my $ref = ref $print;
 			my $highlighted = highlight_prefix(@{$prefixes[$i]})
 			    if @prefixes;
+			my $this_line_color = '';
 			if ($ref eq 'ARRAY') {
 				$print = $highlighted || $print->[0];
 			}
@@ -511,7 +512,10 @@ sub list_and_choose {
 			else {
 				$print = $highlighted || $print;
 			}
-			printf("%s%2d: %s", $chosen, $i+1, $print);
+			if ((! $opts->{LIST_FLAT}) && (($i + 1) % 5 == 0) && (@stuff >= 10)) {
+				$this_line_color = $header_color;
+			}
+			printf("%s%s%2d: %s%s", $chosen, $this_line_color, $i+1, $print, $normal_color);
 			if (($opts->{LIST_FLAT}) &&
 			    (($i + 1) % ($opts->{LIST_FLAT}))) {
 				print "\t";
-- 
1.7.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Highlight every 5th line for add -i
  2010-08-13 12:46 [PATCH] Highlight every 5th line for add -i Ciaran McCreesh
@ 2010-08-14 10:33 ` Stephen Boyd
  2010-08-14 18:58   ` Ciaran McCreesh
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2010-08-14 10:33 UTC (permalink / raw)
  To: Ciaran McCreesh; +Cc: git

  On 08/13/2010 05:46 AM, Ciaran McCreesh wrote:
> It's easier to match up numbers to filenames when there's lots of output
> that way.

Interesting. Maybe it would be better to reorganize the listing so that the number is adjacent to the path name? For example:

    staged    unstaged   #  path
unchanged     +5/-2     1: git-add--interactive.perl
unchanged     +100/-2   2: builtin/log.c
unchanged     +49/-2    3: builtin/add.c
unchanged     +0/-60    4: git.c
unchanged     +5/-2     5: help.c

I'm mostly concerned that the highlighting (boldening?) is going to be confused with selection.

Patch below (I'm sure someone more versed in perl can do it better).

--->8----8<---

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 27fc793..002122d 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -225,8 +225,8 @@ sub list_untracked {
         run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);
  }

-my $status_fmt = '%12s %12s %s';
-my $status_head = sprintf($status_fmt, 'staged', 'unstaged', 'path');
+my $status_fmt = '%12s %12s %4s%s %s';
+my $status_head = sprintf($status_fmt, 'staged', 'unstaged', '#', ' ', 'path');

  {
         my $initial;
@@ -488,7 +488,7 @@ sub list_and_choose {

                 if ($opts->{HEADER}) {
                         if (!$opts->{LIST_FLAT}) {
-                               print "     ";
+                               print " ";
                         }
                         print colored $header_color, "$opts->{HEADER}\n";
                 }
@@ -506,12 +506,14 @@ sub list_and_choose {
                                 $print = sprintf($status_fmt,
                                     $print->{INDEX},
                                     $print->{FILE},
+                                   $i + 1,
+                                   ":",
                                     $value);
                         }
                         else {
                                 $print = $highlighted || $print;
                         }
-                       printf("%s%2d: %s", $chosen, $i+1, $print);
+                       printf("%s%s", $chosen, $print);
                         if (($opts->{LIST_FLAT})&&
                             (($i + 1) % ($opts->{LIST_FLAT}))) {
                                 print "\t";

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Highlight every 5th line for add -i
  2010-08-14 10:33 ` Stephen Boyd
@ 2010-08-14 18:58   ` Ciaran McCreesh
  0 siblings, 0 replies; 3+ messages in thread
From: Ciaran McCreesh @ 2010-08-14 18:58 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 847 bytes --]

On Sat, 14 Aug 2010 03:33:33 -0700
Stephen Boyd <bebarino@gmail.com> wrote:
>   On 08/13/2010 05:46 AM, Ciaran McCreesh wrote:
> > It's easier to match up numbers to filenames when there's lots of
> > output that way.
> 
> Interesting. Maybe it would be better to reorganize the listing so
> that the number is adjacent to the path name? For example:
> 
>     staged    unstaged   #  path
> unchanged     +5/-2     1: git-add--interactive.perl
> unchanged     +100/-2   2: builtin/log.c
> unchanged     +49/-2    3: builtin/add.c
> unchanged     +0/-60    4: git.c
> unchanged     +5/-2     5: help.c
> 
> I'm mostly concerned that the highlighting (boldening?) is going to
> be confused with selection.

That's also good for me. I don't have any particular preference or
opinions on which is clearer.

-- 
Ciaran McCreesh

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-14 18:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-13 12:46 [PATCH] Highlight every 5th line for add -i Ciaran McCreesh
2010-08-14 10:33 ` Stephen Boyd
2010-08-14 18:58   ` Ciaran McCreesh

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).