diff --git a/DESCRIPTION b/DESCRIPTION index 615c079e..1ba6ca81 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,13 +28,13 @@ Depends: R (>= 4.0) Imports: checkmate (>= 2.1.0), + cli (>= 3.4.0), grDevices, lifecycle (>= 0.2.0), rlang (>= 1.1.0), stats, utils Suggests: - cli (>= 3.4.0), knitr (>= 1.42), rmarkdown (>= 2.23), shiny (>= 1.6.0), diff --git a/R/qenv-show.R b/R/qenv-show.R index b2fa7447..6c4718f1 100644 --- a/R/qenv-show.R +++ b/R/qenv-show.R @@ -16,5 +16,26 @@ #' @importFrom methods show #' @export setMethod("show", "qenv", function(object) { - rlang::env_print(object@.xData) + env <- get_env(object) + header <- cli::col_blue(sprintf("", rlang::env_label(env))) + locked <- if (environmentIsLocked(env)) { + " [L]" + } else { + "" + } + parent <- sprintf("", rlang::env_label(rlang::env_parent(env))) + cat(cli::style_bold(paste0(header, locked)), sep = "\n") + cat(parent, "\n") + + shown <- ls(object) + lapply(shown, function(x) { + cat(sprintf("- %s: [%s]\n", x, class(object[[x]])[1])) + }) + + hidden <- setdiff(ls(object, all.names = TRUE), shown) + lapply(hidden, function(x) { + cat(cli::style_blurred(sprintf("- %s: [%s]\n", x, class(object[[x]])[1]))) + }) + + invisible(object) })