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

Differentiate color/format for item count and index #16

Closed
Doctor-love opened this issue Dec 8, 2021 · 10 comments
Closed

Differentiate color/format for item count and index #16

Doctor-love opened this issue Dec 8, 2021 · 10 comments
Labels
enhancement New feature or request

Comments

@Doctor-love
Copy link
Collaborator

In the lovely color coded output, the same color/format ("key: [value]") is used to present both item count and item index.
This is no big deal and I guess it's because all integers get this color, but slightly confusing.

@Doctor-love Doctor-love added the enhancement New feature or request label Dec 8, 2021
@Doctor-love
Copy link
Collaborator Author

Visual example:

output_color

@wader
Copy link
Owner

wader commented Dec 8, 2021

Aha you mean ... :frames: [2] here looks like .frames is the array [2]? good point. Any suggestion on how it can be indicated that it's actually an array with two values of any type? Currently when displaying truncated arrays it is shown as [50:1378]: ..., so maybe [0:2] or [:2]? maybe a "slice" etc could have own color also?

Now when i think about it the truncated format currently is one-off if it is suppose to be "jq" slice syntax.

@wader
Copy link
Owner

wader commented Dec 8, 2021

Something like this:

mp3> last(fgrep("toc")) | d({line_bytes: 10, array_truncate:10})
    │00 01 02 03 04 05 06 07 08 09│0123456789│.frames[0].xing.toc: [0:100]
0x5a│                     00      │       .  │  [0]: 0
0x5a│                        99   │        . │  [1]: 153
0x5a│                           99│         .│  [2]: 153
0x64│99                           │.         │  [3]: 153
0x64│   99                        │ .        │  [4]: 153
0x64│      99                     │  .       │  [5]: 153
0x64│         99                  │   .      │  [6]: 153
0x64│            99               │    .     │  [7]: 153
0x64│               99            │     .    │  [8]: 153
0x64│                  99         │      .   │  [9]: 153
    │                             │          │  [10:100]: ...
mp3>

Or even more jq-ish

mp3> last(fgrep("toc")) | display({line_bytes: 10, array_truncate:10})
    │00 01 02 03 04 05 06 07 08 09│0123456789│.frames[0].xing.toc[0:100]:
0x5a│                     00      │       .  │  [0]: 0
0x5a│                        99   │        . │  [1]: 153
0x5a│                           99│         .│  [2]: 153
0x64│99                           │.         │  [3]: 153
0x64│   99                        │ .        │  [4]: 153
0x64│      99                     │  .       │  [5]: 153
0x64│         99                  │   .      │  [6]: 153
0x64│            99               │    .     │  [7]: 153
0x64│               99            │     .    │  [8]: 153
0x64│                  99         │      .   │  [9]: 153
    │                             │          │  [10:100]: ...
mp3>

@Doctor-love
Copy link
Collaborator Author

I would say that the last example is the clearest

@wader
Copy link
Owner

wader commented Dec 8, 2021

Agree, the more i look at it the more i like it. Ill see if i can do that without broking someting... dump.go is a mess at the moment, have some refactoring plans

wader added a commit that referenced this issue Dec 8, 2021
@Doctor-love
Copy link
Collaborator Author

That's very nice!

@Doctor-love
Copy link
Collaborator Author

But isn't it off by one or is this just the "jq" way of presenting count/length?

@wader
Copy link
Owner

wader commented Dec 9, 2021

Yeap it's jq:s slice syntax [start:end] (same as go) where start index is inclusive and end index exclusive, memory rule for me is length will be end-start :) So idea was that the output should be copy/pasteable, ex:

mp3> .frames[0].xing.toc[0:100] | length
100
mp3> .frames[0].xing.toc[10:100] | length
90

@wader
Copy link
Owner

wader commented Dec 23, 2021

@Doctor-love lets open new issues if more decoration are needed?

@wader wader closed this as completed Dec 23, 2021
@Doctor-love
Copy link
Collaborator Author

Agreed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants