[Sciviews-commits] r220 - in komodo/SciViews-K: content content/js locale/en-GB locale/fr-FR templates
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Nov 5 19:53:17 CET 2009
Author: prezez
Date: 2009-11-05 19:53:17 +0100 (Thu, 05 Nov 2009)
New Revision: 220
Modified:
komodo/SciViews-K/content/RHelpWindow.xul
komodo/SciViews-K/content/default-keybindings.kkf
komodo/SciViews-K/content/js/commands.js
komodo/SciViews-K/content/js/r.js
komodo/SciViews-K/content/js/sciviews.js
komodo/SciViews-K/content/overlayMain.xul
komodo/SciViews-K/content/rsearch.html
komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
komodo/SciViews-K/templates/.Rprofile
Log:
Some fixes for help browser. "Run selection" command in browser added.
New editor command: run line or selection.
First implementation of tabbed help browser as an option (still buggy - so initially it is hidden).
Modified: komodo/SciViews-K/content/RHelpWindow.xul
===================================================================
--- komodo/SciViews-K/content/RHelpWindow.xul 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/content/RHelpWindow.xul 2009-11-05 18:53:17 UTC (rev 220)
@@ -56,9 +56,6 @@
<script type="text/javascript">
<![CDATA[
-
-//TODO: context menu, running examples and selected R code from help pages
-
var sv;
var rHelpBrowser;
var rHelpTopic;
@@ -90,7 +87,7 @@
rHelpTopic.select();
- // Try to differenciate an URL from a help topic
+ // Try to differentiate an URL from a help topic
var isUri = uri.search(/^((f|ht)tps?|chrome|about|file):\/{0,3}/) === 0;
if (isUri) {
@@ -109,6 +106,9 @@
} else {
go();
}
+ } else {
+ var isUri = rHelpTopic.value.search(/^((f|ht)tps?|chrome|about|file):\/{1,3}/) === 0;
+ rHelpTopic.style.color = isUri? "#000000" : "#8080ff";
}
}
@@ -150,10 +150,7 @@
// so far used only to change title and location text
// From: https://developer.mozilla.org/en/Code_snippets/Progress_Listeners
-const STATE_START = Components.interfaces.
- nsIWebProgressListener.STATE_START;
-const STATE_STOP = Components.interfaces.
- nsIWebProgressListener.STATE_STOP;
+
var progressListener = {
QueryInterface: function(aIID) {
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
@@ -168,7 +165,7 @@
// aWebProgress.DOMWindow to obtain the tab/window which
// triggers the state change
- if (aFlag & STATE_START) {
+ if (aFlag & Components.interfaces.nsIWebProgressListener.STATE_START) {
// This fires when the load event is initiated
document.getElementById("cmd_stop")
.setAttribute("disabled", false);
@@ -177,7 +174,7 @@
document.getElementById("cmd_reload").hidden = true;
}
- if (aFlag & STATE_STOP) {
+ if (aFlag & Components.interfaces.nsIWebProgressListener.STATE_STOP) {
// This fires when the load finishes
self.document.title = aWebProgress.DOMWindow.document.title;
rHelpTopic.value = aWebProgress.DOMWindow.document.location;
@@ -229,6 +226,48 @@
}
}
+function rHelpBrowserContextOnShow(event) {
+
+ var selText = sv.tools.strings.trim(window._content.getSelection()
+ .toString());
+
+ if (selText) {
+ var el = document.getElementById("cmd_rsearch_for");
+ el.setAttribute("label", sv.translate("Search R for \"%S\"",
+ selText.substr(0, 10) + (selText.length > 10? "..." : "")));
+
+ document.getElementById("cmd_rsearch_for").hidden = false;
+ document.getElementById("cmd_run_r_code").hidden = false;
+ } else {
+ document.getElementById("cmd_rsearch_for").hidden = true;
+ document.getElementById("cmd_run_r_code").hidden = true;
+ }
+
+
+
+}
+
+function runSelAsRCode() {
+ var selText = sv.tools.strings.trim(window._content.getSelection()
+ .getRangeAt(0).toString());
+
+ // Looks like R help page, so require package first
+ win = window._content;
+ doc = window._content.document;
+ if (win.document.title.indexOf("R: ") == 0) {
+ var docTables = doc.getElementsByTagName("table");
+ if (docTables.length > 0
+ && docTables[0].summary.search(/page for (\S+) \{([\w\.]+)\}/) == 0) {
+
+ selText = "require(" + RegExp.$2 + ")\n" + selText;
+
+ //TODO: for remote help files, ask to install package in not available
+ }
+ }
+ sv.r.eval(selText);
+}
+
+
// display formatted search results in a help window
function rHelpSearch(topic) {
if (!topic) return;
@@ -238,7 +277,7 @@
// encodeURIComponent(topic),
// rHelpBrowser.webNavigation.LOAD_FLAGS_NONE,
// null, null, null);
- rHelpBrowser.webNavigation.loadURI(sv.helpStartURI.replace(/index.html$/,
+ rHelpBrowser.webNavigation.loadURI(rHelpBrowser.homePage.replace(/index.html$/,
"Search?name=" + encodeURIComponent(topic) + "&title=1&keyword=1&alias=1"),
rHelpBrowser.webNavigation.LOAD_FLAGS_NONE, null, null, null);
}
@@ -253,8 +292,8 @@
// 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 = "")';
-
+ cmd += 'cat(paste("\n", "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);
// Old treatment for R < 2.10
@@ -262,8 +301,13 @@
// [(isWin? null : ".R"), "doc", "html", "index.html"]);
//path = sv.tools.file.getURI(path);
+ // get just the last line, get rid of the help.start's message
+ path = path.substring(path.lastIndexOf("\n") + 1);
+
browser.homePage = sv.helpStartURI = path;
+ //alert(browser.homePage);
+
if (goTo) go(path);
});
}
@@ -291,33 +335,61 @@
}).apply(browserUtils);
+function _getWindowByURI(uri) {
+ var wm = Components.classes['@mozilla.org/appshell/window-mediator;1']
+ .getService(Components.interfaces.nsIWindowMediator);
+ en = wm.getEnumerator("");
+
+ if (uri) {
+ var win;
+ while (en.hasMoreElements()) {
+ win = en.getNext();
+ if ((win.location.href == uri) ||
+ (win.location.href.lastIndexOf(uri) == win.location.href.length - uri.length))
+ return win;
+ }
+ }
+ return null;
+}
+
+
function windowOnLoad (event) {
// DOMContentLoaded is fired also for HTML content
if (event.target != self.document)
return;
- var args = window.arguments;
- sv = args[0];
- if (typeof(args[1]) != "undefined") page = args[1];
+ var page;
+ if (window.arguments) {
+ var args = window.arguments;
+ sv = args[0];
+ if (typeof(args[1]) != "undefined") page = args[1];
+ } else {
+ var mainWindow = _getWindowByURI("chrome://komodo/content/komodo.xul");
+ sv = mainWindow.sv;
+ }
+
rHelpTopic = document.getElementById("rhelp-topic");
rHelpTopic.clickSelectsAll = true;
rHelpBrowser = document.getElementById("rhelp-browser");
-
rHelpBrowser.addProgressListener(progressListener,
Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
var findToolbar = document.getElementById("FindToolbar");
-
// Listen to find toolbar attribute modifications:
findToolbar.addEventListener("DOMAttrModified",
onFindToolbarAttrModified, false);
go(page? page : "about:blank");
+ _getHomePage(rHelpBrowser, !page);
- _getHomePage(rHelpBrowser, !page);
+ // Print preview does not work on a Mac, disable that command then
+ var isMac = navigator.platform.search(/Mac/) === 0;
+ document.getElementById("cmd_print_preview")
+ .setAttribute("disabled", isMac);
+ document.getElementById("rhelp-print-preview").hidden = isMac;
}
// this is fired earlier than load event, so all required variables
@@ -339,16 +411,9 @@
}
function printPreview() {
- // 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);
- }
+ 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
@@ -381,6 +446,7 @@
<key id="key_find_next" keycode="VK_F3" command="cmd_find_next" modifiers="" />
<key id="key_go_back" keycode="VK_BACK" command="cmd_go_back" modifiers="" />
<key id="key_go_home" keycode="VK_HOME" command="cmd_go_home" modifiers="alt" />
+ <key id="key_run_r_code" keycode="R" command="cmd_run_r_code" modifiers="accel" />
</keyset>
<commandset id="commandset_main">
@@ -408,8 +474,26 @@
label="Page setup" desc="Page setup" />
<command id="cmd_save_page" oncommand="savePage();"
label="Save page" desc="Save page" accesskey="s" />
+ <command id="cmd_run_r_code" oncommand="runSelAsRCode();"
+ label="Run as R code" desc="Execute selected text in R" accesskey="r" />
+ <command id="cmd_rsearch_for" oncommand="rHelpSearch(sv.tools.strings.trim(window._content.getSelection().toString()));"
+ label="Search R for selection" desc="Search R for selected text" accesskey="S" />
</commandset>
+<popupset>
+ <menupopup id="rHelpBrowserContext"
+ onpopupshowing="rHelpBrowserContextOnShow(event);">
+ <menuitem id="menu_cmd_run_r_code"
+ command="cmd_run_r_code"
+ acceltext="Ctrl+R"
+ />
+ <menuitem id="menu_cmd_rsearch_for"
+ command="cmd_rsearch_for"
+ />
+ </menupopup>
+</popupset>
+
+
<toolbox id="rhelp-toolbox" class="toolbox-top" mode="icons" defaultmode="icons" iconsize="small">
<toolbar type="toolbar" id="nav-toolbar" class="toolbar"
mode="icons" iconsize="small"
@@ -490,7 +574,9 @@
<vbox flex="1">
<hbox flex="1">
<browser id="rhelp-browser" type="content-primary"
- src="about:blank" flex="1"/>
+ src="about:blank" flex="1"
+ context="rHelpBrowserContext"
+ />
</hbox>
</vbox>
<vbox id="browser-bottombox">
Modified: komodo/SciViews-K/content/default-keybindings.kkf
===================================================================
--- komodo/SciViews-K/content/default-keybindings.kkf 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/content/default-keybindings.kkf 2009-11-05 18:53:17 UTC (rev 220)
@@ -9,8 +9,8 @@
binding cmd_sv_RRunAll F5
binding cmd_sv_RSourceAll Shift+F5
-binding cmd_sv_RRunSelection F6
-binding cmd_sv_RSourceSelection Shift+F6
+binding cmd_sv_RRunLineOrSelection F6
+binding cmd_sv_RSourceLineOrSelection Shift+F6
binding cmd_sv_RRunBlock F7
binding cmd_sv_RSourceBlock Shift+F7
binding cmd_sv_RRunLine F11
@@ -18,4 +18,4 @@
binding cmd_sv_RSourcePara Shift+F12
binding cmd_sv_RRunFunction Ctrl+F12
binding cmd_sv_RSourceFunction Ctrl+Shift+F12
-binding cmd_sv_start_R Ctrl+F10
\ No newline at end of file
+binding cmd_sv_start_R Ctrl+F10
Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/content/js/commands.js 2009-11-05 18:53:17 UTC (rev 220)
@@ -20,7 +20,7 @@
// sv.command object constructor
(function () {
- var RHelpWin; // A reference to the R Help Window
+ this.RHelpWin = null; // A reference to the R Help Window
var _this = this;
function _getWindowByURI(uri) {
@@ -348,7 +348,10 @@
}
// sv.command.openHelp - returns reference to the RHelpWindow
+//FIXME: help in tab still buggy
this.openHelp = function (uri) {
+ var RHelpWin = _this.RHelpWin;
+
// We will need special treatment in windows
var isWin = navigator.platform.search(/Win\d+$/) === 0;
@@ -374,28 +377,65 @@
uri = ""; // home page will be shown
}
- // First, open the window with blank page:
+ var rhelpTabbed = sv.prefs.getString("rhelp.tabbed", false) == "true";
+
var rHelpXulUri = "chrome://sciviewsk/content/RHelpWindow.xul";
- RHelpWin = _getWindowByURI(rHelpXulUri);
+ // Open R-help in a right tab
+ // FIXME: opening in tab is still buggy
+ if (rhelpTabbed) {
+ // make sure tab is visible and select it:
+ var tabPanel = document.getElementById("rhelpviewbox");
+ var tab = document.getElementById("rhelp_tab");
+ var tabBox = tabPanel.parentNode.parentNode;
+ tabPanel.hidden = false;
+ tab.hidden = false;
+ tabBox.selectedIndex = tabBox.tabs.getIndexOfItem(tab);
- if (!RHelpWin || RHelpWin.closed) {
- sv.log.debug("Starting R help with page " + uri);
+ var RHelpFrame = document.getElementById("rhelpview-frame");
- // try/catch here somehow prevented from storing window reference in RHelpWin. No idea why...
- RHelpWin = window.openDialog(rHelpXulUri, "RHelp",
- "chrome=yes,dependent,resizable=yes," +
- "scrollbars=yes,status=no,close,dialog=no", sv, uri);
+ RHelpFrame.webNavigation.loadURI(rHelpXulUri, null, null, null, null);
+ //RHelpFrame.setAttribute("src", rHelpXulUri);
+ RHelpWin = RHelpFrame.contentWindow;
+ RHelpWin.go(uri);
+
} else {
- //sv.log.debug("Showing R help for page " + uri);
- //alreadyOpen = true;
- RHelpWin.go(uri);
+ //alert("open help.");
+ _this.RHelpWin = _getWindowByURI(rHelpXulUri);
+ if (!RHelpWin || RHelpWin.closed) {
+ sv.log.debug("Starting R help with page " + uri);
+
+ // try/catch here somehow prevented from storing window reference in RHelpWin. No idea why...
+ RHelpWin = window.openDialog(rHelpXulUri, "RHelp",
+ "chrome=yes,dependent,resizable=yes," +
+ "scrollbars=yes,status=no,close,dialog=no", sv, uri);
+ } else {
+ RHelpWin.go(uri);
+ }
}
+
RHelpWin.focus();
+ RHelpWin.close = _this.closeHelp;
+
+ _this.RHelpWin = RHelpWin;
return RHelpWin;
}
+ // close r-help tab:
+ this.closeHelp = function() {
+ var tabPanel = document.getElementById("rhelpviewbox");
+ var tab = document.getElementById("rhelp_tab");
+ var tabBox = tabPanel.parentNode.parentNode;
+
+ tabPanel.hidden = true;
+ tab.hidden = true;
+ tabBox.selectedIndex = ((tabBox.tabs.getIndexOfItem(tab) + 2) % tabBox.tabs.itemCount) - 1;
+ document.getElementById("rhelpview-frame").setAttribute("src", "about:blank");
+ //_this.RHelpWin.closed = true;
+ }
+
+
this.setControllers = function () {
//sv.log.debug("this.setControllers");
// Allow some commands only when R is running...
@@ -411,7 +451,8 @@
// Make these commands active only when current document language is R
var cmdsIfIsRView = ["RunAll", "SourceAll", "RunBlock", "RunFunction",
"RunLine", "RunPara", "SourceBlock", "SourceFunction", "SourcePara",
- "TriggerCompletion"];
+ "RunLineOrSelection"];
+
// ... and if some text is selected
var cmdsIfIsRViewAndSelection = ["RunSelection", "SourceSelection"];
@@ -470,9 +511,19 @@
vmProto.do_cmd_sv_RRunSelection = function () {
sv.r.send("sel");
};
+
vmProto.do_cmd_sv_RSourceSelection = function () {
sv.r.source("sel");
};
+
+ vmProto.do_cmd_sv_RRunLineOrSelection = function () {
+ sv.r.send("line/sel");
+ };
+
+ vmProto.do_cmd_sv_RSourceLineOrSelection = function () {
+ sv.r.source("line/sel");
+ };
+
vmProto.do_cmd_sv_RRunBlock = function () {
sv.r.send("block");
};
@@ -490,6 +541,28 @@
};
}
+// Code below is for extra items in editor context menu (eg. "run selection"),
+// Commented out because it is still buggy
+// function editorContextMenuOnShowing (event) {
+// //try{
+//
+// var ids = ["editor-context-sep-sv", "editor-context-sv-r-send-line-sel"];
+//
+// var langNotR = ko.views.manager.currentView.document.language != "R";
+// var visibility = langNotR? "collapse" : "visible";
+///*
+// for (i in ids) {
+// document.getElementById(ids[i])
+// .style.visibility = visibility;
+// }
+//*/
+// //} catch(e) {}
+//
+// }
+//var editorContextMenu = document.getElementById("editorContextMenu");
+//editorContextMenu.addEventListener("popupshowing", editorContextMenuOnShowing, false);
+
+
// Set default keybindings from file
// chrome://sciviewsk/content/default-keybindings.kkf
// preserving user modified ones and avoiding key conflicts
Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/content/js/r.js 2009-11-05 18:53:17 UTC (rev 220)
@@ -173,14 +173,14 @@
// If R is not running, start it now
if (!sv.r.running) {
// Indicate R should be started
- ko.statusBar.AddMessage("R must be started for this command (R -> Start R)", "Rstart", 5000, true, true);
+ ko.statusBar.AddMessage(sv.translate("R must be started for this command (R -> Start R)"), "Rstart", 5000, true, true);
// Indicate that we want to execute this command when R is started
//sv.r.pendingCmd = cmd;
// and start R now
//sv.command.startR();
return null;
}
- cmd = (new String(cmd)).trim();
+ cmd = cmd.rtrim();
// Store the current R command
if (sv.socket.prompt == ":> ") {
// Special case for q() and quit() => use sv.r.quit() instead
@@ -431,7 +431,7 @@
if (!kv)
return false; // No current view, do nothing!
kv.setFocus();
- var ke = kv.scimoz;
+ var scimoz = kv.scimoz;
var doc = kv.document;
var file;
@@ -444,18 +444,17 @@
if (!what)
what = "all"; // Default value
- // Special case: if "all" and document saved, source the original file
- if (what == "all" && !(doc.isUntitled || doc.isDirty)) {
+ // Special case: if "all" and local document is saved, source as the original file
+ if (what == "all" && doc.file.isLocal && !doc.isUntitled && !doc.isDirty) {
res = sv.r.eval('source("' + file + '", encoding = "' +
kv.encoding + '")');
} else {
-
- // else, save all or part in the temporary file and source that file
+ // save all or part in the temporary file and source that file
// After executing, tell R to delete it.
- var code = (what == "all")? ke.text : sv.getTextRange(what);
+ var code = sv.getTextRange(what);
sv.cmdout.clear();
- sv.cmdout.append(':> #source("' + file + '*") # unsaved buffer (' +
- what + ')');
+ sv.cmdout.append(':> #source("' + file + '*") # buffer: ' +
+ what);
var tempFile = sv.tools.file.temp();
sv.tools.file.write(tempFile, code, 'utf-8', false);
@@ -491,7 +490,7 @@
if (!what)
what = "all"; // Default value
- var code = sv.getTextRange(what, true);
+ var code = sv.getTextRange(what, what.indexOf("sel") == -1).rtrim();
if (code) {
// indent multiline commands
code = code.replace(/\r?\n/g, "\n ")
@@ -624,7 +623,7 @@
var cmd = '';
cmd += pkg? ' package = "' + pkg + '", ' : "";
cmd += topic? ' topic = "' + topic + '", ' : "";
- cmd = cmd = 'cat(getHelpURL(help(' + cmd + ' htmlhelp = TRUE)))';
+ 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);
@@ -677,7 +676,7 @@
var rSearchUrl = "chrome://sciviewsk/content/rsearch.html";
var content = sv.tools.file.read(file);
//content = content.replace(/([\w\.\-]+)::([\w\.\-]+)/ig, '<a href="javascript:sv.r.help(\'$2\', \'$1\');">$1::$2</a>');
- content = content.replace(/([\w\.\-]+)::([\w\.\-]+)/ig,
+ content = content.replace(/([\w\.\-]+)::([\w\.\-\[]+)/ig,
'<a href="' + rSearchUrl + '?$1::$2">$1::$2</a>');
content = "<pre id=\"rPagerTextContent\" title=\"" + title + "\">" + content + "</div>";
@@ -686,8 +685,6 @@
sv.command.openHelp(rSearchUrl + "?file:" + file);
}
-
-
// The callback for sv.r.search
//TODO: make private
sv.r.search_select = function (topics) {
@@ -1664,9 +1661,6 @@
}
-
-
-
// sv.r.pkg.install - install R packages
// examples:
// sv.r.pkg.install() // use default CRAN mirror
@@ -1713,7 +1707,7 @@
}
// At this point repos should be always set
- sv.cmdout.append(">> Using " + repos);
+ sv.cmdout.append(sv.translate("Using repository at %S", repos));
repos = repos.toLowerCase();
@@ -1735,6 +1729,9 @@
var res = false;
if (pkgs.trim() != "") {
pkgs = pkgs.split(sv.r.sep);
+ // Case insensitive sorting:
+ pkgs.sort(function(a,b) a.toUpperCase() > b.toUpperCase());
+
pkgs = ko.dialogs.selectFromList(
sv.translate("Install R package"),
sv.translate("Select package(s) to install") + ":", pkgs);
Modified: komodo/SciViews-K/content/js/sciviews.js
===================================================================
--- komodo/SciViews-K/content/js/sciviews.js 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/content/js/sciviews.js 2009-11-05 18:53:17 UTC (rev 220)
@@ -150,6 +150,10 @@
// Depending on 'what', we select different parts of the file
// By default, we keep current selection
+
+ if (what == "line/sel")
+ what = (pStart == pEnd)? "line" : "sel";
+
switch(what) {
case "sel":
// Simply retain current selection
@@ -323,7 +327,7 @@
}
if (what != "all") {
- text = scimoz.getTextRange(pStart, pEnd).trim();
+ text = scimoz.getTextRange(pStart, pEnd).replace(/(^[\n\r]+|[\n\r]+$)/, "");
if (gotoend) {
scimoz.gotoPos(pEnd);
}
Modified: komodo/SciViews-K/content/overlayMain.xul
===================================================================
--- komodo/SciViews-K/content/overlayMain.xul 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/content/overlayMain.xul 2009-11-05 18:53:17 UTC (rev 220)
@@ -129,6 +129,16 @@
oncommand="ko.commands.doCommand('cmd_sv_RSourcePara')"
desc="R: &rSrcPara;" label="&rSrcPara;" accesskey="&rSrcPara.key;"/>
+ <command id="cmd_sv_RRunLineOrSelection" key="key_cmd_sv_RRunLineOrSelection"
+ oncommand="ko.commands.doCommand('cmd_sv_RRunLineOrSelection')"
+ desc="R: &rSendLineOrSelection;" label="&rSendLineOrSelection;"
+ accesskey="&rSendLineOrSelection.key;"/>
+
+ <command id="cmd_sv_RSourceLineOrSelection" key="key_cmd_sv_RSourceLineOrSelection"
+ oncommand="ko.commands.doCommand('cmd_sv_RSourceLineOrSelection')"
+ desc="R: &rSrcLineOrSelection;" label="&rSrcLineOrSelection;"
+ accesskey="&rSrcLineOrSelection.key;"/>
+
<commandset id="cmdset_r_control" commandupdater="true" events="select"
oncommandupdate="ko.commands.updateCommandset(this);">
<command id="cmd_sv_RRunSelection" key="key_cmd_sv_RRunSelection"
@@ -155,6 +165,19 @@
class="menu-iconic-wide"/>
</menupopup>
+ <!--<menupopup id="editorContextMenu">-->
+ <!-- <menuseparator id="editor-context-sep-sv"-->
+ <!-- insertafter="context-sep-paste"-->
+ <!-- />-->
+ <!-- <menuitem id="editor-context-sv-r-send-line-sel"-->
+ <!-- class="menuitem-iconic r-send-selection-icon"-->
+ <!-- observes="cmd_sv_RRunLineOrSelection"-->
+ <!-- oncommand="ko.commands.doCommand('cmd_sv_RRunLineOrSelection')"-->
+ <!-- insertafter="context-sep-paste"-->
+ <!-- />-->
+ <!--insertafter="context-sep-paste"-->
+ <!--</menupopup>-->
+
<menubar id="menubar_main">
<menu id="sciviews_menu" label="R" accesskey="R"
insertbefore="menu_window,help_menu">
@@ -203,16 +226,22 @@
<menuitem id="r_browse_wd" observes="cmd_sv_BrowseWD"
class="menuitem-iconic r-working-dir-icon"/>
<menuseparator/>
- <menuitem id="r_send_line_menu" observes="cmd_sv_RRunLine"
- class="menuitem-iconic r-run-line-icon"/>
+ <!--<menuitem id="r_send_line_menu" observes="cmd_sv_RRunLine"-->
+ <!-- class="menuitem-iconic r-run-line-icon"/>-->
<menuitem id="r_send_all_menu" observes="cmd_sv_RRunAll"
class="menuitem-iconic r-run-all-icon"/>
<menuitem id="r_src_all_menu" observes="cmd_sv_RSourceAll"
class="menuitem-iconic r-source-all-icon"/>
- <menuitem id="r_send_sel_menu" observes="cmd_sv_RRunSelection"
+ <!--<menuitem id="r_send_sel_menu" observes="cmd_sv_RRunSelection"-->
+ <!-- class="menuitem-iconic r-run-selection-icon"/>-->
+ <!--<menuitem id="r_src_sel_menu" observes="cmd_sv_RSourceSelection"-->
+ <!-- class="menuitem-iconic r-source-selection-icon"/>-->
+
+ <menuitem id="r_send_line_sel_menu" observes="cmd_sv_RRunLineOrSelection"
class="menuitem-iconic r-run-selection-icon"/>
- <menuitem id="r_src_sel_menu" observes="cmd_sv_RSourceSelection"
+ <menuitem id="r_src_line_sel_menu" observes="cmd_sv_RSourceLineOrSelection"
class="menuitem-iconic r-source-selection-icon"/>
+
<menuitem id="r_send_block_menu" observes="cmd_sv_RRunBlock"
class="menuitem-iconic r-run-block-icon"/>
<menuitem id="r_src_block_menu" observes="cmd_sv_RSourceBlock"
@@ -228,4 +257,36 @@
</menupopup>
</menu>
</menubar>
+
+
+ <tabbox id="rightTabBox">
+ <tabs id="right_toolbox_tabs">
+ <tab id="rhelp_tab"
+ label="R Help tabbed"
+ accesskey="r"
+ insertafter="toolbox_tab"
+ oncommand="ko.toolboxes.user.viewMgr.tree.focus();"
+ onfocus="ko.toolboxes.user.viewMgr.focus();"
+ hidden="true"
+ persist="hidden"
+ />
+ </tabs>
+ <tabpanels id="right_toolbox_tabpanels">
+ <tabpanel id="rhelpviewbox"
+ flex="1"
+ insertafter="toolboxviewbox"
+ hidden="true"
+ persist="hidden"
+ >
+ <vbox id="rhelpviewbox-vbox" flex="1">
+ <iframe id="rhelpview-frame"
+ src="about:blank"
+ flex="1"
+ />
+ </vbox>
+ </tabpanel>
+ </tabpanels>
+ </tabbox>
+
+
</overlay>
Modified: komodo/SciViews-K/content/rsearch.html
===================================================================
--- komodo/SciViews-K/content/rsearch.html 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/content/rsearch.html 2009-11-05 18:53:17 UTC (rev 220)
@@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>R help: search results</title>
-
+<link rel="stylesheet" href="chrome://sciviewsk/skin/rsearch.css" type="text/css" />
<script type="text/javascript">
function _getWindowByURI(uri) {
@@ -23,9 +23,6 @@
return null;
}
-
-
-var rHelpXulUri = "chrome://sciviewsk/content/RHelpOverlay.xul";
var rHelpWin, sv;
function askR(topic) {
@@ -43,68 +40,92 @@
}
-function displayResults(data) {
- if (!data)
- return;
+function appendElem(parent, tagName, textContent, attributes) {
+ var el = document.createElement(tagName);
- var doc = document;
+ if (textContent)
+ el.textContent = textContent;
- var header = doc.body.appendChild(doc.createElement("h1"));
- header.textContent = "Search results";
+ if (attributes) {
+ for (i in attributes) {
+ el.setAttribute(i, attributes[i]);
+ }
+ }
+ if (parent) {
+ if (typeof parent == "string")
+ parent = document.getElementById(parent);
- var out = doc.body.appendChild(doc.createElement("div"));
+ if (parent)
+ parent.appendChild(el);
+ }
- //while (out.childNodes.length) out.removeChild(out.firstChild);
+ return el;
+}
+function appendElem(parent, tagName, textContent, attributes) {
+ var el = document.createElement(tagName);
+
+ if (textContent)
+ el.textContent = textContent;
+
+ if (attributes) {
+ for (i in attributes) {
+ el.setAttribute(i, attributes[i]);
+ }
+ }
+ if (parent) {
+ if (typeof parent == "string")
+ parent = document.getElementById(parent);
+
+ if (parent) {
+ if (parent.appendChild)
+ parent.appendChild(el);
+ else if (parent.appendElem)
+ parent.appendElem(el);
+ }
+ }
+ return el;
+}
+
+function displayResults(data) {
+ if (!data)
+ return;
+
+ var doc = document;
+ appendElem(doc.body, "h1", "Search results");
+ var out = appendElem(doc.body, "div");
data = data.split(/[\r\n]+/);
- var p = doc.createElement("p");
- p.appendChild(doc.createTextNode('Search text was: "' + data[0].replace(/(^\s+|\s+$)/g, "") + '"'));
- out.appendChild(p);
+ appendElem(out, "p", 'Search text was: "' + sv.tools.strings.trim(data[0]) + '"');
if (data.length == 1) {
- var p = doc.createElement("p");
- p.appendChild(doc.createTextNode("Nothing found."));
- out.appendChild(p);
+ appendElem(out, "p", "Nothing found.");
return;
}
-
var prevPkg = "", fnList, li, el, p, pkgList;
+ var resTable = appendElem(out, "table", "", {cellpadding: 2, id: "resultTable"});
- pkgList = doc.createElement("div");
-
for (var i = 1; i < data.length; i++) {
var di = data[i].split(/\s*;\s*/);
- var li = doc.createElement("li");
curPkg = di[2];
if (curPkg != prevPkg) {
- if (fnList) pkgList.appendChild(fnList);
+ var th = appendElem(appendElem(resTable, "tr"), "th", "",
+ {colspan: 2});
+ appendElem(th, "a", "Package: " + curPkg,
+ {href: "file://" + di[3] + "/html/00Index.html"});
+ }
+ prevPkg = curPkg;
- p = doc.createElement("p");
- el = doc.createElement("a");
- el.appendChild(doc.createTextNode("Package: " + curPkg));
- el.setAttribute("href", "file://" + di[3] + "/html/00Index.html");
- p.appendChild(el);
+ var tr = appendElem(resTable, "tr");
+ appendElem(appendElem(tr, "td"),
+ "a", di[0], {href: "file://" + di[4]});
- pkgList.appendChild(p);
- fnList = doc.createElement("ol");
- }
- prevPkg = curPkg;
- li = doc.createElement("li");
+ appendElem(tr, "td", di[1]);
- el = li.appendChild(doc.createElement("a"));
- el.setAttribute("href", "file://" + di[4]);
- el.appendChild(doc.createTextNode(di[0]));
-
- li.appendChild(el);
- li.appendChild(doc.createTextNode(" - " + di[1]));
- fnList.appendChild(li);
}
- pkgList.appendChild(fnList);
- doc.body.appendChild(pkgList);
}
@@ -117,11 +138,12 @@
var cmd = '';
cmd += pkg? ' package = "' + pkg + '", ' : "";
cmd += topic? ' topic = "' + topic + '", ' : "";
- cmd = 'cat(unclass(help(' + cmd + ' htmlhelp = TRUE)))';
+ //cmd = 'cat(unclass(help(' + cmd + ' htmlhelp = TRUE)))';
+ // For R 2.10:
+ cmd = 'cat(getHelpURL(help(' + cmd + ' htmlhelp = TRUE)))';
res = sv.r.evalCallback(cmd, function(path) {
- rHelpWin.go("file://" + path,
- Components.interfaces.nsIWebNavigation
+ rHelpWin.go(path, Components.interfaces.nsIWebNavigation
.LOAD_FLAGS_REPLACE_HISTORY);
});
}
@@ -130,9 +152,11 @@
function init() {
- rHelpWin = _getWindowByURI(rHelpXulUri);
- sv = rHelpWin.sv;
+ var mainWindow = _getWindowByURI("chrome://komodo/content/komodo.xul");
+ sv = mainWindow.sv;
+ rHelpWin = sv.command.RHelpWin;
+
var topic = decodeURIComponent(document.location.search.replace(/^\?/, ""));
if (topic.indexOf("file:") == 0) {
@@ -143,7 +167,7 @@
rHelpWin.document.title = document.title = content.firstChild.getAttribute("title");
document.body = content;
} else {
- var matches = topic.match(/([\w\.\-\_]+)::([\w\.\-\_]+)/i);
+ var matches = topic.match(/([\w\.\-]+)::([\w\.\-\[]+)/i);
if (matches) {
rHelp(matches[2], matches[1]);
} else {
Modified: komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
===================================================================
--- komodo/SciViews-K/locale/en-GB/sciviewsk.dtd 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/locale/en-GB/sciviewsk.dtd 2009-11-05 18:53:17 UTC (rev 220)
@@ -59,6 +59,12 @@
<!ENTITY rSendFun.key "F">
<!ENTITY rSendLine "Send active line">
<!ENTITY rSendLine.key "L">
+
+<!ENTITY rSendLineOrSelection "Send active line/selection">
+<!ENTITY rSendLineOrSelection.key "C">
+<!ENTITY rSrcLineOrSelection "Source active line/selection">
+<!ENTITY rSrcLineOrSelection.key "T">
+
<!ENTITY rSendPara "Send current paragraph">
<!ENTITY rSendPara.key "P">
<!ENTITY rSendSel "Send selection">
Modified: komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
===================================================================
--- komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd 2009-11-05 18:53:17 UTC (rev 220)
@@ -59,6 +59,12 @@
<!ENTITY rSendFun.key "F">
<!ENTITY rSendLine "Exécuter la ligne courante">
<!ENTITY rSendLine.key "L">
+
+<!ENTITY rSendLineOrSelection "Send active line/selection">
+<!ENTITY rSendLineOrSelection.key "C">
+<!ENTITY rSrcLineOrSelection "Source active line/selection">
+<!ENTITY rSrcLineOrSelection.key "T">
+
<!ENTITY rSendPara "Exécuter le paragraphe actuel">
<!ENTITY rSendPara.key "P">
<!ENTITY rSendSel "Exécuter la sélection">
Modified: komodo/SciViews-K/templates/.Rprofile
===================================================================
--- komodo/SciViews-K/templates/.Rprofile 2009-11-03 13:27:46 UTC (rev 219)
+++ komodo/SciViews-K/templates/.Rprofile 2009-11-05 18:53:17 UTC (rev 220)
@@ -217,14 +217,14 @@
# A custom pager consists in displaying the file in Komodo
svPager <- function (files, header, title, delete.file) {
files <- gsub("\\", "\\\\", files[1], fixed = TRUE)
- koCmd(paste("sv.r.pager(", files, ",", title ,")", sep="\""))
+ koCmd(sprintf('sv.r.pager("%s", "%s")', files, title))
+
if (delete.file) {
- koCmd(paste("window.setTimeout(try { sv.tools.file.getfile(", files, ").remove(false); } catch(e) {}, 10000);", sep="\""))
+ koCmd(sprintf('window.setTimeout("try { sv.tools.file.getfile(\\"%s\\").remove(false); } catch(e) {}", 10000);', files));
}
}
-
svBrowser <- function(url) {
- koCmd(paste("sv.command.openHelp(", gsub("\\", "\\\\", url, fixed = TRUE), ")", sep="\""))
+ koCmd(sprintf("sv.command.openHelp(\"%s\")", gsub("\\", "\\\\", url, fixed = TRUE)))
}
# Look if and where komodo is installed
@@ -252,14 +252,20 @@
if (file.exists(Sys.getenv("koAppFile"))) {
Komodo <- Sys.getenv("koAppFile")
} else {
- Komodo <- "komodo" # On Windows, 'komodo' should be enough
+ # On Windows, 'komodo' should be enough
# But for reasons that escape me, komodo seems to stip off its own
# directory from the path variable. So, I have to restore it from
# the Windows registry :-(
+
Ret <- tclRequire("registry", warn = TRUE)
Path <- tclvalue(.Tcl("registry get {HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment} {Path}"))
- if (!is.null(Path) && !is.na(Path) && Path != "")
- Sys.setenv(path = Path)
+ if (!is.null(Path) && !is.na(Path) && Path != "") {
+ Path <- strsplit(Path, ";")[[1]]
+ Path <- Path[sapply(Path, function(x) file.exists(file.path(x, "komodo.exe")))][1]
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/sciviews -r 220
More information about the Sciviews-commits
mailing list