R/get_highlighted_text.R

#' Get Highlighted Text
#'
#' Returns the highlighted text either in the source or the console panes.
#'
#' @return
#' Character string.
get_highlighted_text <- function() {
  ## Get the document context.
  context <- rstudioapi::getActiveDocumentContext()

  ## Highlighted text
  text <- context$selection[[1]]$text

  return(text)
}
famuvie/straddin documentation built on May 16, 2019, 10:08 a.m.