[Sciviews-commits] r444 - in komodo/SciViews-K: . components content content/js content/js/tools defaults locale/en-GB locale/fr-FR pylib skin skin/icons/misc skin/images udl

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Feb 25 12:56:53 CET 2012


Author: phgrosjean
Date: 2012-02-25 12:56:52 +0100 (Sat, 25 Feb 2012)
New Revision: 444

Added:
   komodo/SciViews-K/content/default-keybindings-mac.kkf
   komodo/SciViews-K/defaults/R reference (0.9.26).kpz
   komodo/SciViews-K/defaults/svKomodo_0.9-54.tar.gz
   komodo/SciViews-K/defaults/svKomodo_0.9-54.zip
   komodo/SciViews-K/skin/images/briefcase.png
   komodo/SciViews-K/skin/images/data.frame_go.png
   komodo/SciViews-K/skin/images/data.frame_tick.png
   komodo/SciViews-K/skin/images/globe-network.png
   komodo/SciViews-K/skin/images/help_red.png
   komodo/SciViews-K/skin/images/object_tick.png
   komodo/SciViews-K/skin/images/package_stop.png
Removed:
   komodo/SciViews-K/defaults/ANNOUNCE
   komodo/SciViews-K/defaults/NEWS
   komodo/SciViews-K/defaults/R reference (0.9.25).kpz
   komodo/SciViews-K/defaults/R.bat
   komodo/SciViews-K/defaults/README
   komodo/SciViews-K/defaults/Rgui.bat
   komodo/SciViews-K/defaults/SciViews-K (0.9.25).kpz
   komodo/SciViews-K/defaults/SciViews_0.9-4.tar.gz
   komodo/SciViews-K/defaults/SciViews_0.9-4.zip
   komodo/SciViews-K/defaults/svKomodo_0.9-53.tar.gz
   komodo/SciViews-K/defaults/svKomodo_0.9-53.zip
   komodo/SciViews-K/sciviewsk-0.10.dev-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.0-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.1-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.10-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.11-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.12-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.15-slim-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.16-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.2-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.21-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.3-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.4-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.5-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.6-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.7-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.8-ko.xpi
   komodo/SciViews-K/sciviewsk-0.9.9-ko.xpi
Modified:
   komodo/SciViews-K/.DS_Store
   komodo/SciViews-K/components/koRLinter.py
   komodo/SciViews-K/components/koR_UDL_Language.py
   komodo/SciViews-K/components/svRinterpreter.js
   komodo/SciViews-K/content/RHelpWindow.xul
   komodo/SciViews-K/content/RObjectsOverlay.xul
   komodo/SciViews-K/content/default-keybindings.kkf
   komodo/SciViews-K/content/js/ask.js
   komodo/SciViews-K/content/js/commands.js
   komodo/SciViews-K/content/js/pref-R.js
   komodo/SciViews-K/content/js/prefs.js
   komodo/SciViews-K/content/js/r.js
   komodo/SciViews-K/content/js/rjson.js
   komodo/SciViews-K/content/js/sciviews.js
   komodo/SciViews-K/content/js/tools/array.js
   komodo/SciViews-K/content/js/tools/e4x2dom.js
   komodo/SciViews-K/content/js/tools/file.js
   komodo/SciViews-K/content/js/tools/strings.js
   komodo/SciViews-K/content/overlayMain.xul
   komodo/SciViews-K/content/pref-R.xul
   komodo/SciViews-K/content/prefOverlay.xul
   komodo/SciViews-K/defaults/.DS_Store
   komodo/SciViews-K/defaults/svStart.R
   komodo/SciViews-K/defaults/toolbox.zip
   komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
   komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
   komodo/SciViews-K/pylib/lang_r.py
   komodo/SciViews-K/skin/icons/misc/.DS_Store
   komodo/SciViews-K/skin/images/.DS_Store
   komodo/SciViews-K/skin/rhelpwin.css
   komodo/SciViews-K/skin/sciviewsk.css
   komodo/SciViews-K/udl/Rlex.udl
Log:
Reworking and unifying commands an menus

Modified: komodo/SciViews-K/.DS_Store
===================================================================
(Binary files differ)

Modified: komodo/SciViews-K/components/koRLinter.py
===================================================================
--- komodo/SciViews-K/components/koRLinter.py	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/components/koRLinter.py	2012-02-25 11:56:52 UTC (rev 444)
@@ -94,7 +94,6 @@
         if R == "":
             errmsg = "Could not find a suitable R interpreter for linting."
             raise COMException(nsError.NS_ERROR_NOT_AVAILABLE, errmsg)
-        R = "R"
         #self.checkValidVersion()
 
         # Save R buffer to a temporary file
@@ -105,7 +104,7 @@
 
         p = None
         try:
-            argv = [R] + ["--slave"] + ["-e", "if(isTRUE(require('svTools',quietly=TRUE)))lint('" + os.path.basename(Rfilename) + "',type='flat')"]
+            argv = [R] + ["--slave"] + ["-e", "if(isTRUE(require('svTools',quietly=TRUE)))lint('" + os.path.basename(Rfilename) + "',type='flat',encoding='utf8')"]
             env = koprocessutils.getUserEnv()
             cwd = os.path.dirname(Rfilename)
             p = process.ProcessOpen(argv, cwd=cwd, env=env)

