Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set field color using JQ_COLORS #1791

Closed
wants to merge 6 commits into from

Conversation

haguenau
Copy link
Contributor

This should address #1739.

As far as I can tell, this works and passes the test suite (which I updated to test this specific addition). There is a chance that the code changes are not perfect; for example I'm not sure how much sense it makes to have introduced an enum member JV_KIND_FIELD for this (although it keeps the code mostly regular).

This is a drive-by change; I believe the colon character is better
described as a separator than a delimiter within JQ_COLORS.
For some reason, the ANSI escape codes for fields were written as
`34;1` ("blue", then "bright"), whereas for all other types, the order
was "effect" first, "color" second. This changes the order for fields
to `1;34` for consistency, matching the current code.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 84.457% when pulling 0d53abc on haguenau:feature/set-field-color into 4b4fefa on stedolan:master.

@nicowilliams
Copy link
Contributor

Interesting. Obviously there is no use for this new "kind" other than as an index into the array of colors. I'll think about it. Thanks for your contribution!

@haguenau
Copy link
Contributor Author

Cool. Please don't hesitate to let me know if you see changes that you think would make sense.

@ericpruitt
Copy link
Contributor

@nicowilliams , would you be willing to merge an updated version of this patch or even #1977?

@ericpruitt
Copy link
Contributor

ericpruitt commented Jan 25, 2020

I'm attaching a patch that's a updated version of this PR for anyone that builds jq themselves. Thanks, @haguenau, for the original code.

jq-src-JQ_COLORS-field-color.patch.txt

EDIT: I noticed that in cf61515, jq.1.prebuilt was not updated with the new default scheme.

@t829702
Copy link

t829702 commented Jan 22, 2021

is this abandoned?

@ericpruitt
Copy link
Contributor

ericpruitt commented Jan 22, 2021

Depends on what you mean by abandoned. I'm still using this patch, and the last time I synchronized my copy of jq with the upstream repo (December), the patch still applied cleanly, so I haven't needed to post any updates here.

@zpangwin
Copy link

zpangwin commented Jun 15, 2021

is this abandoned?

I see commits on the repo as recently as a month and a half ago... guessing the dev's are just busy / this isn't a high priority for them. I'm not familar with travis builds but I see that it has something flagged for:

continuous-integration/travis-ci/pr — The Travis CI build could not complete due to an error"

It could be something as simple as that holding things back.

Anyway, I hope folks are able to make it happen too... can't stand the hard-to-read dark blue key/property names on my terminal. Even if the default was a bright purple, that would at least have decent contrast on light and dark backgrounds. Obviously customizing would be better but I probably wouldn't have bothered to look this up / subscribe to the ticket and PR if the defaults were more reasonable :-)

Guess it's back to alias jq='/usr/bin/jq --monochrome-output' for me until this makes it in / someone posts idiot-proof build instructions that I can follow for patching lol

@haguenau
Copy link
Contributor Author

I have not followed jq development very closely since submitting this pull request two years ago. I must admit I do not fully understand nicowilliam's reasons for having to think more about this; I assume the change is somehow unclean.

If there is interest, I would be happy to look into reworking the change so that it applies successfully to the current code.

@fdevibe
Copy link

fdevibe commented Jun 8, 2022

I would, too, be very interested in hearing counter-arguments against this. The hard-coded field color is very difficult to read on a dark background, and dark backgrounds are pretty common in what I would assume jq's user base is.

Changing the field color is also something quite a few people request in https://stackoverflow.com/questions/51338701/how-do-i-customize-the-colors-used-by-jq-c

@NickCis
Copy link

NickCis commented Jun 28, 2023

Really looking into getting this merge, Can I offer any help with it?.

@itchyny itchyny added this to the 1.7 release milestone Jun 28, 2023
@itchyny
Copy link
Contributor

itchyny commented Jun 28, 2023

Added to the next release milestone. Needs rebasing though.

@ericpruitt
Copy link
Contributor

I'll open a PR later today with my latest version of the patch.

@haguenau
Copy link
Contributor Author

haguenau commented Jun 28, 2023 via email

@ericpruitt
Copy link
Contributor

I've opened #2638.

@itchyny
Copy link
Contributor

itchyny commented Jun 29, 2023

Taking a careful look into this patch, I finally understand why this is hard to merge. This patch adds JV_KIND_FIELD to jv_kind, but this is not what jv_kind is intended. This enum type is a basic and core type of JSON representation in jq, and such a new value shouldn't be added just for colors. So I propose; do not touch jv_kind and color_kinds, but color_bufs can have 8 (==sizeof(color_kinds)/sizeof(color_kinds[0]) + 1) entries, and FIELD_COLOR can be colors[sizeof(color_kinds)/sizeof(color_kinds[0])] or simply colors[7].

itchyny added a commit to itchyny/jq that referenced this pull request Jul 12, 2023
itchyny added a commit to itchyny/jq that referenced this pull request Jul 12, 2023
…qlang#2638)

Co-authored-by: David Haguenauer <ml@kurokatta.org>
Co-authored-by: Eric Pruitt <eric.pruitt@gmail.com>
itchyny added a commit to itchyny/jq that referenced this pull request Jul 12, 2023
…qlang#2638)

Co-authored-by: David Haguenauer <ml@kurokatta.org>
Co-authored-by: Eric Pruitt <eric.pruitt@gmail.com>
itchyny added a commit to itchyny/jq that referenced this pull request Jul 12, 2023
…qlang#2638)

Co-authored-by: David Haguenauer <ml@kurokatta.org>
Co-authored-by: Eric Pruitt <eric.pruitt@gmail.com>
nicowilliams pushed a commit that referenced this pull request Jul 18, 2023
Co-authored-by: David Haguenauer <ml@kurokatta.org>
Co-authored-by: Eric Pruitt <eric.pruitt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants