Skip to content

nu-explore/ Use hex-dump for binary data - #12184

Merged
fdncred merged 6 commits into
nushell:mainfrom
zhiburt:patch-add-binary-support-in-explore
Mar 22, 2024
Merged

fdncred merged 6 commits into
nushell:mainfrom
zhiburt:patch-add-binary-support-in-explore

Conversation

@zhiburt

@zhiburt zhiburt commented Mar 12, 2024 •

Copy link
Copy Markdown
Contributor

Hi there

So as 2 minute thing we could show hex-dump as it is as a string (no-coloring).

But I'd do some more things around,.
Probably will take a few days (WIP).

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

─────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────
  00000000:   6d 6f 64 20  63 6f 6d 6d  61 6e 64 3b  0a 6d 6f 64   mod command;_mod  │
  00000010:   20 63 6f 6e  66 69 67 5f  66 69 6c 65  73 3b 0a 6d    config_files;_m  │
  00000020:   6f 64 20 69  64 65 3b 0a  6d 6f 64 20  6c 6f 67 67   od ide;_mod logg  │
  00000030:   65 72 3b 0a  6d 6f 64 20  72 75 6e 3b  0a 6d 6f 64   er;_mod run;_mod  │
  00000040:   20 73 69 67  6e 61 6c 73  3b 0a 23 5b  63 66 67 28    signals;_#[cfg(  │
  00000050:   75 6e 69 78  29 5d 0a 6d  6f 64 20 74  65 72 6d 69   unix)]_mod termi  │
  00000060:   6e 61 6c 3b  0a 6d 6f 64  20 74 65 73  74 5f 62 69   nal;_mod test_bi  │
  00000070:   6e 73 3b 0a  23 5b 63 66  67 28 74 65  73 74 29 5d   ns;_#[cfg(test)]  │
  00000080:   0a 6d 6f 64  20 74 65 73  74 73 3b 0a  0a 23 5b 63   _mod tests;__#[c  │
  00000090:   66 67 28 66  65 61 74 75  72 65 20 3d  20 22 6d 69   fg(feature = "mi  │
  000000a0:   6d 61 6c 6c  6f 63 22 29  5d 0a 23 5b  67 6c 6f 62   malloc")]_#[glob  │
  000000b0:   61 6c 5f 61  6c 6c 6f 63  61 74 6f 72  5d 0a 73 74   al_allocator]_st  │
  000000c0:   61 74 69 63  20 47 4c 4f  42 41 4c 3a  20 6d 69 6d   atic GLOBAL: mim  │
  000000d0:   61 6c 6c 6f  63 3a 3a 4d  69 4d 61 6c  6c 6f 63 20   alloc::MiMalloc   │
  000000e0:   3d 20 6d 69  6d 61 6c 6c  6f 63 3a 3a  4d 69 4d 61   = mimalloc::MiMa  │
  000000f0:   6c 6c 6f 63  3b 0a 0a 75  73 65 20 63  72 61 74 65   lloc;__use crate  │
  00000100:   3a 3a 7b 0a  20 20 20 20  63 6f 6d 6d  61 6e 64 3a   ::{_    command:  │
  00000110:   3a 70 61 72  73 65 5f 63  6f 6d 6d 61  6e 64 6c 69   :parse_commandli  │
  00000120:   6e 65 5f 61  72 67 73 2c  0a 20 20 20  20 63 6f 6e   ne_args,_    con  │
  00000130:   66 69 67 5f  66 69 6c 65  73 3a 3a 73  65 74 5f 63   fig_files::set_c  │
  00000140:   6f 6e 66 69  67 5f 70 61  74 68 2c 0a  20 20 20 20   onfig_path,_      │
  00000150:   6c 6f 67 67  65 72 3a 3a  7b 63 6f 6e  66 69 67 75   logger::{configu  │
  00000160:   72 65 2c 20  6c 6f 67 67  65 72 7d 2c  0a 7d 3b 0a   re, logger},_};_  │
  00000170:   75 73 65 20  63 6f 6d 6d  61 6e 64 3a  3a 67 61 74   use command::gat  │
  00000180:   68 65 72 5f  63 6f 6d 6d  61 6e 64 6c  69 6e 65 5f   her_commandline_  │
  00000190:   61 72 67 73  3b 0a 75 73  65 20 6c 6f  67 3a 3a 4c   args;_use log::L  │
  000001a0:   65 76 65 6c  3b 0a 75 73  65 20 6d 69  65 74 74 65   evel;_use miette  │
  000001b0:   3a 3a 52 65  73 75 6c 74  3b 0a 75 73  65 20 6e 75   ::Result;_use nu  │
  000001c0:   5f 63 6c 69  3a 3a 67 61  74 68 65 72  5f 70 61 72   _cli::gather_par  │

ref: #12157
cc: @fdncred @lrdickson

@fdncred

fdncred commented Mar 12, 2024

Copy link
Copy Markdown
Contributor

Thanks @zhiburt. I think we'd like to have coloring if possible. I'm also not opposed to landing this in the interim. Let's see what other folks think.

@devyn

devyn commented Mar 12, 2024

