Skip to content

Commit

Permalink
tweak default colours for hl_grep and hl_diff()
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbutuseless committed May 5, 2024
1 parent 780d8b4 commit 8bae722
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 33 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export(hl_grep)
export(hl_opts)
export(is_emphatic)
export(knit_print.emphatic)
export(show_html)
export(write_xlsx)
importFrom(grDevices,col2rgb)
importFrom(grDevices,convertColor)
Expand Down
1 change: 1 addition & 0 deletions R/core-html.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ as_html <- function(x, ..., style = NULL, complete = FALSE, browsable = FALSE) {
#' @param viewer function which activates viewer
#' @return None
#' @export
#' @examples
#' # Will try and spawn a viewer for content
#' hl_grep(mode, "switch") |>
#' as_html() |>
Expand Down
14 changes: 7 additions & 7 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ get_env_dbl <- function(nm, unset) {
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.onLoad <- function(libname, pkgname) {

options(HL_NA = Sys.getenv ("HL_NA" , unset = 'NA'))
options(HL_TEXT_MODE = Sys.getenv ("HL_TEXT_MODE" , unset = 'contrast'))
options(HL_TEXT_CONTRAST = get_env_dbl("HL_TEXT_CONTRAST", unset = 1))
options(HL_GREP_COL = Sys.getenv("HL_GREP_COL" , unset = "#0F19F0"))
options(HL_SUB_COL = Sys.getenv("HL_SUB_COL" , unset = "dodgerblue"))
options(HL_INS_COL = Sys.getenv("HL_INS_COL" , unset = "darkgreen"))
options(HL_DEL_COL = Sys.getenv("HL_DEL_COL" , unset = "firebrick"))
options(HL_NA = Sys.getenv ("HL_NA" , unset = 'NA'))
options(HL_TEXT_MODE = Sys.getenv ("HL_TEXT_MODE" , unset = 'contrast'))
options(HL_TEXT_CONTRAST = get_env_dbl("HL_TEXT_CONTRAST", unset = 1))
options(HL_GREP_COL = Sys.getenv("HL_GREP_COL" , unset = "yellow"))
options(HL_SUB_COL = Sys.getenv("HL_SUB_COL" , unset = "darkslategray1"))
options(HL_INS_COL = Sys.getenv("HL_INS_COL" , unset = "palegreen1"))
options(HL_DEL_COL = Sys.getenv("HL_DEL_COL" , unset = "rosybrown1"))

# Is this the Rstudio 256 colour console?
rstudio_256 <- Sys.getenv("RSTUDIO_CONSOLE_COLOR", 0) == 256
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ writeLines(svg, "data-raw/figures/example-svg-anim.svg")
| | `"remove"` remove all text without a user-defined colour |
| `HL_TEXT_CONTRAST` | When `text_mode = "contrast"` this numeric value (in range [0, 1]) adjusts the visibility of the text. Default: 1 (high contrast) |
| `HL_GREP_COL` |The fill colour to use with `hl_grep()` if no colour is specified. Default: "#0F19F0"|
| `HL_SUB_COL`, `HL_INS_COL`, `HL_DEL_COL` | the default colours to use with `hl_diff()` for substitution, insertion and deletion (respectively). Defaults: `dodgerblue` (substitute), `darkgreen` (insert) and `firebrick` (delete) |
| `HL_SUB_COL`, `HL_INS_COL`, `HL_DEL_COL` | the default colours to use with `hl_diff()` for substitution, insertion and deletion (respectively). |


## Vignettes
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,17 @@ svg <- as_svg_anim(objs, width = 600, height = 300, duration = 2,
`.Rprofile`
- `options(HL_NA = FALSE)` at any time

| Option | Description |
|:-----------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `HL_NA` | String to use for NA values. Default “NA” |
| `HL_FULL_COLOUR` | Should full colour ANSI codes be used when outputting to the console? Default: FALSE on Rstudio, but TRUE on all other R consoles |
| `HL_TEXT_MODE` | How to handle text if no text colour has been explicitly specified by the user |
| | `"contrast"` (default) automatically select a colour which contrasts with the background |
| | `"asis"` do not change the colour from the console’s default |
| | `"remove"` remove all text without a user-defined colour |
| `HL_TEXT_CONTRAST` | When `text_mode = "contrast"` this numeric value (in range \[0, 1\]) adjusts the visibility of the text. Default: 1 (high contrast) |
| `HL_GREP_COL` | The fill colour to use with `hl_grep()` if no colour is specified. Default: “\#0F19F0” |
| `HL_SUB_COL`, `HL_INS_COL`, `HL_DEL_COL` | the default colours to use with `hl_diff()` for substitution, insertion and deletion (respectively). Defaults: `dodgerblue` (substitute), `darkgreen` (insert) and `firebrick` (delete) |
| Option | Description |
|:-----------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------|
| `HL_NA` | String to use for NA values. Default “NA” |
| `HL_FULL_COLOUR` | Should full colour ANSI codes be used when outputting to the console? Default: FALSE on Rstudio, but TRUE on all other R consoles |
| `HL_TEXT_MODE` | How to handle text if no text colour has been explicitly specified by the user |
| | `"contrast"` (default) automatically select a colour which contrasts with the background |
| | `"asis"` do not change the colour from the console’s default |
| | `"remove"` remove all text without a user-defined colour |
| `HL_TEXT_CONTRAST` | When `text_mode = "contrast"` this numeric value (in range \[0, 1\]) adjusts the visibility of the text. Default: 1 (high contrast) |
| `HL_GREP_COL` | The fill colour to use with `hl_grep()` if no colour is specified. Default: “\#0F19F0” |
| `HL_SUB_COL`, `HL_INS_COL`, `HL_DEL_COL` | the default colours to use with `hl_diff()` for substitution, insertion and deletion (respectively). |

## Vignettes

Expand Down
2 changes: 1 addition & 1 deletion data-raw/figures/example-hlgrep-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions data-raw/figures/example-hlgrep-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion data-raw/figures/example-strdiff-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions data-raw/figures/example-strdiff-4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions data-raw/figures/example-svg-anim.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions man/show_html.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8bae722

Please sign in to comment.