[Sciviews-commits] r211 - in komodo/SciViews-K: . _prj_internal_ content content/js skin skin/images

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 14 18:42:12 CEST 2009


Author: prezez
Date: 2009-10-14 18:42:12 +0200 (Wed, 14 Oct 2009)
New Revision: 211

Added:
   komodo/SciViews-K/content/RHelpWindow.xul
   komodo/SciViews-K/content/RPkgManager.xul
   komodo/SciViews-K/skin/images/arrow_refresh.png
   komodo/SciViews-K/skin/images/arrow_refresh_disabled.png
   komodo/SciViews-K/skin/images/arrow_refresh_hover.png
Removed:
   komodo/SciViews-K/content/RHelpOverlay.xul
   komodo/SciViews-K/content/pkgManagerOverlay.xul
Modified:
   komodo/SciViews-K/_prj_internal_/
   komodo/SciViews-K/content/js/commands.js
   komodo/SciViews-K/content/js/misc.js
   komodo/SciViews-K/content/js/sciviews.js
   komodo/SciViews-K/content/rsearch.html
   komodo/SciViews-K/install.rdf
   komodo/SciViews-K/skin/rhelpwin.css
   komodo/SciViews-K/skin/sciviewsk.css
Log:
Renamed RHelp and RPackageManager xul files (these were in fact separate windows, not overlays).
sv.getTextRange now selects word independently of scintilla wordChars setting.
RHelp: more modifications for interface and search results page.
Some sv.misc functions fixed/modified. 0.9.5 ?



Property changes on: komodo/SciViews-K/_prj_internal_
___________________________________________________________________
Name: svn:ignore
   + !*
*-dev.*
*


