[Sciviews-commits] r203 - in komodo/SciViews-K: . R content content/js skin

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Oct 2 16:07:23 CEST 2009


Author: prezez
Date: 2009-10-02 16:07:23 +0200 (Fri, 02 Oct 2009)
New Revision: 203

Added:
   komodo/SciViews-K/skin/rhelpwin.css
Modified:
   komodo/SciViews-K/R/Rprofile
   komodo/SciViews-K/content/RHelpOverlay.xul
   komodo/SciViews-K/content/js/commands.js
   komodo/SciViews-K/content/js/r.js
   komodo/SciViews-K/content/js/robjects.js
   komodo/SciViews-K/content/js/socket.js
   komodo/SciViews-K/sciviewsk-0.9.2-ko.xpi
Log:
sv.socket.rCommand and sv.r.evalCallback modified so that they pass any number of additional arguments to callback function. If callback is an object, callback.value stores the result from R.
sv.r.siteSearch rewritten to go to search page directly, and open results in RHelpWin.
Small mods to sv.r.objects context menu.

Modified: komodo/SciViews-K/R/Rprofile
===================================================================
--- komodo/SciViews-K/R/Rprofile	2009-09-30 09:36:22 UTC (rev 202)
+++ komodo/SciViews-K/R/Rprofile	2009-10-02 14:07:23 UTC (rev 203)
@@ -146,6 +146,10 @@
 							R.Version()$minor, ") connected", sep = ""))
 					}
 					rm(koact)
+
+					# set charset in komodo:
+					koCmd(paste("sv.socket.charset = '", localeToCharset()[1], "';", sep=""));
+
 				} else {
 					cat("R is not SciViews ready, install latest svMisc, svSocket & svGUI packages\n")
 				}
@@ -163,7 +167,7 @@
 	system("komodo", wait = FALSE)
 
 	# Make sure to use Komodo as your R editor
-	
+
 }
 
-### SciViews install end ###
\ No newline at end of file
+### SciViews install end ###

Modified: komodo/SciViews-K/content/RHelpOverlay.xul
===================================================================
--- komodo/SciViews-K/content/RHelpOverlay.xul	2009-09-30 09:36:22 UTC (rev 202)
+++ komodo/SciViews-K/content/RHelpOverlay.xul	2009-10-02 14:07:23 UTC (rev 203)
@@ -41,12 +41,11 @@
 <?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/toolbar.css" type="text/css"?>-->
 <?xml-stylesheet href="chrome://komodo/skin/bindings/buttons.css" type="text/css"?>
 <?xml-stylesheet href="chrome://komodo/skin/bindings/views.css" type="text/css"?>
 <?xml-stylesheet href="chrome://komodo/skin/bindings/widgets.css" type="text/css"?>
 <?xml-stylesheet href="chrome://sciviewsk/skin/sciviewsk.css" type="text/css"?>
-<?xml-stylesheet href="chrome://sciviewsk/skin/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://sciviewsk/skin/rhelpwin.css" type="text/css"?>
 
 
 <window
@@ -125,9 +124,9 @@
 		if (!next) {
 			//var isShown = findToolbar.getAttribute("hidden") != "true";
 			findToolbar.open();
-
 			findToolbar._findField.value = rHelpBrowser.docShell.document.getSelection();
 			findToolbar._find(findToolbar._findField.value);
+			findToolbar._findField.focus();
 		} else {
 			findToolbar._findAgain(event.shiftKey);
 		}
@@ -257,7 +256,7 @@
 	function printPreview() {
 		function enterPP ()	document.getElementById("nav-toolbar").hidden = true;
 		function exitPP ()	document.getElementById("nav-toolbar").hidden = false;
-		
+
 		PrintUtils.printPreview(enterPP, exitPP);
 	}
 </script>

Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js	2009-09-30 09:36:22 UTC (rev 202)
+++ komodo/SciViews-K/content/js/commands.js	2009-10-02 14:07:23 UTC (rev 203)
@@ -178,7 +178,6 @@
 	// application being terminated. A more straightforward way would be to use
 	// runService.RunAndNotify but this wouldn't allow to start app in a console
 	// window. So we have to do this trick here.
-	// This is not used for anything yet.
 	function AppTerminateObserver (command) {
 		this.register(command);
 	};
@@ -350,10 +349,7 @@
 	this.helpStartURI = "";
 
 	this.openHelp = function (uri) {
-		sv.cmdout.append(uri);
-
-
-	    // We will need special treatment of in windows
+	    // We will need special treatment in windows
 	    var isWin = navigator.platform.search(/Win\d+$/) === 0;
 
 	    if (!_this.helpStartURI) {
@@ -369,7 +365,6 @@
 				path = sv.tools.file.getURI(path);
 				_this.helpStartURI = path;
 				_this.openHelp(path);
-				//alert(_this.helpStartURI);
 			});
 			return;
 		}
@@ -381,6 +376,7 @@
 		// because:
 		// 1) sv.tools.file.getfile() returns null on Mac OS X
 		// 2) sv.tools.file.getURI() raises an error on Mac OS X
+		// Any ideas why??
 
 		// This should hopefully work on all platforms (it does on Win and Linux)
 		// First, check if "uri" is an URI already:
