| 180 | } |
| 181 | |
| 182 | void print_columns(const struct string_list *list, unsigned int colopts, |
| 183 | const struct column_options *opts) |
| 184 | { |
| 185 | struct column_options nopts; |
| 186 | |
| 187 | if (opts && (0 > opts->padding)) |
| 188 | BUG("padding must be non-negative"); |
| 189 | if (!list->nr) |
| 190 | return; |
| 191 | assert((colopts & COL_ENABLE_MASK) != COL_AUTO); |
| 192 | |
| 193 | memset(&nopts, 0, sizeof(nopts)); |
| 194 | nopts.indent = opts && opts->indent ? opts->indent : ""; |
| 195 | nopts.nl = opts && opts->nl ? opts->nl : "\n"; |
| 196 | nopts.padding = opts ? opts->padding : 1; |
| 197 | nopts.width = opts && opts->width ? opts->width : term_columns() - 1; |
| 198 | if (!column_active(colopts)) { |
| 199 | display_plain(list, "", "\n"); |
| 200 | return; |
| 201 | } |
| 202 | switch (COL_LAYOUT(colopts)) { |
| 203 | case COL_PLAIN: |
| 204 | display_plain(list, nopts.indent, nopts.nl); |
| 205 | break; |
| 206 | case COL_ROW: |
| 207 | case COL_COLUMN: |
| 208 | display_table(list, colopts, &nopts); |
| 209 | break; |
| 210 | default: |
| 211 | BUG("invalid layout mode %d", COL_LAYOUT(colopts)); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | int finalize_colopts(unsigned int *colopts, int stdout_is_tty) |
| 216 | { |
no test coverage detected