LucasPickering / slumber

Terminal-based HTTP/REST client
https://slumber.lucaspickering.me/
MIT License
434 stars 21 forks source link

Allow code-folding of JSON response bodies #398

Open anussel5559 opened 1 month ago

anussel5559 commented 1 month ago

Did you search for existing issues already? yup!

Is your feature request related to a problem? Please describe. Not an issue - purely a QoL enhancement

Describe the solution you'd like Right now, it's pretty easy for a response body to overflow the length of the response pane in the main slumber view. Scrolling is easy as is filtering, but code folding might be a nice way for users to move about the response.

Describe alternatives you've considered None outside of piping the result of a singular slumber request to something like otree

Additional context Maybe there's a way to leverage otree inside the response pane? 🤷

LucasPickering commented 1 month ago

This is a good idea, I'd find it useful. I'm not sure exactly what the interaction would look like. Typically for folding you'd use left and right arrows to close/open, but the response pane already uses those to switch needs. Needs some messing around.

As far as implementation, I'd love to use a 3rd party library for this, but I'm not sure how hard it would be to integrate with. Maybe there's already a ratatui widget for it?

anussel5559 commented 1 month ago

maybe tui-rs-tree-widget?

LucasPickering commented 1 month ago

I had originally looked into tui-rs-tree-widget when adding the tree view to the left Recipes pane. I decided not to use it because the amount of glue code required to make it work with Slumber's data structures was about the same complexity as just reimplementing it myself. We could reuse the tree code from that for a JSON explorer. In terms of a third party library, I was thinking of something more all-inclusive, where you just give it a serde_json::Value and it makes it all pretty and foldable for you. Probably doesn't exist though.