Modified: komodo/SciViews-K/components/koR_UDL_Language.py
===================================================================
--- komodo/SciViews-K/components/koR_UDL_Language.py	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/components/koR_UDL_Language.py	2012-02-25 11:56:52 UTC (rev 444)
@@ -63,8 +63,8 @@
         "line": [ "#", ],
     }
 
-    #downloadURL = "http://cran.r-project.org"
-    #searchURL = "http://www.rseek.org/"
+    downloadURL = "http://cran.r-project.org"
+    searchURL = "http://www.rseek.org/"
 
     variableIndicators = '$'
     _dedenting_statements = [u'return', u'break', u'else', u'next']

Modified: komodo/SciViews-K/components/svRinterpreter.js
===================================================================
--- komodo/SciViews-K/components/svRinterpreter.js	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/components/svRinterpreter.js	2012-02-25 11:56:52 UTC (rev 444)
@@ -33,21 +33,21 @@
     // Category: An array of categories to register this component in.
     _xpcom_categories: [{
 
-      // Each object in the array specifies the parameters to pass to
-      // nsICategoryManager.addCategoryEntry(). 'true' is passed for both
-      // aPersist and aReplace params.
-      category: "r",
+		// Each object in the array specifies the parameters to pass to
+		// nsICategoryManager.addCategoryEntry(). 'true' is passed for both
+		// aPersist and aReplace params.
+		category: "r",
 
-      // Optional, defaults to the object's classDescription
-      //entry: "",
+		// Optional, defaults to the object's classDescription
+		//entry: "",
 
-      // Optional, defaults to object's contractID (unless 'service' specified)
-      //value: "...",
+		// Optional, defaults to object's contractID (unless 'service' specified)
+		//value: "...",
 
-      // Optional, defaults to false. When set to true, and only if 'value' is
-      // not specified, the concatenation of the string "service," and the
-      // object's contractID is passed as aValue parameter of addCategoryEntry.
-       service: false
+		// Optional, defaults to false. When set to true, and only if 'value' is
+		// not specified, the concatenation of the string "service," and the
+		// object's contractID is passed as aValue parameter of addCategoryEntry.
+		service: false
     }],
 
     // QueryInterface implementation, e.g. using the generateQI helper