Deleted: komodo/SciViews-K/content/RHelpOverlay.xul
===================================================================
--- komodo/SciViews-K/content/RHelpOverlay.xul	2009-10-11 17:26:15 UTC (rev 210)
+++ komodo/SciViews-K/content/RHelpOverlay.xul	2009-10-14 16:42:12 UTC (rev 211)
@@ -1,410 +0,0 @@
-<?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://global/skin/toolbarbutton.css" type="text/css"?>
-<?xml-stylesheet href="chrome://global/skin/printPreview.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/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"?>
-<?xml-stylesheet href="chrome://sciviewsk/skin/sciviewsk.css" type="text/css"?>
-<?xml-stylesheet href="chrome://sciviewsk/skin/rhelpwin.css" type="text/css"?>
-
-<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"
-    persist="screenX screenY width height"
-    style="min-height: 400px; min-width: 300px;">
-<script type="text/javascript">
-<![CDATA[
-
-//FIXME: rHelpBrowser.homePage is not always set at startup
-
-var sv;
-var rHelpBrowser;
-var rHelpTopic;
-//var rHelpHome; // perhaps redundant, same as rHelpBrowser.homePage
-
-function go(uri) {
-	// these are still undefined when calling .go on load event,
-	// so define them here:
-
-	rHelpBrowser = document.getElementById("rhelp-browser");
-	if (uri === "" || uri == "@home@") {
-		rHelpBrowser.goHome();
-		return;
-	}
-	rHelpTopic = document.getElementById("rhelp-topic");
-	// In case the window was not yet fully loaded.
-	if (!rHelpTopic) {
-		self.addEventListener("load", function(event) {
-			go(uri);
-		}, false);
-		return;
-	}
-	//alert(uri);
-
-	if (uri) {
-		rHelpTopic.value = uri;
-	} else {
-		uri = rHelpTopic.value;
-	}
-	rHelpTopic.select();
-
-
-	// Try to differenciate an URL from a help topic
-	var isUri = uri.search(/^((f|ht)tps?|chrome|about|file):\/{0,3}/) === 0;
-
-	if (isUri) {
-		// This looks like a URL
-		rHelpBrowser.webNavigation.loadURI(uri, null, null, null, null);
-	} else {
-		// Look for this 'topic' web page
-		sv.r.help(uri);
-	}
-}
-
-function txtInput(aEvent) {
-	if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) {
-		go();
-	}
-}
-
-function search(topic) {
-	if (!topic)		return;
-
-	rHelpTopic.select();
-	sv.r.search(topic);
-}
-
-function onFindCommand (event) {
-	var button = event.target;
-	if (!button.checked) {
-		find();
-	} else {
-		var findToolbar = document.getElementById("FindToolbar");
-		findToolbar.close();
-	}
-}
-
-
-function find(next) {
-	//rHelpTopic.select();
-	//findInDoc(rHelpTopic.value);
-	var findToolbar = document.getElementById("FindToolbar");
-
-	if (!next) {
-		//var isShown = findToolbar.getAttribute("hidden") != "true";
-		findToolbar.open();
-		findToolbar._findField.value = rHelpBrowser.contentWindow.getSelection();
-		findToolbar._find(findToolbar._findField.value);
-		findToolbar._findField.focus();
-	} else {
-		findToolbar._findAgain(event.shiftKey);
-	}
-}
-
-// Browser progress listener:
-// 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) ||
-			aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
-			aIID.equals(Components.interfaces.nsISupports))
-				return this;
-			throw Components.results.NS_NOINTERFACE;
-	},
-
-	onStateChange: function(aWebProgress, aRequest, aFlag, aStatus) {
-		// If you use myListener for more than one tab/window, use
-		// aWebProgress.DOMWindow to obtain the tab/window which
-		// triggers the state change
-
-		if (aFlag & STATE_START) {
-			// This fires when the load event is initiated
-			document.getElementById("cmd_stop")
-				.setAttribute("disabled", false);
-		}
-
-		if (aFlag & STATE_STOP) {
-			// This fires when the load finishes
-			self.document.title = aWebProgress.DOMWindow.document.title;
-			rHelpTopic.value = aWebProgress.DOMWindow.document.location;
-
-			document.getElementById("cmd_stop")
-				.setAttribute("disabled", true);
-
-			document.getElementById("cmd_go_back")
-				.setAttribute("disabled", !rHelpBrowser.webNavigation
-						  .canGoBack)
-			document.getElementById("cmd_go_forward")
-				.setAttribute("disabled", !rHelpBrowser.webNavigation
-						  .canGoForward);
-		}
-	},
-
-	onLocationChange: function(aProgress, aRequest, aURI){
-		// This fires when the location bar changes; i.e load event is
-		// confirmed or when the user switches tabs. If you use
-		// myListener for more than one tab/window, use
-		// aProgress.DOMWindow to obtain the tab/window which triggered
-		//the change.
-
-		// This redirects result page from html search form to rHelpSearch results:
-		//FIXME: on the results page, when .goBack is invoked, page will be redirected again
-		if (aProgress.DOMWindow.document.location.href
-					.search(/search\/SearchEngine\.html\?.*SEARCHTERM=([a-z0-9+%]*)(?=&|$)/) != -1) {
-
-				rHelpSearch(RegExp.$1);
-		}
-
-	},
-
-	// For definitions of the remaining functions see XULPlanet.com
-	onProgressChange: function(aWebProgress, aRequest, curSelf,
-		maxSelf, curTot, maxTot) { },
-	onStatusChange: function(aWebProgress, aRequest, aStatus,
-		aMessage) { },
-	onSecurityChange: function(aWebProgress, aRequest, aState) { }
-}
-
-function onFindToolbarAttrModified(event) {
-	if (event.attrName == "hidden"
-		&& (!event.newValue || event.newValue == "true")) {
-		document.getElementById("rhelp-find").checked = !event.target.hidden;
-	}
-}
-
-// this does not work yet.
-// display formatted search results in a help window
-function rHelpSearch(topic) {
-	if (!topic)	return;
-
-	var cmd = 'svtmp <- help.search("' + topic + '")[];' +
-		'svtmp$matches <- cbind(svtmp$matches, Path = apply(svtmp$matches[, c(1,3)], 1, function(z) c(help(z[1],  package = z[2]))));' +
-		'cat(svtmp$pattern, "\n");' +  'write.table(svtmp$matches, sep=";", row.names = F, col.names = F, quote = F); rm(svtmp)';
-
-	sv.r.evalCallback(cmd, function(data) {
-		sv._lastHelpSearchContent = data;
-
-		rHelpBrowser.webNavigation.loadURI("chrome://sciviewsk/content/rsearch.html",
-					null, 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()") + ");";
-
-	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);
-
-		browser.homePage = sv.helpStartURI = path;
-
-		if (goTo)		go(path);
-	});
-}
-
-
-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];
-
-	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);
-}
-
-// this is fired earlier than load event, so all required variables
-// will be defined
-self.addEventListener("DOMContentLoaded", windowOnLoad, false);
-
-// required by PrintUtils.printPreview()
-function getWebNavigation() rHelpBrowser.webNavigation;
-function getNavToolbox() document.getElementById("nav-toolbar");
-function getPPBrowser() rHelpBrowser;
-
-]]>
-</script>
-<script type="text/javascript" src="chrome://global/content/printUtils.js" />
-<script type="text/javascript">
-	function printPage() {
-		PrintUtils.print();
-	}
-
-	function printPreview() {
-		function enterPP ()	document.getElementById("nav-toolbar").hidden = true;
-		function exitPP ()	document.getElementById("nav-toolbar").hidden = false;
-
-		PrintUtils.printPreview(enterPP, exitPP);
-	}
-</script>
-
-<keyset id="keyset_main">
-    <key id="key_find" key="F" observes="cmd_find" modifiers="accel" />
-    <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" />
-</keyset>
-
-<commandset id="commandset_main">
-  <command id="cmd_find" oncommand="find(false);" />
-  <command id="cmd_find_next" oncommand="find(true);" />
-  <command id="cmd_go" oncommand="go();" disabled="false"
-		   label="Go" tooltiptext="Show topic or web page" />
-  <command id="cmd_search" oncommand="rHelpSearch(document.getElementById('rhelp-topic').value);" disabled="false" label="Search"
-	       tooltiptext="Search expression in R help" />
-  <command id="cmd_go_back" oncommand="rHelpBrowser.goBack();" disabled="true"
-		   label="Back" tooltiptext="Back"/>
-  <command id="cmd_go_forward" oncommand="rHelpBrowser.goForward();" disabled="true"
-		   label="Forward" tooltiptext="Forward"/>
-  <command id="cmd_go_home" oncommand="rHelpBrowser.goHome();"
-		    label="Home" tooltiptext="R help index"/>
-  <command id="cmd_stop" oncommand="rHelpBrowser.stop();"
-		    label="Stop" tooltiptext="Stop"/>
-  <command id="cmd_print" oncommand="printPage();" />
-  <command id="cmd_print_preview" oncommand="printPreview();" />
-</commandset>
-
-<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"
-			 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"
-		    command="cmd_go_forward" buttonstyle="pictures"/>
-		<toolbarbutton id="rhelp-home" class="home-icon"
-		    command="cmd_go_home" buttonstyle="pictures"/>
-		<toolbarbutton id="rhelp-stop-button" class="stop-icon"
-		    command="cmd_stop" buttonstyle="pictures"/>
-		<toolbarbutton id="rhelp-web" type="menu" class="r-web-icon"
-		    disabled="false" label="Web" orient="horizontal"
-			tooltiptext="R help on the web" buttonstyle="pictures">
-			<menupopup>
-				<menuitem id="rhelp-menu-sitesearch" label="R Site Search"
-					accesskey="s"
-					oncommand="go('http://finzi.psych.upenn.edu/search.html');"/>
-<!--	 TODO: if CRAN mirror was set in R, go directly there, eg.	go('@CRAN@')		-->
-				<menuitem id="rhelp-menu-cran" label="CRAN"
-					accesskey="c"
-					oncommand="go('http://cran.r-project.org/');"/>
-				<menuitem id="rhelp-menu-wiki" label="R wiki"
-					accesskey="w"
-					oncommand="go('http://wiki.r-project.org/');"/>
-				<menuitem id="rhelp-menu-bioconductor" label="Bioconductor"
-					accesskey="b"
-					oncommand="go('http://www.bioconductor.org/');"/>
-				<menuitem id="rhelp-menu-graph" label="Graph Gallery"
-					accesskey="g"
-					oncommand="go('http://addictedtor.free.fr/graphiques/');"/>
-				<menuitem id="rhelp-menu-forge" label="R-Forge"
-					accesskey="f"
-					oncommand="go('http://r-forge.r-project.org/');"/>
-			</menupopup>
-		</toolbarbutton>
-		<toolbarseparator/>
-		<toolbarbutton id="rhelp-print-preview" class="print-button"
-		    command="cmd_print_preview" label="Print preview"
-			tooltiptext="Print preview" buttonstyle="pictures"/>
-		<toolbarbutton id="rhelp-print" class="print-button"
-		    command="cmd_print" label="Print"
-			tooltiptext="Print this page" buttonstyle="pictures"/>
-	</toolbar>
-</toolbox>
-    <vbox flex="1">
-        <hbox flex="1">
-            <browser id="rhelp-browser" type="content-primary"
-                src="about:blank" flex="1"/>
-        </hbox>
-    </vbox>
-		<vbox id="browser-bottombox">
-		<findbar browserid="rhelp-browser" id="FindToolbar" hidden="true"/>
-	</vbox>
-</window>