@@ -395,7 +391,7 @@
 		} catch (e) {
 			// fallback:
 			if (!isUri)
-			uri = "file://" + uri;
+				uri = "file://" + uri;
 
 			sv.log.exception(e, "sv.command.openHelp");
 		}

Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js	2009-09-30 09:36:22 UTC (rev 202)
+++ komodo/SciViews-K/content/js/r.js	2009-10-02 14:07:23 UTC (rev 203)
@@ -11,7 +11,7 @@
 //
 // sv.r.eval(cmd); // Evaluate 'cmd' in R
 // sv.r.evalHidden(cmd, earlyExit); // Evaluate 'cmd' in R in a hidden way
-// sv.r.evalCallback(cmd, procfun); // Evaluate 'cmd' in R and call 'procfun'
+// sv.r.evalCallback(cmd, procfun, ...); // Evaluate 'cmd' in R and call 'procfun'
 // sv.r.escape(cmd); // Escape R multiline mode, 'cmd' to run then
 // sv.r.setwd(); // Set the working dir (choose or set to current buffer)
 // sv.r.run(); // Run current selection or line in R and goto next line
@@ -93,12 +93,9 @@
                                // from R-Forge
 // sv.r.pkg.CRANmirror();   // Select preferred CRAN mirror
 
-
 /// REMOVED! use sv.command.openHelp instead
 // sv.r.helpStart(start); // Start R help in the browser, unless start is false
 
-
-
 ////////////////////////////////////////////////////////////////////////////////
 //
 // TODO: in overlay: add "source file" context menu item in the project tab
@@ -224,8 +221,9 @@
 //   " koCmd('alert(\"koCmd is back\");')", earlyExit = true);
 
 // Evaluate R expression and call procfun in Komodo with the result as argument
