[Sciviews-commits] r359 - in komodo/SciViews-K/content: . js

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 2 00:21:51 CET 2011


Author: prezez
Date: 2011-03-02 00:21:51 +0100 (Wed, 02 Mar 2011)
New Revision: 359

Modified:
   komodo/SciViews-K/content/js/commands.js
   komodo/SciViews-K/content/overlayMain.xul
Log:
Added "Source into R" menu item in Places.

Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js	2011-02-28 21:14:16 UTC (rev 358)
+++ komodo/SciViews-K/content/js/commands.js	2011-03-01 23:21:51 UTC (rev 359)
@@ -1,6 +1,6 @@
 // SciViews-K command functions
 // Define the 'sv.command' namespace
-// Copyright (c) 2009-2010, K. Barton & Ph. Grosjean (phgrosjean at sciviews.org)
+// Copyright (c) 2009-2011, K. Barton & Ph. Grosjean (phgrosjean at sciviews.org)
 // License: MPL 1.1/GPL 2.0/LGPL 2.1
 ////////////////////////////////////////////////////////////////////////////////
 // sv.command.startR();			// Start the preferred R app and connect to it
@@ -513,19 +513,18 @@
 		sch.save();
 		//gKeybindingMgr.saveAndApply();
 		//gKeybindingMgr.saveCurrentConfiguration();
-
-		//sv.log.debug("You may need to restart Komodo.");
-
-		// A (temporary) hack to allow for R autocompletion/calltips to be
-		// triggered with the same key-shortcut as for other languages.
-		// cmd_svRTriggerCompletion will exit for files other than R
-		//var tpc_cmd = document.getElementById("cmd_triggerPrecedingCompletion");
-		//tpc_cmd.setAttribute("oncommand", [tpc_cmd.getAttribute("oncommand"),
-		//	"ko.commands.doCommandAsync('cmd_svRTriggerCompletion',
-		//  event);"].join(";"));
-        //sv.log.debug("Keybindings has been applied.");
 	}
 
+    this.sourcePlacesSelection = function sv_sourcePlacesSelection() {
+        var files = ko.places.manager.getSelectedItems()
+            .filter(function(x)(x.name.search(/\.[Rr]$/) != -1))
+            .map(function(x) x.file.path);
+        if (!files.length) return;
+        var cmd = files.map(function(x) "source('" + sv.tools.string.addslashes(x) +"')" )
+            .join("\n");
+        sv.r.eval(cmd);
+    }
+
 	addEventListener("load", function() setTimeout(_setControllers, 600), false);
 	addEventListener("load", _setKeybindings, false);
 

Modified: komodo/SciViews-K/content/overlayMain.xul
===================================================================
--- komodo/SciViews-K/content/overlayMain.xul	2011-02-28 21:14:16 UTC (rev 358)
+++ komodo/SciViews-K/content/overlayMain.xul	2011-03-01 23:21:51 UTC (rev 359)
@@ -168,11 +168,6 @@
 		</commandset>
 	</commandset>
 
-	<menupopup id="popup_tools">
-		<menuitem id="menu_sciviewsk" label="SciViews-K" observes="Tasks:svAbout"
-			class="menu-iconic-wide"/>
-	</menupopup>
-
 	<!--<menupopup id="editorContextMenu">-->
 	<!--	<menuseparator id="editor-context-sep-sv"-->
 	<!--	insertafter="context-sep-paste"-->
@@ -319,6 +314,18 @@
 			/>
 	</menupopup>
 
+<menupopup id="places-files-popup">
+	<menuseparator id="placesContextMenu_separatorR"
+		testEval_HideIf="ko.places.manager.getSelectedItems().filter(function(x) /\.[Rr]$/.test(x.name)).length == 0"
+	/>
+<menuitem oncommand="sv.command.sourcePlacesSelection()"
+		  disableIf="folder"
+		  class="menuitem-iconic"
+		  id="placesContextMenu_Rsource"
+		  label="Source into R"
+		  testEval_HideIf="ko.places.manager.getSelectedItems().filter(function(x) /\.[Rr]$/.test(x.name)).length == 0"
+/>
+</menupopup>
 
 	<tabbox id="rightTabBox">
 		<tabs id="right_toolbox_tabs">



More information about the Sciviews-commits mailing list