Skip to content

Add x/u/U commands to hide/unhide/unhide-all nodes#146

Open
YongJieYongJie wants to merge 1 commit into
PaulJuliusMartinez:mainfrom
YongJieYongJie:feature/hiding-and-unhiding-nodes
Open

Add x/u/U commands to hide/unhide/unhide-all nodes#146
YongJieYongJie wants to merge 1 commit into
PaulJuliusMartinez:mainfrom
YongJieYongJie:feature/hiding-and-unhiding-nodes

Conversation

@YongJieYongJie
Copy link
Copy Markdown

@YongJieYongJie YongJieYongJie commented Feb 7, 2024

Proposed Feature: Ability to hide and unhide nodes

One of jless's major strength over simple pretty-printing of JSON is the interactivity it provides. This PR adds support for hiding and unhiding of individual map key nodes (based on jq query matching), enhancing the interactivity by allowing user to hide irrelevant nodes to better navigate and view the JSON.

The attached video demonstrates three features:

  1. Using x to hide individual object keys (ServiceId, ServiceType and AvailabilityZones). Notice that the objects keys are hidden across all objects in the ServiceDetails array.
  2. Using u to undo hiding of the above object keys one at a time
  3. Using U to undo hiding of all object keys all at once
2024.02.06-jless-hiding-unhiding-demo.mp4

Changes

  1. Additional vec<string> field on the flatjson struct to store jq paths for testing which rows to hide.
    • When x is pressed, we generate the jq path for the current node, and push it to the above vector.
    • When u is pressed, we pop the last item of the above vector.
    • When U is pressed, we clear the vector.
  2. Update implementation of flatjson::next_visible_row() and flatjson::prev_visible_row() to skip over hidden rows.
    • A row needs to be hidden if its jq path is included in the vector above.

@YongJieYongJie YongJieYongJie changed the title Feature proposal: Add x/u/U commands to hide/unhide/unhide-all nodes Add x/u/U commands to hide/unhide/unhide-all nodes Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant