R/utils.R

Defines functions text_col msg

msg <- function(..., startup = FALSE) {
  if (startup) {
    if (!isTRUE(getOption("yotover.quiet"))) {
      packageStartupMessage(text_col(...))
    }
  } else {
    message(text_col(...))
  }
}

text_col <- function(x) {
  # If RStudio not available, messages already printed in black
  if (!rstudioapi::isAvailable()) {
    return(x)
  }
  
  if (!rstudioapi::hasFun("getThemeInfo")) {
    return(x)
  }
  
  theme <- rstudioapi::getThemeInfo()
  
  if (isTRUE(theme$dark)) crayon::white(x) else crayon::black(x)
}
pachamaltese/constitucionabierta documentation built on Dec. 31, 2020, 1:11 a.m.