From 3cf3720a2c0a72d6f722a9b990891a27301fadcf Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Thu, 16 Sep 2010 21:01:25 +0100 Subject: [PATCH] R implementation of the swank side of the (brand-new) slime-media contrib Define a generic function to be used with the new makeReplResultFunction hook, with an implementation using png files for trellis objects. --- swank-media.R | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 swank-media.R diff --git a/swank-media.R b/swank-media.R new file mode 100644 index 0000000..6e81dbb --- /dev/null +++ b/swank-media.R @@ -0,0 +1,19 @@ +makeMediaReplResult <- function(value) { + UseMethod("makeMediaReplResult") +} + +makeMediaReplResult.default <- function(value) { + makeReplResult(value) +} + +makeMediaReplResult.trellis <- function(value) { + filename <- tempfile("swank-media-") + png(filename, width=320, height=200) + print(value) + dev.off() + list(quote(`:write-image`), list(list(quote(`:type`), quote(png), + quote(`:file`), filename)), + deparse(value$call, nlines=1)) +} + +makeReplResultFunction <- makeMediaReplResult -- 2.39.5