Skip to content

Commit

Permalink
Clarify prompt text in try_rsthemes() for #3
Browse files Browse the repository at this point in the history
Restore current theme on exit if user cycles through all themes

Prompt after all themes, including last
  • Loading branch information
gadenbuie committed Jun 28, 2019
1 parent 3c35b41 commit 4038d91
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions R/rsthemes.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,18 @@ try_rsthemes <- function(
rstudioapi::applyTheme(theme)
if (delay > 0) {
Sys.sleep(delay)
} else if (theme != themes[length(themes)]) {
res <- readline("Press [enter] for next, [k] to keep, [q] to quit...")
if (tolower(res) == "k") return(invisible())
if (tolower(res) == "q") {
message("Restoring \"", current_theme$editor, "\"")
rstudioapi::applyTheme(current_theme$editor)
return(invisible())
} else {
if (theme != themes[length(themes)]) {
res <- readline("Enter [blank] for next, [k] to keep, [q] to quit: ")
} else {
res <- readline("Enter [blank] or [q] to quit, [k] to keep: ")
}
if (tolower(res) == "k") return(invisible())
if (tolower(res) == "q") break
}
}
message("Restoring \"", current_theme$editor, "\"")
rstudioapi::applyTheme(current_theme$editor)
}

#' @describeIn rsthemes List style options
Expand Down

0 comments on commit 4038d91

Please sign in to comment.