-// context might be used to pass more data as the second argument of procfun
-sv.r.evalCallback = function (cmd, procfun, context) {
+// all additional arguments will be passed to procfun,
+// result will be stored in procfun.value
+sv.r.evalCallback = function (cmd, procfun) {
 	// If R is not running, do nothing
 	if (!sv.r.running) {
 		// Indicate R should be started
@@ -240,10 +238,12 @@
 		//sv.command.startR();
 		return null;
 	}
+	var args = Array.apply(null, arguments);
+	args.splice(0, 1, "<<<h>>>" + cmd, false, null);
+
 	// Evaluate a command in hidden mode (contextual help, calltip, etc.)
 	// and call 'procfun' at the end of the evaluation
-	var res = sv.socket.rCommand("<<<h>>>" + cmd,
-		false, null, procfun, context);
+	var res = sv.socket.rCommand.apply(sv.socket, args);
 	return(res);
 }
 
@@ -654,7 +654,7 @@
 // Search R help for topic
 sv.r.search = function (topic, internal) {
 	var res = false;
-	if (typeof(topic) == "undefined" | topic == "") {
+	if (!topic) {
 		topic = sv.getTextRange("word");
 		// Ask for the search string
 		topic = ko.dialogs.prompt(sv.translate("Search R objects using a regular" +
@@ -662,7 +662,7 @@
 			sv.translate("Pattern"), topic,
 			sv.translate("Search R help"), "okRsearchPattern");
 	}
-	if (topic != null & topic != "") {
+	if (topic) {
 		// Get list of matching items and evaluate it with sv.r.search_select()
 		res = sv.r.evalCallback('cat(apropos("' + topic + '"), sep = "' +
 			sv.r.sep + '")', sv.r.search_select);
@@ -697,23 +697,42 @@
 
 
 // Search R web sites for topic
-// TODO: open results in RHelpWin, do not use R
-sv.r.siteSearch = function (topic) {
+sv.r.siteSearch = function (topic, idxname) {
 	var res = false;
-	if (typeof(topic) == "undefined" | topic == "")
+	if (!topic)
 		topic = sv.getTextRange("word");
-	if (topic == "") {
+	topic = topic.trim();
+
+
+	if (!idxname)
+		idxname = ["Rhelp08", "functions", "views"];
+	else {
+		var idxsep = "&idxname=";
+		var idxnameAllow = ["Rhelp08", "Rhelp01", "Rhelp02", "functions",
+		"views", "R-devel", "R-sig-mixed-models"];
+
+		for (var i in idxname)
+			if (idxnameAllow.indexOf(idxname[i]) == -1)
+				idxname.splice(i, 1);
+	}
+
+	if (!topic) {
 		ko.statusBar.AddMessage(sv.translate("Selection is empty..."), "R",
 			1000, false);
-	} else {
-		res = sv.r.evalHidden('RSiteSearch("' + topic + '")', earlyExit = true);
-		ko.statusBar.AddMessage("R site search asked for '" + topic + "'",
-			"R", 5000, true);
+		return;
 	}
 
-	return(res);
+	idxname = idxsep + idxname.join(idxsep);
+
+	var url = "http://search.r-project.org/cgi-bin/namazu.cgi?query=" + topic +
+	"&max=20&result=normal&sort=score" + idxname;
+
+	sv.command.openHelp(url);
+
 }
 
+
+
 // List available datasets ("loaded" or not defined = loaded packages, or "all")
 sv.r.dataList = function (which) {
 	var res = false;

Modified: komodo/SciViews-K/content/js/robjects.js
===================================================================
--- komodo/SciViews-K/content/js/robjects.js	2009-09-30 09:36:22 UTC (rev 202)
+++ komodo/SciViews-K/content/js/robjects.js	2009-10-02 14:07:23 UTC (rev 203)
@@ -114,42 +114,42 @@
 
 // sv.r.objects constructor
 (function () {
-	
+
 	// Item separator for objList
 	var sep = ";;";
-	
+
 	var cmdPattern = 'print(objList(id = "$ID$_$ENV$_$OBJ$", envir = "$ENV$",' +
 		' object = "$ENV$", all.info = FALSE, compare = FALSE), sep = "' + sep +
 		'", eol = "\\n")';
-	
+
 	// This should be changed if new icons are added
 	var iconTypes = ['array', 'character', 'data.frame', 'Date', 'dist',
 		'empty', 'factor', 'function', 'glm', 'integer', 'list', 'lm', 'lme',
 		'logical', 'matrix', 'numeric', 'object', 'objects', 'package',
 		'standardGeneric', 'S3', 'S4', 'ts', 'environment', 'formula'];
-	
+
 	// Reference to parent object for private functions
 	var _this = this;
-	
+
 	var filterBy = 0; // Filter by name by default
 	var isInitialized = false;
-	
+
 	// Set debug mode
 	this.debug = sv.log.isAll();
-	
+
 	this.visibleData = [];
 	this.treeData = [];
-	
+
 	this.treeBox = null;
 	this.selection = null;
-	
+
 	var atomSvc = Components.classes["@mozilla.org/atom-service;1"]
 		.getService(Components.interfaces.nsIAtomService);
-	
+
 	this.__defineGetter__ ('rowCount', function () {
 		return this.visibleData.length;
 	});
-	
+
 	function _createVisibleData () {
 		if (!isInitialized) {
 			_this.init();
@@ -159,29 +159,29 @@
 		_this.visibleData = [];
 		_addVItems(_this.treeData, -1, 0);
 		var rowsChanged = _this.visibleData.length - rowsBefore;
-	
+
 		if (rowsChanged) {
 			_this.treeBox.rowCountChanged(0, rowsChanged);
 		}
 		_this.treeBox.invalidateRange(_this.treeBox.getFirstVisibleRow(),
 			_this.treeBox.getLastVisibleRow());
 	};
-	
+
 	function _addObjectList (pack) {
 		// Need this for attached files on windows
 		pack = pack.addslashes();
-	
+
 		var id = sv.prefs.getString("sciviews.client.id", "SciViewsK");
-	
+
 		// For use with modified objList
 		var cmd = 'print(objList(id = "' + id + '_' + pack + '", envir = "' +
 			pack + '", all.info = FALSE, compare = FALSE), sep = "' + sep +
 			'", eol = "\\n", raw.output = TRUE, header = TRUE)';
-	
+
 		sv.log.debug(cmd);
 		sv.r.evalCallback(cmd, _parseObjectList, pack);
 	};
-	
+
 	function _parseObjectList (data, packSelected) {
 		// Get position in the search path
 		function getPos (pack) {
@@ -190,22 +190,22 @@
 				searchPaths[pos] != pack; pos++) { }
 			return pos;
 		}
-	
+
 		var p, pos, packAdded = [];
 		if (data.trim() != "") {
 			var lines = data.split(/[\r\n]{1,2}/);
-	
+
 			// Get rid of the "Objects list:" line
 			if (lines[0].indexOf("Objects list:") != -1)
 				lines.shift();
-	
+
 			var item, line, pack, idx;
 			var packIdx = [];
 			for (var i = 0; i < _this.treeData.length; i++)
 				packIdx[i] = _this.treeData[i].name;
-	
+
 			var isList, dimNumeric, dim, dimRegExp = /^(\d+x)*\d+$/;
-	
+
 			for (var i = 0; i < lines.length; i++) {
 				if (lines[i].indexOf(sep) == -1) {
 					// Parse header line: look for environment name
@@ -237,10 +237,10 @@
 					}
 				} else {
 					line = lines[i].split(sep);
-	
+
 					if (line.length < 4)
 						continue;
-	
+
 					dimNumeric = 1;
 					if (dimRegExp.test(line[1])) {
 						dim = line[1].split(/x/);
@@ -248,7 +248,7 @@
 							dimNumeric *= parseInt(dim[j]);
 					}
 					var parent = _this.treeData[p];
-	
+
 					parent.children.push({
 						name: line[0],
 						fullName: line[0],
@@ -271,13 +271,13 @@
 				}
 			}
 		}
-	
+
 		var currentElement = _this.treeData[p];
 		_this.sort();
 		if (packAdded.length == 1 && currentElement.index != -1)
 			_this.treeBox.ensureRowIsVisible(currentElement.index);
 	};
-	
+
 	function _removeObjectList (pack) {
 		for (var i = 0; i < _this.treeData.length; i++) {
 			if (_this.treeData[i].name == pack) {
@@ -287,7 +287,7 @@
 		}
 		_createVisibleData();
 	};
-	
+
 	function _addSubObject (obj) {
 		var objName = obj.origItem.name;
 		// objList does not quote non syntactic names, so we do it here
@@ -297,7 +297,7 @@
 			objName = "`" + objName + "`";
 		else
 			objName = obj.origItem.fullName;
-			
+
 		var env = obj.origItem.env.addslashes();
 		var id = sv.prefs.getString("sciviews.client.id", "SciViewsK");
 		var cmd = 'print(objList(id = "' + id + '_' + env + '_' + objName +
@@ -307,17 +307,17 @@
 		sv.log.debug(cmd);
 		sv.r.evalCallback(cmd, _parseSubObjectList, obj);
 	};
-	
+
 	function _parseSubObjectList (data, obj) {
 		var lines = data.split(/[\r\n]{1,2}/);
-		
+
 		if (data == "" || (data.trim() == "An empty objects list")
 			|| lines.length < 3) {
 			obj.isContainer = false;
 			_this.treeBox.invalidateRow(obj.origItem.index);
 			return;
 		}
-	
+
 		// This is only for compatibility with different print.objList versions
 		// may be removed when final form of output will be estabilished
 		// get rid of the "Objects list:" line
@@ -325,12 +325,12 @@
 			lines.shift()
 		if (!lines.length)
 			return;
-	
+
 		// Environment - 1st line
 		var env = lines[0].substr(lines[0].lastIndexOf("=") + 1).trim();
 		// Parent object - 2ng line
 		var treeParent = lines[1].substr(lines[1].lastIndexOf("=") + 1).trim();
-	
+
 		var vd = _this.visibleData;
 		if (!obj) {
 			// Reloading sub-lists without passing parent tree item not used yet
@@ -347,27 +347,27 @@
 				// TODO: search for pkgs on top level
 			}
 		}
-	
+
 		var origItem = obj.origItem;
 		origItem.childrenLoaded = true;
-	
+
 		var childType = origItem.group == "function"? "args" : "sub-object";
 		var dimNumeric, dim, dimRegExp = /^(\d+x)*\d+$/;
-	
+
 		origItem.children = [];
 		for (var i = 2; i < lines.length; i++) {
 			if (lines[i].indexOf(sep) != -1) {
 				line = lines[i].split(sep);
 				if (line.length < 6)
 					continue;
-	
+
 				dimNumeric = 1;
 				if (dimRegExp.test(line[2])) {
 					dim = line[2].split(/x/);
 					for (var j in dim)
 						dimNumeric *= parseInt(dim[j]);
 				}
-	
+
 				origItem.children.push({
 					name: line[0],
 					fullName: line[1],
@@ -386,20 +386,20 @@
 				});
 			}
 		}
-	
+
 		obj.childrenLength = origItem.children.length;
 		_this.toggleOpenState(origItem.index);
 	};
-	
+
 	function _getFilter () {
 		var tb = document.getElementById("sciviews_robjects_filterbox");
 		var obRx, filterRegExp, test;
-	
+
 		if (!tb.value)
 			return function (x) {
 				return true;
 			}
-	
+
 		try {
 			obRx = new RegExp(tb.value, "i");
 			tb.className = "";
@@ -414,30 +414,30 @@
 			}
 		}
 	};
-	
+
 	this.applyFilter = function () {
 		_this.filter = _getFilter();
 		_createVisibleData();
 	};
-	
+
 	this.filter =  function (x) {
 		return true;
 	};
-	
+
 	function _addVItems (item, parentIndex, level, parentUid) {
 		if (typeof(item) == "undefined")
 			return(parentIndex);
 		if (typeof(level) == "undefined") level = -1;
 		if (!parentUid) parentUid = "";
 		if (!parentIndex) parentIndex = 0;
-	
+
 		var idx = parentIndex;
 		var len = item.length;
 		var conditionalView;
-	
+
 		for (var i = 0; i < len; i++) {
 			//item[i].class != "package" &&
-			if (level == 1 && !_this.filter(item[i].sortData[filterBy])) { 
+			if (level == 1 && !_this.filter(item[i].sortData[filterBy])) {
 				item[i].index = -1;
 				continue;
 				// Set conditionalView = true if any child nodes pass fitering
@@ -450,12 +450,12 @@
 				i == 0, i == len - 1,
 				parentIndex, parentUid);
 			_this.visibleData[idx] = vItem;
-	
+
 			if (vItem.isContainer && vItem.isOpen && vItem.childrenLength > 0) {
 				var idxBefore = idx;
 				idx = _addVItems(item[i].children, idx, level + 1,
 					vItem.uid + "»");
-	
+
 				// No children is visible
 				if (idxBefore == idx) {
 					vItem.isContainerEmpty = true;
@@ -471,7 +471,7 @@
 		}
 		return idx;
 	};
-	
+
 	// Attach one level list of child items to an item
 	function _addVIChildren (vItem, parentIndex, isOpen) {
 		var children = vItem.origItem.children;
@@ -494,10 +494,10 @@
 		}
 		vItem.isContainerEmpty = vItem.children.length == 0;
 	};
-	
+
 	function _getVItem (obj, index, level, first, last, parentIndex, parentUid) {
 		var vItem = {};
-	
+
 		if (obj.group == "list" || obj.group == "function" || obj.list) {
 			vItem.isContainer = true;
 			vItem.isContainerEmpty = false;
@@ -520,10 +520,10 @@
 		vItem.last = last;
 		vItem.labels = [obj.name, obj.dims, obj.group, obj.class, obj.fullName];
 		vItem.origItem = obj;
-		vItem.origItem.index = index;	
+		vItem.origItem.index = index;
 		return vItem;
 	};
-	
+
 	this.sort =  function (column) {
 		var columnName, currentElement, tree, sortDirection, realOrder, order,
 			sortDirs;
@@ -532,14 +532,14 @@
 
 		sortDirs = ["descending", "natural", "ascending", "descending"];
 		realOrder = sortDirs.indexOf(sortDirection) - 1;
-	
+
 		try {
 			currentElement = this.visibleData[this.selection.currentIndex].
 				origItem;
 		} catch (e) {
 			currentElement = null;
 		}
-	
+
 		// If the column is passed and sort already done, reverse it
 		if (column) {
 			columnName = column.id;
@@ -550,14 +550,14 @@
 		} else {
 			columnName = tree.getAttribute("sortResource");
 		}
-	
+
 		var colNames = ["r-name", "r-dims",  "r-class", "r-group", "r-fullName",
 						"r-position"];
 		var sCol = colNames.indexOf(columnName);
 		var defaultSortCol = 0;
 		if (typeof(sCol) == "undefined")
 			sCol = 0;
-	
+
 		// Sort using original element order
 		if (realOrder == 0) {
 			sCol = 4;
@@ -565,11 +565,11 @@
 		} else {
 			order = realOrder;
 		}
-	
+
 		function _sortCompare (a, b) {
 			if (a.sortData[sCol] > b.sortData[sCol]) return 1 * order;
 			if (a.sortData[sCol] < b.sortData[sCol]) return -1 * order;
-	
+
 			if (sCol != defaultSortCol) {
 				if (a.sortData[defaultSortCol] > b.sortData[defaultSortCol])
 					return 1;
@@ -578,14 +578,14 @@
 			}
 			return 0;
 		}
-	
+
 		function _sortComparePkgs (a, b) {
 			// Index 1 is the package's position in the search path
 			if (a.sortData[1] > b.sortData[1]) return 1;
 			if (a.sortData[1] < b.sortData[1]) return -1;
 			return 0;
 		}
-	
+
 		function _sortRecursive (arr) {
 			arr.sort(_sortCompare);
 			for (var i in arr) {
@@ -594,21 +594,21 @@
 				}
 			}
 		}
-	
+
 		sortDirection = sortDirs[realOrder + 1];
-	
+
 		// Setting these will make the sort option persist
 		tree.setAttribute("sortDirection", sortDirection);
 		tree.setAttribute("sortResource", columnName);
-	
+
 		var cols = tree.getElementsByTagName("treecol");
 		for (var i = 0; i < cols.length; i++) {
 			cols[i].removeAttribute("sortDirection");
 		}
-	
+
 		document.getElementById(columnName)
 			.setAttribute("sortDirection", sortDirection);
-	
+
 		// Sort packages always by name
 		this.treeData.sort(_sortComparePkgs);
 		for (var i in this.treeData) {
@@ -616,22 +616,22 @@
 				_sortRecursive(this.treeData[i].children);
 			}
 		}
-	
+
 		_createVisibleData();
-	
+
 		if (currentElement) {
 			this.selection.select(currentElement.index);
 			this.treeBox.ensureRowIsVisible(currentElement.index);
 		}
 	};
-	
+
 	this.foldAll = function (open) {
 		if (!this.rowCount)
 			return;
 		var idx = this.selection.currentIndex;
 		if (idx == -1)
 			idx = 0;
-	
+
 		var curItem = this.visibleData[idx].origItem;
 		var parentObject = curItem.parentObject;
 		if (parentObject) {
@@ -648,7 +648,7 @@
 			}
 		}
 	};
-	
+
 	this.toggleOpenState = function (idx) {
 		var vd = this.visibleData;
 		var item = vd[idx];
@@ -656,31 +656,31 @@
 			//sv.log.debug(idx);
 			return;
 		}
-	
+
 		if (item.isList && !item.origItem.isOpen &&
 			!item.origItem.childrenLoaded) {
 			_addSubObject(item);
 			return;
 		}
-	
+
 		var rowsChanged;
 		var iLevel = item.level;
-	
+
 		if (!item.childrenLength) {
 			return;
 		}
-	
+
 		if (item.origItem.isOpen) { // Closing subtree
 			var k;
 			for (k = idx + 1; k < vd.length && vd[k].level > iLevel; k++) { }
 			rowsChanged = k - idx - 1;
 			item.children = vd.splice(idx + 1, rowsChanged);
-	
+
 			// Make parentIndexes of child rows relative
 			for (var i = 0; i < item.children.length; i++) {
 				item.children[i].parentIndex -= idx;
 			}
-	
+
 			// Decrease parentIndexes of subsequent rows
 			for (var i = idx + 1; i < vd.length; i++) {
 				if (vd[i].parentIndex > idx)
@@ -691,7 +691,7 @@
 			if (typeof(item.children) == "undefined") {
 				_addVIChildren(item, idx, false);
 			}
-	
+
 			// Filter child items
 			var insertItems = [];
 			for (var i = 0; i < item.children.length; i++) {
@@ -699,14 +699,14 @@
 					insertItems.push(item.children[i]);
 				//}
 			}
-	
+
 			rowsChanged = insertItems.length;
 			// Change parentIndexes of child rows from relative to absolute
 			for (var i = 0; i < insertItems.length; i++) {
 				insertItems[i].parentIndex += idx;
 				insertItems[i].origItem.index = i + idx + 1;
 			}
-	
+
 			var vd2 = vd.slice(0, idx + 1).concat(insertItems,
 				vd.slice(idx + 1));
 			// Increase parentIndexes of subsequent rows:
@@ -724,61 +724,61 @@
 				(item.origItem.isOpen? 1 : -1) * rowsChanged);
 		this.treeBox.invalidateRow(idx);
 	};
-	
+
 	this.setTree = function (treeBox) {
 		this.treeBox = treeBox;
 	};
-	
+
 	this.setCellText = function (idx, col, value) {
 		this.visibleData[idx].labels[col.index] = value;
 	};
-	
+
 	this.setCellValue = function (idx, col, value) {
 	};
-	
+
 	this.getCellText = function (idx, column) {
 		//if (column.index == 1)
 		//	return "*" + this.visibleData[idx].origItem.sortData[1];
 		return _this.visibleData[idx].labels[column.index];
 		//+":" + this.visibleData[idx].level;
 	};
-	
+
 	this.isContainer = function (idx) {
 		return this.visibleData[idx].isContainer;
 	};
-	
+
 	this.isContainerOpen = function (idx) {
 		return this.visibleData[idx].origItem.isOpen;
 	};
-	
+
 	this.isContainerEmpty = function (idx) {
 		return this.visibleData[idx].isContainerEmpty;
 	};
-	
+
 	this.isSeparator = function (idx) {
 		return false;
 	};
-	
+
 	this.isSorted = function () {
 		return false;
 	};
-	
+
 	this.isEditable = function (idx, column) {
 		return false;
 	};
-	
+
 	this.getParentIndex = function (idx) {
 		return this.visibleData[idx].parentIndex;
 	};
-	
+
 	this.getLevel = function (idx) {
 		return this.visibleData[idx].level;
 	};
-	
+
 	this.hasNextSibling = function (idx, after) {
 		return !this.visibleData[idx].last;
 	};
-	
+
 	this.getImageSrc = function (row, col) {
 		if (col.index == 0) {
 			var Class = this.visibleData[row].origItem.class;
@@ -795,26 +795,26 @@
 		} else
 			return "";
 	};
-	
+
 	this.getCellValue = function (idx, column) {};
-	
+
 	this.cycleHeader = function (col, elem) {};
-	
+
 	this.selectionChanged = function () {};
-	
+
 	this.cycleCell = function (idx, column) {};
-	
+
 	this.performAction = function (action) {};
-	
+
 	this.performActionOnCell = function (action, index, column) {};
-	
+
 	this.getRowProperties = function (idx, props) {
 		var item = this.visibleData[idx]
 		var origItem = item.origItem;
-	
+
 		props.AppendElement(atomSvc.getAtom("type-" + origItem.type));
 		props.AppendElement(atomSvc.getAtom("class-" + origItem.class));
-	
+
 		if (item.last) {
 			props.AppendElement(atomSvc.getAtom("lastChild"));
 		}
@@ -822,7 +822,7 @@
 			props.AppendElement(atomSvc.getAtom("firstChild"));
 		}
 	};
-	
+
 	this.getCellProperties = function (idx, column, props) {
 		if (column.id == "r-name") {
 			props.AppendElement(atomSvc.getAtom("icon"));
@@ -831,14 +831,14 @@
 			props.AppendElement(atomSvc.getAtom("type-" + origItem.type));
 			props.AppendElement(atomSvc.getAtom("class-" + origItem.class));
 			props.AppendElement(atomSvc.getAtom("group-" + origItem.group));
-	
+
 			if (item.isContainerEmpty && origItem.class == "package")
 				props.AppendElement(atomSvc.getAtom("empty_package"));
 		}
 	};
-	
+
 	this.getColumnProperties = function (column, element, prop) {};
-	
+
 	this.getSelectedRows = function () {
 		var start = new Object();
 		var end = new Object();
@@ -852,7 +852,7 @@
 		}
 		return(rows);
 	};
-	
+
 	// Drag'n'drop support
 	this.listObserver = {
 		onDragStart: function (event, transferData, action) {
@@ -863,7 +863,7 @@
 				namesArr.join(', '));
 			return true;
 		},
-	
+
 		onDrop: function (event, transferData, session) {
 			var path, pos;
 			var data = transferData;
@@ -874,18 +874,18 @@
 			pos = _this.searchPaths.indexOf(path);
 			if (pos == -1)
 				return false;
-	
+
 			document.getElementById("sciviews_robjects_searchpath_listbox")
 				.getItemAtIndex(pos).checked = true;
 			_addObjectList(path);
 			return true;
 		},
-	
+
 		onDragOver: function (event, flavour, session) {
 			session.canDrop = flavour.contentType == 'text/unicode'
 				|| flavour.contentType == 'text/x-r-package-name';
 		},
-	
+
 		getSupportedFlavours: function () {
 			var flavours = new FlavourSet();
 			flavours.appendFlavour("text/x-r-package-name");
@@ -893,36 +893,36 @@
 			return flavours;
 		}
 	};
-	
+
 	this.canDrop = function () {
 		return false;
 	};
-	
+
 	this.drop = function (idx, orientation) {};
-	
+
 	this.init = function () {
 		this.visibleData = [];
 		_addObjectList(".GlobalEnv");
 		this.getPackageList();
-	
+
 		// For compatibility with Komodo 4 where "listbox" apparently does not
 		// fire "oncommand" event. So, replace it with "onclick". This causes
 		// issue with selection by key-press
 		var listBox = document
 			.getElementById("sciviews_robjects_searchpath_listbox");
-	
+
 		//listBox.oncommand = this.packageSelectedEvent;
-	
+
 		if ((typeof listBox.oncommand == "undefined")) {
 			listBox.onclick = this.packageSelectedEvent;
 			listBox.removeAttribute("oncommand");
 		}
 		isInitialized = true;
-	
+
 		document.getElementById("sciviews_robjects_objects_tree").view = this;
 		this.treeBox.scrollToRow(0);
 	};
-	
+
 	// Callback to process the list of packages in the search path from R
 	function _processPackageList (data, refreshObjects) {
 		if (data == "") { // No changes
@@ -931,25 +931,25 @@
 		_this.searchPaths = data.replace(/[\n\r]/g, "").split(sep);
 		_this.displayPackageList(refreshObjects);
 	};
-	
+
 	// Get the list of packages on the search path from R
 	this.getPackageList =  function (refreshObjects) {
 		var cmd = 'cat(objSearch(sep = "' + sep + '", compare = FALSE))';
 		sv.r.evalCallback(cmd, _processPackageList, refreshObjects);
 	};
-	
+
 	// Clear the list of packages on the search path (when quitting R)
 	this.clearPackageList =  function () {
 		_this.searchPaths = [];
 		_this.displayPackageList(false);
 		_parseObjectList("Env=.GlobalEnv\n");
 	}
-	
+
 	this.toggleViewSearchPath = function (event) {
 		var what = event.target.tagName;
 		var broadcaster = document.getElementById("cmd_robjects_viewSearchPath");
 		var box = document.getElementById(broadcaster.getAttribute("box"));
-	
+
 		if (what == "splitter" || what == "grippy") {
 			var state = document.getElementById("sciviews_robjects_splitter")
 				.getAttribute("state");
@@ -960,14 +960,14 @@
 			broadcaster.setAttribute("state",
 				box.collapsed? "collapsed" : "open");
 		}
-	
+
 		if (!box.collapsed) {
 			if (!_this.searchPaths.length) {
 				_this.getPackageList();
 			}
 		}
 	}
-	
+
 	// Display the list of packages in the search path
 	this.displayPackageList = function (refreshObjects) {
 		var pack;
@@ -976,12 +976,12 @@
 		while(node.firstChild)
 			node.removeChild(node.firstChild);
 		var packs = this.searchPaths;
-	
+
 		var selectedPackages = new Array(_this.treeData.length);
 		for (var i = 0; i < selectedPackages.length; i++) {
 			selectedPackages[i] = _this.treeData[i].name;
 		}
-	
+
 		for(var i = 0; i < packs.length; i++) {
 			pack = packs[i];
 			var item = document.createElement("listitem");
@@ -990,11 +990,11 @@
 			item.setAttribute("checked", selectedPackages.indexOf(pack) != -1);
 			node.appendChild(item);
 		}
-	
+
 		if (refreshObjects)
 			_this.refreshAll();
 	};
-	
+
 	// Change the display status of a package by clicking an item in the list
 	this.packageSelectedEvent = function (event) {
 		var el = event.target;
@@ -1007,15 +1007,15 @@
 			_removeObjectList(pack);
 		}
 	};
-	
+
 	this.refreshAll = function () {
 		var selectedPackages = new Array(_this.treeData.length);
 		for (var i = 0; i < selectedPackages.length; i++)
 			selectedPackages[i] = _this.treeData[i].name;
-	
+
 		if (selectedPackages.length == 0)
 			selectedPackages.push('.GlobalEnv');
-	
+
 		var cmd = 'invisible(sapply(c("' + selectedPackages.join('","')	+
 			'"), function(x) ' + 'print(objList(envir = x, all.info = FALSE,' +
 			' compare = FALSE), sep = "' + sep +
@@ -1023,11 +1023,11 @@
 		sv.log.debug(cmd);
 		sv.r.evalCallback(cmd, _parseObjectList);
 	}
-	
+
 	this.refreshGlobalEnv = function (data) {
 		_parseObjectList(data);
 	}
-	
+
 	//TODO: on package deletion -> remove it also from the search path
 	this.removeSelected = function (doRemove) {
 		var item, type, name, vItem, cmd = [];
@@ -1036,13 +1036,13 @@
 		var rows = this.getSelectedRows();
 		if (rows.length == 0)
 			return false;
-	
+
 		for (i in rows) {
 			vItem = this.visibleData[rows[i]];
 			item = vItem.origItem;
 			name = item.fullName;
 			type = item.type;
-	
+
 			switch (type){
 				case "environment":
 					if (name != ".GlobalEnv" && name != "TempEnv")
@@ -1058,7 +1058,7 @@
 							parent.parentIndex != -1) {
 							parent = this.visibleData[parent.parentIndex].
 								origItem;
-	
+
 							if (!parent || (rmItems[env] &&
 								(rmItems[env].indexOf(parent.fullName) != -1))
 								|| (parent.type == "environment" &&
@@ -1068,9 +1068,9 @@
 						}
 						if (typeof rmItems[env] == "undefined")
 							rmItems[env] = [];
-	
+
 						rmItems[env].push(name);
-	
+
 						if (type == "sub-object") {
 							if (typeof ObjectsToSetNull[env] == "undefined")
 								ObjectsToSetNull[env] = [];
@@ -1080,7 +1080,7 @@
 								ObjectsToRemove[env] = [];
 							ObjectsToRemove[env].push(name);
 						}
-	
+
 						var siblings = item.parentObject.children;
 						for (var j in siblings) {
 							if (siblings[j] == item) {
@@ -1093,7 +1093,7 @@
 				default:
 			}
 		}
-	
+
 		for (var i in envToDetach) {
 			cmd.push('detach("' + envToDetach[i].addslashes() + '")');
 			for (var j in _this.treeData) {
@@ -1103,21 +1103,21 @@
 				}
 			}
 		}
-	
+
 		for (var env in ObjectsToRemove)
 			cmd.push('rm(list = c("' + ObjectsToRemove[env].join('", "') +
 				'"), pos = "' + env + '")');
-	
+
 		for (var env in ObjectsToSetNull) {
 			cmd.push('eval(expression(' +
 				ObjectsToSetNull[env].join(" <- NULL, ") +
 				' <- NULL), envir = as.environment("' + env + '"))');
 		}
-	
+
 		_createVisibleData();
-	
+
 		if (!cmd.length) return false;
-	
+
 		if(doRemove) {
 			// Remove immediately
 			sv.r.evalCallback(cmd.join("\n"), sv.cmdout.append);
@@ -1131,12 +1131,12 @@
 			scimoz.scrollCaret();
 			scimoz.insertText(scimoz.currentPos, cmd.join(nl) + nl);
 		}
-	
+
 		_this.selection.select(Math.min(rows[0], _this.rowCount - 1));
 		//_this.selection.clearSelection();
 		return true;
 	}
-	
+
 	this.getSelectedNames = function (fullNames, extended) {
 		if (typeof extended == 'undefined')
 			extended = false;
@@ -1148,7 +1148,7 @@
 		for (i in selectedItemsOrd) {
 			item = selectedItemsOrd[i];
 			cellText = item[name];
-	
+
 			if (cellText) {
 				if ((!fullNames || item.type == "object")
 					&& cellText.search(/^[a-z\.][\w\._]*$/i) == -1) {
@@ -1167,7 +1167,7 @@
 		}
 		return (namesArr);
 	}
-	
+
 	this.insertName = function (fullNames, extended) {
 		// TODO: `quote` non-syntactic names of 1st level (.type = 'object')
 		// extended mode: object[c('sub1', 'sub2', 'sub3')]
@@ -1177,66 +1177,73 @@
 		//view.setFocus();
 		var scimoz = view.scimoz;
 		var length = scimoz.length;
-	
+
 		if (scimoz.getWCharAt(scimoz.selectionStart - 1)
 			.search(/^[\w\.\u0100-\uFFFF"'`,\.;:=]$/) != -1)
 			text = " " + text;
 		if (scimoz.getWCharAt(scimoz.selectionEnd)
 			.search(/^[\w\.\u0100-\uFFFF"'`]$/) != -1)
 			text += " ";
-	
+
 		scimoz.insertText(scimoz.currentPos, text);
 		scimoz.currentPos += scimoz.length - length;
 		scimoz.charRight();
 	}
-	
+
 	this.setFilterBy = function (menuItem, column) {
 		var newFilterBy = ['name', 'dims', 'class', 'group', 'fullName']
 			.indexOf(column);
 		if (newFilterBy == -1)
 			return;
-	
+
 		if (newFilterBy != filterBy) {
 			var items = menuItem.parentNode.getElementsByTagName("menuitem");
 			for (var i = 0; i < items.length; i++)
 				items[i].setAttribute("checked", items[i] == menuItem);
-	
+
 			filterBy = newFilterBy;
 			this.applyFilter();
 		 } else {
 			menuItem.setAttribute("checked", true);
 		 }
-	
+
 		 var filterBox = document.getElementById("sciviews_robjects_filterbox") ;
-	
+
 		 filterBox.emptyText = menuItem.getAttribute("label") + "...";
 		 filterBox.focus();
-	
+
 		//document.getElementById("sciviews_robjects_filterbox")
 		//    .setAttribute("emptytext", menuItem.getAttribute("label"));
 		//sv.alert(document.getElementById("sciviews_robjects_filterbox")
 		//    .getAttribute("emptytext"));
 		return;
 	}
-	
+
 	this.contextOnShow = function () {
 		var currentIndex = _this.selection.currentIndex;
+
 		if (currentIndex != -1) {
-			var isPackage, noDetach, isFunction;
+			var isPackage, noDetach, isFunction, inPackage = false;
 			var item, type, name;
 			item = this.visibleData[currentIndex].origItem;
 			type = item.class;
 			name = item.fullName;
-	
+
 			isPackage = type == "package";
 			noDetach = isPackage && (name == ".GlobalEnv" || name == "TempEnv");
 			isFunction = type == "function";
-			var inPackage = false;
-	
+
+			/*
 			if (!isPackage) {
 				inPackage = item.env && (item.env.indexOf("package:") == 0);
[TRUNCATED]

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


More information about the Sciviews-commits mailing list