[Sciviews-commits] r194 - in komodo/SciViews-K: . content content/js templates
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Sep 20 23:03:36 CEST 2009
Author: phgrosjean
Date: 2009-09-20 23:03:36 +0200 (Sun, 20 Sep 2009)
New Revision: 194
Added:
komodo/SciViews-K/content/RHelpOverlay.xul
Modified:
komodo/SciViews-K/content/js/commands.js
komodo/SciViews-K/content/js/misc.js
komodo/SciViews-K/content/js/r.js
komodo/SciViews-K/content/js/sciviews.js
komodo/SciViews-K/content/pkgManagerOverlay.xul
komodo/SciViews-K/sciviewsk-0.8.1-ko.xpi
komodo/SciViews-K/templates/.Rprofile
Log:
Better R Help display in a separate window
Added: komodo/SciViews-K/content/RHelpOverlay.xul
===================================================================
--- komodo/SciViews-K/content/RHelpOverlay.xul (rev 0)
+++ komodo/SciViews-K/content/RHelpOverlay.xul 2009-09-20 21:03:36 UTC (rev 194)
@@ -0,0 +1,184 @@
+<?xml version="1.0"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Version: MPL 1.1/GPL 2.0/LGPL 2.1
+
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is SciViews-K by Philippe Grosjean et al.
+
+ Contributor(s):
+ Philippe Grosjean
+ ActiveState Software Inc (code inspired from)
+
+ Alternatively, the contents of this file may be used under the terms of
+ either the GNU General Public License Version 2 or later (the "GPL"), or
+ the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ in which case the provisions of the GPL or the LGPL are applicable instead
+ of those above. If you wish to allow use of your version of this file only
+ under the terms of either the GPL or the LGPL, and not to allow others to
+ use your version of this file under the terms of the MPL, indicate your
+ decision by deleting the provisions above and replace them with the notice
+ and other provisions required by the GPL or the LGPL. If you do not delete
+ the provisions above, a recipient may use your version of this file under
+ the terms of any one of the MPL, the GPL or the LGPL.
+
+ ***** END LICENSE BLOCK ***** -->
+
+<!DOCTYPE overlay PUBLIC "-//MOZILLA//DTD XUL V1.0//EN"
+"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/global/global.css" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/toolbar.css" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/bindings/buttons.css" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/bindings/views.css" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/bindings/widgets.css" type="text/css"?>
+
+<window
+ id="RHelpWindow" title="R Help" onload="rHelpOnLoad();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ width="600" height="400" screenX="20" screenY="20"
+ persist="screenX screenY width height"
+ style="min-height: 400px; min-width: 300px;">
+
+ <script type="text/javascript">
+ <![CDATA[
+ var sv;
+ var rHelpBrowser;
+ var rHelpTopic;
+ var rHelpHome;
+
+ function display(page) {
+ rHelpBrowser.webNavigation.loadURI(page, null, null, null, null);
+ }
+
+ function go() {
+ var page = rHelpTopic.value;
+ rHelpTopic.select();
+ // Try to differenciate an URL from a help topic
+ if (page.match(/^[a-zA-Z]+:\/\//) != null) {
+ // This looks like a URL
+ rHelpBrowser.webNavigation.loadURI(page, null, null, null, null);
+ } else {
+ // Look for this 'topic' web page
+ sv.r.help(rHelpTopic.value);
+ }
+ }
+
+ function txtInput(aEvent) {
+ if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) {
+ go();
+ }
+ }
+
+ function search() {
+ rHelpTopic.select();
+ sv.r.search(rHelpTopic.value);
+ }
+
+ function print() {
+ alert("Print not implemented yet!");
+ //window.print();
+ }
+
+ function home() {
+ // Change rHelpHome (not set before to display quicker the first time)
+ rHelpHome = sv.prefs.getString("Rhelp.index",
+ "about:blank")
+ rHelpBrowser.webNavigation.loadURI(rHelpHome,
+ null, null, null, null);
+ }
+
+ function goBack() {
+ var webNavigation = rHelpBrowser.webNavigation;
+ if (webNavigation.canGoBack)
+ webNavigation.goBack();
+ }
+
+ function goForward() {
+ var webNavigation = rHelpBrowser.webNavigation;
+ if (webNavigation.canGoForward)
+ webNavigation.goForward();
+ }
+
+ self.onload = function () {
+ var args = window.arguments;
+ sv = args[0];
+ var page = rHelpHome;
+ if (typeof(args[1]) != "undefined") page = args[1];
+ rHelpTopic = document.getElementById("rhelp-topic");
+ rHelpBrowser = document.getElementById("rhelp-browser");
+ rHelpBrowser.webNavigation.loadURI(page,
+ null, null, null, null);
+ }
+ ]]>
+ </script>
+ <hbox>
+ <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="macro-play-icon"
+ oncommand="go();" disabled="false" label="Go"
+ tooltiptext="Show topic or web page" persist="buttonstyle" buttonstyle="pictures"/>
+ <toolbarbutton id="rhelp-search" class="help-icon"
+ oncommand="search();" disabled="false" label="Search"
+ tooltiptext="Search expression in R help" persist="buttonstyle" buttonstyle="pictures"/>
+ <spacer flex="1"/>
+ <toolbarbutton id="rhelp-back-button" class="history-back-icon"
+ oncommand="goBack();" disabled="false" label="Back"
+ tooltiptext="Back" persist="buttonstyle" buttonstyle="pictures"/>
+ <toolbarbutton id="rhelp-forward-button" class="history-forward-icon"
+ oncommand="goForward();" disabled="false" label="Forward"
+ tooltiptext="Forward" persist="buttonstyle" buttonstyle="pictures"/>
+ <toolbarbutton id="rhelp-home" class="open-file-icon"
+ oncommand="home();" disabled="false" label="Home"
+ tooltiptext="R help index" persist="buttonstyle" buttonstyle="pictures"/>
+ <toolbarbutton id="rhelp-web" type="menu"
+ disabled="false" label="Web"
+ tooltiptext="R help on the web" persist="buttonstyle" buttonstyle="pictures">
+ <menupopup>
+ <menuitem id="rhelp-menu-sitesearch" label="R Site Search"
+ accesskey="s"
+ oncommand="display('http://finzi.psych.upenn.edu/search.html');"/>
+ <menuitem id="rhelp-menu-cran" label="CRAN"
+ accesskey="c"
+ oncommand="display('http://cran.r-project.org/');"/>
+ <menuitem id="rhelp-menu-wiki" label="R wiki"
+ accesskey="w"
+ oncommand="display('http://wiki.r-project.org/');"/>
+ <menuitem id="rhelp-menu-bioconductor" label="Bioconductor"
+ accesskey="b"
+ oncommand="display('http://www.bioconductor.org/');"/>
+ <menuitem id="rhelp-menu-graph" label="Graph Gallery"
+ accesskey="g"
+ oncommand="display('http://addictedtor.free.fr/graphiques/');"/>
+ <menuitem id="rhelp-menu-forge" label="R-Forge"
+ accesskey="f"
+ oncommand="display('http://r-forge.r-project.org/');"/>
+ </menupopup>
+ </toolbarbutton>
+ <toolbarseparator/>
+ <toolbarbutton id="rhelp-print" class="print-button"
+ oncommand="print();" disabled="false" label="Print"
+ tooltiptext="Print this page" persist="buttonstyle" buttonstyle="pictures"/>
+ </hbox>
+
+ <vbox flex="1">
+ <hbox flex="1">
+ <browser id="rhelp-browser" type="content-primary"
+ src="about:blank" flex="1"/>
+ </hbox>
+ </vbox>
+</window>
Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js 2009-09-19 22:04:11 UTC (rev 193)
+++ komodo/SciViews-K/content/js/commands.js 2009-09-20 21:03:36 UTC (rev 194)
@@ -8,6 +8,7 @@
// and hide incompatible items.
// sv.command.startR(); // Start the preferred R app and connect to it
// sv.command.openPkgManager(); // Open the package manager window
+// sv.command.openHelp(webpage);// Open the R Help window at this web page
// sv.command.setControllers(); // Set controllers for R related commands
// sv.command.setKeybindings(clearOnly); // Set SciViews-K default keybindings
///////////////////////////////////////////////////////////////////////////////
@@ -18,9 +19,9 @@
// sv.command object constructor
(function () {
+ var RHelpWin; // A reference to the R Help Window
// private methods
-
function _keepCheckingR (stopMe) {
clearInterval(sv.r.testInterval);
if (!stopMe) {
@@ -316,6 +317,32 @@
sv);
}
+ this.openHelp = function (webpage) {
+ if (typeof(webpage) == "undefined") {
+ // We are asking for the R help home page
+ if (typeof(RHelpWin) == "undefined" || RHelpWin.closed) {
+ sv.r.helpStart(true);
+ } else {
+ RHelpWin.home();
+ RHelpWin.focus();
+ }
+ } else {
+ // We want to display a specific page
+ if (typeof(RHelpWin) == "undefined" || RHelpWin.closed) {
+ RHelpWin = window.openDialog(
+ "chrome://sciviewsk/content/RHelpOverlay.xul",
+ "RHelp",
+ "chrome=yes,dependent,resizable=yes,scrollbars=yes,status=no",
+ sv, webpage);
+ // Recalculate home page for R Help only
+ sv.r.helpStart(false);
+ } else {
+ RHelpWin.display(webpage);
+ }
+ RHelpWin.focus();
+ }
+ }
+
this.setControllers = function () {
//sv.log.debug("this.setControllers");
// Allow some commands only when R is running...
@@ -496,4 +523,4 @@
}).apply(sv.command);
addEventListener("load", sv.command.setControllers, false);
-addEventListener("load", sv.command.setKeybindings, false);
+addEventListener("load", sv.command.setKeybindings, false);
\ No newline at end of file
Modified: komodo/SciViews-K/content/js/misc.js
===================================================================
--- komodo/SciViews-K/content/js/misc.js 2009-09-19 22:04:11 UTC (rev 193)
+++ komodo/SciViews-K/content/js/misc.js 2009-09-20 21:03:36 UTC (rev 194)
@@ -22,7 +22,7 @@
if (typeof(sv.misc) == 'undefined')
sv.misc = {};
-// sv.misc.sessionData(name); // Create or open a .csv dataset from session
+// Create or open a .csv dataset from session
sv.misc.sessionData = function (data) {
if (typeof(data) == "undefined") {
data = ko.dialogs.prompt(
Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js 2009-09-19 22:04:11 UTC (rev 193)
+++ komodo/SciViews-K/content/js/r.js 2009-09-20 21:03:36 UTC (rev 194)
@@ -23,8 +23,8 @@
// sv.r.calltip_show(tip); // Companion functions for sv.r.calltip
// sv.r.complete(code); // AutoComplete mechanism for R
// sv.r.display(topic, what); // Display 'topic' according to 'what' type
-// sv.r.helpStart(); // Start R help in the default browser
-// sv.r.help(topic, package); // Get help in R for 'topic', 'topic' is optional
+// sv.r.helpStart(start); // Start R help in the browser, unless start is false
+// sv.r.help(topic, package); // Get help in R for 'topic', 'package' is optional
// sv.r.example(topic); // Run example in R for 'topic', 'topic' is optional
// sv.r.search(topic); // Search R help for 'topic'
// sv.r.search_select(topics); // Callback function: display a list of
@@ -588,10 +588,26 @@
}
// Start R help in the default browser
-sv.r.helpStart = function () {
- var res = sv.r.eval("help.start()");
- ko.statusBar.AddMessage(sv.translate("R help started... should display" +
- + " in browser soon"), "R", 5000, true);
+sv.r.helpStart = function (start) {
+ var cmd = 'suppressMessages(make.packages.html()); options(htmlhelp = TRUE); ' +
+ 'cat(paste("file://", URLencode(tempdir()), "/.R/doc/html/index.html\n", sep = ""))';
+ if (typeof(start) == "undefined" || start == true) {
+ ko.statusBar.AddMessage(sv.translate("R help started... should display" +
+ " in browser soon"), "RhelpStart", 10000, true);
+ var res = sv.r.evalCallback(cmd, function (page) {
+ ko.statusBar.AddMessage("", "RhelpStart");
+ page = sv.tools.strings.removeLastCRLF(page);
+ sv.prefs.setString("Rhelp.index", page, true);
+ // Launch the help window
+ sv.command.openHelp(page);
+ });
+ } else { // Just set the home page
+ var res = sv.r.evalCallback(cmd, function (page) {
+ ko.statusBar.AddMessage("", "RhelpStart");
+ page = sv.tools.strings.removeLastCRLF(page);
+ sv.prefs.setString("Rhelp.index", page, true);
+ });
+ }
return(res);
}
@@ -611,7 +627,7 @@
cmd = 'cat(unclass(help(' + cmd + ' htmlhelp = TRUE)))';
// TODO: error handling when package does not exists
- res = sv.r.evalCallback(cmd, sv.browseURI);
+ res = sv.r.evalCallback(cmd, sv.command.openHelp);
ko.statusBar.AddMessage(sv.translate("R help asked for \"%S\"", topic),
"R", 5000, true);
}
@@ -636,12 +652,14 @@
// Search R help for topic
sv.r.search = function (topic, internal) {
var res = false;
- if (typeof(topic) == "undefined" | topic == "") topic = sv.getText();
- // Ask for the search string
- topic = ko.dialogs.prompt(sv.translate("Search R objects using a regular" +
- " expression (e.g. '^log' for objects starting with 'log')"),
- sv.translate("Pattern"), topic,
- sv.translate("Search R help"), "okRsearchPattern");
+ if (typeof(topic) == "undefined" | topic == "") {
+ topic = sv.getText();
+ // Ask for the search string
+ topic = ko.dialogs.prompt(sv.translate("Search R objects using a regular" +
+ " expression (e.g. '^log' for objects starting with 'log')"),
+ sv.translate("Pattern"), topic,
+ sv.translate("Search R help"), "okRsearchPattern");
+ }
if (topic != null & topic != "") {
// Get list of matching items and evaluate it with sv.r.search_select()
res = sv.r.evalCallback('cat(apropos("' + topic + '"), sep = "' +
@@ -665,7 +683,7 @@
res = sv.r.help(sv.tools.strings.removeLastCRLF(topics));
} else {
// Select the item you want in the list
- var topic = ko.dialogs.selectFromList("R help",
+ var topic = ko.dialogs.selectFromList("R help topics",
"Select a topic:", items, "one");
if (topic != null)
res = sv.r.help(sv.tools.strings.removeLastCRLF(topic.join("")));
Modified: komodo/SciViews-K/content/js/sciviews.js
===================================================================
--- komodo/SciViews-K/content/js/sciviews.js 2009-09-19 22:04:11 UTC (rev 193)
+++ komodo/SciViews-K/content/js/sciviews.js 2009-09-20 21:03:36 UTC (rev 194)
@@ -433,15 +433,16 @@
return(false);
}
-
-//is this still necessarry?
-// Get contextual help for a word in the buffer, or for snippets
+// Get some help for a snippet, or a word in the buffer by hitting Shift+F1
sv.helpContext = function () {
try {
if (ko.window.focusedView() == null) {
if (ko.projects.active) {
var item = ko.projects.active.getSelectedItem();
var content = item.value;
+ // We need to eliminate newlines for easier regexp search
+ content = content.replace(/[\n\r]/g, '\t');
+
// Look for a string defining the URL for associated help file
// This is something like: [[%pref:URL|R|RWiki-help:<value>]]
Modified: komodo/SciViews-K/content/pkgManagerOverlay.xul
===================================================================
--- komodo/SciViews-K/content/pkgManagerOverlay.xul 2009-09-19 22:04:11 UTC (rev 193)
+++ komodo/SciViews-K/content/pkgManagerOverlay.xul 2009-09-20 21:03:36 UTC (rev 194)
@@ -45,7 +45,7 @@
<?xml-stylesheet href="chrome://sciviewsk/skin/pkgManager.css" type="text/css"?>
<window id="RPackageManager" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- height="500" width="500" persists="width height"
+ height="500" width="500" persist="width height"
style="min-height: 500px; min-width: 500px;" title="Manage R Packages">
<script type="text/javascript">
Modified: komodo/SciViews-K/sciviewsk-0.8.1-ko.xpi
===================================================================
(Binary files differ)
Modified: komodo/SciViews-K/templates/.Rprofile
===================================================================
--- komodo/SciViews-K/templates/.Rprofile 2009-09-19 22:04:11 UTC (rev 193)
+++ komodo/SciViews-K/templates/.Rprofile 2009-09-20 21:03:36 UTC (rev 194)
@@ -1,6 +1,6 @@
### SciViews install begin ###
# SciViews-R installation and startup for running R with Komodo/SciViews-K
-# Version 0.8.1, 2009-09-06 Ph. Grosjean (phgrosjean at sciviews.org)
+# Version 0.8.1b, 2009-09-20 Ph. Grosjean (phgrosjean at sciviews.org)
# Make sure we don't process this twice in case of duplicate items in .Rprofile
if (!exists(".SciViewsReady", envir = .GlobalEnv)) {
@@ -286,10 +286,9 @@
options(pager = svPager)
}
} else {
-
# if komodo path was passed in environment
if (file.exists(Sys.getenv("koAppFile"))) {
- Komodo <- paste("\"", Sys.getenv("koAppFile"), "\"", sep="")
+ Komodo <- Sys.getenv("koAppFile")
} else {
Komodo <- "komodo" # On Windows, 'komodo' should be enough
# But for reasons that escape me, komodo seems to stip off its own
@@ -305,7 +304,7 @@
owarn <- getOption("warn")
options(warn = -1)
# Try to run Komodo now
- res <- try(system(Komodo, wait = FALSE), silent = TRUE)
+ res <- try(system(paste('"', Komodo, '"', sep = ""), wait = FALSE), silent = TRUE)
if (res == -1) {
Komodo <- NULL
cat("R cannot find Komodo. Please, make sure you install it correctly\n",
More information about the Sciviews-commits
mailing list