From 83564fad409ce6fab40e868080ace725b9aa140b Mon Sep 17 00:00:00 2001 From: Philipp A Date: Tue, 13 Jun 2023 20:03:53 +0200 Subject: [PATCH] Init null_device with size --- R/environment_shadow.r | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/R/environment_shadow.r b/R/environment_shadow.r index a9e488e..d8fb2a3 100644 --- a/R/environment_shadow.r +++ b/R/environment_shadow.r @@ -128,8 +128,18 @@ init_null_device <- function() { ok_device <- switch(os, win = png, osx = pdf, unix = png) null_filename <- switch(os, win = 'NUL', osx = NULL, unix = '/dev/null') + has_units_arg <- 'units' %in% names(formals(ok_device)) - null_device <- function(filename = null_filename, ...) ok_device(filename, ...) + null_device <- function( + filename = null_filename, + width = getOption('repr.plot.width'), + height = getOption('repr.plot.width'), + units = 'in', + ... + ) { + if (has_units_arg) ok_device(filename, width, height, units, ...) + else ok_device(filename, width, height, ...) + } if (identical(getOption('device'), pdf)) { options(device = null_device)