Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: darkstudio
Type: Package
Title: An Alternative Look for RStudio's Modern and Sky Themes
Version: 0.2.0
Version: 0.3.0
Author: Riley Roach
Maintainer: Riley Roach <curt@null.net>
Description: Modifies RStudio's Modern and Sky themes to use grey rather than blue.
Expand All @@ -11,4 +11,4 @@ LazyData: true
Imports:
rstudioapi,
fs
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# darkstudio v0.3.0

## Added

- Users can now select a font family of their choice for the UI.
10 changes: 9 additions & 1 deletion R/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#' @param type character:
#' Accepts 'user' or NULL. If 'user', \code{activate()} will look for RStudio
#' in \code{/Users/xxx/Applications} instead of \code{/Applications} on macOS.
#' @param font_family character:
#' Name of the font family to use for the RStudio UI. If \code{NULL}, uses
#' to darkstudio defaults. If \code{"rstudio"}, uses default RStudio fonts.
#'
#' daRkStudio modifies \code{index.htm}, a file used by RStudio to construct
#' it's DOM (Document Object Model).
Expand All @@ -34,6 +37,9 @@
#' # Default:
#' activate()
#'
#' # Set UI font
#' activate(font_family = "Noto Sans")
#'
#' # macOS:
#' path_index <- "/Applications/RStudio.app/Contents/Resources/www/index.htm"
#' activate(path = path_index, backup = TRUE)
Expand All @@ -46,7 +52,7 @@
#' @return TRUE
#' @return Returns \code{TRUE} if the operation is successful.
#' @export
activate <- function(path = NULL, backup = TRUE, type = NULL) {
activate <- function(path = NULL, backup = TRUE, type = NULL, font_family = NULL) {
# Fail quickly if the RStudio API is not available
if (!rstudioapi::isAvailable()) {
stop("RStudio must be running in order to install darkstudio.")
Expand Down Expand Up @@ -78,6 +84,8 @@ activate <- function(path = NULL, backup = TRUE, type = NULL) {
fs::path_package(package = "darkstudio"), "resources/darkstudio.css"
)

customise(ds_css, font_family)

fs::file_copy(path = ds_css, new_path = ds_dir, overwrite = TRUE)

file_index <- index$read(path = path_index)
Expand Down
38 changes: 38 additions & 0 deletions R/customise.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#' custom.R
#' Created by Stefano Coretta on 2023-12-18
#' @keywords internal
customise <- function(ds_css, font_family) {

# read darkstudio.css
css_lines <- readLines(ds_css)

if (is.null(font_family)) {
ui_font_line <- grep("-apple-system", css_lines)
# use original darkstudio fonts
css_lines[ui_font_line] <- paste0(
"--ds-ui-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif;")

writeLines(css_lines, ds_css)

} else if (font_family == "rstudio") {
ui_font_line <- grep("-apple-system", css_lines)
# use RStudio default UI fonts
css_lines[ui_font_line] <- paste0(
"--ds-ui-font: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, sans-serif;")

writeLines(css_lines, ds_css)

} else if (!is.null(font_family)) {
ui_font_line <- grep("-apple-system", css_lines)
# add user font; hard-coded from original .css
css_lines[ui_font_line] <- paste0(
"--ds-ui-font: '", font_family, "', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif;")

writeLines(css_lines, ds_css)

} else {

}
}
5 changes: 4 additions & 1 deletion inst/resources/darkstudio.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* -------- FONTS --------- */

:root {
--ds-ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
--ds-ui-font: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif;
Arial, sans-serif;
Arial, sans-serif;
Arial, sans-serif;
--ds-ui-bg: #2c2c2c;
--ds-ui-font-fg: #ffffff;
Expand Down
13 changes: 10 additions & 3 deletions man/activate.Rd

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

14 changes: 14 additions & 0 deletions man/customise.Rd

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