@@ -61,7 +61,7 @@
     */
     escape: function () {
 		// Currently do noting
-		return null;
+		return(null);
 	},
 
     /**
@@ -242,7 +242,6 @@
 	.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
 
 // Use UTF-8 encoding by default, except on Windows where ISO8859-1 is a better bet
-
 try {
 	if (navigator.platform.search(/Win\d+$/) === 0) {
 		converter.charset = "ISO8859-1";

Modified: komodo/SciViews-K/content/RHelpWindow.xul
===================================================================
--- komodo/SciViews-K/content/RHelpWindow.xul	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/content/RHelpWindow.xul	2012-02-25 11:56:52 UTC (rev 444)
@@ -70,7 +70,7 @@
 		rHelpBrowser.goHome();
 		return;
 	 case "@CRAN@":
-		uri = sv.prefs.getString("CRANMirror");
+		uri = sv.prefs.getString("r.cran.mirror");
 		if (!uri || uri.indexOf("ftp:/") === 0)
 			uri = "http://cran.r-project.org/";
 	}

Modified: komodo/SciViews-K/content/RObjectsOverlay.xul
===================================================================
--- komodo/SciViews-K/content/RObjectsOverlay.xul	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/content/RObjectsOverlay.xul	2012-02-25 11:56:52 UTC (rev 444)
@@ -202,6 +202,9 @@
 								<menuitem id="r_objects_pkg_load" label="Load packages..."
 								accesskey="l" class="menuitem-iconic r-pkg-load-icon"
 								oncommand="sv.r.pkg.load();"/>
+								<menuitem id="r_objects_pkg_unload" label="Unload..."
+								accesskey="l" class="menuitem-iconic r-pkg-unload-icon"
+								oncommand="sv.r.pkg.unload();"/>
 								<menuitem id="r_objects_pkg_load" label="Attach workspace..."
 								accesskey="a" class="menuitem-iconic r-data-attach"
 								oncommand="sv.r.loadWorkspace(null, true);"/>
@@ -217,6 +220,13 @@
 								<menuitem id="r_objects_pkg_remove" label="Remove..."
 								accesskey="r" class="menuitem-iconic r-pkg-remove-icon"
 								oncommand="sv.r.pkg.remove();"/>
+								<menuseparator/>
+								<menuitem id="r_cran_mirror" label="Select CRAN mirror"
+								accesskey="S" class="menuitem-iconic r-cran-mirror-icon"
+								oncommand="sv.r.pkg.chooseCRANMirror();"/>
+								<menuitem id="r_repositories" label="Select R repositories"
+								accesskey="r" class="menuitem-iconic r-repositories-icon"
+								oncommand="sv.r.pkg.repositories();"/>
 							</menupopup>
 						</toolbarbutton>
 						<toolbarseparator style="min-width:10px;" flex="1"/>

Added: komodo/SciViews-K/content/default-keybindings-mac.kkf
===================================================================
--- komodo/SciViews-K/content/default-keybindings-mac.kkf	                        (rev 0)
+++ komodo/SciViews-K/content/default-keybindings-mac.kkf	2012-02-25 11:56:52 UTC (rev 444)
@@ -0,0 +1,29 @@
+version 18
+
+# SciViews-K default keybindings
+# will be applied if no other key has been assigned by user, and if a key
+# combination is not used. Commands' ids must start with "cmd_sv" and be
+# defined in the XUL overlay.
+# Copyright (c) 2010-2012, Ph. Grosjean & K. Barton
+# License: MPL 1.1/GPL 2.0/LGPL 2.1
+
+binding cmd_svStartR Ctrl+Shift+F10
+
+binding cmd_svBrowseWD F7
+#binding cmd_svSessionMgr F6
+#binding cmd_svRCheckPackage F4
+
+binding cmd_svRRunLineOrSelection Ctrl+Shift+R
+binding cmd_svRRunLineEnter Ctrl+Shift+Return
+binding cmd_svRRunPara Ctrl+Shift+C
+binding cmd_svRRunBlock Ctrl+Shift+Y
+binding cmd_svRSourceFunction Meta+Shift+D
+binding cmd_svRSourceAll Ctrl+Shift+A
+binding cmd_svREscape Ctrl+Shift+Q
+
+binding cmd_svRHelpContext Alt+F1
+binding cmd_svRHelpSearch Alt+Shift+F1
+
+binding cmd_svRObjRefreshDisplay Meta+P
+binding cmd_svRActiveDF Meta+D
+binding cmd_svRLoadDF Meta+L

Modified: komodo/SciViews-K/content/default-keybindings.kkf
===================================================================
--- komodo/SciViews-K/content/default-keybindings.kkf	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/content/default-keybindings.kkf	2012-02-25 11:56:52 UTC (rev 444)
@@ -4,18 +4,26 @@
 # will be applied if no other key has been assigned by user, and if a key
 # combination is not used. Commands' ids must start with "cmd_sv" and be
 # defined in the XUL overlay.
-# Copyright (c) 2010, Ph. Grosjean & K. Barton
+# Copyright (c) 2010-2012, Ph. Grosjean & K. Barton
 # License: MPL 1.1/GPL 2.0/LGPL 2.1
 
-binding cmd_svRRunAll F5
-binding cmd_svRSourceAll Shift+F5
-binding cmd_svRRunLineOrSelection F6
-binding cmd_svRSourceLineOrSelection Shift+F6
-binding cmd_svRRunBlock F7
-binding cmd_svRSourceBlock Shift+F7
-binding cmd_svRRunLine F11
-binding cmd_svRRunPara F12
-binding cmd_svRSourcePara Shift+F12
-binding cmd_svRRunFunction Ctrl+F12
-binding cmd_svRSourceFunction Ctrl+Shift+F12
-binding cmd_svStartR Ctrl+F10
+binding cmd_svStartR Ctrl+Shift+F10
+
+binding cmd_svBrowseWD F7
+#binding cmd_svSessionMgr F6
+#binding cmd_svRCheckPackage F4
+
+binding cmd_svRRunLineOrSelection Ctrl+Shift+R
+binding cmd_svRRunLineEnter Ctrl+Shift+Return
+binding cmd_svRRunPara Ctrl+Shift+C
+binding cmd_svRRunBlock Ctrl+Shift+Y
+binding cmd_svRSourceFunction Ctrl+Shift+D
+binding cmd_svRSourceAll Ctrl+Shift+A
+binding cmd_svREscape Ctrl+Shift+Q
+
+binding cmd_svRHelpContext Alt+F1
+binding cmd_svRHelpSearch Alt+Shift+F1
+
+binding cmd_svRObjRefreshDisplay Ctrl+P
+binding cmd_svRActiveDF Ctrl+D
+binding cmd_svRLoadDF Ctrl+L

Modified: komodo/SciViews-K/content/js/ask.js
===================================================================
--- komodo/SciViews-K/content/js/ask.js	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/content/js/ask.js	2012-02-25 11:56:52 UTC (rev 444)
@@ -8,6 +8,7 @@
 // sv.ask.factors(object, restrict);   // List all factor variables for object
 //
 ////////////////////////////////////////////////////////////////////////////////
+// TODO: finalize and make use of this!
 // TODO: list files in a directory and a given extension
 //       implement sv.ask.vars and sv.ask.factors
 

Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/content/js/commands.js	2012-02-25 11:56:52 UTC (rev 444)
@@ -1,10 +1,11 @@
 // SciViews-K command functions
 // Define the 'sv.command' namespace
-// Copyright (c) 2009-2011, K. Barton & Ph. Grosjean (phgrosjean at sciviews.org)
+// Copyright (c) 2009-2012, K. Barton & Ph. Grosjean (phgrosjean at sciviews.org)
 // License: MPL 1.1/GPL 2.0/LGPL 2.1
 ////////////////////////////////////////////////////////////////////////////////
+// sv.command.RHelpWin;         // Reference to the R Help window
+// sv.command.configureR();     // Configure the R interpreter
 // sv.command.startR();			// Start the preferred R app and connect to it
-// TODO: sv.command.quitR(saveWorkspace)
 // 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
@@ -19,11 +20,12 @@
 	this.RHelpWin = null;  // A reference to the R Help Window
 	var _this = this;
 
+	// Private methods
+	// Get a window, knowing its URI
 	function _getWindowByURI(uri) {
 		var wm = Components.classes['@mozilla.org/appshell/window-mediator;1']
 			.getService(Components.interfaces.nsIWindowMediator);
 		var en = wm.getEnumerator("");
-
 		if (uri) {
 			var win;
 			while (en.hasMoreElements()) {
@@ -34,13 +36,14 @@
 		return(null);
 	}
 
-	//Get reference to a window, opening it if is closed
-	function _getWindowRef(uri, name, features, focus) {//, ...
+	// Get reference to a window, opening it if is closed
+	function _getWindowRef(uri, name, features, focus) { //, ...
 		var win = _getWindowByURI(uri);
 		if (!win || win.closed) {
 			try {
 				var args = Array.apply(null, arguments);
-				args = args.slice(0,3).concat(args.slice(4));
+				args = args.slice(0, 3).concat(args.slice(4));
+				// Default characteristics for the window
 				if (!features) args[2] = "chrome,modal,titlebar";
 				win = window.openDialog.apply(null, args);
 			} catch (e) {
@@ -48,9 +51,9 @@
 			}
 		}
 		if (focus) win.focus();
+		return(win);
 	}
 
-	// Private methods
 	// Continuous checking is now disabled - R often hanged
 	function _keepCheckingR (stopMe) {
 		/*
@@ -74,8 +77,7 @@
 	function _RControl_supported () {
 		var currentView = ko.views.manager.currentView;
 		if (!currentView || !currentView.koDoc) return(false);
-		//return(_isRRunning() && currentView.koDoc.language == "R");
-		return(currentView.koDoc.language == "R");
+		return(_isRRunning() && currentView.koDoc.language == "R");
 	}
 
 	function _RControlSelection_supported () {
@@ -86,6 +88,11 @@
 			currentView.scimoz.selectionStart) != 0));
 	}
 
+	// Display R interpreter configuration panel
+	this.configure = function () {
+		prefs_doGlobalPrefs("svPrefRItem", true);
+	}
+	
 	// Start R
 	this.startR = function () {
 		// Check if R is not already running and servicing on server port
@@ -102,83 +109,81 @@
 		// Remove /defaults/00LOCK if remained after a fail-start
 		try {
 			var lockFile = sv.tools.file.getfile(cwd, "00LOCK");
-			if (lockFile.exists())	lockFile.remove(true);
+			if (lockFile.exists()) lockFile.remove(true);
 		} catch(e) { }
 	
-		// PhG: on Mac OS X, R.app is not a file, but a dir!!!
+		// On Mac OS X, R.app is not a file, but a dir!
 		if (!cmd || (sv.tools.file.exists(sv.tools.strings.trim(
 			sv.prefs.getString("svRDefaultInterpreter"))) ==
 			sv.tools.file.TYPE_NONE)) {
-			if(ko.dialogs.okCancel(
-			sv.translate("Default R interpreter is not (correctly) set in " +
-				"Preferences. Do you want to do it now?"),
+			if (ko.dialogs.okCancel(sv.translate("R interpreter is not" +
+				"(correctly) configured in Preferences. Do you want to do it now?"),
 				"OK", null, "SciViews-K") == "OK") {
-					prefs_doGlobalPrefs("svPrefRItem", true);
-				}
+				this.configure();
+			}
 			return;
 		}
 
-	var isWin = navigator.platform.indexOf("Win") === 0;
-	var id = sv.prefs.getString("svRApplication",
-        isWin? "r-gui" : "r-terminal");
-
-	// runIn = "command-output-window", "new-console",
-	// env strings: "ENV1=fooJ\nENV2=bar"
-	// gPrefSvc.prefs.getStringPref("runEnv");
-	// Calculate output width
-	var scimoz = document.getElementById("rconsole-scintilla2").scimoz;
-	var width = (Math.floor(window.innerWidth /
-		scimoz.textWidth(0, "0")) - 7)
-	// min = 66, max = 200 (otherwise, it is harder to read) 
-	if (width < 66) width = 66;
-	if (width > 266) width = 266;
+		// Default R program depends on the platform
+		var isWin = navigator.platform.indexOf("Win") === 0;
+		var id = sv.prefs.getString("svRApplication",
+			isWin? "r-gui" : "r-terminal");
+		
+		// Width of R output defined to fit R output panel (min = 66, max = 200)
+		var scimoz = document.getElementById("rconsole-scintilla2").scimoz;
+		var width = (Math.floor(window.innerWidth /
+			scimoz.textWidth(0, "0")) - 7)
+		if (width < 66) width = 66;
+		if (width > 200) width = 200;
+		
+		var clientType = sv.prefs.getString("sciviews.client.type", "http");
+		var env = [
+			"koId=" + sv.prefs.getString("sciviews.client.id", "SciViewsK"),
+			"koHost=localhost",
+			"koActivate=FALSE",
+			"Rinitdir=" + sv.prefs.getString("sciviews.session.dir", "~"),
+			"koType=" + clientType,
+			"koServe=" + sv.prefs.getString("sciviews.client.socket", "8888"),
+			"koPort=" + sv.prefs.getString("sciviews.server.socket", "7052"),
+			"koKotype=" + sv.prefs.getString("sciviews.server.type", "file"),
+			"koDebug=" + String(sv.socket.debug).toUpperCase(),
+			"koAppFile=" + sv.tools.file.path("binDir", "komodo" +
+				(isWin? ".exe" : "")),
+			"OutDec=" + sv.prefs.getString("r.csv.dec", "."),
+			"OutSep=" + sv.prefs.getString("r.csv.sep", ","),
+			"width=" + width
+		];
+		var runIn = "no-console";
+		env.push("Rid=" + id);
 	
-	var clientType = sv.prefs.getString("sciviews.client.type", "socket");
-	var env = ["koId=" + sv.prefs.getString("sciviews.client.id", "SciViewsK"),
-		"koHost=localhost",
-		"koActivate=FALSE",
-		"Rinitdir=" + sv.prefs.getString("sciviews.session.dir", "~"),
-		"koType=" + clientType,
-		"koServe=" + sv.prefs.getString("sciviews.client.socket", "8888"),
-		"koPort=" + sv.prefs.getString("sciviews.server.socket", "7052"),
-		"koKotype=" + sv.prefs.getString("sciviews.server.type", "file"),
-		"koDebug=" + String(sv.socket.debug).toUpperCase(),
-		"koAppFile=" + sv.tools.file.path("binDir", "komodo" + (isWin? ".exe" : "")),
-		"OutDec=" + sv.prefs.getString("r.csv.dec", "."),
-		"OutSep=" + sv.prefs.getString("r.csv.sep", ","),
-		"width=" + width
-	];
-		// Not done here!! "width=" + width
-	var runIn = "no-console";
-	env.push("Rid=" + id);
-
-	switch (id) {
-		case "r-tk":
-			env.push("Rid=R-tk");
-			// Set DISPLAY only when not set:
-			var XEnv = Components.classes["@activestate.com/koEnviron;1"]
-				.createInstance(Components.interfaces.koIEnviron);
-			if (!XEnv.has("DISPLAY")) env.push("DISPLAY=:0");
-			delete(XEnv);
-			break;
-		case "r-terminal":
-			runIn = "new-console";
-			break;
-		default:
-	}
-
-	ko.run.runCommand(window, cmd, cwd, env.join("\n"), false,
-		false, false, runIn, false, false, false);
-
-	// Register observer of application termination
-	this.rObserver = new AppTerminateObserver(cmd);
+		switch (id) {
+			case "r-tk":
+				env.push("Rid=R-tk");
+				// Set DISPLAY only when not set:
+				var XEnv = Components.classes["@activestate.com/koEnviron;1"]
+					.createInstance(Components.interfaces.koIEnviron);
+				if (!XEnv.has("DISPLAY")) env.push("DISPLAY=:0");
+				delete(XEnv);
+				break;
+			
+			case "r-terminal":
+				runIn = "new-console";
+				break;
+			default:
+		}
 	
-	// Ensure the client type is correct for everyone
-	sv.socket.setSocketType(clientType);
+		ko.run.runCommand(window, cmd, cwd, env.join("\n"), false,
+			false, false, runIn, false, false, false);
 	
-	// ... make sure to start with a clear R Output window
-	sv.cmdout.clear(false);
-}
+		// Register observer of application termination
+		this.rObserver = new AppTerminateObserver(cmd);
+		
+		// Ensure the client type is correct for everyone
+		sv.socket.setSocketType(clientType);
+		
+		// ... make sure to start with a clear R Output window
+		sv.cmdout.clear(false);
+	}
 
 	// This will observe status message notification to be informed about
 	// application being terminated. A more straightforward way would be to use
@@ -187,9 +192,10 @@
 	function AppTerminateObserver (command) {
 		this.register(command);
 	};
-
+	
 	AppTerminateObserver.prototype = {
 		command: "",
+		
 		// This is launched when status message is set, we then check if it was
 		// about terminated application
 		observe: function (subject, topic, data) {
@@ -203,6 +209,7 @@
 				// Do something here like activate/deactivate commands...
 			}
 		},
+		
 		register: function (command) {
 			var observerSvc = Components.
 				classes["@mozilla.org/observer-service;1"].
@@ -212,22 +219,20 @@
 			sv.log.debug("R has been started with command: " + command);
 			// Sending commands to R does not seem to work, I think it is
 			// too early, R is still starting. This should be in .Rprofile
-			//sv.socket.rUpdate();
 			// Possibly refresh the GUI by running SciViews-specific
 			// R task callbacks and make sure R Objects pane is updated
 			//sv.r.evalHidden("try(koRefresh(force = TRUE), silent = TRUE)");
 
-			// this hopefully will be called from R, when it starts:
+			// This hopefully will be called from R, when it starts:
 			_this.updateRStatus(true);
 		},
+		
 		unregister: function () {
 			var observerSvc = Components.
 				classes["@mozilla.org/observer-service;1"].
 				getService(Components.interfaces.nsIObserverService);
 			observerSvc.removeObserver(this, 'status_message');
-
 			sv.log.debug("R has been closed. Command was: " + this.command);
-
 			_this.updateRStatus(false);
 		}
 	};
@@ -365,28 +370,60 @@
 
         const XRRunning = 1, XRStopped = 2, XisRDoc = 4, XHasSelection = 8;
         var handlers = {
-                'cmd_svOpenPkgManager': [ "sv.command.openPkgManager();", XRRunning ],
-                'cmd_svBrowseWD': [ 'sv.r.setwd(\'current\', true);', XRRunning ],
-                'cmd_svQuitR': [ 'sv.r.quit();', XRRunning ],
-                'cmd_svOpenHelp': [ "sv.command.openHelp();", XRRunning ],
-                'cmd_svSessionMgr': [ "sv.command.openSessionMgr();", XRRunning ],
-                'cmd_svStartR': ['sv.command.startR();', 0], // XRStopped],
-                'cmd_svREscape': [ 'sv.r.escape();', XRRunning ],
+                'cmd_svConfigureR': ['sv.command.configure();', 0],
+				'cmd_svInstallRtoolbox': ['sv.checkToolbox();', 0],
+				'cmd_svUIlevel': ['sv.askUI(true);', 0],
+				'cmd_svStartR': ['sv.command.startR();', 0], // XRStopped],
+				'cmd_svQuitR': ['sv.r.quit();', XRRunning],
+				'cmd_svOpenPkgManager': ['sv.command.openPkgManager();', XRRunning],
+                'cmd_svBrowseWD': ['sv.r.setwd("current", true);', XRRunning],  
+                'cmd_svOpenHelp': ['sv.command.openHelp();', XRRunning],
+				// Still incomplete! 'cmd_svSessionMgr': ['sv.command.openSessionMgr();', XRRunning],
+				'cmd_svSessionMgr': ['sv.r.switchSession(true);', XRRunning],
+                'cmd_svREscape': ['sv.r.escape();', XRRunning],
                 // 'cmd_svUpdateRInfo': ['sv.socket.rUpdate();', XRRunning],
-                'cmd_svRRunAll': [ 'sv.r.send("all");',XisRDoc | XRRunning ],
-                'cmd_svRSourceAll': [ 'sv.r.source("all");',XisRDoc | XRRunning ],
-                'cmd_svRRunBlock': [ 'sv.r.send("block");',XisRDoc | XRRunning ],
-                'cmd_svRRunFunction': [ 'sv.r.send("function");',XisRDoc | XRRunning ],
-                'cmd_svRRunLine': [ 'sv.r.send("line");',XisRDoc | XRRunning ],
-                'cmd_svRRunPara': [ 'sv.r.send("para");',XisRDoc | XRRunning ],
-                'cmd_svRSourceBlock': [ 'sv.r.source("block");',XisRDoc | XRRunning ],
-                'cmd_svRSourceFunction': [ 'sv.r.source("function");',XisRDoc | XRRunning ],
-                'cmd_svRSourcePara': [ 'sv.r.source("para");',XisRDoc | XRRunning ],
-				'cmd_svRRunLineOrSelection': [ 'sv.r.run();', XisRDoc | XRRunning ],
-                'cmd_svRSourceLineOrSelection': [ 'sv.r.source("line/sel");', XisRDoc | XRRunning ],
-                'cmd_svRRunSelection': [ 'sv.r.send("sel");',XisRDoc | XRRunning | XHasSelection ],
-                'cmd_svRSourceSelection': [ 'sv.r.source("sel");', XisRDoc | XRRunning | XHasSelection ],
-                'cmd_viewrtoolbar': [ 'ko.uilayout.toggleToolbarVisibility(\'RToolbar\')', 0 ]
+                'cmd_svRRunAll': ['sv.r.send("all");', XisRDoc | XRRunning],
+                'cmd_svRSourceAll': ['sv.r.source("all");', XisRDoc | XRRunning],
+                'cmd_svRRunBlock': ['sv.r.send("block");', XisRDoc | XRRunning],
+                'cmd_svRRunFunction': ['sv.r.send("function");', XisRDoc | XRRunning],
+                'cmd_svRRunLine': ['sv.r.send("line");', XisRDoc | XRRunning],
+                'cmd_svRRunPara': ['sv.r.send("para");', XisRDoc | XRRunning],
+                'cmd_svRSourceBlock': ['sv.r.source("block");', XisRDoc | XRRunning],
+                'cmd_svRSourceFunction': ['sv.r.source("function");', XisRDoc | XRRunning],
+                'cmd_svRSourcePara': ['sv.r.source("para");', XisRDoc | XRRunning],
+				'cmd_svRRunLineOrSelection': ['sv.r.run();', XisRDoc | XRRunning],
+                'cmd_svRSourceLineOrSelection': ['sv.r.source("line/sel");', XisRDoc | XRRunning],
+                'cmd_svRRunSelection': ['sv.r.send("sel");', XisRDoc | XRRunning | XHasSelection],
+                'cmd_svRSourceSelection': ['sv.r.source("sel");', XisRDoc | XRRunning | XHasSelection],
+                'cmd_viewrtoolbar': ['ko.uilayout.toggleToolbarVisibility(\'RToolbar\')', 0],
+				'cmd_svRRunLineEnter': ['sv.r.runEnter();', XisRDoc | XRRunning],
+				'cmd_svRHelpContext': ['sv.r.help("", false);', XisRDoc | XRRunning],
+				'cmd_svRHelpSearch': ['sv.r.search();', XisRDoc | XRRunning],
+				'cmd_svRObjStructure': ['sv.r.display("", "structure");', XisRDoc | XRRunning],
+				'cmd_svRObjRefreshDisplay': ['ko.uilayout.ensureTabShown("sciviews_robjects_tab", true); sv.r.objects.getPackageList(true);', XRRunning],
+				'cmd_svRObjList': ['sv.r.eval("ls()");', XRRunning],
+				'cmd_svRObjRemove': ['sv.r.eval("rm(list = ls())");', XRRunning],
+				'cmd_svRActiveDF': ['sv.r.obj();', XRRunning],
+				'cmd_svRLoadDF': ['sv.r.data();', XRRunning],
+				'cmd_svRActiveLM': ['sv.r.obj("lm");', XRRunning],
+				'cmd_svRListDemos': ['sv.r.eval("demo()");', XRRunning],
+				'cmd_svRBrowseVignettes': ['sv.r.browseVignettes();', XRRunning],
+				'cmd_svRSiteSearch': ['sv.r.siteSearch();', XRRunning],
+				'cmd_svRRunExample': ['sv.r.example();', XRRunning],
+				'cmd_svRClearSessionData': ['sv.r.eval(\'unlink(path.expand(file.path(getOption("R.initdir"), c(".RData", ".Rhistory"))))\');', XRRunning],
+				'cmd_svRWorkspaceLoad': ['sv.r.loadWorkspace();', XRRunning],
+				'cmd_svRWorkspaceSave': ['sv.r.saveWorkspace();', XRRunning],
+				'cmd_svRHistoryLoad': ['sv.r.loadHistory();', XRRunning],
+				'cmd_svRHistorySave': ['sv.r.saveHistory();', XRRunning],
+				'cmd_svRWDFile': ['sv.r.setwd("file");', XRRunning],
+				'cmd_svRWDSession': ['sv.r.setwd("session");', XRRunning],
+				'cmd_svRWDPrevious': ['sv.r.setwd("previous");', XRRunning],
+				'cmd_svRNewGraph': ['sv.r.eval("dev.new()");', XRRunning],
+				'cmd_svRNextGraph': ['sv.r.eval("dev.set()");', XRRunning],
+				'cmd_svRCloseGraph': ['sv.r.eval("dev.off()");', XRRunning],
+				'cmd_svRCloseAllGraphs': ['sv.r.eval("graphics.off()");', XRRunning],
+				'cmd_svRSaveGraphPDF': ['sv.r.saveGraph("pdfwrite");', XRRunning],
+				'cmd_svRSaveGraphPNG': ['sv.r.saveGraph("png16m");', XRRunning]
         }
 
         // Temporary
@@ -406,7 +443,7 @@
             return ((view.scimoz.selectionEnd - view.scimoz.selectionStart) != 0);
         }
 
-        function svController() {}
+        function svController () {}
 
 		svController.prototype = new Controller();
         
@@ -414,7 +451,7 @@
         
 		svController.prototype.destructor = function () { }
         
-        svController.prototype.isCommandEnabled = function(command) {
+        svController.prototype.isCommandEnabled = function (command) {
             if(!(command in handlers)) return(false);
 			return(true);
 		}
@@ -439,7 +476,7 @@
         svController.prototype.supportsCommand = svController.prototype
 			.isCommandEnabled;
 
-        svController.prototype.doCommand = function(command) {
+        svController.prototype.doCommand = function (command) {
             if (command in handlers) return(eval(handlers[command][0]));
             return (false);
         }
@@ -470,25 +507,36 @@
 	// Set default keybindings from file
 	// chrome://sciviewsk/content/default-keybindings.kkf
 	// preserving user modified ones and avoiding key conflicts
+	// TODO: we need to change all schemes!!!
+	// TODO: use of gKeybindingMgr could simplify this code
 	function _setKeybindings (clearOnly) {
 		var keybindingSvc = Components
 			.classes["@activestate.com/koKeybindingSchemeService;1"]
 			.getService(Components.interfaces.koIKeybindingSchemeService);
-
-//TODO: use of gKeybindingMgr could simplify this code
 		//gKeybindingMgr.keybindingSchemeService
 
-		var svSchemeDefault = sv.tools.file
-			.readURI("chrome://sciviewsk/content/default-keybindings.kkf");
+		var bindingFile;
+		// On Mac OS X, binding is slightly different (e.g., Ctrl replaced by Meta)
+		if (navigator.platform.substr(0, 3) == "Mac") {
+			bindingFile = "chrome://sciviewsk/content/default-keybindings-mac.kkf";
+		} else {
+			bindingFile = "chrome://sciviewsk/content/default-keybindings.kkf";
+		}
+		var svSchemeDefault = sv.tools.file.readURI(bindingFile);
 
 		//gKeybindingMgr.currentScheme.name
 		var currentSchemeName = sv.prefs.getString("keybinding-scheme");
-
 		var sch = keybindingSvc.getScheme(currentSchemeName);
 
+		var bindingRx = /[\r\n]+(# *SciViews|binding cmd_sv.*)/g;
+
 		//gKeybindingMgr.parseConfiguration
-		var bindingRx = /[\r\n]+(# *SciViews|binding cmd_sv.*)/g;
-		if (clearOnly != true) {
+		if (clearOnly == true) {
+			//gKeybindingMgr.removeCommandsWithPrefix("cmd_sv");
+			sch.data = sch.data.replace(bindingRx, "");
+			sv.log.debug("SciViews keybindings (" + updatedKeys.length +
+				") have been cleared in \"" + currentSchemeName + "\" scheme.");
+		} else {
 			function _getSvKeys (data, pattern) {
 				if (!pattern) pattern = "";
 				var keys = data.match(new RegExp("^binding " + pattern +
@@ -502,44 +550,39 @@
 			}
 
 			var svCmdPattern = "cmd_sv";
-			var svKeysDefault = _getSvKeys (svSchemeDefault, svCmdPattern);
-			var svKeysCurrent = _getSvKeys (sch.data, svCmdPattern);
+			var svKeysDefault = _getSvKeys(svSchemeDefault, svCmdPattern);
+			var svKeysCurrent = _getSvKeys(sch.data, svCmdPattern);
 
 			// Temporarily delete SciViews keybindings
 			sch.data = sch.data.replace(bindingRx, "");
 
 			// Check for key conflicts
-			//var usedbys = this.usedBy([keysequence]);
-			var svKeysCurrentOther = _getSvKeys (sch.data, "");
-			var currKeyArr = [];
-			for (var k in svKeysCurrentOther)
-				currKeyArr.push(svKeysCurrentOther[k]);
-			for (var k in svKeysDefault) {
-				if (currKeyArr.indexOf(svKeysDefault[k]) != -1)
-					delete svKeysDefault[k];
-			}
+		//	var svKeysCurrentOther = _getSvKeys(sch.data, "");
+		//	var currKeyArr = [];
+		//	for (var k in svKeysCurrentOther)
+		//		currKeyArr.push(svKeysCurrentOther[k]);
+		//	for (var k in svKeysDefault) {
+		//		if (currKeyArr.indexOf(svKeysDefault[k]) != -1)
+		//			delete svKeysDefault[k];
+		//	}
 
 			var newSchemeData = "";
 			var key, updatedKeys = [];
 			for (var k in svKeysDefault) {
 				sv.log.debug(k);
-				if (svKeysCurrent[k]) {
-					key = svKeysCurrent[k];
-				} else {
+		// PhG: with these lines, it is impossible to change existing default keys from here!
+		//		if (svKeysCurrent[k]) {
+		//			key = svKeysCurrent[k];
+		//		} else {
 					key = svKeysDefault[k];
 					updatedKeys.push(k);
-				}
+		//		}
 				newSchemeData += "binding " + k + " " + key + "\n";
 			}
 			sch.data += "\n\n# SciViews\n" + newSchemeData;
 			sv.log.debug(" SciViews keybindings (" + updatedKeys.length +
 				") have been updated in \"" +
 				currentSchemeName + "\" scheme.");
-		} else {
-			//gKeybindingMgr.removeCommandsWithPrefix("cmd_sv");
-			sch.data = sch.data.replace(bindingRx, "");
-			sv.log.debug("SciViews keybindings (" + updatedKeys.length +
-				") have been cleared in \"" + currentSchemeName + "\" scheme.");
 		}
 		sch.save();
 		//gKeybindingMgr.saveAndApply();
@@ -556,7 +599,7 @@
         sv.r.eval(cmd);
     }
 
+	addEventListener("load", _setKeybindings, false);
 	addEventListener("load", function() setTimeout(_setControllers, 600), false);
-	addEventListener("load", _setKeybindings, false);
 
 }).apply(sv.command);

Modified: komodo/SciViews-K/content/js/pref-R.js
===================================================================
--- komodo/SciViews-K/content/js/pref-R.js	2012-02-24 16:07:18 UTC (rev 443)
+++ komodo/SciViews-K/content/js/pref-R.js	2012-02-25 11:56:52 UTC (rev 444)
@@ -1,41 +1,100 @@
 // SciViews-K R preferences panel functions
-// Copyright (c) 2009-2010 Ph. Grosjean (phgrosjean at sciviews.org) & Kamil Barton
+// Copyright (c) 2009-2012 Ph. Grosjean (phgrosjean at sciviews.org) & Kamil Barton
 // License: MPL 1.1/GPL 2.0/LGPL 2.1
 ////////////////////////////////////////////////////////////////////////////////
-// svPrefR_OnPreferencePageOK(prefset);         // User click OK
-// PrefR_OnLoad();                            	// R preference widow loaded
-// TODO: update this list...
-//////////////////////////////////////////////////////////////////////////////
+// apps;                                  // Array with supported R applications  
+//
+//// Utilities /////////////////////////////////////////////////////////////////
+// _menuListSetValues(attribute);         // Set the value in a menu list
+// _menuListGetValues(attribute);         // Get the selection in a menu
+// _populateRInterps();                   // Populate list of supported R apps
+//
+//// Implementation of the pref-R dialog box ///////////////////////////////////
+// PrefR_OnLoad();                        // R preference window loaded
+// PrefR_editMenulist(el, value);         // Edit a list for a menu
+// PrefR_svRDefaultInterpreterOnSelect(event); // R app selected in the list
+// PrefR_svRApplicationUpdate(event);     // Update list of application
+// PrefR_updateCommandLine(update);       // Update the command line label
+// PrefR_setExecutable(path);             // Set the path to the R executable
+// PrefR_UpdateCranMirrors(localOnly);    // Update the list of CRAN mirrors
+//
+//// Standard interface for preference pages ///////////////////////////////////
+// OnPreferencePageLoading(prefset);      // Code run when the page is loaded
+//                                           Note: PrefR_OnLoad() used instead
+// OnPreferencePageOK(prefset);           // User clicks OK
+////////////////////////////////////////////////////////////////////////////////
+// Prefs to possibly include later on:
+// * Address for remote R (sv.socket.host)?
+//   if not localhost - disable source* commands
+// * R help: show in tab or in separate window
+// * R Site search url (%S replaced by topic)
 
-
-/* TODO: prefs to include:
-* address for remote R (sv.socket.host)? (if not localhost - disable source* commands)
-* R help: show in tab (sidebar - another TODO) or in separate window
-* R Site search url (%S replaced by topic)
-*/
-
-
 var sv;
 
[TRUNCATED]

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


More information about the Sciviews-commits mailing list