YS-L / csvlens

Command line csv viewer
MIT License
2.47k stars 41 forks source link

Option: expand to full-width #88

Closed plutonium-239 closed 1 month ago

plutonium-239 commented 2 months ago

In #11, it was discussed that columns don't take up full-width by default, and that's fine. However, I would love the addition of a keybind that automatically expands the table (could be multiple truncated columns) to full-width. Take this example use case:

Have a 3 (arbitrary) column csv of sentences (say original, translation, transliteration), then I would like all three of these columns to be equally divided into columns of full-width/3

Is something like this feasible?

YS-L commented 2 months ago

Thanks for the suggestion! This makes sense and should be feasible, though I'm wondering if this should be a key binding or something that should happen automatically.

Ideally, csvlens should take up full width if that doesn't reduce the number of columns that can be displayed. The current column widths heuristic optimizes for CSV with many columns, but probably not so much for CSV with few columns and long text.

plutonium-239 commented 2 months ago

You're right, but I leave that decision up to you

As for the current column width heuristic, is this the function of interest?

YS-L commented 2 months ago

Yes, that is the function that determines column widths.

YS-L commented 1 month ago

Main branch should now handle this automatically. For example,

Before: before

After: after

Let me know if it works in your case.

plutonium-239 commented 1 month ago

Can you make a patch/minor release with the latest code? (or is there one planned soon?) I don't have cargo to build from source and am feeling a bit lazy😅(low on storage)

YS-L commented 1 month ago

Yes, I plan to make a release in about a week or so.

In the mean time, you can check out this CI run which builds the binaries with this change included: https://github.com/YS-L/csvlens/actions/runs/10019417514?pr=94.

Feel free to download the binary for your platform and try out. Appreciate any feedback!

plutonium-239 commented 1 month ago

It works!