[Sciviews-commits] r219 - in komodo/SciViews-K: . content content/js templates
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 3 14:27:46 CET 2009
Author: phgrosjean
Date: 2009-11-03 14:27:46 +0100 (Tue, 03 Nov 2009)
New Revision: 219
Added:
komodo/SciViews-K/sciviewsk-0.9.6-ko.xpi
Removed:
komodo/SciViews-K/R/
Modified:
komodo/SciViews-K/.DS_Store
komodo/SciViews-K/content/RHelpWindow.xul
komodo/SciViews-K/content/js/r.js
komodo/SciViews-K/content/js/sciviews.js
komodo/SciViews-K/content/js/socket.js
komodo/SciViews-K/install.rdf
komodo/SciViews-K/templates/.Rprofile
komodo/SciViews-K/templates/R reference.kpz
komodo/SciViews-K/templates/SciViews-K.kpz
Log:
New SciViews-K plugin 0.9.6 compatible with R 2.10 (help functions changed)
Modified: komodo/SciViews-K/.DS_Store
===================================================================
(Binary files differ)
Modified: komodo/SciViews-K/content/RHelpWindow.xul
===================================================================
--- komodo/SciViews-K/content/RHelpWindow.xul 2009-10-29 17:47:04 UTC (rev 218)
+++ komodo/SciViews-K/content/RHelpWindow.xul 2009-11-03 13:27:46 UTC (rev 219)
@@ -50,7 +50,7 @@
<window
id="RHelpWindow" title="R Help"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- width="600" height="400" screenX="20" screenY="20"
+ width="700" height="500" screenX="20" screenY="20"
persist="screenX screenY width height"
style="min-height: 400px; min-width: 300px;">
<script type="text/javascript">
@@ -233,24 +233,34 @@
function rHelpSearch(topic) {
if (!topic) return;
- rHelpBrowser.webNavigation.loadURI("chrome://sciviewsk/content/rsearch.html?" +
- encodeURIComponent(topic),
- rHelpBrowser.webNavigation.LOAD_FLAGS_NONE,
- null, null, null);
+ // This is an old code for R < 2.10
+ //rHelpBrowser.webNavigation.loadURI("chrome://sciviewsk/content/rsearch.html?" +
+ // encodeURIComponent(topic),
+ // rHelpBrowser.webNavigation.LOAD_FLAGS_NONE,
+ // null, null, null);
+ rHelpBrowser.webNavigation.loadURI(sv.helpStartURI.replace(/index.html$/,
+ "Search?name=" + encodeURIComponent(topic) + "&title=1&keyword=1&alias=1"),
+ rHelpBrowser.webNavigation.LOAD_FLAGS_NONE, null, null, null);
}
function _getHomePage(browser, goTo) {
var isWin = navigator.platform.search(/Win\d+$/) === 0;
-
- var cmd = 'suppressMessages(make.packages.html()); ';
- cmd += 'options(htmlhelp = TRUE); ';
- cmd += "cat(" + (isWin? "R.home()" : "tempdir()") + ");";
-
+ // Everything is changed in R 2.10
+ // Old code...
+ //var cmd = 'suppressMessages(make.packages.html()); ';
+ //cmd += 'options(htmlhelp = TRUE); ';
+ //cmd += "cat(" + (isWin? "R.home()" : "tempdir()") + ");";
+ // Make sure that help is started, but do not open a browser
+ var cmd = 'help.start(browser = function(...) return()); ';
+ // return the home page of R 2.10 help system
+ cmd += 'cat("http://127.0.0.1:", tools:::httpdPort, "/doc/html/index.html", sep = "")';
+
var res = sv.r.evalCallback(cmd, function (path) {
path = sv.tools.strings.removeLastCRLF(path);
- path = sv.tools.file.getfile(path,
- [(isWin? null : ".R"), "doc", "html", "index.html"]);
- path = sv.tools.file.getURI(path);
+ // Old treatment for R < 2.10
+ //path = sv.tools.file.getfile(path,
+ // [(isWin? null : ".R"), "doc", "html", "index.html"]);
+ //path = sv.tools.file.getURI(path);
browser.homePage = sv.helpStartURI = path;
@@ -329,10 +339,16 @@
}
function printPreview() {
- function enterPP () document.getElementById("nav-toolbar").hidden = true;
- function exitPP () document.getElementById("nav-toolbar").hidden = false;
-
- PrintUtils.printPreview(enterPP, exitPP);
+ // Print preview does not work on a Mac, use print instead because we
+ // have there a "preview" button available anyway
+ var isMac = navigator.platform.search(/Mac/) === 0;
+ if (isMac) {
+ PrintUtils.print();
+ } else {
+ function enterPP () document.getElementById("nav-toolbar").hidden = true;
+ function exitPP () document.getElementById("nav-toolbar").hidden = false;
+ PrintUtils.printPreview(enterPP, exitPP);
+ }
}
// modified "prefbarSavePage" from prefbar extension for Firefox
@@ -398,22 +414,6 @@
<toolbar type="toolbar" id="nav-toolbar" class="toolbar"
mode="icons" iconsize="small"
defaulticonsize="small">
-<vbox align="stretch" flex="1">
- <textbox id="rhelp-topic" flex="0"
- emptytext="topic or web page"
- onkeypress="txtInput(event);"
- tooltiptext="Search topic or Web page"
- />
- </vbox>
- <toolbarbutton id="rhelp-go" class="go-icon"
- command="cmd_go" buttonstyle="pictures"/>
- <toolbarbutton id="rhelp-search" class="search-icon"
- command="cmd_search" buttonstyle="pictures"/>
- <spacer flex="1"/>
- <toolbarbutton id="rhelp-find" class="find-icon"
- oncommand="onFindCommand(event);" disabled="false" label="Search in page"
- tooltiptext="Search this page (Ctrl-F/F3)"
- buttonstyle="pictures"/>
<toolbarbutton id="rhelp-back-button" class="history-back-icon"
command="cmd_go_back" buttonstyle="pictures"/>
<toolbarbutton id="rhelp-forward-button" class="history-forward-icon"
@@ -449,6 +449,23 @@
oncommand="go('http://r-forge.r-project.org/');"/>
</menupopup>
</toolbarbutton>
+ <vbox align="stretch" flex="1">
+ <textbox id="rhelp-topic" flex="0"
+ emptytext="topic or web page"
+ onkeypress="txtInput(event);"
+ tooltiptext="Search topic or Web page"
+ />
+ </vbox>
+ <toolbarbutton id="rhelp-go" class="go-icon"
+ command="cmd_go" buttonstyle="pictures"/>
+ <toolbarbutton id="rhelp-search" class="search-icon"
+ command="cmd_search" buttonstyle="pictures"/>
+ <spacer flex="1"/>
+ <toolbarbutton id="rhelp-find" class="find-icon"
+ oncommand="onFindCommand(event);" disabled="false" label="Search in page"
+ tooltiptext="Search this page (Ctrl-F/F3)"
+ buttonstyle="pictures"/>
+
<toolbarseparator/>
<toolbarbutton id="rhelp-menu" type="menu" label="File/Tools" orient="horizontal">
<menupopup>
Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js 2009-10-29 17:47:04 UTC (rev 218)
+++ komodo/SciViews-K/content/js/r.js 2009-11-03 13:27:46 UTC (rev 219)
@@ -104,7 +104,7 @@
// Define the 'sv.r' namespace
if (typeof(sv.r) == 'undefined')
sv.r = {
- RMinVersion: "2.7.0",
+ RMinVersion: "2.10.0",
sep: ";;"
};
@@ -624,8 +624,8 @@
var cmd = '';
cmd += pkg? ' package = "' + pkg + '", ' : "";
cmd += topic? ' topic = "' + topic + '", ' : "";
- cmd = 'cat(unclass(help(' + cmd + ' htmlhelp = TRUE)))';
-
+ cmd = cmd = 'cat(getHelpURL(help(' + cmd + ' htmlhelp = TRUE)))';
+ // Old version for R < 2.10: cmd = 'cat(unclass(help(' + cmd + ' htmlhelp = TRUE)))';
// TODO: error handling when package does not exists
res = sv.r.evalCallback(cmd, sv.command.openHelp);
ko.statusBar.AddMessage(sv.translate("R help asked for \"%S\"", topic),
Modified: komodo/SciViews-K/content/js/sciviews.js
===================================================================
--- komodo/SciViews-K/content/js/sciviews.js 2009-10-29 17:47:04 UTC (rev 218)
+++ komodo/SciViews-K/content/js/sciviews.js 2009-11-03 13:27:46 UTC (rev 219)
@@ -60,7 +60,7 @@
var sv = {
// TODO: set this automatically according to the plugin version
version: 0.9,
- release: 4,
+ release: 6,
showVersion: true,
checkVersion: function (version) {
if (this.version < version) {
Modified: komodo/SciViews-K/content/js/socket.js
===================================================================
--- komodo/SciViews-K/content/js/socket.js 2009-10-29 17:47:04 UTC (rev 218)
+++ komodo/SciViews-K/content/js/socket.js 2009-11-03 13:27:46 UTC (rev 219)
@@ -40,7 +40,7 @@
(function () {
/////// Socket client //////////////////////////////////////////////////////
- this.svSocketMinVersion = "0.9-44"; // Will be used later for compatibility
+ this.svSocketMinVersion = "0.9-48"; // Will be used later for compatibility
// checking between R and Komodo tools
this.host = "127.0.0.1"; // Host to connect to (local host only, currently)
this.cmdout = true; // Do we write to 'Command Output'?
Modified: komodo/SciViews-K/install.rdf
===================================================================
--- komodo/SciViews-K/install.rdf 2009-10-29 17:47:04 UTC (rev 218)
+++ komodo/SciViews-K/install.rdf 2009-11-03 13:27:46 UTC (rev 219)
@@ -4,7 +4,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>sciviewsk at sciviews.org</em:id>
<em:name>SciViews-K</em:name>
- <em:version>0.9.5</em:version>
+ <em:version>0.9.6</em:version>
<em:description>Edit R (http://www.r-project.org) code with Komodo</em:description>
<em:creator>Philippe Grosjean</em:creator>
<em:homepageURL>http://sciviews.org/SciViews-K</em:homepageURL>
Added: komodo/SciViews-K/sciviewsk-0.9.6-ko.xpi
===================================================================
(Binary files differ)
Property changes on: komodo/SciViews-K/sciviewsk-0.9.6-ko.xpi
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: komodo/SciViews-K/templates/.Rprofile
===================================================================
--- komodo/SciViews-K/templates/.Rprofile 2009-10-29 17:47:04 UTC (rev 218)
+++ komodo/SciViews-K/templates/.Rprofile 2009-11-03 13:27:46 UTC (rev 219)
@@ -1,6 +1,6 @@
### SciViews install begin ###
# SciViews-R installation and startup for running R with Komodo/SciViews-K
-# Version 0.9.0, 2009-09-20 Ph. Grosjean (phgrosjean at sciviews.org)
+# Version 0.9.6, 2009-11-03 Ph. Grosjean (phgrosjean at sciviews.org)
#TODO: Include all this as a function in svMisc??
#TODO: [KB] Fix problem with installing sv* packages when not running R as root.
@@ -38,8 +38,8 @@
minVersion["R"], "is needed), please, upgrade it\n")
} else res <- TRUE
- # Load main R packages
- res <- all(sapply(c("methods", "datasets", "utils", "grDevices", "graphics", "stats"),
+ # Load main R packages (tools added to the list because now required by svMisc)
+ res <- all(sapply(c("methods", "datasets", "utils", "grDevices", "graphics", "stats", "tools"),
function(x) require(x, quietly = TRUE, character.only = TRUE)))
@@ -197,7 +197,7 @@
# Indicate what we have as default packages
options(defaultPackages = c("datasets", "utils", "grDevices",
- "graphics", "stats", "methods", "tcltk", "svMisc",
+ "graphics", "stats", "methods", "tools", "tcltk", "svMisc",
"svSocket", "svGUI"))
} else {
cat("R is not SciViews ready, install latest svMisc, svSocket & svGUI packages\n")
@@ -281,11 +281,212 @@
rm(minVersion, res, svPager)
# Make sure we use HTML help (required for Shift-F1 and Alt-Shift-F1)
- # to display R help in Komodo Edit (in Windows, chmhelp is the default)
- if (.Platform$OS.type == "windows") options(chmhelp = FALSE)
- options(htmlhelp = TRUE)
+ # to display R help in Komodo Edit (in Windows, chmhelp is the default up to R 2.9.2)
+ #Old code: if (.Platform$OS.type == "windows") options(chmhelp = FALSE)
+ #Old code: options(htmlhelp = TRUE)
+ # In R 2.10, help system is completely changed
+ options(help_type = "html")
+ # Make sure the help server is started
+ if (tools:::httpdPort == 0L)
+ tools::startDynamicHelp()
+ # Record the home page for the help server in an option
+ options(helphome = paste("http://127.0.0.1:", tools:::httpdPort,
+ "/doc/html/index.html", sep = ""))
+ # I need to get the help file URL, but help() does not provide it any more!
+ # This is a temporary workaround for this problem
+ assignTemp("getHelpURL", function(x, ...) {
+ file <- as.character(x)
+ if (length(file) == 0) return("")
+ return(paste("http://127.0.0.1:", tools:::httpdPort,
+ "/library/", basename(dirname(dirname(file))),
+ "/html/", basename(file), sep = ""))
+ })
+# print method of object returned by help() is very unflexible for R.app and
+# does not allow in any way to use anything else than the R.app internal
+# browser for help!!!
+# That makes me very unhappy! Hey guys, I would like to use SciViews help
+# browser here! So, no other solution than to be even harsher, and to force
+# rewriting of the print function in base environment!!!
+# (problem emailed to Simon Urbanek on 03/11/2009... I hope he will propose
+# a work-around for this in R 2.10.1!!!)
+unlockBinding("print.help_files_with_topic", env = baseenv())
+assign("print.help_files_with_topic",
+function (x, ...)
+{
+ browser <- getOption("browser")
+ topic <- attr(x, "topic")
+ type <- attr(x, "type")
+ # This is the problematic code!
+ #if (.Platform$GUI == "AQUA" && type == "html") {
+ # browser <- function(x, ...) {
+ # .Internal(aqua.custom.print("help-files", x))
+ # return(invisible(x))
+ # }
+ #}
+ paths <- as.character(x)
+ if (!length(paths)) {
+ writeLines(c(gettextf("No documentation for '%s' in specified packages and libraries:",
+ topic), gettextf("you could try '??%s'", topic)))
+ return(invisible(x))
+ }
+ if (type == "html")
+ if (tools:::httpdPort == 0L)
+ tools::startDynamicHelp()
+ if (attr(x, "tried_all_packages")) {
+ paths <- unique(dirname(dirname(paths)))
+ msg <- gettextf("Help for topic '%s' is not in any loaded package but can be found in the following packages:",
+ topic)
+ if (type == "html" && tools:::httpdPort > 0L) {
+ path <- file.path(tempdir(), ".R/doc/html")
+ dir.create(path, recursive = TRUE, showWarnings = FALSE)
+ out <- paste("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n",
+ "<html><head><title>R: help</title>\n", "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"UTF-8\">\n",
+ "<link rel=\"stylesheet\" type=\"text/css\" href=\"/doc/html/R.css\">\n",
+ "</head><body>\n\n<hr>\n", sep = "")
+ out <- c(out, "<p>", msg, "</p><br>")
+ out <- c(out, "<table width=\"100%\" summary=\"R Package list\">\n",
+ "<tr align=\"left\" valign=\"top\">\n", "<td width=\"25%\">Package</td><td>Library</td></tr>\n")
+ pkgs <- basename(paths)
+ links <- paste("<a href=\"http://127.0.0.1:", tools:::httpdPort,
+ "/library/", pkgs, "/help/", topic, "\">", pkgs,
+ "</a>", sep = "")
+ out <- c(out, paste("<tr align=\"left\" valign=\"top\">\n",
+ "<td>", links, "</td><td>", dirname(paths), "</td></tr>\n",
+ sep = ""))
+ out <- c(out, "</table>\n</p>\n<hr>\n</body></html>")
+ writeLines(out, file.path(path, "all.available.html"))
+ browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
+ "/doc/html/all.available.html", sep = ""), browser)
+ }
+ else {
+ writeLines(c(strwrap(msg), "", paste(" ", formatDL(c(gettext("Package"),
+ basename(paths)), c(gettext("Library"), dirname(paths)),
+ indent = 22))))
+ }
+ }
+ else {
+ if (length(paths) > 1L) {
+ if (type == "html" && tools:::httpdPort > 0L) {
+ browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
+ "/library/NULL/help/", topic, sep = ""), browser)
+ return(invisible(x))
+ }
+ file <- paths[1L]
+ p <- paths
+ msg <- gettextf("Help on topic '%s' was found in the following packages:",
+ topic)
+ paths <- dirname(dirname(paths))
+ txt <- formatDL(c("Package", basename(paths)), c("Library",
+ dirname(paths)), indent = 22L)
+ writeLines(c(strwrap(msg), "", paste(" ", txt), ""))
+ if (interactive()) {
+ fp <- file.path(paths, "Meta", "Rd.rds")
+ tp <- basename(p)
+ titles <- tp
+ if (type == "html" || type == "latex")
+ tp <- tools::file_path_sans_ext(tp)
+ for (i in seq_along(fp)) {
+ tmp <- try(.readRDS(fp[i]))
+ titles[i] <- if (inherits(tmp, "try-error"))
+ "unknown title"
+ else tmp[tools::file_path_sans_ext(tmp$File) ==
+ tp[i], "Title"]
+ }
+ txt <- paste(titles, " {", basename(paths), "}",
+ sep = "")
+ res <- menu(txt, title = gettext("Choose one"),
+ graphics = getOption("menu.graphics"))
+ if (res > 0)
+ file <- p[res]
+ }
+ else {
+ writeLines(gettext("\nUsing the first match ..."))
+ }
+ }
+ else file <- paths
+ if (type == "html") {
+ if (tools:::httpdPort > 0L) {
+ path <- dirname(file)
+ dirpath <- dirname(path)
+ pkgname <- basename(dirpath)
+ browseURL(paste("http://127.0.0.1:", tools:::httpdPort,
+ "/library/", pkgname, "/html/", basename(file),
+ sep = ""), browser)
+ }
+ else {
+ warning("HTML help is unavailable", call. = FALSE)
+ att <- attributes(x)
+ xx <- sub("/html/([^/]*)\\.html$", "/help/\\1",
+ x)
+ attributes(xx) <- att
+ attr(xx, "type") <- "text"
+ print(xx)
+ }
+ }
+ else if (type == "text") {
+ path <- dirname(file)
+ dirpath <- dirname(path)
+ pkgname <- basename(dirpath)
+ RdDB <- file.path(path, pkgname)
+ if (file.exists(paste(RdDB, "rdx", sep = "."))) {
+ temp <- tools::Rd2txt(tools:::fetchRdDB(RdDB,
+ basename(file)), out = tempfile("Rtxt"), package = pkgname)
+ file.show(temp, title = gettextf("R Help on '%s'",
+ topic), delete.file = TRUE)
+ }
+ else {
+ zfile <- zip.file.extract(file, "Rhelp.zip")
+ if (file.exists(zfile)) {
+ first <- readLines(zfile, n = 1L)
+ enc <- if (length(grep("\\(.*\\)$", first)))
+ sub("[^(]*\\((.*)\\)$", "\\1", first)
+ else ""
+ if (enc == "utf8")
+ enc <- "UTF-8"
+ if (.Platform$OS.type == "windows" && enc ==
+ "" && l10n_info()$codepage < 1000)
+ enc <- "CP1252"
+ file.show(zfile, title = gettextf("R Help on '%s'",
+ topic), delete.file = (zfile != file), encoding = enc)
+ }
+ else stop(gettextf("No text help for '%s' is available:\ncorresponding file is missing",
+ topic), domain = NA)
+ }
+ }
+ else if (type %in% c("ps", "postscript", "pdf")) {
+ ok <- FALSE
+ zfile <- zip.file.extract(file, "Rhelp.zip")
+ if (zfile != file)
+ on.exit(unlink(zfile))
+ if (file.exists(zfile)) {
+ .show_help_on_topic_offline(zfile, topic, type)
+ ok <- TRUE
+ }
+ else {
+ path <- dirname(file)
+ dirpath <- dirname(path)
+ pkgname <- basename(dirpath)
+ RdDB <- file.path(dirpath, "help", pkgname)
+ if (file.exists(paste(RdDB, "rdx", sep = "."))) {
+ key <- sub("\\.tex$", "", basename(file))
+ tf2 <- tempfile("Rlatex")
+ tools::Rd2latex(tools:::fetchRdDB(RdDB, key),
+ tf2)
+ .show_help_on_topic_offline(tf2, topic, type)
+ ok <- TRUE
+ }
+ }
+ if (!ok)
+ stop(gettextf("No offline help for '%s' is available:\ncorresponding file is missing",
+ topic), domain = NA)
+ }
+ }
+ invisible(x)
+}, envir = baseenv())
+lockBinding("print.help_files_with_topic", env = baseenv())
+
# Change the working directory to the provided directory
setwd(getOption("R.initdir"))
Modified: komodo/SciViews-K/templates/R reference.kpz
===================================================================
(Binary files differ)
Modified: komodo/SciViews-K/templates/SciViews-K.kpz
===================================================================
(Binary files differ)
More information about the Sciviews-commits
mailing list