From 992ac86533322c22ad61b9b5fcee5b5c00f947f0 Mon Sep 17 00:00:00 2001 From: Salim B Date: Sun, 11 Oct 2020 16:17:55 +0200 Subject: [PATCH 01/34] ignore system-specific temp, backup, thumbnail etc. files --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index a14fbca..a986fb2 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,10 @@ vignettes/*.pdf *.utf8.md *.knit.md .Rproj.user + +# System-specific temp, backup, thumbnail etc. files +.~lock* +*.backup +~$* +.DS_Store +Thumbs.db From 48ccc6b5b5842998b01a633e4e650fba20e9e9e5 Mon Sep 17 00:00:00 2001 From: Salim B Date: Sun, 11 Oct 2020 16:20:45 +0200 Subject: [PATCH 02/34] add @salim-b as contributor --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index c72a447..6847bc8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,8 @@ Package: rscodeio Title: A VSCode skin for RStudio Version: 0.1.0 Authors@R: c(person("Anthony", "North", email = "anthony.jl.north@gmail.com", role = c("aut", "cre")), - person("Miles", "McBain", email = "miles.mcbain@gmail.com", role = "ctb")) + person("Miles", "McBain", email = "miles.mcbain@gmail.com", role = "ctb"), + person("Salim", "Brüggemann", email = "salim-b@pm.me", role = c("ctb"), comment = c(ORCID = "0000-0002-5329-5987"))) Description: It really just modifies RStudio presentation. Depends: R (>= 3.3.0) License: MIT + file LICENSE From aca7027c8bfd6d5e9aa404b4ddf15ebbcd776a36 Mon Sep 17 00:00:00 2001 From: Salim B Date: Sun, 11 Oct 2020 16:51:54 +0200 Subject: [PATCH 03/34] avoid `$` due to partial matching and rename fn --- R/rscodeio.R | 4 ++-- R/utils.R | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/rscodeio.R b/R/rscodeio.R index 84fce56..5748432 100644 --- a/R/rscodeio.R +++ b/R/rscodeio.R @@ -19,8 +19,8 @@ install_theme <- function(menus = TRUE) { if(utils::compareVersion(as.character(rstudioapi::versionInfo()$version), "1.2.0") < 0) stop("You need RStudio 1.2 or greater to get theme support") - ## check if menu theme already installed and uninstall - if(rscodeio_installed()){ + ## check if menu theme is already installed and if so, uninstall first + if (is_rscodeio_installed()) { uninstall_theme() } diff --git a/R/utils.R b/R/utils.R index 7ede2d8..af9cef2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -59,6 +59,6 @@ is_rstudio_server <- function() { rstudioapi::versionInfo()$mode == "server" } -rscodeio_installed <- function() { - !is.null(rstudioapi::getThemes()$rscodeio) || !is.null(rstudioapi::getThemes()$`tomorrow night bright (rscodeio)`) +is_rscodeio_installed <- function() { + !is.null(rstudioapi::getThemes()[["rscodeio"]]) || !is.null(rstudioapi::getThemes()[["tomorrow night bright (rscodeio)"]]) } From 3fdd156047d162eb335417a7a5f56877b47e60b7 Mon Sep 17 00:00:00 2001 From: Salim B Date: Mon, 12 Oct 2020 21:42:34 +0200 Subject: [PATCH 04/34] add lintr config --- .lintr | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .lintr diff --git a/.lintr b/.lintr new file mode 100644 index 0000000..7c07aad --- /dev/null +++ b/.lintr @@ -0,0 +1,11 @@ +linters: with_defaults(absolute_path_linter = absolute_path_linter, + implicit_integer_linter = implicit_integer_linter, + line_length_linter = line_length_linter(160), + nonportable_path_linter = nonportable_path_linter, + semicolon_terminator_linter = semicolon_terminator_linter, + todo_comment_linter = todo_comment_linter, + trailing_whitespace_linter = NULL, + T_and_F_symbol_linter = T_and_F_symbol_linter, + undesirable_function_linter = undesirable_function_linter, + undesirable_operator_linter = undesirable_operator_linter(c(lintr:::default_undesirable_operators, `->` = NA)), + unneeded_concatenation_linter = unneeded_concatenation_linter) From 5a166ca8762c3f6b31307457fda5c19dbe0896f0 Mon Sep 17 00:00:00 2001 From: Salim B Date: Mon, 12 Oct 2020 21:44:34 +0200 Subject: [PATCH 05/34] improve pkg title and description --- DESCRIPTION | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6847bc8..5b4ad41 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,19 @@ Package: rscodeio -Title: A VSCode skin for RStudio +Title: An RStudio Theme Inspired by Visual Studio Code Version: 0.1.0 Authors@R: c(person("Anthony", "North", email = "anthony.jl.north@gmail.com", role = c("aut", "cre")), person("Miles", "McBain", email = "miles.mcbain@gmail.com", role = "ctb"), person("Salim", "Brüggemann", email = "salim-b@pm.me", role = c("ctb"), comment = c(ORCID = "0000-0002-5329-5987"))) -Description: It really just modifies RStudio presentation. Depends: R (>= 3.3.0) +Description: This package provides two greyish dark RStudio + editor themes which only differ in the syntax highlighting style: + while 'rscodeio' offers the colors found in Visual Studio Code, + 'Tomorrow Night Bright (rscodeio)' combines this package's dark + interface theming with the syntax highlighting colors from the + similarly named editor theme provided by RStudio. Furthermore, both + themes style RStudio's menu, something which is not exposed by the + current theming API and therefore requires administrator privileges to + replace the relevant QSS files. License: MIT + file LICENSE Encoding: UTF-8 LazyData: true From e83e1c25888cb4eadf28ef59278ac97de39d06f7 Mon Sep 17 00:00:00 2001 From: Salim B Date: Mon, 12 Oct 2020 21:45:02 +0200 Subject: [PATCH 06/34] tidy DESCRIPTION --- DESCRIPTION | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5b4ad41..35a025e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,20 @@ Package: rscodeio Title: An RStudio Theme Inspired by Visual Studio Code Version: 0.1.0 -Authors@R: c(person("Anthony", "North", email = "anthony.jl.north@gmail.com", role = c("aut", "cre")), - person("Miles", "McBain", email = "miles.mcbain@gmail.com", role = "ctb"), - person("Salim", "Brüggemann", email = "salim-b@pm.me", role = c("ctb"), comment = c(ORCID = "0000-0002-5329-5987"))) -Depends: R (>= 3.3.0) +Authors@R: + c(person(given = "Anthony", + family = "North", + role = c("aut", "cre"), + email = "anthony.jl.north@gmail.com"), + person(given = "Miles", + family = "McBain", + role = "ctb", + email = "miles.mcbain@gmail.com"), + person(given = "Salim", + family = "Brüggemann", + role = "ctb", + email = "salim-b@pm.me", + comment = c(ORCID = "0000-0002-5329-5987"))) Description: This package provides two greyish dark RStudio editor themes which only differ in the syntax highlighting style: while 'rscodeio' offers the colors found in Visual Studio Code, @@ -15,10 +25,12 @@ Description: This package provides two greyish dark RStudio current theming API and therefore requires administrator privileges to replace the relevant QSS files. License: MIT + file LICENSE -Encoding: UTF-8 -LazyData: true +Depends: + R (>= 3.3.0) Imports: fs, purrr, rstudioapi +Encoding: UTF-8 +LazyData: true RoxygenNote: 7.1.1 From 756017d1bce3bd50af8c62edfd3f93d00aa475e6 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 13 Oct 2020 03:59:34 +0200 Subject: [PATCH 07/34] enable roxygen2 markdown support pkg-wide --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 35a025e..a567a7e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,4 +33,5 @@ Imports: rstudioapi Encoding: UTF-8 LazyData: true +Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.1 From 752e3115fd9e828dd9b73da9171e96886be536bd Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 13 Oct 2020 04:02:26 +0200 Subject: [PATCH 08/34] set explicit line end conversion in project config --- rscodeio.Rproj | 1 + 1 file changed, 1 insertion(+) diff --git a/rscodeio.Rproj b/rscodeio.Rproj index cba1b6b..69fafd4 100644 --- a/rscodeio.Rproj +++ b/rscodeio.Rproj @@ -14,6 +14,7 @@ LaTeX: pdfLaTeX AutoAppendNewline: Yes StripTrailingWhitespace: Yes +LineEndingConversion: Posix BuildType: Package PackageUseDevtools: Yes From 1234a1cb184a8f127936845bef7d2da5234caf54 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 13 Oct 2020 15:50:47 +0200 Subject: [PATCH 09/34] lintr config: add object length linter --- .lintr | 1 + 1 file changed, 1 insertion(+) diff --git a/.lintr b/.lintr index 7c07aad..ba22fdd 100644 --- a/.lintr +++ b/.lintr @@ -2,6 +2,7 @@ linters: with_defaults(absolute_path_linter = absolute_path_linter, implicit_integer_linter = implicit_integer_linter, line_length_linter = line_length_linter(160), nonportable_path_linter = nonportable_path_linter, + object_length_linter = lintr::object_length_linter(40), semicolon_terminator_linter = semicolon_terminator_linter, todo_comment_linter = todo_comment_linter, trailing_whitespace_linter = NULL, From 9b4467fa8c7a128110d06d665eae7ef25dcc2398 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 13 Oct 2020 15:51:18 +0200 Subject: [PATCH 10/34] add additional dependencies --- DESCRIPTION | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index a567a7e..7bcc6cc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,9 @@ Depends: R (>= 3.3.0) Imports: fs, + glue, purrr, + rlang, rstudioapi Encoding: UTF-8 LazyData: true From 9c639c29d24f36b12b0d21d13bdbba4e01288893 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 13 Oct 2020 16:30:16 +0200 Subject: [PATCH 11/34] use comments as rscodeio identifiers in custom QSS files --- inst/resources/stylesheets/rstudio-gnome-dark.qss | 2 ++ inst/resources/stylesheets/rstudio-windows-dark.qss | 2 ++ 2 files changed, 4 insertions(+) diff --git a/inst/resources/stylesheets/rstudio-gnome-dark.qss b/inst/resources/stylesheets/rstudio-gnome-dark.qss index d2b9ba2..1eb3485 100644 --- a/inst/resources/stylesheets/rstudio-gnome-dark.qss +++ b/inst/resources/stylesheets/rstudio-gnome-dark.qss @@ -1,3 +1,5 @@ +/* This is rscodeio's dark GNOME stylesheet */ + QMenuBar { background-color: rgb(60, 60, 60); color: rgb(204, 204, 204); diff --git a/inst/resources/stylesheets/rstudio-windows-dark.qss b/inst/resources/stylesheets/rstudio-windows-dark.qss index d2b9ba2..0e4173b 100644 --- a/inst/resources/stylesheets/rstudio-windows-dark.qss +++ b/inst/resources/stylesheets/rstudio-windows-dark.qss @@ -1,3 +1,5 @@ +/* This is rscodeio's dark Windows stylesheet */ + QMenuBar { background-color: rgb(60, 60, 60); color: rgb(204, 204, 204); From 8a6848483290ed6c0d0ff4aae4756b6aca2e12cf Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 13 Oct 2020 16:37:26 +0200 Subject: [PATCH 12/34] overhaul package: - rewrite majority of R code to be more consistent and logically coherent incl. lots of renamings - improve QSS installation for Windows by checking file access permissions; display a warning with more infos if permissions are insufficient (not admin) - improve QSS installation for Linux: ask interactively for administrator credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s #' [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html) and perform all admin-level actions in one go - improve/extend documentation; should be less confusing now for users who didn't know about QSS --- NAMESPACE | 8 +- R/rscodeio.R | 231 +++++++++++------- R/utils.R | 171 +++++++++++-- .../rscodeio_tomorrow_night_bright.rstheme | 10 + man/activate_menu_theme.Rd | 14 -- man/deactivate_menu_theme.Rd | 14 -- man/install_menu_theme.Rd | 24 ++ man/install_theme.Rd | 23 -- man/install_themes.Rd | 42 ++++ man/uninstall_menu_theme.Rd | 22 ++ man/uninstall_theme.Rd | 14 -- man/uninstall_themes.Rd | 21 ++ 12 files changed, 411 insertions(+), 183 deletions(-) delete mode 100644 man/activate_menu_theme.Rd delete mode 100644 man/deactivate_menu_theme.Rd create mode 100644 man/install_menu_theme.Rd delete mode 100644 man/install_theme.Rd create mode 100644 man/install_themes.Rd create mode 100644 man/uninstall_menu_theme.Rd delete mode 100644 man/uninstall_theme.Rd create mode 100644 man/uninstall_themes.Rd diff --git a/NAMESPACE b/NAMESPACE index 669232c..42ffd9c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,6 @@ # Generated by roxygen2: do not edit by hand -export(activate_menu_theme) -export(deactivate_menu_theme) -export(install_theme) -export(uninstall_theme) +export(install_menu_theme) +export(install_themes) +export(uninstall_menu_theme) +export(uninstall_themes) diff --git a/R/rscodeio.R b/R/rscodeio.R index 5748432..00dde81 100644 --- a/R/rscodeio.R +++ b/R/rscodeio.R @@ -1,120 +1,169 @@ -#' Install the rscodeio theme +#' Install rscodeio editor themes and menu bar styling #' -#' You'll need RStudio at least 1.2.x and if your RStudio -#' is installed to a default location on Windows or Linux, -#' you'll need to be running RStudio as -#' Administrator to install the menu theme files (Just required for install). +#' RStudio 1.2 or later is required for this. Additionally, administrator privileges are required to also install the Qt CSS (QSS) files to style RStudio's menu +#' bar, something which is not possible with [RStudio's built-in theming API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html). #' -#' You can elect not to install the menu theme files with `menus = FALSE`. +#' # Menu bar styling #' -#' @param menus if FALSE do not install the RStudio menu theme qss files. -#' @return nothing. +#' On Linux, it will be asked interactively for administrator credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s +#' [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). Windows users must run RStudio as administrator in order to install +#' rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is not necessary and thus always skipped. +#' +#' The installation of the menu theme files can be skipped by setting `style_menu_bar = FALSE`. See [install_menu_theme()] for more details about the menu bar +#' styling. +#' +#' @param apply_theme The rscodeio editor theme variant to apply. All variants are installed and the one specified here is activated right away. The other +#' variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of +#' - `"rscodeio"` for the default color variant inspired by Visual Studio Code. +#' - `"Tomorrow Night Bright (rscodeio)"` for the colors known from the similarly named default RStudio theme. +#' @param style_menu_bar Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required. On macOS and +#' RStudio Server, menu bar styling is not necessary and thus always skipped. +#' @param install_globally Whether to install the editor themes for the current user (`FALSE`) or all users globally (`TRUE`). The latter may require +#' administrator privileges. +#' @return Nothing (`NULL` invisibly). #' @export -install_theme <- function(menus = TRUE) { +install_themes <- function(apply_theme = c("rscodeio", + "Tomorrow Night Bright (rscodeio)"), + style_menu_bar = TRUE, + install_globally = FALSE) { + + # ensure RStudio API is available + if (!rstudioapi::isAvailable()) { + stop("rscodeio must be installed from within RStudio.", + call. = FALSE) + } - ## check RStudio API available - if(!rstudioapi::isAvailable()) stop("RSCodeio must be installed from within RStudio.") + # ensure minimally required RStudio version + if (rstudioapi::versionInfo()$version < as.package_version("1.2.0")) + stop("You need RStudio 1.2 or later to get theme support", + call. = FALSE) - ## check RStudio supports themes - if(utils::compareVersion(as.character(rstudioapi::versionInfo()$version), "1.2.0") < 0) - stop("You need RStudio 1.2 or greater to get theme support") + # add the editor theme variants + ## existing editor themes of the same names have to be removed first + uninstall_themes(restore_menu_bar = FALSE) - ## check if menu theme is already installed and if so, uninstall first - if (is_rscodeio_installed()) { - uninstall_theme() - } + purrr::walk(.x = c("rscodeio.rstheme", + "rscodeio_tomorrow_night_bright.rstheme"), + .f = ~ rstudioapi::addTheme(fs::path_package(package = "rscodeio", + "resources", .x), + globally = install_globally)) - ## add the themes - rscodeio_default_theme <- rstudioapi::addTheme(fs::path_package(package = "rscodeio", - "resources","rscodeio.rstheme")) - - rstudioapi::addTheme(fs::path_package(package = "rscodeio", - "resources","rscodeio_tomorrow_night_bright.rstheme")) + # add the custom Qt CSS (QSS) + if (style_menu_bar) install_menu_theme() - ## add the custom Qt CSS - if (menus) activate_menu_theme() - - ## activate default rscodeio theme - rstudioapi::applyTheme(rscodeio_default_theme) + # activate chosen rscodeio editor theme variant + rstudioapi::applyTheme(rlang::arg_match(apply_theme)) } -#' Uninstall the rscodeio theme +#' Uninstall the rscodeio editor themes and menu bar styling +#' +#' To restore RStudio's default _dark_ Qt theme (`.qss`) files (i.e. setting `restore_menu_bar = TRUE`), administrator privileges are required. On Linux, it +#' will be asked interactively for administrator credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s +#' [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). Windows users must run RStudio as administrator in order to uninstall +#' rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is not necessary and thus its menu bar restoration will be skipped. #' -#' @return nothing. +#' @param restore_menu_bar Whether to restore RStudio's default menu bar styling. Irrelevant if rscodeio menu bar styling is not installed (see +#' [install_menu_theme()] for details about menu bar styling). +#' @return Nothing (`NULL` invisibly). #' @export -uninstall_theme <- function(){ - - deactivate_menu_theme() - - installed_rscodeio_themes <- grep(x = purrr::map_depth(.x = rstudioapi::getThemes(), - .depth = 1L, - .f = purrr::pluck("name")), - pattern = "rscodeio", - value = TRUE) - - for (theme in installed_rscodeio_themes) { - rstudioapi::removeTheme(theme) - } -} +uninstall_themes <- function(restore_menu_bar = TRUE) { + + if (restore_menu_bar) uninstall_menu_theme() + purrr::walk(.x = installed_rscodeio_editor_themes(), + .f = rstudioapi::removeTheme) +} -#' Activate rscodeio styling in file menu. +#' Install rscodeio menu bar styling +#' +#' This function overwrites RStudio's default _dark_ Qt theme (`.qss`) files with rscodeio's customized ones in order to properly style RStudio's menu bar which +#' cannot be altered by [RStudio's current theming API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html). The original Qt theme files +#' are backed up and can be restored by calling [uninstall_menu_theme()]. +#' +#' Running [`install_themes(style_menu_bar = TRUE)`][install_themes()] (which is the default) has the same effect as running this function. +#' `install_menu_theme()` can be useful to install the rscodeio menu bar styling _without_ the accompanying editor themes. +#' +#' Administrator privileges are required to copy the QSS files to RStudio's installation directory. On Linux, it will be asked interactively for administrator +#' credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). +#' Windows users must run RStudio as administrator On macOS and RStudio Server, menu bar styling is not necessary and running this function has no effect. #' -#' @return nothing. +#' @return Nothing (`NULL` invisibly). #' @export -activate_menu_theme <- function() { +install_menu_theme <- function() { - ## Styling menus not supported on Mac or RStudio Server. - if(host_os_is_mac() | is_rstudio_server()) return(NULL) + # menu bar styling is not supported on macOS or RStudio Server + if (is_macos() || is_rstudio_server()) return(NULL) - if(file.exists(gnome_theme_dark_backup()) | - file.exists(windows_theme_dark_backup())) { - message("RSCodeio menu theme already activated. Deactivate first.") - return(FALSE) - } - - ## backup dark Qt themes - file.copy(from = gnome_theme_dark(), - to = gnome_theme_dark_backup()) - file.copy(from = windows_theme_dark(), - to = windows_theme_dark_backup()) - - ## replace with RSCodeio Qt themes - file.copy(from = system.file(fs::path("resources","stylesheets","rstudio-gnome-dark.qss"), - package = "rscodeio"), - to = gnome_theme_dark(), - overwrite = TRUE) - file.copy(from = system.file(fs::path("resources","stylesheets","rstudio-windows-dark.qss"), - package = "rscodeio"), - to = windows_theme_dark(), - overwrite = TRUE) + process_menu_themes(backup_gnome = !is_rscodeio_menu_theme(path_theme_dark_gnome()), + backup_windows = !is_rscodeio_menu_theme(path_theme_dark_windows()), + override_gnome = TRUE, + override_windows = TRUE) } -#' Deactivate rscodeio style in file menu. +#' Uninstall rscodeio menu bar styling +#' +#' This function restores RStudio's default _dark_ Qt theme (`.qss`) files. #' -#' @return nothing. +#' Running [`uninstall_themes(restore_menu_bar = TRUE)`][uninstall_themes()] (which is the default) has the same effect as running this function. +#' `uninstall_menu_theme()` can be useful to remove the rscodeio menu bar styling _without_ removing the accompanying editor themes. +#' +#' Administrator privileges are required to restore RStudio's default QSS files. On Linux, it will be asked interactively for administrator credentials by +#' calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). Windows users +#' must run RStudio as administrator. On macOS and RStudio Server, menu bar styling is not necessary and running this function has no effect. +#' +#' @return Nothing (`NULL` invisibly). #' @export -deactivate_menu_theme <- function(){ - - ## Styling menus not supported on Mac. - if(host_os_is_mac()) return(NULL) +uninstall_menu_theme <- function() { + + ## menu bar styling not supported on Mac + if (is_macos()) return(NULL) + + path_theme_dark_gnome <- path_theme_dark_gnome() + path_theme_dark_gnome_backup <- path_theme_dark_gnome_backup() + path_theme_dark_windows <- path_theme_dark_windows() + path_theme_dark_windows_backup <- path_theme_dark_windows_backup() + is_rscodeio_current_gnome <- is_rscodeio_menu_theme(path_theme_dark_gnome) + is_rscodeio_current_windows <- is_rscodeio_menu_theme(path_theme_dark_windows) + exists_theme_dark_gnome_backup <- fs::file_exists(path_theme_dark_gnome_backup) + exists_theme_dark_windows_backup <- fs::file_exists(path_theme_dark_windows_backup) + + # shouldn't really happen + if (exists_theme_dark_gnome_backup && is_rscodeio_menu_theme(path_theme_dark_gnome_backup)) { + + stop("The following backed up file supposed to be an RStudio Qt theme is actually an rscodeio theme:\n", path_theme_dark_gnome_backup, "\n", + "Delete the file if you'd like this error to be gone.\nUsing the R console: fs::file_delete(rscodeio:::path_theme_dark_gnome_backup())", + call. = FALSE) + } + if (exists_theme_dark_windows_backup && is_rscodeio_menu_theme(path_theme_dark_windows_backup)) { - if(!file.exists(gnome_theme_dark_backup()) | - !file.exists(windows_theme_dark_backup())) { - message("RStudio theme backups not found. rscodeio already deactivated?") - return(FALSE) + stop("The following backed up file supposed to be an RStudio Qt theme is actually an rscodeio theme:\n", path_theme_dark_windows_backup, "\n", + "Delete the file if you'd like this error to be gone.\nUsing the R console: fs::file_delete(rscodeio:::path_theme_dark_windows_backup())", + call. = FALSE) } - ## restore dark Qt themes - file.copy(from = gnome_theme_dark_backup(), - to = gnome_theme_dark(), - overwrite = TRUE) - file.copy(from = windows_theme_dark_backup(), - to = windows_theme_dark(), - overwrite = TRUE) + process_menu_themes(restore_gnome = exists_theme_dark_gnome_backup && is_rscodeio_current_gnome, + restore_windows = exists_theme_dark_windows_backup && is_rscodeio_current_windows) + + # print instructive warnings if restoral is impossible + if (!exists_theme_dark_gnome_backup && is_rscodeio_current_gnome) { + + warning("Unable to restore default RStudio menu bar styling for GNOME because the corresponding backup file couldn't be found.\n", + "The most convenient way to restore the original file at ", path_theme_dark_gnome, " is to simply update or reinstall RStudio.\n", + "RStudio stable release installers are available at https://rstudio.com/products/rstudio/download/", + call. = FALSE) + } + if (!exists_theme_dark_windows_backup && is_rscodeio_current_windows) { - ## delete backups - unlink(gnome_theme_dark_backup()) - unlink(windows_theme_dark_backup()) + warning("Unable to restore default RStudio menu bar styling for Windows because the corresponding backup file couldn't be found.\n", + "The most convenient way to restore the original file at ", path_theme_dark_windows, " is to simply update or reinstall RStudio.\n", + "RStudio stable release installers are available at https://rstudio.com/products/rstudio/download/", + call. = FALSE) + } + # display message if rscodeio's menu bar styling has already been removed + if (!exists_theme_dark_gnome_backup && !exists_theme_dark_windows_backup) { + if (!is_rscodeio_current_gnome && !is_rscodeio_current_windows) { + message("rscodeio's menu bar styling is already removed.") + } + } } diff --git a/R/utils.R b/R/utils.R index af9cef2..2780f99 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,7 +1,7 @@ -get_stylesheets_location <- function(){ +path_theme_dir <- function() { ## We shouldn't get here on mac - if(host_os_is_mac()) stop("Qss Stylesheets are not used on Mac") + if (is_macos()) stop("QSS Stylesheets are not used on Mac.") rstudio_dirs <- list( pandoc_dir = Sys.getenv("RSTUDIO_PANDOC"), @@ -11,48 +11,53 @@ get_stylesheets_location <- function(){ rmarkdown_mathjax_path = Sys.getenv("RMARKDOWN_MATHJAX_PATH") ) - extract_rstudio_path_parts <- function(path){ - dir_parts <- fs::path_split(path)[[1]] - rstudio_ind <- which(dir_parts %in% c("RStudio","rstudio")) - if(length(rstudio_ind) != 1) return(NULL) + extract_rstudio_path_parts <- function(path) { + dir_parts <- fs::path_split(path)[[1L]] + rstudio_ind <- which(dir_parts %in% c("RStudio", "rstudio")) + if (length(rstudio_ind) != 1L) return(NULL) dir_parts[seq(rstudio_ind)] } potential_paths <- Filter(function(path_parts) { - !is.null(path_parts) && dir.exists(fs::path_join(c(path_parts, - "resources", - "stylesheets"))) - }, - lapply(rstudio_dirs, extract_rstudio_path_parts) + !is.null(path_parts) && dir.exists(fs::path_join(c(path_parts, + "resources", + "stylesheets")))}, + lapply(rstudio_dirs, extract_rstudio_path_parts) ) - if(length(potential_paths) == 0) stop("Could not find location of your RStudio installation.") + if (length(potential_paths) == 0L) { + stop("Unable to determine RStudio installation path.", + call. = FALSE) + } ## return first path that existed - fs::path_join(c(potential_paths[[1]], "resources", "stylesheets")) + fs::path_join(c(potential_paths[[1L]], "resources", "stylesheets")) +} +path_theme_dark_gnome <- function() { + fs::path(path_theme_dir(), "rstudio-gnome-dark.qss") } -gnome_theme_dark <- function() { - fs::path(get_stylesheets_location(),"rstudio-gnome-dark.qss") +path_theme_dark_gnome_backup <- function() { + fs::path(path_theme_dir(), "rstudio-gnome-dark-rscodeio-backup.qss") } -gnome_theme_dark_backup <- function() { - fs::path(get_stylesheets_location(), "rstudio-gnome-dark-rscodeio-backup.qss") +path_theme_dark_windows <- function() { + fs::path(path_theme_dir(), "rstudio-windows-dark.qss") } -windows_theme_dark <- function() { - fs::path(get_stylesheets_location(),"rstudio-windows-dark.qss") +path_theme_dark_windows_backup <- function() { + fs::path(path_theme_dir(), "rstudio-windows-dark-rscodeio-backup.qss") } -windows_theme_dark_backup <- function() { - fs::path(get_stylesheets_location(),"rstudio-windows-dark-rscodeio-backup.qss") +is_macos <- function() { + unname(Sys.info()["sysname"] == "Darwin") } -host_os_is_mac <- function() { - Sys.info()["sysname"] == "Darwin" +is_linux <- function() { + unname(Sys.info()["sysname"] == "Linux") } is_rstudio_server <- function() { @@ -62,3 +67,123 @@ is_rstudio_server <- function() { is_rscodeio_installed <- function() { !is.null(rstudioapi::getThemes()[["rscodeio"]]) || !is.null(rstudioapi::getThemes()[["tomorrow night bright (rscodeio)"]]) } + +is_rscodeio_menu_theme <- function(path_theme) { + grepl(x = readLines(con = path_theme, + n = 1L), + pattern = "rscodeio") +} + +installed_rscodeio_editor_themes <- function() { + grep(x = purrr::map_depth(.x = rstudioapi::getThemes(), + .depth = 1L, + .f = purrr::pluck("name")), + pattern = "rscodeio", + value = TRUE) +} + +process_menu_themes <- function(backup_gnome = FALSE, + backup_windows = FALSE, + override_gnome = FALSE, + override_windows = FALSE, + restore_gnome = FALSE, + restore_windows = FALSE) { + + # return early if nothing to do + if (!any(backup_gnome, + backup_windows, + override_gnome, + override_windows, + restore_gnome, + restore_windows)) return(NULL) + + path_theme_dark_gnome <- path_theme_dark_gnome() + path_theme_dark_gnome_backup <- path_theme_dark_gnome_backup() + path_theme_dark_gnome_rscodeio <- fs::path_package(package = "rscodeio", + "resources", "stylesheets", "rstudio-gnome-dark.qss") + path_theme_dark_windows <- path_theme_dark_windows() + path_theme_dark_windows_backup <- path_theme_dark_windows_backup() + path_theme_dark_windows_rscodeio <- fs::path_package(package = "rscodeio", + "resources", "stylesheets", "rstudio-windows-dark.qss") + + ## interactively ask for administrator privilege credentials on Linux + if (is_linux()) { + + cmd_backup_gnome <- glue::glue('sudo cp "{path_theme_dark_gnome}" "{path_theme_dark_gnome_backup}" ; ') + cmd_backup_windows <- glue::glue('sudo cp "{path_theme_dark_windows}" "{path_theme_dark_windows_backup}" ; ') + cmd_override_gnome <- glue::glue('sudo cp "{path_theme_dark_gnome_rscodeio}" "{path_theme_dark_gnome}" ; ') + cmd_override_windows <- glue::glue('sudo cp "{path_theme_dark_windows_rscodeio}" "{path_theme_dark_windows}" ; ') + cmd_restore_gnome <- glue::glue('sudo cp "{path_theme_dark_gnome_backup}" "{path_theme_dark_gnome}" && sudo rm "{path_theme_dark_gnome_backup}" ; ') + cmd_restore_windows <- glue::glue('sudo cp "{path_theme_dark_windows_backup}" "{path_theme_dark_windows}" && sudo rm "{path_theme_dark_windows_backup}" ; ') + + pkexec_cmd_args <- paste0("env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash -c '", + if (backup_gnome) cmd_backup_gnome, + if (backup_windows) cmd_backup_windows, + if (override_gnome) cmd_override_gnome, + if (override_windows) cmd_override_windows, + if (restore_gnome) cmd_restore_gnome, + if (restore_windows) cmd_restore_windows) + pkexec_cmd_args <- substr(pkexec_cmd_args, + start = 1L, + stop = nchar(pkexec_cmd_args) - 2L) + pkexec_cmd_args <- paste0(pkexec_cmd_args, "'") + + + return_code <- system2(command = "pkexec", + args = pkexec_cmd_args) + + # print instructive warnings if something went wrong + if (return_code != 0L) { + + common_warning <- ' of default RStudio menu bar styling failed. As a workaround, you can manually run the following in a shell as root (sudo):\n\n' + + if (backup_gnome) warning('Backup', common_warning, cmd_backup_gnome, call. = FALSE) + if (backup_windows) warning('Backup', common_warning, cmd_backup_windows, call. = FALSE) + if (override_gnome) warning('Installation', common_warning, cmd_override_gnome, call. = FALSE) + if (override_windows) warning('Installation', common_warning, cmd_override_windows, call. = FALSE) + if (restore_gnome) warning('Restoral', common_warning, cmd_restore_gnome, call. = FALSE) + if (restore_windows) warning('Restoral', common_warning, cmd_restore_windows, call. = FALSE) + } + + } else { + ## other OS' like Windows and macOS need RStudio being run as administrator + if (all(fs::file_access(path = c(if (override_gnome || restore_gnome) path_theme_dark_gnome, + if (override_windows || restore_windows) path_theme_dark_windows, + if (backup_gnome || restore_gnome) path_theme_dark_gnome_backup, + if (backup_windows || restore_windows) path_theme_dark_windows_backup, + if (restore_gnome) path_theme_dark_gnome_rscodeio, + if (restore_windows) path_theme_dark_windows_rscodeio), + mode = "write"))) { + + list(c(path_theme_dark_gnome, path_theme_dark_gnome_backup)[backup_gnome], + c(path_theme_dark_windows, path_theme_dark_windows_backup)[backup_windows], + c(path_theme_dark_gnome_rscodeio, path_theme_dark_gnome)[override_gnome], + c(path_theme_dark_windows_rscodeio, path_theme_dark_gnome)[override_windows], + c(path_theme_dark_gnome_backup, path_theme_dark_gnome)[restore_gnome], + c(path_theme_dark_windows_backup, path_theme_dark_gnome)[restore_windows]) %>% + purrr::walk(~ { + if (length(.x)) { + fs::file_copy(path = .x[1L], + new_path = .x[2L], + overwrite = TRUE) + } + }) + + if (restore_gnome) fs::file_delete(path_theme_dark_gnome_backup) + if (restore_windows) fs::file_delete(path_theme_dark_windows_backup) + + } else { + + begin_warning <- paste("Backup"[backup_gnome || backup_windows], + "Installation"[override_gnome || override_windows], + "Restoral"[restore_gnome || restore_windows], + sep = "/") + + warning(substr(begin_warning, + start = 1L, + stop = nchar(begin_warning) - 1L), + " of default RStudio menu bar styling impossible due to insufficient user rights. RStudio must be run as administrator for this to work.", + call. = FALSE) + } + } +} diff --git a/inst/resources/rscodeio_tomorrow_night_bright.rstheme b/inst/resources/rscodeio_tomorrow_night_bright.rstheme index cc2e5a5..7fcd3aa 100644 --- a/inst/resources/rscodeio_tomorrow_night_bright.rstheme +++ b/inst/resources/rscodeio_tomorrow_night_bright.rstheme @@ -1015,3 +1015,13 @@ color: #80D7FF !important; text-decoration: none; } + +/* COMMENTED OUT: zebra-striped tables don't look good yet +.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme table[summary="Rd table"] tr:nth-child(even) { + background-color: #1a1a1a; +} + +.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme table[summary="Rd table"] td { + padding: .2em; +} + */ diff --git a/man/activate_menu_theme.Rd b/man/activate_menu_theme.Rd deleted file mode 100644 index dc85cde..0000000 --- a/man/activate_menu_theme.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rscodeio.R -\name{activate_menu_theme} -\alias{activate_menu_theme} -\title{Activate rscodeio styling in file menu.} -\usage{ -activate_menu_theme() -} -\value{ -nothing. -} -\description{ -Activate rscodeio styling in file menu. -} diff --git a/man/deactivate_menu_theme.Rd b/man/deactivate_menu_theme.Rd deleted file mode 100644 index dcc0609..0000000 --- a/man/deactivate_menu_theme.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rscodeio.R -\name{deactivate_menu_theme} -\alias{deactivate_menu_theme} -\title{Deactivate rscodeio style in file menu.} -\usage{ -deactivate_menu_theme() -} -\value{ -nothing. -} -\description{ -Deactivate rscodeio style in file menu. -} diff --git a/man/install_menu_theme.Rd b/man/install_menu_theme.Rd new file mode 100644 index 0000000..8d37aed --- /dev/null +++ b/man/install_menu_theme.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rscodeio.R +\name{install_menu_theme} +\alias{install_menu_theme} +\title{Install rscodeio menu bar styling} +\usage{ +install_menu_theme() +} +\value{ +Nothing (\code{NULL} invisibly). +} +\description{ +This function overwrites RStudio's default \emph{dark} Qt theme (\code{.qss}) files with rscodeio's customized ones in order to properly style RStudio's menu bar which +cannot be altered by \href{https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html}{RStudio's current theming API}. The original Qt theme files +are backed up and can be restored by calling \code{\link[=uninstall_menu_theme]{uninstall_menu_theme()}}. +} +\details{ +Running \code{\link[=install_themes]{install_themes(style_menu_bar = TRUE)}} (which is the default) has the same effect as running this function. +\code{install_menu_theme()} can be useful to install the rscodeio menu bar styling \emph{without} the accompanying editor themes. + +Administrator privileges are required to copy the QSS files to RStudio's installation directory. On Linux, it will be asked interactively for administrator +credentials by calling \href{https://en.wikipedia.org/wiki/Polkit}{Polkit}'s \href{https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html}{\code{pkexec}}. +Windows users must run RStudio as administrator On macOS and RStudio Server, menu bar styling is not necessary and running this function has no effect. +} diff --git a/man/install_theme.Rd b/man/install_theme.Rd deleted file mode 100644 index d004354..0000000 --- a/man/install_theme.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rscodeio.R -\name{install_theme} -\alias{install_theme} -\title{Install the rscodeio theme} -\usage{ -install_theme(menus = TRUE) -} -\arguments{ -\item{menus}{If FALSE, do not install the RStudio menu theme QSS files.} -} -\value{ -Nothing. -} -\description{ -You'll need RStudio at least 1.2.x and if your RStudio -is installed to a default location on Windows or Linux, -you'll need to be running RStudio as -Administrator to install the menu theme files (Just required for install). -} -\details{ -You can elect not to install the menu theme files with `menus = FALSE`. -} diff --git a/man/install_themes.Rd b/man/install_themes.Rd new file mode 100644 index 0000000..9e87bba --- /dev/null +++ b/man/install_themes.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rscodeio.R +\name{install_themes} +\alias{install_themes} +\title{Install rscodeio editor themes and menu bar styling} +\usage{ +install_themes( + apply_theme = c("rscodeio", "Tomorrow Night Bright (rscodeio)"), + style_menu_bar = TRUE, + install_globally = FALSE +) +} +\arguments{ +\item{apply_theme}{The rscodeio editor theme variant to apply. All variants are installed and the one specified here is activated right away. The other +variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of +\itemize{ +\item \code{"rscodeio"} for the default color variant inspired by Visual Studio Code. +\item \code{"Tomorrow Night Bright (rscodeio)"} for the colors known from the similarly named default RStudio theme. +}} + +\item{style_menu_bar}{Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required. On macOS and +RStudio Server, menu bar styling is not necessary and thus always skipped.} + +\item{install_globally}{Whether to install the editor themes for the current user (\code{FALSE}) or all users globally (\code{TRUE}). The latter may require +administrator privileges.} +} +\value{ +Nothing (\code{NULL} invisibly). +} +\description{ +RStudio 1.2 or later is required for this. Additionally, administrator privileges are required to also install the Qt CSS (QSS) files to style RStudio's menu +bar, something which is not possible with \href{https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html}{RStudio's built-in theming API}. +} +\section{Menu bar styling}{ +On Linux, it will be asked interactively for administrator credentials by calling \href{https://en.wikipedia.org/wiki/Polkit}{Polkit}'s +\href{https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html}{\code{pkexec}}. Windows users must run RStudio as administrator in order to install +rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is not necessary and thus always skipped. + +The installation of the menu theme files can be skipped by setting \code{style_menu_bar = FALSE}. See \code{\link[=install_menu_theme]{install_menu_theme()}} for more details about the menu bar +styling. +} + diff --git a/man/uninstall_menu_theme.Rd b/man/uninstall_menu_theme.Rd new file mode 100644 index 0000000..5dc1b5f --- /dev/null +++ b/man/uninstall_menu_theme.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rscodeio.R +\name{uninstall_menu_theme} +\alias{uninstall_menu_theme} +\title{Uninstall rscodeio menu bar styling} +\usage{ +uninstall_menu_theme() +} +\value{ +Nothing (\code{NULL} invisibly). +} +\description{ +This function restores RStudio's default \emph{dark} Qt theme (\code{.qss}) files. +} +\details{ +Running \code{\link[=uninstall_themes]{uninstall_themes(restore_menu_bar = TRUE)}} (which is the default) has the same effect as running this function. +\code{uninstall_menu_theme()} can be useful to remove the rscodeio menu bar styling \emph{without} removing the accompanying editor themes. + +Administrator privileges are required to restore RStudio's default QSS files. On Linux, it will be asked interactively for administrator credentials by +calling \href{https://en.wikipedia.org/wiki/Polkit}{Polkit}'s \href{https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html}{\code{pkexec}}. Windows users +must run RStudio as administrator. On macOS and RStudio Server, menu bar styling is not necessary and running this function has no effect. +} diff --git a/man/uninstall_theme.Rd b/man/uninstall_theme.Rd deleted file mode 100644 index a2f3f93..0000000 --- a/man/uninstall_theme.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rscodeio.R -\name{uninstall_theme} -\alias{uninstall_theme} -\title{Uninstall the rscodeio theme} -\usage{ -uninstall_theme() -} -\value{ -nothing. -} -\description{ -Uninstall the rscodeio theme -} diff --git a/man/uninstall_themes.Rd b/man/uninstall_themes.Rd new file mode 100644 index 0000000..67a2ca1 --- /dev/null +++ b/man/uninstall_themes.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rscodeio.R +\name{uninstall_themes} +\alias{uninstall_themes} +\title{Uninstall the rscodeio editor themes and menu bar styling} +\usage{ +uninstall_themes(restore_menu_bar = TRUE) +} +\arguments{ +\item{restore_menu_bar}{Whether to restore RStudio's default menu bar styling. Irrelevant if rscodeio menu bar styling is not installed (see +\code{\link[=install_menu_theme]{install_menu_theme()}} for details about menu bar styling).} +} +\value{ +Nothing (\code{NULL} invisibly). +} +\description{ +To restore RStudio's default \emph{dark} Qt theme (\code{.qss}) files (i.e. setting \code{restore_menu_bar = TRUE}), administrator privileges are required. On Linux, it +will be asked interactively for administrator credentials by calling \href{https://en.wikipedia.org/wiki/Polkit}{Polkit}'s +\href{https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html}{\code{pkexec}}. Windows users must run RStudio as administrator in order to uninstall +rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is not necessary and thus its menu bar restoration will be skipped. +} From 2608140922a0f6cf0c7b8590fe0deed50f942bc6 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 13 Oct 2020 16:55:07 +0200 Subject: [PATCH 13/34] remove unnecessary noise (obsolete leftover) --- R/utils.R | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/R/utils.R b/R/utils.R index 2780f99..798f79f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -122,12 +122,8 @@ process_menu_themes <- function(backup_gnome = FALSE, if (override_gnome) cmd_override_gnome, if (override_windows) cmd_override_windows, if (restore_gnome) cmd_restore_gnome, - if (restore_windows) cmd_restore_windows) - pkexec_cmd_args <- substr(pkexec_cmd_args, - start = 1L, - stop = nchar(pkexec_cmd_args) - 2L) - pkexec_cmd_args <- paste0(pkexec_cmd_args, "'") - + if (restore_windows) cmd_restore_windows, + "'") return_code <- system2(command = "pkexec", args = pkexec_cmd_args) From 869b16adade691ef1746905e168de7a3b9ce6742 Mon Sep 17 00:00:00 2001 From: Salim B Date: Tue, 13 Oct 2020 16:57:05 +0200 Subject: [PATCH 14/34] minor doc change --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 798f79f..6f6e4fa 100644 --- a/R/utils.R +++ b/R/utils.R @@ -106,7 +106,7 @@ process_menu_themes <- function(backup_gnome = FALSE, path_theme_dark_windows_rscodeio <- fs::path_package(package = "rscodeio", "resources", "stylesheets", "rstudio-windows-dark.qss") - ## interactively ask for administrator privilege credentials on Linux + ## interactively ask for administrator credentials on Linux if (is_linux()) { cmd_backup_gnome <- glue::glue('sudo cp "{path_theme_dark_gnome}" "{path_theme_dark_gnome_backup}" ; ') From 166340c3d5f095e5348ae2b3089ba1df1e95f57e Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 15 Oct 2020 00:47:09 +0200 Subject: [PATCH 15/34] remove redundancy --- R/rscodeio.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/rscodeio.R b/R/rscodeio.R index 00dde81..67a08d0 100644 --- a/R/rscodeio.R +++ b/R/rscodeio.R @@ -16,8 +16,7 @@ #' variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of #' - `"rscodeio"` for the default color variant inspired by Visual Studio Code. #' - `"Tomorrow Night Bright (rscodeio)"` for the colors known from the similarly named default RStudio theme. -#' @param style_menu_bar Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required. On macOS and -#' RStudio Server, menu bar styling is not necessary and thus always skipped. +#' @param style_menu_bar Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required. #' @param install_globally Whether to install the editor themes for the current user (`FALSE`) or all users globally (`TRUE`). The latter may require #' administrator privileges. #' @return Nothing (`NULL` invisibly). From 138a28a3fb6a6e270276084d2ad32c34ec8c8a86 Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 15 Oct 2020 01:00:50 +0200 Subject: [PATCH 16/34] avoid pipe operator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (wasn't really intentional to use it😅) --- R/utils.R | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/R/utils.R b/R/utils.R index 6f6e4fa..45a5d72 100644 --- a/R/utils.R +++ b/R/utils.R @@ -151,19 +151,19 @@ process_menu_themes <- function(backup_gnome = FALSE, if (restore_windows) path_theme_dark_windows_rscodeio), mode = "write"))) { - list(c(path_theme_dark_gnome, path_theme_dark_gnome_backup)[backup_gnome], - c(path_theme_dark_windows, path_theme_dark_windows_backup)[backup_windows], - c(path_theme_dark_gnome_rscodeio, path_theme_dark_gnome)[override_gnome], - c(path_theme_dark_windows_rscodeio, path_theme_dark_gnome)[override_windows], - c(path_theme_dark_gnome_backup, path_theme_dark_gnome)[restore_gnome], - c(path_theme_dark_windows_backup, path_theme_dark_gnome)[restore_windows]) %>% - purrr::walk(~ { - if (length(.x)) { - fs::file_copy(path = .x[1L], - new_path = .x[2L], - overwrite = TRUE) - } - }) + purrr::walk(.x = list(c(path_theme_dark_gnome, path_theme_dark_gnome_backup)[backup_gnome], + c(path_theme_dark_windows, path_theme_dark_windows_backup)[backup_windows], + c(path_theme_dark_gnome_rscodeio, path_theme_dark_gnome)[override_gnome], + c(path_theme_dark_windows_rscodeio, path_theme_dark_gnome)[override_windows], + c(path_theme_dark_gnome_backup, path_theme_dark_gnome)[restore_gnome], + c(path_theme_dark_windows_backup, path_theme_dark_gnome)[restore_windows]), + .f = ~ { + if (length(.x)) { + fs::file_copy(path = .x[1L], + new_path = .x[2L], + overwrite = TRUE) + } + }) if (restore_gnome) fs::file_delete(path_theme_dark_gnome_backup) if (restore_windows) fs::file_delete(path_theme_dark_windows_backup) From e21a6e1b9d0935c18657ee23ffa6762c11970914 Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 15 Oct 2020 01:06:59 +0200 Subject: [PATCH 17/34] fix styling of hyperlinked in help pane --- inst/resources/rscodeio_tomorrow_night_bright.rstheme | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inst/resources/rscodeio_tomorrow_night_bright.rstheme b/inst/resources/rscodeio_tomorrow_night_bright.rstheme index 7fcd3aa..636d3af 100644 --- a/inst/resources/rscodeio_tomorrow_night_bright.rstheme +++ b/inst/resources/rscodeio_tomorrow_night_bright.rstheme @@ -1011,7 +1011,9 @@ overflow: auto; } -.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme a { +.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme a, +.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme p a, +.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme p a code { color: #80D7FF !important; text-decoration: none; } From 38d33086aa40bfb6a2e373047c46bf126a5df3a3 Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 15 Oct 2020 01:07:36 +0200 Subject: [PATCH 18/34] document() --- man/install_themes.Rd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/man/install_themes.Rd b/man/install_themes.Rd index 9e87bba..5780481 100644 --- a/man/install_themes.Rd +++ b/man/install_themes.Rd @@ -18,8 +18,7 @@ variants can be selected anytime later in RStudio's global options. Variation on \item \code{"Tomorrow Night Bright (rscodeio)"} for the colors known from the similarly named default RStudio theme. }} -\item{style_menu_bar}{Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required. On macOS and -RStudio Server, menu bar styling is not necessary and thus always skipped.} +\item{style_menu_bar}{Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required.} \item{install_globally}{Whether to install the editor themes for the current user (\code{FALSE}) or all users globally (\code{TRUE}). The latter may require administrator privileges.} From b5dd9959a9c7d7a51a0d7c773392466119704cf3 Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 15 Oct 2020 18:07:29 +0200 Subject: [PATCH 19/34] set per-project Rmd formatting harmonization this is performed by Pandoc under the hood and only available in RStudio 1.4+, see https://rstudio.github.io/visual-markdown-editing/ --- rscodeio.Rproj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rscodeio.Rproj b/rscodeio.Rproj index 69fafd4..c542d93 100644 --- a/rscodeio.Rproj +++ b/rscodeio.Rproj @@ -20,3 +20,8 @@ BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageRoxygenize: rd,collate,namespace + +MarkdownWrap: Column +MarkdownWrapAtColumn: 160 +MarkdownReferences: Section +MarkdownCanonical: Yes From 2ee99f962eb756b3e2b3f3618299f619e307e410 Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 15 Oct 2020 18:08:25 +0200 Subject: [PATCH 20/34] update README and overhaul it to be more clear/precise --- README.md | 115 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 80 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index fbab339..0e4f650 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,110 @@ -

- +

+ + +

- - cran - - - release - - - lifecycle - + + cran + +release + +lifecycle +

# rscodeio -An RStudio theme inspired by Visual Studio Code. +An RStudio theme inspired by Visual Studio Code + +## Prerequisites -# Prerequisites +- RStudio 1.2.0 or later -RStudio 1.2.x or higher. +- Administrator privileges (more on that [below](#details)) -# Installation +## Installation -Get the package: +Run the following to install the package: + +``` {.r} +if (!("remotes" %in% rownames(installed.packages()))) { + install.packages(pkgs = "remotes", + repos = "https://cloud.r-project.org/") +} -```r remotes::install_github("anthonynorth/rscodeio") ``` -`rscodeio` modifies the theme of RStudio menus. These are not exposed by the current theming API and so this is achieved by modifying style sheets in the RStudio installation. To modify files in this area will likely require the installation to be run with administrator privileges. To do this: +Then run the following to install the rscodeio editor themes and menu bar styling: -- On Windows start RStudio by right clicking on a shortcut or menu icon and selecting 'Run as Administrator' -- On Linux start RStudio in a terminal using `sudo rstudio --no-sandbox` -- On Mac this is not required. Theming the menus is not supported. - - They're inherited from OS so might want to use your dark OS theme. +``` {.r} +rscodeio::install_themes() +``` -From within RStudio running as administrator, run this command to install and apply the theme: +The above command right away activates the editor theme variant specified in the `apply_theme` argument (which defaults to `"rscodeio"`). To activate the second +editor theme variant instead, run: +``` {.r} +rscodeio::install_themes(apply_theme = "Tomorrow Night Bright (rscodeio)") ``` -rscodeio::install_theme() + +The chosen editor theme can be changed anytime later in RStudio's global options. + +To completely uninstall the rscodeio editor themes and menu bar styling again, run: + +``` {.r} +rscodeio::uninstall_themes() ``` -And close RStudio. Reopen it in the normal way and the theme should be fully applied. +## Details {#details} -Once installed it can also be selected using the RStudio theme picker in the usual way. +This package provides two greyish dark RStudio editor themes which only differ in the syntax highlighting style: while `rscodeio` offers the colors found in +Visual Studio Code, `Tomorrow Night Bright (rscodeio)` combines the same dark interface theming with the syntax highlighting colors from the similarly named +editor theme provided by RStudio. -# Recommended RStudio settings +Furthermore, RStudio's menu bar will be changed to a matching dark style, something which is not exposed by [RStudio's current theming +API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html) and therefore requires administrator privileges to replace the relevant [Qt Style +Sheet (QSS)](https://doc.qt.io/Qt-5/stylesheet-syntax.html) files in RStudio's installation directory. + +- On Linux, it will be asked interactively for administrator credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s + [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). + +- On Windows, RStudio must be run as administrator for rscodeio being able to successfully install the menu bar styling. + +- On macOS and RStudio Server, menu bar styling is not necessary and thus administrator privileges are not required. (On macOS, the light/dark menu bar + styling is inherited from the OS, so you might want to use your dark OS theme.) + +### Recommended RStudio settings For best results, make sure the following settings are enabled: -- ToolsGlobal Options…CodeDisplay → **☑ Highlight selected line** -- ToolsGlobal Options…CodeDisplay → **☑ Show indent guides** -- ToolsGlobal Options…CodeDisplay → **☑ Show syntax highlighting in console input** -- ToolsGlobal Options…CodeDisplay → **☑ Highlight R function calls** +- ToolsGlobal Options...CodeDisplay → **☑ Highlight selected line** +- ToolsGlobal Options...CodeDisplay → **☑ Show indent guides** +- ToolsGlobal Options...CodeDisplay → **☑ Show syntax highlighting in console input** +- ToolsGlobal Options...CodeDisplay → **☑ Highlight R function calls** + +### Switching to another theme + +As mentioned above, rscodeio provides custom editor theme variants but also styles RStudio's menu bar by modifying some QSS files. This means the RStudio menu +bar will remain dark even if you switch to another editor theme. To revert the menu bar to its default state, **administrator privileges are required**. -# Switching to another theme +To only remove the menu bar styling, run + +``` {.r} +rscodeio::uninstall_menu_theme() +``` + +To reinstall the menu bar styling again, run + +``` {.r} +rscodeio::install_menu_theme() +``` -`rscodeio` modifies UI elements that are not part of standard theming. This means the RStudio file menus will remain dark even if you switch to another theme. To revert them, within an RStudio session run as administrator, use: `rscodeio::deactivate_menu_theme`. Reactivate again with: `rscodeio::activate_menu_theme`. +On Windows, for both of the above to work, Rstudio must be run as administrator. -# Supported Platforms +### Supported Platforms -`rscodeio` has only been tested on Windows and Pop!\_OS Linux so far. [Feedback](https://github.com/anthonynorth/rscodeio/issues) from other platforms welcome. +`rscodeio` has only been tested on Windows and Linux (Ubuntu and Pop!\_OS Linux) so far. [Feedback](https://github.com/anthonynorth/rscodeio/issues) from other +platforms is welcome. From 5e15c2da415e75a77eff6e2ec17a854b8620dd4c Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 15 Oct 2020 18:09:03 +0200 Subject: [PATCH 21/34] be more precise about QSS terminology --- R/rscodeio.R | 34 ++++++++++++++++++---------------- man/install_menu_theme.Rd | 6 +++--- man/install_themes.Rd | 16 +++++++--------- man/uninstall_menu_theme.Rd | 2 +- man/uninstall_themes.Rd | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/R/rscodeio.R b/R/rscodeio.R index 67a08d0..29c8095 100644 --- a/R/rscodeio.R +++ b/R/rscodeio.R @@ -1,7 +1,8 @@ #' Install rscodeio editor themes and menu bar styling #' -#' RStudio 1.2 or later is required for this. Additionally, administrator privileges are required to also install the Qt CSS (QSS) files to style RStudio's menu -#' bar, something which is not possible with [RStudio's built-in theming API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html). +#' RStudio 1.2 or later is required for this. Additionally, administrator privileges are required to also install the Qt Style Sheet (QSS) files to style +#' RStudio's menu bar, something which is not possible with [RStudio's current theming +#' API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html). #' #' # Menu bar styling #' @@ -9,13 +10,13 @@ #' [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). Windows users must run RStudio as administrator in order to install #' rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is not necessary and thus always skipped. #' -#' The installation of the menu theme files can be skipped by setting `style_menu_bar = FALSE`. See [install_menu_theme()] for more details about the menu bar -#' styling. +#' The installation of the QSS files styling the menu bar can be skipped by setting `style_menu_bar = FALSE`. See [install_menu_theme()] for more details about +#' the menu bar styling. #' #' @param apply_theme The rscodeio editor theme variant to apply. All variants are installed and the one specified here is activated right away. The other -#' variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of -#' - `"rscodeio"` for the default color variant inspired by Visual Studio Code. -#' - `"Tomorrow Night Bright (rscodeio)"` for the colors known from the similarly named default RStudio theme. +#' variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of - +#' `"rscodeio"` for the default color variant inspired by Visual Studio Code. - `"Tomorrow Night Bright (rscodeio)"` for the colors known from the similarly +#' named default RStudio theme. #' @param style_menu_bar Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required. #' @param install_globally Whether to install the editor themes for the current user (`FALSE`) or all users globally (`TRUE`). The latter may require #' administrator privileges. @@ -47,7 +48,7 @@ install_themes <- function(apply_theme = c("rscodeio", "resources", .x), globally = install_globally)) - # add the custom Qt CSS (QSS) + # add the custom QSS files if (style_menu_bar) install_menu_theme() # activate chosen rscodeio editor theme variant @@ -56,7 +57,7 @@ install_themes <- function(apply_theme = c("rscodeio", #' Uninstall the rscodeio editor themes and menu bar styling #' -#' To restore RStudio's default _dark_ Qt theme (`.qss`) files (i.e. setting `restore_menu_bar = TRUE`), administrator privileges are required. On Linux, it +#' To restore RStudio's default _dark_ Qt Style Sheet (QSS) files (i.e. setting `restore_menu_bar = TRUE`), administrator privileges are required. On Linux, it #' will be asked interactively for administrator credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s #' [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). Windows users must run RStudio as administrator in order to uninstall #' rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is not necessary and thus its menu bar restoration will be skipped. @@ -75,9 +76,10 @@ uninstall_themes <- function(restore_menu_bar = TRUE) { #' Install rscodeio menu bar styling #' -#' This function overwrites RStudio's default _dark_ Qt theme (`.qss`) files with rscodeio's customized ones in order to properly style RStudio's menu bar which -#' cannot be altered by [RStudio's current theming API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html). The original Qt theme files -#' are backed up and can be restored by calling [uninstall_menu_theme()]. +#' This function overwrites RStudio's default _dark_ [Qt Style Sheet (QSS)](https://doc.qt.io/Qt-5/stylesheet-syntax.html) files with rscodeio's customized ones +#' in order to properly style RStudio's menu bar which cannot be altered by [RStudio's current theming +#' API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html). The original Qt Style Sheet files are backed up and can be restored by +#' calling [uninstall_menu_theme()]. #' #' Running [`install_themes(style_menu_bar = TRUE)`][install_themes()] (which is the default) has the same effect as running this function. #' `install_menu_theme()` can be useful to install the rscodeio menu bar styling _without_ the accompanying editor themes. @@ -101,7 +103,7 @@ install_menu_theme <- function() { #' Uninstall rscodeio menu bar styling #' -#' This function restores RStudio's default _dark_ Qt theme (`.qss`) files. +#' This function restores RStudio's default _dark_ Qt [Qt Style Sheet (QSS)](https://doc.qt.io/Qt-5/stylesheet-syntax.html) files. #' #' Running [`uninstall_themes(restore_menu_bar = TRUE)`][uninstall_themes()] (which is the default) has the same effect as running this function. #' `uninstall_menu_theme()` can be useful to remove the rscodeio menu bar styling _without_ removing the accompanying editor themes. @@ -129,13 +131,13 @@ uninstall_menu_theme <- function() { # shouldn't really happen if (exists_theme_dark_gnome_backup && is_rscodeio_menu_theme(path_theme_dark_gnome_backup)) { - stop("The following backed up file supposed to be an RStudio Qt theme is actually an rscodeio theme:\n", path_theme_dark_gnome_backup, "\n", - "Delete the file if you'd like this error to be gone.\nUsing the R console: fs::file_delete(rscodeio:::path_theme_dark_gnome_backup())", + stop("The following backed up file supposed to be an unmodified RStudio QSS file is actually an rscodeio QSS file:\n", path_theme_dark_gnome_backup, + "\n", "Delete the file if you'd like this error to be gone.\nUsing the R console: fs::file_delete(rscodeio:::path_theme_dark_gnome_backup())", call. = FALSE) } if (exists_theme_dark_windows_backup && is_rscodeio_menu_theme(path_theme_dark_windows_backup)) { - stop("The following backed up file supposed to be an RStudio Qt theme is actually an rscodeio theme:\n", path_theme_dark_windows_backup, "\n", + stop("The following backed up file supposed to be an unmodified RStudio QSS file is actually an rscodeio QSS file:\n", path_theme_dark_windows_backup, "\n", "Delete the file if you'd like this error to be gone.\nUsing the R console: fs::file_delete(rscodeio:::path_theme_dark_windows_backup())", call. = FALSE) } diff --git a/man/install_menu_theme.Rd b/man/install_menu_theme.Rd index 8d37aed..185b567 100644 --- a/man/install_menu_theme.Rd +++ b/man/install_menu_theme.Rd @@ -10,9 +10,9 @@ install_menu_theme() Nothing (\code{NULL} invisibly). } \description{ -This function overwrites RStudio's default \emph{dark} Qt theme (\code{.qss}) files with rscodeio's customized ones in order to properly style RStudio's menu bar which -cannot be altered by \href{https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html}{RStudio's current theming API}. The original Qt theme files -are backed up and can be restored by calling \code{\link[=uninstall_menu_theme]{uninstall_menu_theme()}}. +This function overwrites RStudio's default \emph{dark} \href{https://doc.qt.io/Qt-5/stylesheet-syntax.html}{Qt Style Sheet (QSS)} files with rscodeio's customized ones +in order to properly style RStudio's menu bar which cannot be altered by \href{https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html}{RStudio's current theming API}. The original Qt Style Sheet files are backed up and can be restored by +calling \code{\link[=uninstall_menu_theme]{uninstall_menu_theme()}}. } \details{ Running \code{\link[=install_themes]{install_themes(style_menu_bar = TRUE)}} (which is the default) has the same effect as running this function. diff --git a/man/install_themes.Rd b/man/install_themes.Rd index 5780481..c664228 100644 --- a/man/install_themes.Rd +++ b/man/install_themes.Rd @@ -12,11 +12,9 @@ install_themes( } \arguments{ \item{apply_theme}{The rscodeio editor theme variant to apply. All variants are installed and the one specified here is activated right away. The other -variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of -\itemize{ -\item \code{"rscodeio"} for the default color variant inspired by Visual Studio Code. -\item \code{"Tomorrow Night Bright (rscodeio)"} for the colors known from the similarly named default RStudio theme. -}} +variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of - +\code{"rscodeio"} for the default color variant inspired by Visual Studio Code. - \code{"Tomorrow Night Bright (rscodeio)"} for the colors known from the similarly +named default RStudio theme.} \item{style_menu_bar}{Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required.} @@ -27,15 +25,15 @@ administrator privileges.} Nothing (\code{NULL} invisibly). } \description{ -RStudio 1.2 or later is required for this. Additionally, administrator privileges are required to also install the Qt CSS (QSS) files to style RStudio's menu -bar, something which is not possible with \href{https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html}{RStudio's built-in theming API}. +RStudio 1.2 or later is required for this. Additionally, administrator privileges are required to also install the Qt Style Sheet (QSS) files to style +RStudio's menu bar, something which is not possible with \href{https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html}{RStudio's current theming API}. } \section{Menu bar styling}{ On Linux, it will be asked interactively for administrator credentials by calling \href{https://en.wikipedia.org/wiki/Polkit}{Polkit}'s \href{https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html}{\code{pkexec}}. Windows users must run RStudio as administrator in order to install rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is not necessary and thus always skipped. -The installation of the menu theme files can be skipped by setting \code{style_menu_bar = FALSE}. See \code{\link[=install_menu_theme]{install_menu_theme()}} for more details about the menu bar -styling. +The installation of the QSS files styling the menu bar can be skipped by setting \code{style_menu_bar = FALSE}. See \code{\link[=install_menu_theme]{install_menu_theme()}} for more details about +the menu bar styling. } diff --git a/man/uninstall_menu_theme.Rd b/man/uninstall_menu_theme.Rd index 5dc1b5f..bb0801f 100644 --- a/man/uninstall_menu_theme.Rd +++ b/man/uninstall_menu_theme.Rd @@ -10,7 +10,7 @@ uninstall_menu_theme() Nothing (\code{NULL} invisibly). } \description{ -This function restores RStudio's default \emph{dark} Qt theme (\code{.qss}) files. +This function restores RStudio's default \emph{dark} Qt \href{https://doc.qt.io/Qt-5/stylesheet-syntax.html}{Qt Style Sheet (QSS)} files. } \details{ Running \code{\link[=uninstall_themes]{uninstall_themes(restore_menu_bar = TRUE)}} (which is the default) has the same effect as running this function. diff --git a/man/uninstall_themes.Rd b/man/uninstall_themes.Rd index 67a2ca1..cb7db79 100644 --- a/man/uninstall_themes.Rd +++ b/man/uninstall_themes.Rd @@ -14,7 +14,7 @@ uninstall_themes(restore_menu_bar = TRUE) Nothing (\code{NULL} invisibly). } \description{ -To restore RStudio's default \emph{dark} Qt theme (\code{.qss}) files (i.e. setting \code{restore_menu_bar = TRUE}), administrator privileges are required. On Linux, it +To restore RStudio's default \emph{dark} Qt Style Sheet (QSS) files (i.e. setting \code{restore_menu_bar = TRUE}), administrator privileges are required. On Linux, it will be asked interactively for administrator credentials by calling \href{https://en.wikipedia.org/wiki/Polkit}{Polkit}'s \href{https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html}{\code{pkexec}}. Windows users must run RStudio as administrator in order to uninstall rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is not necessary and thus its menu bar restoration will be skipped. From cb9ebdf963d78522c184611a91c31912cbf2bc5e Mon Sep 17 00:00:00 2001 From: Salim B Date: Fri, 16 Oct 2020 17:07:51 +0200 Subject: [PATCH 22/34] fix formatting of doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (RStudio's built-in auto-formatting broke the proper Markdown syntax 😒) --- R/rscodeio.R | 6 +++--- man/install_themes.Rd | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/R/rscodeio.R b/R/rscodeio.R index 29c8095..cef55d4 100644 --- a/R/rscodeio.R +++ b/R/rscodeio.R @@ -14,9 +14,9 @@ #' the menu bar styling. #' #' @param apply_theme The rscodeio editor theme variant to apply. All variants are installed and the one specified here is activated right away. The other -#' variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of - -#' `"rscodeio"` for the default color variant inspired by Visual Studio Code. - `"Tomorrow Night Bright (rscodeio)"` for the colors known from the similarly -#' named default RStudio theme. +#' variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of +#' - `"rscodeio"` for the default color variant inspired by Visual Studio Code. +#' - `"Tomorrow Night Bright (rscodeio)"` for the colors known from the similarly named default RStudio theme. #' @param style_menu_bar Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required. #' @param install_globally Whether to install the editor themes for the current user (`FALSE`) or all users globally (`TRUE`). The latter may require #' administrator privileges. diff --git a/man/install_themes.Rd b/man/install_themes.Rd index c664228..b782d68 100644 --- a/man/install_themes.Rd +++ b/man/install_themes.Rd @@ -12,9 +12,11 @@ install_themes( } \arguments{ \item{apply_theme}{The rscodeio editor theme variant to apply. All variants are installed and the one specified here is activated right away. The other -variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of - -\code{"rscodeio"} for the default color variant inspired by Visual Studio Code. - \code{"Tomorrow Night Bright (rscodeio)"} for the colors known from the similarly -named default RStudio theme.} +variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of +\itemize{ +\item \code{"rscodeio"} for the default color variant inspired by Visual Studio Code. +\item \code{"Tomorrow Night Bright (rscodeio)"} for the colors known from the similarly named default RStudio theme. +}} \item{style_menu_bar}{Whether to also install rscodeio's custom QSS files to style RStudio's menu bar. Administrator privileges are required.} From 964295b201581bc55e3ce5492a3abd7aab895589 Mon Sep 17 00:00:00 2001 From: Salim B Date: Sat, 17 Oct 2020 16:02:37 +0200 Subject: [PATCH 23/34] be more precise --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e4f650..cb76757 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ For best results, make sure the following settings are enabled: ### Switching to another theme -As mentioned above, rscodeio provides custom editor theme variants but also styles RStudio's menu bar by modifying some QSS files. This means the RStudio menu +As mentioned above, rscodeio provides custom editor theme variants but also styles RStudio's menu bar by replacing some QSS files. This means the RStudio menu bar will remain dark even if you switch to another editor theme. To revert the menu bar to its default state, **administrator privileges are required**. To only remove the menu bar styling, run From 35892ffbf03ac6dbeb787c7182682448cf3e897f Mon Sep 17 00:00:00 2001 From: Salim B Date: Sat, 17 Oct 2020 16:03:55 +0200 Subject: [PATCH 24/34] mention necessary menu bar styling reinstallation after RStudio update --- R/rscodeio.R | 6 ++++++ README.md | 3 +++ man/install_menu_theme.Rd | 3 +++ man/install_themes.Rd | 3 +++ 4 files changed, 15 insertions(+) diff --git a/R/rscodeio.R b/R/rscodeio.R index cef55d4..98fd322 100644 --- a/R/rscodeio.R +++ b/R/rscodeio.R @@ -13,6 +13,9 @@ #' The installation of the QSS files styling the menu bar can be skipped by setting `style_menu_bar = FALSE`. See [install_menu_theme()] for more details about #' the menu bar styling. #' +#' Note that the menu bar styling has to be reapplied after _every_ update or reinstallation of RStudio. This is because the custom QSS files provided by +#' rscodeio get overwritten during RStudio's installation process. +#' #' @param apply_theme The rscodeio editor theme variant to apply. All variants are installed and the one specified here is activated right away. The other #' variants can be selected anytime later in RStudio's global options. Variation only affects the syntax highlighting and terminal styling. One of #' - `"rscodeio"` for the default color variant inspired by Visual Studio Code. @@ -88,6 +91,9 @@ uninstall_themes <- function(restore_menu_bar = TRUE) { #' credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). #' Windows users must run RStudio as administrator On macOS and RStudio Server, menu bar styling is not necessary and running this function has no effect. #' +#' Note that this function has to be executed again after _every_ update or reinstallation of RStudio. This is because the custom QSS files provided by rscodeio +#' get overwritten during RStudio's installation process. +#' #' @return Nothing (`NULL` invisibly). #' @export install_menu_theme <- function() { diff --git a/README.md b/README.md index cb76757..ee17530 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,9 @@ rscodeio::install_menu_theme() On Windows, for both of the above to work, Rstudio must be run as administrator. +**Note** that the menu bar styling has to be reinstalled after *every* update or reinstallation of RStudio. This is because the custom QSS files provided by +rscodeio get overwritten during RStudio's installation process. + ### Supported Platforms `rscodeio` has only been tested on Windows and Linux (Ubuntu and Pop!\_OS Linux) so far. [Feedback](https://github.com/anthonynorth/rscodeio/issues) from other diff --git a/man/install_menu_theme.Rd b/man/install_menu_theme.Rd index 185b567..55bf771 100644 --- a/man/install_menu_theme.Rd +++ b/man/install_menu_theme.Rd @@ -21,4 +21,7 @@ Running \code{\link[=install_themes]{install_themes(style_menu_bar = TRUE)}} (wh Administrator privileges are required to copy the QSS files to RStudio's installation directory. On Linux, it will be asked interactively for administrator credentials by calling \href{https://en.wikipedia.org/wiki/Polkit}{Polkit}'s \href{https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html}{\code{pkexec}}. Windows users must run RStudio as administrator On macOS and RStudio Server, menu bar styling is not necessary and running this function has no effect. + +Note that this function has to be executed again after \emph{every} update or reinstallation of RStudio. This is because the custom QSS files provided by rscodeio +get overwritten during RStudio's installation process. } diff --git a/man/install_themes.Rd b/man/install_themes.Rd index b782d68..768b319 100644 --- a/man/install_themes.Rd +++ b/man/install_themes.Rd @@ -37,5 +37,8 @@ rscodeio's menu bar styling. On macOS and RStudio Server, menu bar styling is no The installation of the QSS files styling the menu bar can be skipped by setting \code{style_menu_bar = FALSE}. See \code{\link[=install_menu_theme]{install_menu_theme()}} for more details about the menu bar styling. + +Note that the menu bar styling has to be reapplied after \emph{every} update or reinstallation of RStudio. This is because the custom QSS files provided by +rscodeio get overwritten during RStudio's installation process. } From 59303cf7011caf4dc9633909c6687f142cf8e9f7 Mon Sep 17 00:00:00 2001 From: Salim B Date: Sat, 17 Oct 2020 16:07:15 +0200 Subject: [PATCH 25/34] update pkg version (dev) --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7bcc6cc..a964e08 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rscodeio Title: An RStudio Theme Inspired by Visual Studio Code -Version: 0.1.0 +Version: 0.1.9000 Authors@R: c(person(given = "Anthony", family = "North", From 8a9e739664760435cc06da6095f1c3f4cb694e99 Mon Sep 17 00:00:00 2001 From: Salim B Date: Fri, 23 Oct 2020 03:15:07 +0200 Subject: [PATCH 26/34] `install_menu_theme()`: add param `reload_editor_theme` --- R/rscodeio.R | 8 ++++++-- man/install_menu_theme.Rd | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/R/rscodeio.R b/R/rscodeio.R index 98fd322..9ba2f1b 100644 --- a/R/rscodeio.R +++ b/R/rscodeio.R @@ -52,7 +52,7 @@ install_themes <- function(apply_theme = c("rscodeio", globally = install_globally)) # add the custom QSS files - if (style_menu_bar) install_menu_theme() + if (style_menu_bar) install_menu_theme(reload_editor_theme = FALSE) # activate chosen rscodeio editor theme variant rstudioapi::applyTheme(rlang::arg_match(apply_theme)) @@ -94,9 +94,11 @@ uninstall_themes <- function(restore_menu_bar = TRUE) { #' Note that this function has to be executed again after _every_ update or reinstallation of RStudio. This is because the custom QSS files provided by rscodeio #' get overwritten during RStudio's installation process. #' +#' @param reload_editor_theme Whether to reload the editor theme upon installing rscodeio's menu bar styling. This is necessary for the changes to take effect +#' immediately. Otherwise, the changes will only become visible after a restart of RStudio. #' @return Nothing (`NULL` invisibly). #' @export -install_menu_theme <- function() { +install_menu_theme <- function(reload_editor_theme = TRUE) { # menu bar styling is not supported on macOS or RStudio Server if (is_macos() || is_rstudio_server()) return(NULL) @@ -105,6 +107,8 @@ install_menu_theme <- function() { backup_windows = !is_rscodeio_menu_theme(path_theme_dark_windows()), override_gnome = TRUE, override_windows = TRUE) + + if (reload_editor_theme) rstudioapi::applyTheme(rstudioapi::getThemeInfo()$editor) } #' Uninstall rscodeio menu bar styling diff --git a/man/install_menu_theme.Rd b/man/install_menu_theme.Rd index 55bf771..87d4f26 100644 --- a/man/install_menu_theme.Rd +++ b/man/install_menu_theme.Rd @@ -4,7 +4,11 @@ \alias{install_menu_theme} \title{Install rscodeio menu bar styling} \usage{ -install_menu_theme() +install_menu_theme(reload_editor_theme = TRUE) +} +\arguments{ +\item{reload_editor_theme}{Whether to reload the editor theme upon installing rscodeio's menu bar styling. This is necessary for the changes to take effect +immediately. Otherwise, the changes will only become visible after a restart of RStudio.} } \value{ Nothing (\code{NULL} invisibly). From 24859dfdaa97dbf170c361c46e93c5a196c92a7b Mon Sep 17 00:00:00 2001 From: Salim B Date: Wed, 27 Jan 2021 12:52:24 +0100 Subject: [PATCH 27/34] write README in R Markdown format and let knitr/Pandoc create `README.md` --- README.Rmd | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 104 ++++++++++++++++++++++++++++++----------------- 2 files changed, 183 insertions(+), 38 deletions(-) create mode 100644 README.Rmd diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..166bd9e --- /dev/null +++ b/README.Rmd @@ -0,0 +1,117 @@ +--- +output: rmarkdown::github_document +--- + +

+ + + +

+ +

+ + cran + +release + +lifecycle + +

+ +# rscodeio + +An RStudio theme inspired by Visual Studio Code + +## Prerequisites + +- RStudio 1.2.0 or later + +- Administrator privileges (more on that [below](#details)) + +## Installation + +Run the following to install the package: + +``` {.r} +if (!("remotes" %in% rownames(installed.packages()))) { + install.packages(pkgs = "remotes", + repos = "https://cloud.r-project.org/") +} + +remotes::install_github("anthonynorth/rscodeio") +``` + +Then run the following to install the rscodeio editor themes and menu bar styling: + +``` {.r} +rscodeio::install_themes() +``` + +The above command right away activates the editor theme variant specified in the `apply_theme` argument (which defaults to `"rscodeio"`). To activate the second +editor theme variant instead, run: + +``` {.r} +rscodeio::install_themes(apply_theme = "Tomorrow Night Bright (rscodeio)") +``` + +The chosen editor theme can be changed anytime later in RStudio's global options. + +To completely uninstall the rscodeio editor themes and menu bar styling again, run: + +``` {.r} +rscodeio::uninstall_themes() +``` + +## Details {#details} + +This package provides two greyish dark RStudio editor themes which only differ in the syntax highlighting style: while `rscodeio` offers the colors found in +Visual Studio Code, `Tomorrow Night Bright (rscodeio)` combines the same dark interface theming with the syntax highlighting colors from the similarly named +editor theme provided by RStudio. + +Furthermore, RStudio's menu bar will be changed to a matching dark style, something which is not exposed by [RStudio's current theming +API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html) and therefore requires administrator privileges to replace the relevant [Qt Style +Sheet (QSS)](https://doc.qt.io/Qt-5/stylesheet-syntax.html) files in RStudio's installation directory. + +- On Linux, it will be asked interactively for administrator credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s + [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). + +- On Windows, RStudio must be run as administrator for rscodeio being able to successfully install the menu bar styling. + +- On macOS and RStudio Server, menu bar styling is not necessary and thus administrator privileges are not required. (On macOS, the light/dark menu bar + styling is inherited from the OS, so you might want to use your dark OS theme.) + +### Recommended RStudio settings + +For best results, make sure the following settings are enabled: + +- ToolsGlobal Options...CodeDisplay → **☑ Highlight selected line** +- ToolsGlobal Options...CodeDisplay → **☑ Show indent guides** +- ToolsGlobal Options...CodeDisplay → **☑ Show syntax highlighting in console input** +- ToolsGlobal Options...CodeDisplay → **☑ Highlight R function calls** + +### Switching to another theme + +As mentioned above, rscodeio provides custom editor theme variants but also styles RStudio's menu bar by replacing some QSS files. This means the RStudio menu +bar will remain dark even if you switch to another editor theme. To revert the menu bar to its default state, **administrator privileges are required**. + +To only remove the menu bar styling, run + +``` {.r} +rscodeio::uninstall_menu_theme() +``` + +To reinstall the menu bar styling again, run + +``` {.r} +rscodeio::install_menu_theme() +``` + +On Windows, for both of the above to work, Rstudio must be run as administrator. + +**Note** that the menu bar styling has to be reinstalled after *every* update or reinstallation of RStudio. This is because the custom QSS files provided by +rscodeio get overwritten during RStudio's installation process. + +### Supported Platforms + +`rscodeio` has only been tested on Windows and Linux (Ubuntu and Pop!\_OS Linux) so far. [Feedback](https://github.com/anthonynorth/rscodeio/issues) from other +platforms is welcome. diff --git a/README.md b/README.md index ee17530..4116000 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,18 @@ +

-

- cran - -release - -lifecycle + +cran + +release + +lifecycle +

@@ -28,7 +30,7 @@ An RStudio theme inspired by Visual Studio Code Run the following to install the package: -``` {.r} +``` r if (!("remotes" %in% rownames(installed.packages()))) { install.packages(pkgs = "remotes", repos = "https://cloud.r-project.org/") @@ -37,77 +39,103 @@ if (!("remotes" %in% rownames(installed.packages()))) { remotes::install_github("anthonynorth/rscodeio") ``` -Then run the following to install the rscodeio editor themes and menu bar styling: +Then run the following to install the rscodeio editor themes and menu +bar styling: -``` {.r} +``` r rscodeio::install_themes() ``` -The above command right away activates the editor theme variant specified in the `apply_theme` argument (which defaults to `"rscodeio"`). To activate the second -editor theme variant instead, run: +The above command right away activates the editor theme variant +specified in the `apply_theme` argument (which defaults to +`"rscodeio"`). To activate the second editor theme variant instead, run: -``` {.r} +``` r rscodeio::install_themes(apply_theme = "Tomorrow Night Bright (rscodeio)") ``` -The chosen editor theme can be changed anytime later in RStudio's global options. +The chosen editor theme can be changed anytime later in RStudio’s global +options. -To completely uninstall the rscodeio editor themes and menu bar styling again, run: +To completely uninstall the rscodeio editor themes and menu bar styling +again, run: -``` {.r} +``` r rscodeio::uninstall_themes() ``` -## Details {#details} +## Details -This package provides two greyish dark RStudio editor themes which only differ in the syntax highlighting style: while `rscodeio` offers the colors found in -Visual Studio Code, `Tomorrow Night Bright (rscodeio)` combines the same dark interface theming with the syntax highlighting colors from the similarly named -editor theme provided by RStudio. +This package provides two greyish dark RStudio editor themes which only +differ in the syntax highlighting style: while `rscodeio` offers the +colors found in Visual Studio Code, `Tomorrow Night Bright (rscodeio)` +combines the same dark interface theming with the syntax highlighting +colors from the similarly named editor theme provided by RStudio. -Furthermore, RStudio's menu bar will be changed to a matching dark style, something which is not exposed by [RStudio's current theming -API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html) and therefore requires administrator privileges to replace the relevant [Qt Style -Sheet (QSS)](https://doc.qt.io/Qt-5/stylesheet-syntax.html) files in RStudio's installation directory. +Furthermore, RStudio’s menu bar will be changed to a matching dark +style, something which is not exposed by [RStudio’s current theming +API](https://rstudio.github.io/rstudio-extensions/rstudio-theme-creation.html) +and therefore requires administrator privileges to replace the relevant +[Qt Style Sheet (QSS)](https://doc.qt.io/Qt-5/stylesheet-syntax.html) +files in RStudio’s installation directory. -- On Linux, it will be asked interactively for administrator credentials by calling [Polkit](https://en.wikipedia.org/wiki/Polkit)'s +- On Linux, it will be asked interactively for administrator + credentials by calling + [Polkit](https://en.wikipedia.org/wiki/Polkit)’s [`pkexec`](https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html). -- On Windows, RStudio must be run as administrator for rscodeio being able to successfully install the menu bar styling. +- On Windows, RStudio must be run as administrator for rscodeio being + able to successfully install the menu bar styling. -- On macOS and RStudio Server, menu bar styling is not necessary and thus administrator privileges are not required. (On macOS, the light/dark menu bar - styling is inherited from the OS, so you might want to use your dark OS theme.) +- On macOS and RStudio Server, menu bar styling is not necessary and + thus administrator privileges are not required. (On macOS, the + light/dark menu bar styling is inherited from the OS, so you might + want to use your dark OS theme.) ### Recommended RStudio settings For best results, make sure the following settings are enabled: -- ToolsGlobal Options...CodeDisplay → **☑ Highlight selected line** -- ToolsGlobal Options...CodeDisplay → **☑ Show indent guides** -- ToolsGlobal Options...CodeDisplay → **☑ Show syntax highlighting in console input** -- ToolsGlobal Options...CodeDisplay → **☑ Highlight R function calls** +- ToolsGlobal Options…Code → + Display → **☑ Highlight selected line** +- ToolsGlobal Options…Code → + Display → **☑ Show indent guides** +- ToolsGlobal Options…Code → + Display → **☑ Show syntax highlighting in console input** +- ToolsGlobal Options…Code → + Display → **☑ Highlight R function calls** ### Switching to another theme -As mentioned above, rscodeio provides custom editor theme variants but also styles RStudio's menu bar by replacing some QSS files. This means the RStudio menu -bar will remain dark even if you switch to another editor theme. To revert the menu bar to its default state, **administrator privileges are required**. +As mentioned above, rscodeio provides custom editor theme variants but +also styles RStudio’s menu bar by replacing some QSS files. This means +the RStudio menu bar will remain dark even if you switch to another +editor theme. To revert the menu bar to its default state, +**administrator privileges are required**. To only remove the menu bar styling, run -``` {.r} +``` r rscodeio::uninstall_menu_theme() ``` To reinstall the menu bar styling again, run -``` {.r} +``` r rscodeio::install_menu_theme() ``` -On Windows, for both of the above to work, Rstudio must be run as administrator. +On Windows, for both of the above to work, Rstudio must be run as +administrator. -**Note** that the menu bar styling has to be reinstalled after *every* update or reinstallation of RStudio. This is because the custom QSS files provided by -rscodeio get overwritten during RStudio's installation process. +**Note** that the menu bar styling has to be reinstalled after *every* +update or reinstallation of RStudio. This is because the custom QSS +files provided by rscodeio get overwritten during RStudio’s installation +process. ### Supported Platforms -`rscodeio` has only been tested on Windows and Linux (Ubuntu and Pop!\_OS Linux) so far. [Feedback](https://github.com/anthonynorth/rscodeio/issues) from other +`rscodeio` has only been tested on Windows and Linux (Ubuntu and +Pop!\_OS Linux) so far. +[Feedback](https://github.com/anthonynorth/rscodeio/issues) from other platforms is welcome. From c3db00e05acf4f41e054da7b400997cae6418ae3 Mon Sep 17 00:00:00 2001 From: Salim B Date: Sat, 30 Apr 2022 12:25:56 +0200 Subject: [PATCH 28/34] gitignore README source file --- .Rbuildignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index 4c39bbd..8cfd41d 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,4 +5,6 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +# other ^LICENSE\.md$ +^README\.Rmd$ From c00d74d380a33662acfc747b289e2ce9732f2c22 Mon Sep 17 00:00:00 2001 From: Salim B Date: Sat, 30 Apr 2022 12:26:13 +0200 Subject: [PATCH 29/34] update RoxygenNote --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index a964e08..30eda8e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,4 +36,4 @@ Imports: Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.2 From 6fc324c3dff00714d833b51a09143b73d3bcfaea Mon Sep 17 00:00:00 2001 From: Salim B Date: Sat, 30 Apr 2022 13:15:13 +0200 Subject: [PATCH 30/34] tweak help pane CSS i.a. updates related to R 4.2.0's doc enhancements, cf. https://developer.r-project.org/Blog/public/2022/04/08/enhancements-to-html-documentation/index.html --- .../rscodeio_tomorrow_night_bright.rstheme | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/inst/resources/rscodeio_tomorrow_night_bright.rstheme b/inst/resources/rscodeio_tomorrow_night_bright.rstheme index 636d3af..b83997c 100644 --- a/inst/resources/rscodeio_tomorrow_night_bright.rstheme +++ b/inst/resources/rscodeio_tomorrow_night_bright.rstheme @@ -987,28 +987,33 @@ .rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme h4, .rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme h5, .rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme h6 { - line-height: 1.75 !important; color: #DEDEDE !important; + line-height: 1.75 !important; } -.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme pre, .rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme code { - font-family: "Fira Code", Ubuntu, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; - font-size: 85%; - color: white !important; - background-color: #1A1A1A !important; + background-color: #1f1f1f !important; border: 1px solid rgba(255,255,255,.1); border-radius: 3px; + font-family: "Fira Code", Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-size: 85%; + line-height: 2; + padding-top: .2em; + padding-bottom: .2em; + padding-left: .4em; + padding-right: .4em; } -.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme code { - padding: .2em .4em; +.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme pre code { + border: none; + border-radius: 0; + line-height: 1.45; + padding: 0; } .rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme pre { - padding: 1.5em; - line-height: 1.45; overflow: auto; + padding: 1em; } .rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme a, @@ -1018,12 +1023,12 @@ text-decoration: none; } -/* COMMENTED OUT: zebra-striped tables don't look good yet -.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme table[summary="Rd table"] tr:nth-child(even) { - background-color: #1a1a1a; +/* COMMENTED OUT: zebra-striped tables; problems: no obvious way to target only desired tables & performance-issues +.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme table tr:nth-child(even) { + background-color: #1f1f1f; } -.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme table[summary="Rd table"] td { +.rstudio-themes-flat.rstudio-themes-dark.editor_dark.ace_editor_theme table td { padding: .2em; } - */ +*/ From cba120020b5cc5b50b9e17e172926775ad0cb411 Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 12 May 2022 16:40:46 +0200 Subject: [PATCH 31/34] Rproj conf: clean package sources prior to installation (default in upcoming RStudio) --- rscodeio.Rproj | 1 + 1 file changed, 1 insertion(+) diff --git a/rscodeio.Rproj b/rscodeio.Rproj index c542d93..bba5e54 100644 --- a/rscodeio.Rproj +++ b/rscodeio.Rproj @@ -18,6 +18,7 @@ LineEndingConversion: Posix BuildType: Package PackageUseDevtools: Yes +PackageCleanBeforeInstall: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageRoxygenize: rd,collate,namespace From 1c53a82fc22b172825233e659ab4cef71f93b8cb Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 12 May 2022 16:41:10 +0200 Subject: [PATCH 32/34] fix package installation hint background color --- inst/resources/rscodeio.rstheme | 5 +++++ inst/resources/rscodeio_tomorrow_night_bright.rstheme | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/inst/resources/rscodeio.rstheme b/inst/resources/rscodeio.rstheme index 9d2058d..488825d 100644 --- a/inst/resources/rscodeio.rstheme +++ b/inst/resources/rscodeio.rstheme @@ -369,6 +369,11 @@ border-radius: 0; } +/* package installation hint background */ +.rstudio-themes-dark-grey .GEL-OVUBIED { + background-color: rgb(60, 60, 60) !important; +} + /* git status toolbar */ .rstudio-themes-flat .rstudio-themes-dark .GD15MCFCB2C, .rstudio-themes-flat .rstudio-themes-dark .GGBOEFPDC4C { diff --git a/inst/resources/rscodeio_tomorrow_night_bright.rstheme b/inst/resources/rscodeio_tomorrow_night_bright.rstheme index b83997c..327ec43 100644 --- a/inst/resources/rscodeio_tomorrow_night_bright.rstheme +++ b/inst/resources/rscodeio_tomorrow_night_bright.rstheme @@ -819,6 +819,11 @@ border-radius: 0; } +/* package installation hint background */ +.rstudio-themes-dark-grey .GEL-OVUBIED { + background-color: rgb(60, 60, 60) !important; +} + /* git status toolbar */ .rstudio-themes-flat .rstudio-themes-dark .GD15MCFCB2C, .rstudio-themes-flat .rstudio-themes-dark .GGBOEFPDC4C { From 5715ec4be53646f574ca42b5c67623c480d194b9 Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 12 May 2022 21:55:17 +0200 Subject: [PATCH 33/34] fix history search results background color --- inst/resources/rscodeio.rstheme | 5 +++-- inst/resources/rscodeio_tomorrow_night_bright.rstheme | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/inst/resources/rscodeio.rstheme b/inst/resources/rscodeio.rstheme index 488825d..ee5e0d1 100644 --- a/inst/resources/rscodeio.rstheme +++ b/inst/resources/rscodeio.rstheme @@ -369,8 +369,9 @@ border-radius: 0; } -/* package installation hint background */ -.rstudio-themes-dark-grey .GEL-OVUBIED { +/* non-permanent toolbars (package installation hint, history search) */ +.rstudio-themes-dark-grey .GEL-OVUBIED, +.rstudio-themes-dark-grey .GEL-OVUBFEC { background-color: rgb(60, 60, 60) !important; } diff --git a/inst/resources/rscodeio_tomorrow_night_bright.rstheme b/inst/resources/rscodeio_tomorrow_night_bright.rstheme index 327ec43..ed11b31 100644 --- a/inst/resources/rscodeio_tomorrow_night_bright.rstheme +++ b/inst/resources/rscodeio_tomorrow_night_bright.rstheme @@ -819,8 +819,9 @@ border-radius: 0; } -/* package installation hint background */ -.rstudio-themes-dark-grey .GEL-OVUBIED { +/* non-permanent toolbars (package installation hint, history search) */ +.rstudio-themes-dark-grey .GEL-OVUBIED, +.rstudio-themes-dark-grey .GEL-OVUBFEC { background-color: rgb(60, 60, 60) !important; } From 29515eab348d416d50f5be5134cdefff33a5ea4e Mon Sep 17 00:00:00 2001 From: Salim B Date: Thu, 12 May 2022 22:18:23 +0200 Subject: [PATCH 34/34] fix history search results background color (2) maybe these `GEL-OVUB*` classes are not really permanent and thus a dead end? --- inst/resources/rscodeio.rstheme | 5 +++-- inst/resources/rscodeio_tomorrow_night_bright.rstheme | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/inst/resources/rscodeio.rstheme b/inst/resources/rscodeio.rstheme index ee5e0d1..529f554 100644 --- a/inst/resources/rscodeio.rstheme +++ b/inst/resources/rscodeio.rstheme @@ -370,8 +370,9 @@ } /* non-permanent toolbars (package installation hint, history search) */ -.rstudio-themes-dark-grey .GEL-OVUBIED, -.rstudio-themes-dark-grey .GEL-OVUBFEC { +.rstudio-themes-dark-grey .GEL-OVUBDEC, +.rstudio-themes-dark-grey .GEL-OVUBFEC, +.rstudio-themes-dark-grey .GEL-OVUBIED { background-color: rgb(60, 60, 60) !important; } diff --git a/inst/resources/rscodeio_tomorrow_night_bright.rstheme b/inst/resources/rscodeio_tomorrow_night_bright.rstheme index ed11b31..0291f97 100644 --- a/inst/resources/rscodeio_tomorrow_night_bright.rstheme +++ b/inst/resources/rscodeio_tomorrow_night_bright.rstheme @@ -820,8 +820,9 @@ } /* non-permanent toolbars (package installation hint, history search) */ -.rstudio-themes-dark-grey .GEL-OVUBIED, -.rstudio-themes-dark-grey .GEL-OVUBFEC { +.rstudio-themes-dark-grey .GEL-OVUBDEC, +.rstudio-themes-dark-grey .GEL-OVUBFEC, +.rstudio-themes-dark-grey .GEL-OVUBIED { background-color: rgb(60, 60, 60) !important; }