Skip to content

Commit

Permalink
hgd default arguments with getOption()
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Aug 30, 2021
1 parent b68a1d6 commit b97eeda
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ importFrom(grDevices,dev.off)
importFrom(systemfonts,font_info)
importFrom(systemfonts,match_font)
importFrom(utils,browseURL)
importFrom(utils,getOption)
useDynLib(httpgd, .registration=TRUE)
31 changes: 16 additions & 15 deletions R/httpgd.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#' @return No return value, called to initialize graphics device.
#'
#' @importFrom systemfonts match_font
#' @importFrom utils getOption
#' @export
#'
#' @examples
Expand All @@ -73,21 +74,21 @@
#' dev.off() # alternatively: hgd_close()
#' }
hgd <-
function(host = "127.0.0.1",
port = 0,
width = 720,
height = 576,
bg = "white",
pointsize = 12,
system_fonts = list(),
user_fonts = list(),
cors = FALSE,
token = TRUE,
silent = FALSE,
websockets = TRUE,
webserver = TRUE,
fix_text_width = TRUE,
extra_css = "") {
function(host = getOption("httpgd.host", "127.0.0.1"),
port = getOption("httpgd.port", 0),
width = getOption("httpgd.width", 720),
height = getOption("httpgd.height", 576),
bg = getOption("httpgd.bg", "white"),
pointsize = getOption("httpgd.pointsize", 12),
system_fonts = getOption("httpgd.system_fonts", list()),
user_fonts = getOption("httpgd.user_fonts", list()),
cors = getOption("httpgd.cors", FALSE),
token = getOption("httpgd.token", TRUE),
silent = getOption("httpgd.silent", FALSE),
websockets = getOption("httpgd.websockets", TRUE),
webserver = getOption("httpgd.webserver", TRUE),
fix_text_width = getOption("httpgd.fix_text_width", TRUE),
extra_css = getOption("httpgd.extra_css", "")) {
tok <- ""
if (is.character(token)) {
tok <- token
Expand Down
30 changes: 15 additions & 15 deletions man/hgd.Rd

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

0 comments on commit b97eeda

Please sign in to comment.