-
Notifications
You must be signed in to change notification settings - Fork 96
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
Different preview modes: full, count, none #40
base: main
Are you sure you want to change the base?
Different preview modes: full, count, none #40
Conversation
This just prints the container's number of children, while keeping the opening/closing characters. So: foo: [ 2 ] bar: { 3 }
``` $ cargo build Compiling jless v0.7.1 (/...) error[E0308]: mismatched types --> src/lineprinter.rs:765:12 | 765 | Ok(num_printed) | ^^^^^^^^^^^ expected `isize`, found `usize` | help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit | 765 | Ok(num_printed.try_into().unwrap()) | ++++++++++++++++++++ ``` I'm not sure why this error only showed up after my changes. I haven't changed the type of `num_printed`, and I've only changed it by calling `+=` on it a few extra times.
This is modeled exactly after the existing `JsonViewer.mode`, down to its arg handling and toggling.
Rather than calling `highlight_str` a bunch, use `format!` to assemble the string. This also removes the need to `use std::convert::TryInto`, since I'm `as isize`ing everywhere. It also respects and updates `available_space`, though I'm not quite sure if a string as short as this should do so.
This is used in lots of places, so it's not worth changing every single call to `::new()` just to add `preview`. Just set it right after `::new` in app.rs and let it default everywhere else.
This involved adding an extra string to `generate_container_count`, because Rust has weird memory rules around str::len() that was causing the returned value to get stuck based on the initial assigned value of `count_str`, rather than its final value. Or something, I don't know.
ebb770c
to
a9a4225
Compare
This renders nothing, as it's been requested in a couple other Github issues. Toggling now goes `full (default)` --> `count` --> `none`, then repeats.
…counts * origin/master: Change Space command to toggle collapsed state of focused node. (PaulJuliusMartinez#42)
dc7f238
to
b5bccfe
Compare
Need to call `highlight_str()` in `fill_in_container_preview()`, otherwise the renderer thinks the lines extend off to the right, and display `>` as if the line is truncated and h-scroll is available.
`.len()` was not the right method for number of characters in a string, `.chars().count()` is.
b5bccfe
to
2ee1eb6
Compare
In the absence of terminal colors, `[ 3 ]` could be read as either an array with three elements, or an array with just `3` as its sole element.
Mode::Line relies on rendering collapsed nodes as single-line previews, so Preview::None hides these. Rather than changing the way Mode::Line works, its better to just disable Preview::None in Mode::Line. This makes JsonViewer::preview private, since it now has funny rules.
See #38 (comment) for a bit more context around 6f71ce0 and 26a6059 |
…counts Fixed a few conflicts around viewer.rs:toggle_mode() * origin/master: Update constant in test to fit within usize on 32-bit systems. Keep focused line at same height when toggling between Line and Data mode. Implement ctrl-d/ctrl-u commands to jump by half a screen or specified number of lines. v0.7.2 Release Use freopen to move /dev/tty input to stdin so rustyline works when piping in input. (PaulJuliusMartinez#32) Remove x86_64-unknown-linux-musl from CI platforms; libc-stdhandle fails to compile with it. Don't run ci on pull_request event; it's redundant. Add CI badge to README. Only run release workflow when tags are pushed; remove aarch64 architecture. Fix clippy errors. Add CI and Release Workflows.
e6666e6
to
f386d0a
Compare
The CI gods demand it
f386d0a
to
41079e9
Compare
] | ||
.into_iter() | ||
for (available_space, used_space, expected) in | ||
vec![(14, 11, r#"[ 3 items ]"#), (4, 3, r#"[…]"#), (2, 0, r#""#)].into_iter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the linter is being overzealous here, and in the rest of the test_
functions in this commit. It's way harder to read this vec![...]
on a single line. They were on their own lines with specific spacing to make it easier for humans to read.
…counts * origin/master: Remove code for website. (Now on website branch.) Update README.md with updated installation instructions and info about the website.
…unts * origin/main: Remove .value_range field from LinePrinter. (Can be accessed through .row.range.) Show square bracket delimiter around all non-string keys. Use Row in LinePrinter when printing out value, rather than passed in value field. Pass FlatJson and Row into LinePrinter; have it figure out Label stuff Add basic YAML support. (PaulJuliusMartinez#57) Revert Arch Linux installation command now that the package has been added to the official community repository. Remove incorrect Arch Linux installation command; simply state that jless is available in the AUR. Add install instruction for FreeBSD to README (PaulJuliusMartinez#48)
Is there a ETA on this PR? 🙂 |
Adds two new ways to preview child nodes (only in
--mode line
, doesn't affect--mode data
).The existing single way
full
:The first new way
count
shows objects as{ N items }
, where N is the number of key-value pairs. It shows[ N items ]
for arrays.The second new way
none
just removes the child counts/previews entirely:Closes #38