Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Can be zformat used to obtain multi column formatted text?



On Jan 18, 11:56am, Sebastian Gniazdowski wrote:
} Subject: Can be zformat used to obtain multi column formatted text?
}
} I have list of words and ideally would like to display it in 2, 3, 4,
} etc. columns depending on widths of the words. Less ideally, in 2
} columns. How can this be accomplished with zformat?

It probably could be, but it's really meant for two things:

(1) support an external definition of the format string; for example,
    to allow zstyle to define the format and the calling function to
    supply the values for the %-expandos;
(2) lay out a two-column display with a middle column that is the same
    in all rows, e.g., most often spaces or an "=" sign.

Even with (2) you have to build your own rows in the form COL1:COL2
before calling zformat -- it just replaces the ":" with the necessary
extra spaces to line up the two parts.

For more than two columns you're probably going to have better luck
using "print -C" where you can specify the number of columns.  Using
"print -aC" is like the LIST_ROWS_FIRST setopt, but there isn't any
convenient way to emulate LIST_PACKED.  You'd have to work out your
own column widths and use "printf".



Messages sorted by: Reverse Date, Date, Thread, Author