[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep patch: color support
From: |
Alain Magloire |
Subject: |
Re: grep patch: color support |
Date: |
Fri, 23 Mar 2001 14:46:20 -0500 (EST) |
>
>
> --G4iJoqBmSsgzjUCe
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
>
> On Mar 09, 2001, Alan Magloire wrote:
> > Eric Agnew wrote:
> >> I've been playing w/ ANSI color codes way too much lately, & decided
> >> that grep should have a --color option like ls does... so I looked at
> >> the code & hacked it around until it worked. Haven't quite been able
> >> to generate a working 'grepcolors' yet, though, as I didn't want to
> >> move -everything- from the fileutils package over...
> >>
> >> So, yeah- I've attached a patch that'll get grep color-enabled. I'm
> >> sure it could stand a bit of cleaning up, and it might be desirable to
> >> wrap all the color stuff in an #ifdef for people who want to compile
> >> without it, etc.. but this should be a good start. :)
> > If you resubmit your patch and isolate all the color dependencies into
> > another file it might stand a good chance for inclusion. You should Cc:
> > you patch to address@hidden, it's not because I did not have time
> > to go through it thoroughly that others may not find it very useful.
>
> Hello again.. I just found the new grep 2.5e w/ minimal color support-
> actually, it was the only part of what I was trying to do that I hadn't
> figured out yet (highlighting the actual pattern in the match)! So, I've
> applied my original changes to the new file, which means it's even better:
>
> - supports GNU color-ls-type auto/always/never argument to '--color'
> option ('auto' checks isatty, so it won't screw up pipes)
Agreed.
> - supports GREP_COLORS env variable (works just like LS_COLORS, as it's
> from the same exact code) to specify colors for all options
> - can color filename, line number, byte, context lines, & count (and can
> do different colors for count of 0), as well as the actual pattern
My screen ligth up like a X-mas tree.
> I tried taking your suggestion & splitting most of the code into a
> separate file, but my knowledge of C & Makefiles is quite limited & I
> couldn't get it to work.. but since you now have some of the color stuff
> built right into grep.c this shouldn't be too much of a bother. :) Perhaps
> someone more knowledgeable would {rather|be able to} split off the
> parse_grep_color, get_funky_string, etc. functions into a separate file
> (although they didn't seem to mind having them in ls.c). But most of the
> stuff is in big blocks (aside from the scattered print_color_indicator
> calls), so it shouldn't be too confusing.. especially for anyone familiar
> w/ the ls code. :)
>
> Anyway, I'll Cc: to bug-gnu-utils as suggested, & hope this is useful &
> that someone else more knowledgeable can run with it. Now that the other
> color stuff is in there, hopefully the rest will make it in as well.
Thanks for the patch, lots of it can certainly be put to good use.
--
alain