| 1 |
rowidformat <- function(n, has_title_row = FALSE, has_star = FALSE, ...) { |
| 2 |
capital <- rif_capital(has_title_row, has_star, ...) |
| 3 |
shaft <- rif_shaft(n, ...) |
| 4 |
new_pillar_1e(capital, shaft) |
| 5 |
} |
| 6 |
|
| 7 |
new_pillar_1e <- function(capital, shaft, width = NULL) { |
| 8 |
ret <- structure( |
| 9 |
list(capital = capital, shaft = shaft), |
| 10 |
class = "pillar_1e" |
| 11 |
) |
| 12 |
ret <- set_width(ret, width) |
| 13 |
ret |
| 14 |
} |
| 15 |
|
| 16 |
#' @export |
| 17 |
format.pillar_1e <- function(x, width = NULL, ...) { |
| 18 |
width <- pillar_get_width_1e(x, width) |
| 19 |
out <- pillar_format_parts(x, width) |
| 20 |
|
| 21 |
as_glue(unlist(unname(out))) |
| 22 |
} |
| 23 |
|
| 24 |
#' @export |
| 25 |
print.pillar_1e <- function(x, ...) { |
| 26 |
writeLines(style_bold("<pillar>")) |
| 27 |
print(format(x, ...)) |
| 28 |
} |
| 29 |
|
| 30 |
pillar_get_width_1e <- function(x, width) { |
| 31 |
if (is.null(width)) { |
| 32 |
width <- get_width(x) |
| 33 |
} |
| 34 |
|
| 35 |
if (is.null(width)) { |
| 36 |
widths <- get_widths(x) |
| 37 |
width <- max(widths) |
| 38 |
} |
| 39 |
|
| 40 |
min_widths <- max(get_min_widths(x)) |
| 41 |
if (width < min_widths) width <- min_widths |
| 42 |
|
| 43 |
width |
| 44 |
} |
| 45 |
|
| 46 |
pillar_format_parts <- function(x, width, ...) { |
| 47 |
capital_format <- format(x$capital, width = width, ...) |
| 48 |
shaft_format <- format(x$shaft, width = width, ...) |
| 49 |
align <- attr(shaft_format, "align", exact = TRUE) |
| 50 |
|
| 51 |
capital_format <- align(capital_format, width = width, align = align) |
| 52 |
shaft_format <- align(shaft_format, width = width, align = align) |
| 53 |
|
| 54 |
list( |
| 55 |
capital_format = capital_format, |
| 56 |
shaft_format = shaft_format |
| 57 |
) |
| 58 |
} |
| 59 |
|
| 60 |
format_abbrev <- function(x, title = NULL, space = " ") { |
| 61 |
type_format <- ansi_strip(format_full_pillar_type(x)) |
| 62 |
if (is.null(title)) { |
| 63 |
type_format |
| 64 |
} else { |
| 65 |
title_format <- format_full_pillar_title(title) |
| 66 |
paste0(title_format, space, type_format) |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
format_full_pillar_title <- function(title) { |
| 71 |
# Backticks already added here |
| 72 |
title <- format_title(title, Inf) |
| 73 |
style_title(title) |
| 74 |
} |