[Sciviews-commits] r339 - komodo/SciViews-K/content/js
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 9 14:06:08 CET 2010
Author: prezez
Date: 2010-11-09 14:06:08 +0100 (Tue, 09 Nov 2010)
New Revision: 339
Modified:
komodo/SciViews-K/content/js/robjects.js
komodo/SciViews-K/content/js/sciviews.js
Log:
robjects.js: New feature: filtering allows for exclusion if search string starts with "!"
sciviews.js: sv.checkToolbox: support for Komodo6 toolbox2 (but still importing from kpz files)
Modified: komodo/SciViews-K/content/js/robjects.js
===================================================================
--- komodo/SciViews-K/content/js/robjects.js 2010-10-31 16:58:58 UTC (rev 338)
+++ komodo/SciViews-K/content/js/robjects.js 2010-11-09 13:06:08 UTC (rev 339)
@@ -270,6 +270,7 @@
_this.treeBox.ensureRowIsVisible(currentElement.index);
_this.selection.select(currentElement.index);
}
+ return (true);
};
function _removeObjectList (pack) {
@@ -369,27 +370,30 @@
_this.toggleOpenState(origItem.index);
};
+// New: allow for filtering by exclusion: prepend with "!"
function _getFilter () {
var tb = document.getElementById("sciviews_robjects_filterbox");
- var obRx, filterRegExp, test;
+ var obRx, text, not;
+ text = tb.value;
+ not = (text[0] == "!");
+ if (not) {
+ text = text.substr(1);
+ }
- if (!tb.value)
- return(function (x) {
- return(true);
- })
+ if (!text) return(function (x) true);
+
try {
- obRx = new RegExp(tb.value, "i");
+ obRx = new RegExp(text, "i");
tb.className = "";
- return(function (x) {
- return(obRx.test(x));
- })
+ if (not)
+ return(function (x) !(obRx.test(x)));
+ else
+ return(function (x) obRx.test(x));
+
} catch (e) {
- obRx = tb.value;
tb.className = "badRegEx";
- return(function(x) {
- return(x.indexOf(obRx) > -1);
- })
+ return (function(x) (x.indexOf(text) > -1));
}
};
Modified: komodo/SciViews-K/content/js/sciviews.js
===================================================================
--- komodo/SciViews-K/content/js/sciviews.js 2010-10-31 16:58:58 UTC (rev 338)
+++ komodo/SciViews-K/content/js/sciviews.js 2010-11-09 13:06:08 UTC (rev 339)
@@ -347,14 +347,14 @@
if (!v) return;
var ke = v.scintilla.scimoz;
//var ke = v.scimoz;
- var lineClicked = ke.lineFromPosition(position);
+ var lineClicked = ke.lineFromPosition(position);
if (margin == 2) {
if (modifiers == 0) {
// Simple click
// From editor.js. This is implementation of do_cmd_bookmarkToggle with
// different arguments
var markerState = ke.markerGet(lineClicked);
-
+
if (markerState & (1 << ko.markers.MARKNUM_BOOKMARK)) {
ke.markerDelete(lineClicked, ko.markers.MARKNUM_BOOKMARK);
} else {
@@ -365,14 +365,14 @@
} else if (modifiers == 1) {
// Shift click
var markerState = ke.markerGet(lineClicked);
-
+
if (markerState & (1 << ko.markers.MARKNUM_TRANSIENTMARK)) {
ke.markerDelete(lineClicked, ko.markers.MARKNUM_TRANSIENTMARK);
} else {
ke.markerAdd(lineClicked, ko.markers.MARKNUM_TRANSIENTMARK);
//ke.markerAdd(lineClicked, ko.markers.MARKNUM_STDIN_PROMPT);
}
-
+
}
} else if (margin == 1) {
// From views-buffer.xml, method onMarginClick (original comments removed)
@@ -649,10 +649,10 @@
// Append text to the Command Output pane
// TODO: handle \b correctly to delete char up to the beginning of line
// TODO: what to do with \a? I already have a bell in R console...
-sv.cmdout.append = function (str, newline, scrollToStart) {
+sv.cmdout.append = function (str, newline, scrollToStart) {
if (newline === undefined) newline = true;
if (scrollToStart === undefined) scrollToStart = false;
-
+
try {
var runout = ko.run.output;
// Make sure the command output window is visible
@@ -820,90 +820,56 @@
//sv.log.show();
-//FIXME: does not work with the new toolbox in Komodo 6.0.0-beta1
sv.checkToolbox = function () {
+ sv.cmdout.message("(Re-)installing SciViews-K toolboxes...");
try {
var path, tbxs;
var os = Components.classes['@activestate.com/koOs;1'].
getService(Components.interfaces.koIOs);
+ var tbxMgr;
+ if (ko.toolbox2 && ko.toolbox2.manager) { // Komodo >= 6.0.0?
+ tbxMgr = ko.toolbox2.manager;
+ var toolbox2Svc = tbxMgr.toolbox2Svc;
+ var targetDirectory = toolbox2Svc.getStandardToolbox().path;
+ function _installPkg(path) toolbox2Svc.importV5Package(targetDirectory, path);
+ } else { // Komodo 5: (TODO: test is on Komodo 5!)
+ function _installPkg(path) ko.toolboxes.importPackage(path);
+ tbxMgr = null;
+ }
+
// Find all .kpz files in 'defaults', append/replace version string in filenames,
// finally install as toolbox
path = sv.tools.file.path("ProfD", "extensions",
- "sciviewsk at sciviews.org", "defaults");
+ "sciviewsk at sciviews.org", "defaults");
tbxs = sv.tools.file.list(path, "\\.kpz$");
var file1, file2;
for (var i in tbxs) {
- file1 = file2 = tbxs[i];
- file2 = os.path.withoutExtension(file1.replace(/\s*\([\s0-9\.]+\)\s*/, ""));
+ file1 = tbxs[i];
+ file2 = os.path.withoutExtension(file1.replace(/\s*(\([\s0-9a-c\.]+\)\s*)+/, ""));
tbxs[i] = file2 + " (" + sv.version + ")";
file2 = file2 + " (" + sv.version + ").kpz";
file1 = sv.tools.file.path(path, file1);
file2 = sv.tools.file.path(path, file2);
os.rename(file1, file2);
- ko.toolboxes.importPackage(file2);
+ _installPkg(file2);
}
+ if(tbxMgr) tbxMgr.view.reloadToolsDirectoryView(-1);
+
// Message prompting for removing old or duplicated toolboxes
sv.alert(sv.translate("Toolboxes %S have been added. " +
- "To avoid conflicts, you should remove any previous or duplicated versions." +
- " To update the toolbars, restart Komodo.", "\"" +
+ "To avoid conflicts, you should remove any previous or duplicated " +
+ "versions. To update the toolbars, restart Komodo.", "\"" +
tbxs.join("\" and \"") + "\""));
- //document.getElementById("toolboxview").tree.view.invalidate();
-
- //// This is old code kept if we want to take something back from it!
- // Important! this code is dangerous, as it removes current SciViews-K toolbox
- // without notice, all user modifications are lost!!
- // Note that in Komodo 6, interpolateStrings is deprecated in favor of interpolateString!
- //var pkg = ko.interpolate.interpolateStrings("%(path:userDataDir)");
- //pkg += "/XRE/extensions/sciviewsk at sciviews.org/templates/SciViews-K.kpz";
- //var partSvc = Components.classes["@activestate.com/koPartService;1"]
- // .getService(Components.interfaces.koIPartService);
- //var SciViewsK_folders = partSvc.getParts("folder", "name", "SciViews-K",
- // "*", partSvc.currentProject, new Object());
- //if (SciViewsK_folders.length == 0) {
- // // The SciViews-K toolbox is not installed yet... do it now
- // ko.toolboxes.importPackage(pkg);
- //} else {
- // // First, eliminate all SciViews-K toolboxes that are too old
- // var VersionMacro;
- // var SciViewsK_folder;
- // sv.showVersion = false;
- // for (var i = 0; i < SciViewsK_folders.length; i++) {
- // SciViewsK_folder = SciViewsK_folders[i];
- // VersionMacro = SciViewsK_folder.
- // getChildWithTypeAndStringAttribute(
- // "macro", "name", "Version", true);
- // if (VersionMacro) {
- // ko.projects.executeMacro(VersionMacro);
- // if (SciViewsKtoolboxVersion < sv.version) {
- // // This toolbox is too old for our extension
- // ko.toolboxes.user.removeItem(SciViewsK_folder, true);
- // }
- // } else {
- // // Probably a corrupted SciViews-K toolbox => eliminate it
- // ko.toolboxes.user.removeItem(SciViewsK_folder, true);
- // }
- // }
- // // Recheck how many SciViews-K toolboxes are left
- // SciViewsK_folders = partSvc.getParts("folder", "name", "SciViews-K",
- // "*", partSvc.currentProject, new Object());
- // if (SciViewsK_folders.length == 0) {
- // // Install the new one now
- // ko.toolboxes.importPackage(pkg);
- // } else if (SciViewsK_folders.length > 1) {
- // // There are duplications, keep only last one
- // for (var i = 0; i < (SciViewsK_folders.length - 1); i++) {
- // SciViewsK_folder = SciViewsK_folders[i];
- // ko.toolboxes.user.removeItem(SciViewsK_folder, true);
- // }
- // }
- //}
} catch(e) {
sv.log.exception(e, "Error while installing the SciViews-K & R reference toolboxes");
}
- finally { sv.showVersion = true; }
+ finally {
+ sv.showVersion = true;
+ sv.cmdout.message();
+ }
}
// Ensure we check the toolbox is installed once the extension is loaded
More information about the Sciviews-commits
mailing list