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

[feature request] columns but allow some to calculate their width #1

Open
masukomi opened this issue Aug 28, 2022 · 0 comments
Open

Comments

@masukomi
Copy link

I keep wanting to do two column displays that are a listing of some key + some associated details.

Minimally, I'd like to be able to tell text-column the width of the first column and let it figure out the width for the remaining column(s) from some specified max size.

Even better would be to tell it the widths of all the columns, but allow that width to be variable.

For example, I'm imagining calling something like this, where '*' tells the system to figure it out,

# text-columns(Int $max_width, List @column_sizes, *@columns)
text-columns(80, <17 *>, "column\none\ntext", "column\ntwo\ntext")

would produce output like this

foo:               foos should be approached with caution        
                                                                 
flibberty gibbet:  Flibberty gibbets have been seen in the       
                   area. Do not enter.                           
                                                                 
fishyfish:         tastey, but smelly                            

a more complicated invocation might be
text-columns(200, [17, '*', 50, 22, '*'], "foo", "bar", "baz" , "beedle" "fum")

i'm thinking it'd just divide whatever max - had left over amongst the * columns.

error cases:

  • specified_widths > max
  • max - specified widths < num_unspecified_widths (needs at least 1 char per column.. more if a separator is needed)
  • existing text-columns error cases

Bonus points: allow rational numbers instead of '*' although that'll make the math even funkier because what happens if the rationals + the ints are > max ? what happens if rationals + ints are < max (... just space on the right i guess)?

ex. text-columns(80, [12, 1/3, '*'], "foo", "bar", "baz")

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

No branches or pull requests

1 participant