Copy link
Copy Markdown
Contributor

Good idea, paging through binary data is valuable

@zhiburt

zhiburt commented Mar 17, 2024 •

Copy link
Copy Markdown
Contributor Author

Pretty simple one

TODO:

  1. Add 3 modes for peeking index/data/ascii
  2. Allow search in all of them separetely
  3. Allow peaking value depending on a mode index/byte/character
  4. Probably selection would be nice for 3d point.
  5. (HARD) (not really I guess but time consuming certainly) With selection we could do editing.
  6. Tests

fix: I've found that PgDOWN/Up and END is not working in some cases -- need a look.


image

 $env.config.explore.hex-dump.split = false
 $env.config.explore.hex-dump.count_segments = 2
 $env.config.explore.hex-dump.segment_size = 16 

image


IMHO: I don't like the removal of :config

Personally I'd go even further and would create a separate program (it could be also done in explore)
Where we could configure (if you still remember how it was) not only explore but the whole nu.

So any config option could be tweaked and the outcome be visible right away.

Yes the only complication would be how to stash changes, to not change the original config, I mean comments etc. which could be present there. But it's details. Could be done in many ways.

Just an idea

@fdncred

fdncred commented Mar 17, 2024 •

Copy link
Copy Markdown
Contributor

@zhiburt Oh, wow! This looks much better in color!!

It would be nice if the colors and symbols on the right match the current into binary view.
image

IMHO: I don't like the removal of :config

Sorry. We found that explore was a bit too complicated which is why a few things were removed.

Personally I'd go even further and would create a separate program ...

We have talked about a separate program to configure nushell. I've dreamed of a tui where it has a left pane that has the keys (config points) and the right pane has the values. But, like you say, there are details to work out about which file is being loaded env/config/login and what to do with comments. I personally think it would be helpful but probably is a lot of work to do it right.

@fdncred

fdncred commented Mar 20, 2024

Copy link
Copy Markdown
Contributor

@zhiburt do you have time to update the colors to match our current pretty hex output?

@zhiburt

zhiburt commented Mar 21, 2024 •

Copy link
Copy Markdown
Contributor Author

@zhiburt do you have time to update the colors to match our current pretty hex output?

done

Just reused your original function.
Though previously colors were configurable; now it's constant. I guess it could be nice to have it being so. set own chars/colors.
I did not delete configuration code; all though it's unused maybe it'll be useful in future.

image
image

@fdncred fdncred added deprecated:pr-commands (deprecated: too vague) This PR changes our commands in some way pr:screenshot labels Mar 22, 2024
@fdncred

fdncred commented Mar 22, 2024

Copy link
Copy Markdown
Contributor

wow! This looks great! Thanks.

@fdncred
fdncred merged commit cc8f2b6 into nushell:main Mar 22, 2024
@hustcer hustcer added this to the v0.92.0 milestone Mar 22, 2024
devyn added a commit to devyn/nushell.github.io that referenced this pull request Apr 2, 2024
kubouch pushed a commit to nushell/nushell.github.io that referenced this pull request Apr 2, 2024
kubouch added a commit to nushell/nushell.github.io that referenced this pull request Apr 2, 2024
* Release notes for `0.92`

Please add your new features and breaking changes to the release notes
by opening PRs against the `release-notes-0.92` branch.

## TODO
- [ ] look at interesting contributions
- [ ] write all the sections
- [ ] order the sections by interest
- [ ] add the breaking changes
- [ ] detail the breaking changes
- [ ] add the full changelog
- [ ] complete all the `TODO`s inside the release note
- [ ] ... (PRs that need to land before the release, e.g. [deprecations](https://github.com/nushell/nushell/labels/deprecation) or [removals](https://github.com/nushell/nushell/pulls?q=is%3Apr+is%3Aopen+label%3Aremoval-after-deprecation))

* Release notes for 0.92.0 for @devyn so far (#1306)

* Release notes for 0.92.0 for @devyn so far

* add toc

* Edit release notes (#1308)

* Edit release notes

* Fix typo

* Change wording

* Add a bunch more release notes for 0.92 (#1317)

- Plugin command API updates, including LabeledError
- Plugin engine calls
- Plugin test support crate
- Official plugin template

* Add debugger note (#1321)

* Edit release notes for 0.92.0 (#1322)

* Edit release notes

* Add missing toc link

* Update typos

* more little changes to the 0.92 release notes to cover things I did (#1323)

* add/sort breaking changes, full changelog (#1324)

* Fill in Hall of Fame; Add `debug profile` to new commands (#1325)

* Add debug profile to new commands

* Fill in hall of fame

* Update abstract

* 0.92.0 release notes cleanup (#1326)

* stefan release note (#1327)

* More on perf, `into bits` explainer

* Rename perf section

* extra politics

* release notes for nushell/nushell#12184 (binary data in explore) (#1329)

* Fix minor version 0.92.0 (#1328)

---------

Co-authored-by: Devyn Cairns <[email protected]>
Co-authored-by: Jakub Žádník <[email protected]>
Co-authored-by: Stefan Holderbach <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecated:pr-commands (deprecated: too vague) This PR changes our commands in some way

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants