| 1 |
#' @export |
| 2 |
pillar_shaft.pillar_vctr <- function(x, ...) { |
| 3 |
# still seems necessary |
| 4 |
pillar_shaft(unclass(x)) |
| 5 |
} |
| 6 |
|
| 7 |
#' @export |
| 8 |
vec_ptype_full.pillar_vctr <- function(x, ...) { |
| 9 |
format(attr(x, "pillar", exact = TRUE)) |
| 10 |
} |
| 11 |
|
| 12 |
#' @export |
| 13 |
print.pillar_vctr <- function(x, ..., max = NULL) { |
| 14 |
if (is.null(max)) { |
| 15 |
max <- getOption("max.print") |
| 16 |
} |
| 17 |
|
| 18 |
xx <- vec_head(x, max) |
| 19 |
size <- vec_size(x) |
| 20 |
|
| 21 |
obj_print_header.pillar_vctr(xx, ..., .size = size) |
| 22 |
obj_print_data.pillar_vctr(xx, ..., .size = size) |
| 23 |
obj_print_footer.pillar_vctr(xx, ..., .size = size) |
| 24 |
invisible(x) |
| 25 |
} |
| 26 |
|
| 27 |
#' @export |
| 28 |
obj_print_header.pillar_vctr <- function(x, ..., .size) { |
| 29 |
writeLines(paste0("<", vec_ptype_full(x), "[", .size, "]>")) |
| 30 |
pillar_attr <- attr(x, "pillar") |
| 31 |
if (!is.null(pillar_attr$fixed_exponent)) { |
| 32 |
shaft <- pillar_shaft_number_attr(numeric(), pillar_attr) |
| 33 |
type <- attr(shaft, "type") |
| 34 |
if (!is.null(type)) { |
| 35 |
writeLines(paste0("Fixed exponent: ", type[[1]])) |
| 36 |
} |
| 37 |
} |
| 38 |
invisible(x) |
| 39 |
} |
| 40 |
|
| 41 |
#' @export |
| 42 |
obj_print_data.pillar_vctr <- function(x, ..., .size) { |
| 43 |
if (length(x) == 0) { |
| 44 |
return(invisible(x)) |
| 45 |
} |
| 46 |
|
| 47 |
# FIXME: base::print.default() can't use color, roll own implementation? |
| 48 |
out <- stats::setNames(ansi_strip(format(x)), names(x)) |
| 49 |
print(out, quote = FALSE, max = vec_size(x)) |
| 50 |
invisible(x) |
| 51 |
} |
| 52 |
|
| 53 |
#' @export |
| 54 |
obj_print_footer.pillar_vctr <- function(x, ..., .size) { |
| 55 |
delta <- .size - vec_size(x) |
| 56 |
|
| 57 |
if (delta <= 0) { |
| 58 |
return(invisible(x)) |
| 59 |
} |
| 60 |
|
| 61 |
writeLines(style_subtle(pre_dots(paste0("and ", delta, " more")))) |
| 62 |
invisible(x) |
| 63 |
} |
| 64 |
|
| 65 |
#' @export |
| 66 |
print.pillar_vctr_attr <- function(x, ...) { |
| 67 |
writeLines(format(x)) |
| 68 |
invisible(x) |
| 69 |
} |
| 70 |
|
| 71 |
#' @export |
| 72 |
vec_proxy_compare.pillar_vctr <- function(x, ...) { |
| 73 |
vec_data(x) |
| 74 |
} |
| 75 |
#' @export |
| 76 |
vec_proxy_order.pillar_vctr <- function(x, ...) { |
| 77 |
vec_data(x) |
| 78 |
} |