Copied: komodo/SciViews-K/content/RHelpWindow.xul (from rev 210, komodo/SciViews-K/content/RHelpOverlay.xul)
===================================================================
--- komodo/SciViews-K/content/RHelpWindow.xul	                        (rev 0)
+++ komodo/SciViews-K/content/RHelpWindow.xul	2009-10-14 16:42:12 UTC (rev 211)
@@ -0,0 +1,482 @@
+<?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://global/skin/toolbarbutton.css" type="text/css"?>
+<?xml-stylesheet href="chrome://global/skin/printPreview.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/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"?>
+<?xml-stylesheet href="chrome://sciviewsk/skin/sciviewsk.css" type="text/css"?>
+<?xml-stylesheet href="chrome://sciviewsk/skin/rhelpwin.css" type="text/css"?>
+
+<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"
+    persist="screenX screenY width height"
+    style="min-height: 400px; min-width: 300px;">
+<script type="text/javascript">
+<![CDATA[
+
+
+//TODO: context menu, running examples and selected R code from help pages
+
+var sv;
+var rHelpBrowser;
+var rHelpTopic;
+
+
+function go(uri) {
+	// these are still undefined when calling .go on load event,
+	// so define them here:
+
+	rHelpBrowser = document.getElementById("rhelp-browser");
+	if (uri === "" || uri == "@home@") {
+		rHelpBrowser.goHome();
+		return;
+	}
+	rHelpTopic = document.getElementById("rhelp-topic");
+	// In case the window was not yet fully loaded.
+	if (!rHelpTopic) {
+		self.addEventListener("load", function(event) {
+			go(uri);
+		}, false);
+		return;
+	}
+	//alert(uri);
+
+	if (uri) {
+		rHelpTopic.value = uri;
+	} else {
+		uri = rHelpTopic.value;
+	}
+	rHelpTopic.select();
+
+
+	// Try to differenciate an URL from a help topic
+	var isUri = uri.search(/^((f|ht)tps?|chrome|about|file):\/{0,3}/) === 0;
+
+	if (isUri) {
+		// This looks like a URL
+		rHelpBrowser.webNavigation.loadURI(uri, null, null, null, null);
+	} else {
+		// Look for this 'topic' web page
+		sv.r.help(uri);
+	}
+}
+
+function txtInput(aEvent) {
+	if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) {
+		if (aEvent.ctrlKey) {
+			rHelpSearch(rHelpTopic.value);
+		} else {
+			go();
+		}
+	}
+}
+
+function search(topic) {
+	if (!topic)		return;
+
+	rHelpTopic.select();
+	sv.r.search(topic);
+}
+
+function onFindCommand (event) {
+	var button = event.target;
+	if (!button.checked) {
+		find();
+	} else {
+		var findToolbar = document.getElementById("FindToolbar");
+		findToolbar.close();
+	}
+}
+
+
+function find(next) {
+	//rHelpTopic.select();
+	//findInDoc(rHelpTopic.value);
+	var findToolbar = document.getElementById("FindToolbar");
+
+	if (!next) {
+		//var isShown = findToolbar.getAttribute("hidden") != "true";
+		findToolbar.open();
+		findToolbar._findField.value = rHelpBrowser.contentWindow.getSelection();
+		findToolbar._find(findToolbar._findField.value);
+		findToolbar._findField.focus();
+	} else {
+		findToolbar._findAgain(event.shiftKey);
+	}
+}
+
+// Browser progress listener:
+// 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) ||
+			aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
+			aIID.equals(Components.interfaces.nsISupports))
+				return this;
+			throw Components.results.NS_NOINTERFACE;
+	},
+
+	onStateChange: function(aWebProgress, aRequest, aFlag, aStatus) {
+		// If you use myListener for more than one tab/window, use
+		// aWebProgress.DOMWindow to obtain the tab/window which
+		// triggers the state change
+
+		if (aFlag & STATE_START) {
+			// This fires when the load event is initiated
+			document.getElementById("cmd_stop")
+				.setAttribute("disabled", false);
+
+			document.getElementById("cmd_stop").hidden = false;
+			document.getElementById("cmd_reload").hidden = true;
+		}
+
+		if (aFlag & STATE_STOP) {
+			// This fires when the load finishes
+			self.document.title = aWebProgress.DOMWindow.document.title;
+			rHelpTopic.value = aWebProgress.DOMWindow.document.location;
+
+			document.getElementById("cmd_stop")
+				.setAttribute("disabled", true);
+
+			document.getElementById("cmd_stop").hidden = true;
+			document.getElementById("cmd_reload").hidden = false;
+
+			document.getElementById("cmd_go_back")
+				.setAttribute("disabled", !rHelpBrowser.webNavigation
+						  .canGoBack)
+			document.getElementById("cmd_go_forward")
+				.setAttribute("disabled", !rHelpBrowser.webNavigation
+						  .canGoForward);
+		}
+	},
+
+	onLocationChange: function(aProgress, aRequest, aURI){
+		// This fires when the location bar changes; i.e load event is
+		// confirmed or when the user switches tabs. If you use
+		// myListener for more than one tab/window, use
+		// aProgress.DOMWindow to obtain the tab/window which triggered
+		//the change.
+
+		// This redirects result page from html search form to rHelpSearch results:
+		//FIXME: on the results page, when .goBack is invoked, page will be redirected again
+		if (aProgress.DOMWindow.document.location.href
+					.search(/search\/SearchEngine\.html\?.*SEARCHTERM=([a-z0-9+%]*)(?=&|$)/) != -1) {
+
+				rHelpSearch(RegExp.$1);
+		}
+
+	},
+
+	// For definitions of the remaining functions see XULPlanet.com
+	onProgressChange: function(aWebProgress, aRequest, curSelf,
+		maxSelf, curTot, maxTot) { },
+	onStatusChange: function(aWebProgress, aRequest, aStatus,
+		aMessage) { },
+	onSecurityChange: function(aWebProgress, aRequest, aState) { }
+}
+
+function onFindToolbarAttrModified(event) {
+	if (event.attrName == "hidden"
+		&& (!event.newValue || event.newValue == "true")) {
+		document.getElementById("rhelp-find").checked = !event.target.hidden;
+	}
+}
+
+// display formatted search results in a help window
+function rHelpSearch(topic) {
+	if (!topic)	return;
+
+	rHelpBrowser.webNavigation.loadURI("chrome://sciviewsk/content/rsearch.html?" + encodeURIComponent(topic),
+					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()") + ");";
+
+	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);
+
+		browser.homePage = sv.helpStartURI = path;
+
+		if (goTo)		go(path);
+	});
+}
+
+
+var browserUtils = {};
+
+(function() {
+
+this.purgeCache = function() {
+	var cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
+		.getService(Components.interfaces.nsICacheService);
+
+	cacheService.evictEntries(Components.interfaces.nsICache.STORE_ANYWHERE);
+}
+
+this.purgeHistory = function() {
+	if (rHelpBrowser.docShell.sessionHistory.count) {
+		rHelpBrowser.docShell
+			.sessionHistory.PurgeHistory(rHelpBrowser.docShell.sessionHistory.count);
+	}
+}
+
+
+
+}).apply(browserUtils);
+
+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];
+
+	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);
+}
+
+// this is fired earlier than load event, so all required variables
+// will be defined
+self.addEventListener("DOMContentLoaded", windowOnLoad, false);
+
+// required by PrintUtils.printPreview()
+function getWebNavigation() rHelpBrowser.webNavigation;
+function getNavToolbox() document.getElementById("nav-toolbar");
+function getPPBrowser() rHelpBrowser;
+
+]]>
+</script>
+<script type="text/javascript" src="chrome://global/content/printUtils.js" />
+<script type="text/javascript" src="chrome://global/content/contentAreaUtils.js" />
+<script type="text/javascript">
+	function printPage() {
+		PrintUtils.print();
+	}
+
+	function printPreview() {
+		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
+	function savePage() {
+		var title = window._content.document.title;
+		var uri = window._content.location;
+		var doc = window._content.document;
+		var rchar = "_";
+
+		// We want to use cached data because the document is currently visible.
+		var dispHeader = null;
+		try {
+			dispHeader =
+				doc.defaultView
+				.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+				.getInterface(Components.interfaces.nsIDOMWindowUtils)
+				.getDocumentMetadata("content-disposition");
+		} catch (ex) {
+			// Failure to get a content-disposition is ok
+		}
+
+		internalSave(uri, doc, null, dispHeader,
+					 doc.contentType, false, null, null);
+	}
+
+</script>
+
+<keyset id="keyset_main">
+    <key id="key_find" key="F" observes="cmd_find" modifiers="accel" />
+    <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" />
+</keyset>
+
+<commandset id="commandset_main">
+  <command id="cmd_find" oncommand="find(false);" />
+  <command id="cmd_find_next" oncommand="find(true);" />
+  <command id="cmd_go" oncommand="go();" disabled="false"
+		   label="Go" tooltiptext="Show topic or web page" />
+  <command id="cmd_search" oncommand="rHelpSearch(document.getElementById('rhelp-topic').value);"
+		   disabled="false" label="Search"
+		   tooltiptext="Search expression in R help" />
+  <command id="cmd_go_back" oncommand="rHelpBrowser.goBack();" disabled="true"
+		   label="Back" tooltiptext="Back" />
+  <command id="cmd_go_forward" oncommand="rHelpBrowser.goForward();" disabled="true"
+		   label="Forward" tooltiptext="Forward" />
+  <command id="cmd_go_home" oncommand="rHelpBrowser.goHome();"
+		    label="Home" tooltiptext="R help index" />
+  <command id="cmd_stop" oncommand="rHelpBrowser.stop(rHelpBrowser.webNavigation.STOP_ALL);"
+		    label="Stop" tooltiptext="Stop" />
+  <command id="cmd_reload" oncommand="rHelpBrowser.reload();"
+		    label="Reload page" tooltiptext="Reload page" />
+  <command id="cmd_print" oncommand="printPage();" label="Print" desc="Print this page" />
+  <command id="cmd_print_preview" oncommand="printPreview();"
+		   label="Print preview" desc="Display page print preview" accesskey="r" />
+  <command id="cmd_print_setup" oncommand="PrintUtils.showPageSetup();"
+		   label="Page setup" desc="Page setup" />
+  <command id="cmd_save_page" oncommand="savePage();"
+		   label="Save page" desc="Save page" accesskey="s" />
+</commandset>
+
+<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"
+			 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"
+		    command="cmd_go_forward" buttonstyle="pictures"/>
+		<toolbarbutton id="rhelp-home" class="home-icon"
+		    command="cmd_go_home" buttonstyle="pictures"/>
+		<toolbarbutton id="rhelp-stop-button" class="stop-icon"
+		    command="cmd_stop" buttonstyle="pictures"/>
+		<toolbarbutton id="rhelp-reload-button" class="reload-icon"
+		    command="cmd_reload" buttonstyle="pictures"/>
+		<toolbarbutton id="rhelp-web" type="menu" class="r-web-icon"
+		    disabled="false" label="Web" orient="horizontal"
+			tooltiptext="R help on the web" buttonstyle="pictures">
+			<menupopup>
+				<menuitem id="rhelp-menu-sitesearch" label="R Site Search"
+					accesskey="s"
+					oncommand="go('http://finzi.psych.upenn.edu/search.html');"/>
+<!--	 TODO: if CRAN mirror was set in R, go directly there, eg.	go('@CRAN@')		-->
+				<menuitem id="rhelp-menu-cran" label="CRAN"
+					accesskey="c"
+					oncommand="go('http://cran.r-project.org/');"/>
+				<menuitem id="rhelp-menu-wiki" label="R wiki"
+					accesskey="w"
+					oncommand="go('http://wiki.r-project.org/');"/>
+				<menuitem id="rhelp-menu-bioconductor" label="Bioconductor"
+					accesskey="b"
+					oncommand="go('http://www.bioconductor.org/');"/>
+				<menuitem id="rhelp-menu-graph" label="Graph Gallery"
+					accesskey="g"
+					oncommand="go('http://addictedtor.free.fr/graphiques/');"/>
+				<menuitem id="rhelp-menu-forge" label="R-Forge"
+					accesskey="f"
+					oncommand="go('http://r-forge.r-project.org/');"/>
+			</menupopup>
+		</toolbarbutton>
+		<toolbarseparator/>
+		<toolbarbutton id="rhelp-menu" type="menu" label="File/Tools" orient="horizontal">
+			<menupopup>
+				<menuitem id="rhelp-save-page" class="menuitem-iconic save-buffer-icon"
+						  command="cmd_save_page" />
+				<menuseparator />
+				<menuitem id="rhelp-print-preview" command="cmd_print_preview" />
+				<menuitem id="rhelp-print-setup" command="cmd_print_setup" />
+				<menuitem id="rhelp-print" class="menuitem-iconic print-icon"
+						  command="cmd_print" />
+				<menuseparator />
+				<menuitem id="rhelp-menu-purge-history"
+						  label="Purge history"	accesskey="h"
+						  oncommand="browserUtils.purgeHistory();"/>
+				<menuitem id="rhelp-menu-purge-cache"
+						  label="Purge browser cache" accesskey="c"
+						  oncommand="browserUtils.purgeCache();"/>
+			</menupopup>
+		</toolbarbutton>
+	</toolbar>
+</toolbox>
+    <vbox flex="1">
+        <hbox flex="1">
+            <browser id="rhelp-browser" type="content-primary"
+                src="about:blank" flex="1"/>
+        </hbox>
+    </vbox>
+		<vbox id="browser-bottombox">
+		<findbar browserid="rhelp-browser" id="FindToolbar" hidden="true"/>
+	</vbox>
+</window>


Property changes on: komodo/SciViews-K/content/RHelpWindow.xul
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: komodo/SciViews-K/content/RPkgManager.xul (from rev 210, komodo/SciViews-K/content/pkgManagerOverlay.xul)
===================================================================
--- komodo/SciViews-K/content/RPkgManager.xul	                        (rev 0)
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/sciviews -r 211


More information about the Sciviews-commits mailing list