Skip to content

Commit

Permalink
grey put hidden objects
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Dec 20, 2024
1 parent 2d06288 commit 6cbea73
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
23 changes: 22 additions & 1 deletion R/qenv-show.R
Original file line number Diff line number Diff line change
Expand Up @@ -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("<environment: %s>", rlang::env_label(env)))
locked <- if (environmentIsLocked(env)) {
" [L]"
} else {
""
}
parent <- sprintf("<environment: %s>", 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)
})

0 comments on commit 6cbea73

Please sign in to comment.