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$ 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 diff --git a/.lintr b/.lintr new file mode 100644 index 0000000..ba22fdd --- /dev/null +++ b/.lintr @@ -0,0 +1,12 @@ +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, + 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) diff --git a/DESCRIPTION b/DESCRIPTION index c72a447..30eda8e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,39 @@ 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")) -Description: It really just modifies RStudio presentation. -Depends: R (>= 3.3.0) +Title: An RStudio Theme Inspired by Visual Studio Code +Version: 0.1.9000 +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, + '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 +Depends: + R (>= 3.3.0) Imports: fs, + glue, purrr, + rlang, rstudioapi -RoxygenNote: 7.1.1 +Encoding: UTF-8 +LazyData: true +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.1.2 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 84fce56..9ba2f1b 100644 --- a/R/rscodeio.R +++ b/R/rscodeio.R @@ -1,120 +1,180 @@ -#' 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 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). #' -#' 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 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. +#' - `"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. +#' @return Nothing (`NULL` invisibly). #' @export -install_theme <- function(menus = TRUE) { - - ## check RStudio API available - if(!rstudioapi::isAvailable()) stop("RSCodeio must be installed from within RStudio.") +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 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") + # 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 if menu theme already installed and uninstall - if(rscodeio_installed()){ - uninstall_theme() - } + # add the editor theme variants + ## existing editor themes of the same names have to be removed first + uninstall_themes(restore_menu_bar = FALSE) - ## 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")) + 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 custom Qt CSS - if (menus) activate_menu_theme() + # add the custom QSS files + if (style_menu_bar) install_menu_theme(reload_editor_theme = FALSE) - ## 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 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. #' -#' @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 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. #' -#' @return nothing. +#' 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. +#' +#' 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 -activate_menu_theme <- function() { +install_menu_theme <- function(reload_editor_theme = TRUE) { - ## 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) - } + 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) - ## 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) + if (reload_editor_theme) rstudioapi::applyTheme(rstudioapi::getThemeInfo()$editor) } -#' Deactivate rscodeio style in file menu. +#' Uninstall rscodeio menu bar styling +#' +#' This function restores RStudio's default _dark_ Qt [Qt Style Sheet (QSS)](https://doc.qt.io/Qt-5/stylesheet-syntax.html) 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 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)) { - 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 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) } - ## 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 7ede2d8..45a5d72 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,54 +11,175 @@ 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() { 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)"]]) +} + +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 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, + "'") + + 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"))) { + + 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) + + } 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/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 fbab339..4116000 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,141 @@ -

- -

- - 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.x or higher. +- RStudio 1.2.0 or later -# Installation +- Administrator privileges (more on that [below](#details)) -Get the package: +## 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/") +} -```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 -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…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**. + +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() +``` -# Switching to another theme +On Windows, for both of the above to work, Rstudio must be run as +administrator. -`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`. +**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 +### 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. diff --git a/inst/resources/rscodeio.rstheme b/inst/resources/rscodeio.rstheme index 9d2058d..529f554 100644 --- a/inst/resources/rscodeio.rstheme +++ b/inst/resources/rscodeio.rstheme @@ -369,6 +369,13 @@ border-radius: 0; } +/* non-permanent toolbars (package installation hint, history search) */ +.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; +} + /* 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 cc2e5a5..0291f97 100644 --- a/inst/resources/rscodeio_tomorrow_night_bright.rstheme +++ b/inst/resources/rscodeio_tomorrow_night_bright.rstheme @@ -819,6 +819,13 @@ border-radius: 0; } +/* non-permanent toolbars (package installation hint, history search) */ +.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; +} + /* git status toolbar */ .rstudio-themes-flat .rstudio-themes-dark .GD15MCFCB2C, .rstudio-themes-flat .rstudio-themes-dark .GGBOEFPDC4C { @@ -987,31 +994,48 @@ .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 { +.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; } + +/* 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 td { + padding: .2em; +} +*/ 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); 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..87d4f26 --- /dev/null +++ b/man/install_menu_theme.Rd @@ -0,0 +1,31 @@ +% 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(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). +} +\description{ +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. +\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. + +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_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..768b319 --- /dev/null +++ b/man/install_themes.Rd @@ -0,0 +1,44 @@ +% 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.} + +\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 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 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. +} + diff --git a/man/uninstall_menu_theme.Rd b/man/uninstall_menu_theme.Rd new file mode 100644 index 0000000..bb0801f --- /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 \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. +\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..cb7db79 --- /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 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. +} diff --git a/rscodeio.Rproj b/rscodeio.Rproj index cba1b6b..bba5e54 100644 --- a/rscodeio.Rproj +++ b/rscodeio.Rproj @@ -14,8 +14,15 @@ LaTeX: pdfLaTeX AutoAppendNewline: Yes StripTrailingWhitespace: Yes +LineEndingConversion: Posix BuildType: Package PackageUseDevtools: Yes +PackageCleanBeforeInstall: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageRoxygenize: rd,collate,namespace + +MarkdownWrap: Column +MarkdownWrapAtColumn: 160 +MarkdownReferences: Section +MarkdownCanonical: Yes