Different preview modes: full, count, none#40
Open
brewingcode wants to merge 23 commits intoPaulJuliusMartinez:mainfrom
Open
Different preview modes: full, count, none#40brewingcode wants to merge 23 commits intoPaulJuliusMartinez:mainfrom
brewingcode wants to merge 23 commits intoPaulJuliusMartinez:mainfrom
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.
Author
…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.
Author
|
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
brewingcode
commented
Feb 21, 2022
| ] | ||
| .into_iter() | ||
| for (available_space, used_space, expected) in | ||
| vec![(14, 11, r#"[ 3 items ]"#), (4, 3, r#"[…]"#), (2, 0, r#""#)].into_iter() |
Author
There was a problem hiding this comment.
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? 🙂 |
…container-counts * PaulJuliusMartinez/main: (57 commits) Add [sexp] feature and :writesexp function to write input to a file as a sexp. Add :write <file> (and :write!) commands for writing input to a file. Ctrl-z now suspends jless. Update Arch Linux package URL in README.md (PaulJuliusMartinez#139) Fix a few spelling mistakes. Still under development, but not very active; a little haphazard to be honest. I definitely don't stream on Twitch anymore. Add clarifying note to RELEASE_CHECKLIST.md because I messed up the first time. Move `cargo install jless` to the Installation table proper (PaulJuliusMartinez#122) v0.9.0 Release Add 'C' and 'E' commands to deeply collapse/expand nodes. Return non-zero exit code on parse errors (PaulJuliusMartinez#98) Add short flags for enabling/disabling absolute/relative line numbers: -n/-N/-r/-R. Use --line-numbers and --relative-line-numbers as the names of the flags, instead of "--number" and "--relative-number". Enable line numbers by default (had to upgrade clap to 4.0 in the process). Update CHANGELOG Support jumping to line numbers (with auto-expand) with <n>g and <n>G. Invert styling on array indexes when focused to make the focused line stand out more. Don't forget to subtract space used for indicators from available space. Add "set number/relativenumber" commands. Update Rust version in Github CI workflow. ...
Conflicts with my "preview mode" toggling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
countshows objects as{ N items }, where N is the number of key-value pairs. It shows[ N items ]for arrays.The second new way
nonejust removes the child counts/previews entirely:Closes #38