[Sciviews-commits] r161 - in komodo/SciViews-K: content content/js locale/en-GB locale/fr-FR
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jul 30 11:27:03 CEST 2009
Author: prezez
Date: 2009-07-30 11:27:00 +0200 (Thu, 30 Jul 2009)
New Revision: 161
Modified:
komodo/SciViews-K/content/js/commands.js
komodo/SciViews-K/content/js/socket.js
komodo/SciViews-K/content/overlayMain.xul
komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
Log:
Small changes to sv.command object. "Update R Charset" added to R menu.
Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js 2009-07-30 08:23:02 UTC (rev 160)
+++ komodo/SciViews-K/content/js/commands.js 2009-07-30 09:27:00 UTC (rev 161)
@@ -48,11 +48,9 @@
if (!currentView || !currentView.scimoz)
return false;
- var anythingSelected = (currentView.scimoz.selectionEnd -
- currentView.scimoz.selectionStart) != 0;
- return(_isRRunning()
- && currentView.document.language == "R"
- && anythingSelected);
+ return _RControl_supported()
+ && ((currentView.scimoz.selectionEnd -
+ currentView.scimoz.selectionStart) != 0);
}
// selects the checkbox on selected element, while deselecting others
@@ -200,44 +198,39 @@
var viewManager = ko.views.viewManager;
- viewManager.prototype.is_cmd_sv_OpenPkgManager_enabled =
- viewManager.prototype.is_cmd_sv_OpenPkgManager_supported =
- _isRRunning;
- viewManager.prototype.is_cmd_sv_BrowseWD_enabled =
- viewManager.prototype.is_cmd_sv_BrowseWD_supported =
- _isRRunning;
+ var cmdsIfRRunning = ['OpenPkgManager', 'BrowseWD', 'quit_R', 'update_charset'];
+ var cmdsIfRNotRunning = ['start_R'];
- viewManager.prototype.is_cmd_sv_quit_R_supported =
- viewManager.prototype.is_cmd_sv_quit_R_enabled =
- _isRRunning;
-
- viewManager.prototype.do_cmd_sv_quit_R = function() { sv.r.quit(); };
-
- viewManager.prototype.is_cmd_sv_start_R_enabled =
- viewManager.prototype.is_cmd_sv_start_R_supported =
- function() { return !_isRRunning();};
-
- _keepCheckingR();
-
// make these commands active only when current document language is R
- var cmdNames = ["RunAll", "SourceAll", "RunBlock", "RunFunction", "RunLine", "RunPara",
+ var cmdsIfIsRView = ["RunAll", "SourceAll", "RunBlock", "RunFunction", "RunLine", "RunPara",
"SourceBlock", "SourceFunction", "SourcePara", "TriggerCompletion"];
+ // ... and if some text is selected
+ var cmdsIfIsRViewAndSelection = [ "RunSelection", "SourceSelection"];
-
- for (i in cmdNames) {
- viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_supported"] = _RControl_supported;
- viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_enabled"] = _RControl_supported;
+ function _setCommandCtrl1 (arr, fun, pfx) {
+ pfx = "is_cmd_" + pfx;
+ for (var i in cmdsIfRRunning) {
+ viewManager.prototype[pfx + arr[i] + "_supported"] = fun;
+ viewManager.prototype[pfx + arr[i] + "_enabled"] = fun;
+ }
}
- // make these commands active only when current document language is R
- // ... and if some text is selected
- cmdNames = [ "RunSelection", "SourceSelection"];
- for (i in cmdNames) {
- viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_supported"] = _RControlSelection_supported;
- viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_enabled"] = _RControlSelection_supported;
- }
+ _setCommandCtrl1(cmdsIfRRunning, _isRRunning, "sv_");
+ _setCommandCtrl1(cmdsIfRNotRunning, function() { return !_isRRunning()}, "sv_");
+ _setCommandCtrl1(cmdsIfIsRView, _RControl_supported, "sv_R");
+ _setCommandCtrl1(cmdsIfIsRViewAndSelection, _RControlSelection_supported, "sv_R");
+ viewManager.prototype.do_cmd_sv_quit_R = function() {
+ sv.r.quit(); };
+
+ viewManager.prototype.do_cmd_sv_update_charset = function() {
+ sv.socket.updateCharset(true);
+ sv.cmdout.message(sv.translate("R uses \"%S\" encoding.", sv.socket.charset));
+ };
+
+ _keepCheckingR();
+
// to run it with the same key as autocompletion with other languages
// command "cmd_triggerPrecedingCompletion" is replaced in XUL
// ko.commands.doCommandAsync('cmd_sv_RTriggerCompletion', event)
@@ -422,10 +415,11 @@
addEventListener("load", sv.command.setControllers, false);
addEventListener("load", sv.command.setKeybindings, false);
+
+
/*
//Useful garbage. delete it later.
-
// command controllers template:
vm.prototype.is_cmd_Test_supported
vm.prototype.do_cmd_Test = function() { alert("do_cmd_Test!"); }
Modified: komodo/SciViews-K/content/js/socket.js
===================================================================
--- komodo/SciViews-K/content/js/socket.js 2009-07-30 08:23:02 UTC (rev 160)
+++ komodo/SciViews-K/content/js/socket.js 2009-07-30 09:27:00 UTC (rev 161)
@@ -199,7 +199,7 @@
listener, echo, echofun);
// if exception was returned:
- if (res.name && res.name == "NS_ERROR_OFFLINE") {
+ if (res && res.name && res.name == "NS_ERROR_OFFLINE") {
sv.cmdout.message(sv.translate("Error: offline"), 5000);
}
Modified: komodo/SciViews-K/content/overlayMain.xul
===================================================================
--- komodo/SciViews-K/content/overlayMain.xul 2009-07-30 08:23:02 UTC (rev 160)
+++ komodo/SciViews-K/content/overlayMain.xul 2009-07-30 09:27:00 UTC (rev 161)
@@ -80,8 +80,14 @@
<command id="cmd_sv_quit_R" key="key_cmd_sv_quit_R"
oncommand="ko.commands.doCommand('cmd_sv_quit_R');"
- desc="R: &StartR;" label="&QuitR;" accesskey="&QuitR.key;" />
+ desc="R: &QuitR;" label="&QuitR;" accesskey="&QuitR.key;" />
+
+ <command id="cmd_sv_update_charset" key="key_cmd_sv_update_charset"
+ oncommand="ko.commands.doCommand('cmd_sv_update_charset');"
+ desc="R: &RUpdateCharset;" label="&RUpdateCharset;"
+ accesskey="&RUpdateCharset.key;" />
+
<command id="cmd_sv_OpenPkgManager" key="key_cmd_sv_OpenPkgManager"
oncommand="sv.command.openPkgManager();" disabled="true"
desc="R: &pkgMgr;" label="&pkgMgr;" accesskey="&pkgMgr.key;" />
@@ -172,6 +178,9 @@
<menuitem id="r_quit_console_menu" observes="cmd_sv_quit_R" class="menuitem-iconic r-quit-command-icon" />
+ <menuitem id="r_update_charset" observes="cmd_sv_update_charset"
+ class="menuitem" />
+
<menuitem id="r_start_pkg_manager" observes="cmd_sv_OpenPkgManager" class="menuitem" />
<menuitem id="r_browse_wd" observes="cmd_sv_BrowseWD" class="menuitem-iconic r-working-dir-icon" />
Modified: komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
===================================================================
--- komodo/SciViews-K/locale/en-GB/sciviewsk.dtd 2009-07-30 08:23:02 UTC (rev 160)
+++ komodo/SciViews-K/locale/en-GB/sciviewsk.dtd 2009-07-30 09:27:00 UTC (rev 161)
@@ -83,3 +83,6 @@
<!ENTITY svSelectRApp "Preferred R application">
<!ENTITY svSelectRApp.key "E">
+
+<!ENTITY RUpdateCharset "Update character set">
+<!ENTITY RUpdateCharset.key "C">
Modified: komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
===================================================================
--- komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd 2009-07-30 08:23:02 UTC (rev 160)
+++ komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd 2009-07-30 09:27:00 UTC (rev 161)
@@ -81,3 +81,6 @@
<!ENTITY svSelectRApp "Preferred R application">
<!ENTITY svSelectRApp.key "E">
+
+<!ENTITY RUpdateCharset "Update character set">
+<!ENTITY RUpdateCharset.key "C">
More information about the Sciviews-commits
mailing list