Skip to content
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

Refine and Enhance TUI Functionality #5

Open
JFryy opened this issue Jun 28, 2024 · 4 comments
Open

Refine and Enhance TUI Functionality #5

JFryy opened this issue Jun 28, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@JFryy
Copy link
Owner

JFryy commented Jun 28, 2024

qq needs to refine its a tui. To keep this short, a few things could be implemented to get a lot more value from a tui on a general transcoder/interface. This is not my strong suit for guidance of this tool, so I could very much use some help. If there is a developer who'd like to contribute, here are a few ideas I've been wanting to implement, some of which I can and want to do, some of which I might not be the greatest at, e.g. anything regarding TUI placement/Aesthetics.

  • Truncate Text for large files and position user input statically on changes of filters.
  • Swap between marshall formats, or enable alternative marshal formats, so the editor can see their queries show the format they want - use chroma or whatever colorizer is in use currently similar to the current JSON mode.
  • Support Gron-Style grepping of content in the TUI (this aligns with some support of the -G --grep flag but is is honestly debatable whether a regex engine should be generally included, maybe grepping should be strictly modular)
  • Make things A E S T H E T I C
  • ctrl+direction jump support for space delimiters
  • drop down snippet for autocompletion with up,down navigating along with with tab cycling
  • autocompletion based on search of most relevant JSON path based on query rather than cycle through splatted grons.
@JFryy JFryy added the help wanted Extra attention is needed label Jun 28, 2024
@wader
Copy link

wader commented Jun 28, 2024

Hey, i can list some fancy things https://github.com/wader/fq supports that might be interesting idea:

  • Auto completion of index, function, bindings and keywords. It's also done via eval so you can "complete" a query, ex {abc:123} | .a<tab> works, might seem supercomplex but it's a bit of a trick: it only works if the query to the left of the cursor is valid query (with some extra heuristics for indexing). Also bindings don't work well as they are generally in some scope, mostly useful for globals.
  • Supports sub-REPL:s via ... | repl
  • inputs in the REPL "behaves" the same as the CLI, ex:
    $ fq -i '1,2'
    number, ...[0:3][]> .*2
    2
    4
    number, ...[0:2][]> .*2 | repl
    > number, ...[0:2][]> .*2
    4
    8
    > number, ...[0:2][]> ^D
    number, ...[0:2][]> ^D
    $
  • Has a paste function
    null> paste | repl
    abc
    <ctrl-d>
    > string> .
    "abc\n"
  • Has a slurp/spew function but i have to say i have nearly never used them, maybe if one could come up with some neater syntax that works well with jq.
     null> 1,2,3 | slurp("hello")
     null> $hello
     [
       1,
       2,
       3
     ]
     null> spew("hello")
     1
     2
     3
    

Things i would like to have:

  • Multi-line edit of query
  • Syntax highlight and checking
  • Online documentation (at completion?)

@JFryy JFryy changed the title Refine TUI Experience Refine and Enhance TUI Functionality Jun 28, 2024
@JFryy
Copy link
Owner Author

JFryy commented Jun 28, 2024

Thanks a lot for the advice and detailing some of the functionality/many features of fq (big fan btw!), these suggestions would definitely be a major improvement and I look forward to taking a crack at some of them 👍

@wader
Copy link

wader commented Jun 28, 2024

🥳 Think my advice would be to first focus on really nice and fancy completion, that is what i use all the time with fq. sub-repl i use a tiny bit, slurp/spew not at all. "realtime" syntax checking and highlighting would be really nice but i haven't look into it, for fq it would probably also involve quite a lot of work on the readline implementation that i use.

btw if you write lots of jq i can recommend https://github.com/wader/jq-lsp

@JFryy
Copy link
Owner Author

JFryy commented Jun 28, 2024

Sorry, I definitely used the word "realtime" a bit too liberally in the readme. Very cool, will take a look and see if I can't hack something together w/ any of this when I have time if no one decides they want to work on abeforehand. If anyone wants to work on any component of the above mentioned, I am not too opinionated on implementation as long as it's approximates some of the above improvements @wader mentioned or the post @ here.#6 or any user interface improvements :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants