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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 4 13:24:03 CET 2009


Author: prezez
Date: 2009-02-04 13:24:03 +0100 (Wed, 04 Feb 2009)
New Revision: 110

Added:
   komodo/SciViews-K/content/js/r-help.js
Modified:
   komodo/SciViews-K/content/overlayMain.xul
Log:
replacement for language-specific context help (ko.help.language), 
allows "sv.r.help" to be run under common command.

Added: komodo/SciViews-K/content/js/r-help.js
===================================================================
--- komodo/SciViews-K/content/js/r-help.js	                        (rev 0)
+++ komodo/SciViews-K/content/js/r-help.js	2009-02-04 12:24:03 UTC (rev 110)
@@ -0,0 +1,55 @@
+// this is replacement for language specific help on selection function
+// (cmd_helpLanguage command)
+// to handle R help not using system command
+
+// this should be keep updated with new versions of the original function
+ko.help.language = function () {
+    var language = null;
+    var view = ko.window.focusedView();
+    if (!view) {
+        view = ko.views.manager.currentView;
+    }
+    if (view != null) {
+        if (view.document) {
+            language = view.document.subLanguage;
+            if (language == "XML") {
+                language = view.document.language;
+            }
+        } else {
+            language = view.language;
+        }
+    }
+
+    var command = null, name = null;
+    if (language) {
+		//////////////////////// R help mod:
+		if (language == "R") {
+			var topic;
+			try {
+				topic = ko.interpolate.interpolateStrings("%w").trim();
+				//alert("*" + topic + "*")
+				sv.r.help(topic);
+				return;
+			} catch (e) {}
+
+		} //////////////// end: R help mod
+
+        if (gPrefs.hasStringPref(language + "HelpCommand")) {
+            command = gPrefs.getStringPref(language + "HelpCommand");
+        } else {
+            var langRegistrySvc = Components.classes['@activestate.com/koLanguageRegistryService;1'].getService(Components.interfaces.koILanguageRegistryService);
+            var languageObj = langRegistrySvc.getLanguage(language);
+            if (languageObj.searchURL) {
+                command = "%(browser) " + languageObj.searchURL;
+            }
+        }
+        if (command) {
+            name = language + " Help";
+        }
+    }
+    if (!command) {
+        command = gPrefs.getStringPref("DefaultHelpCommand");
+        name = "Help";
+    }
+    ko.run.runCommand(window, command, null, null, false, false, true, "no-console", 0, "", 0, name);
+}

Modified: komodo/SciViews-K/content/overlayMain.xul
===================================================================
--- komodo/SciViews-K/content/overlayMain.xul	2009-02-03 14:01:07 UTC (rev 109)
+++ komodo/SciViews-K/content/overlayMain.xul	2009-02-04 12:24:03 UTC (rev 110)
@@ -65,11 +65,15 @@
 
   <script type="application/x-javascript" src="chrome://sciviewsk/content/js/commands.js"/>
 
+  <script type="application/x-javascript" src="chrome://sciviewsk/content/js/r-help.js"/>
+
+
   <commandset id="allcommands">
     <command id="Tasks:svAbout" oncommand="alert('SciViews-K (Komodo R Editor) version ' + sv.version + '\na Komodo extension to interact with R\n(see http://www.sciviews.org/SciViews-K)');"/>
 
     <command id="cmd_svStartR" key="key_cmd_svStartR"
-		     oncommand="ko.commands.doCommand('cmd_svStartR');" desc="R: Start R Console (windows)" label="Start R Console (windows)" accel="R" />
+		     oncommand="ko.commands.doCommand('cmd_svStartR');"
+		 desc="R: Start R Console (windows)" label="Start R Console (windows)" accel="R" />
 
     <commandset id="cmdset_r_control" commandupdater="true"
 		    events="current_view_language_changed"
@@ -118,19 +122,19 @@
   <menubar id="menubar_main">
    <menu id="sciviews_menu" label="R Control" accesskey="R" insertbefore="menu_window,help_menu">
     <menupopup id="popup_sciviews_main">
-	<menuitem id="r_start_console_menu" observes="cmd_svStartR" class="menuitem-iconic run-command-icon" />
+	<menuitem id="r_start_console_menu" observes="cmd_svStartR" class="menuitem-iconic r-run-command-icon" />
 	<menuseparator/>
-	<menuitem id="r_send_all_menu" observes="cmd_sv_RRunAll" />
-	<menuitem id="r_src_all_menu" observes="cmd_sv_RSourceAll" />
-	<menuitem id="r_send_block_menu" observes="cmd_sv_RRunBlock" />
-	<menuitem id="r_send_function_menu" observes="cmd_sv_RRunFunction" />
-	<menuitem id="r_send_line_menu" observes="cmd_sv_RRunLine" />
-	<menuitem id="r_send_para_menu" observes="cmd_sv_RRunPara" />
-	<menuitem id="r_send_sel_menu" observes="cmd_sv_RRunSelection" />
-	<menuitem id="r_src_block_menu" observes="cmd_sv_RSourceBlock" />
-	<menuitem id="r_src_function_menu" observes="cmd_sv_RSourceFunction" />
-	<menuitem id="r_src_para_menu" observes="cmd_sv_RSourcePara" />
-	<menuitem id="r_src_sel_menu" observes="cmd_sv_RSourceSelection" />
+	<menuitem id="r_send_line_menu" observes="cmd_sv_RRunLine" class="menuitem-iconic r-run-line-icon" />
+	<menuitem id="r_send_all_menu" observes="cmd_sv_RRunAll" class="menuitem-iconic r-run-all-icon" />
+	<menuitem id="r_src_all_menu" observes="cmd_sv_RSourceAll" class="menuitem-iconic r-source-all-icon" />
+	<menuitem id="r_send_sel_menu" observes="cmd_sv_RRunSelection" class="menuitem-iconic r-run-selection-icon" />
+	<menuitem id="r_src_sel_menu" observes="cmd_sv_RSourceSelection" class="menuitem-iconic r-source-selection-icon" />
+	<menuitem id="r_send_block_menu" observes="cmd_sv_RRunBlock" class="menuitem-iconic r-run-block-icon" />
+	<menuitem id="r_src_block_menu" observes="cmd_sv_RSourceBlock" class="menuitem-iconic r-source-block-icon" />
+	<menuitem id="r_send_para_menu" observes="cmd_sv_RRunPara" class="menuitem-iconic r-run-para-icon" />
+	<menuitem id="r_src_para_menu" observes="cmd_sv_RSourcePara" class="menuitem-iconic r-source-para-icon" />
+	<menuitem id="r_send_function_menu" observes="cmd_sv_RRunFunction" class="menuitem-iconic r-run-function-icon" />
+	<menuitem id="r_src_function_menu" observes="cmd_sv_RSourceFunction" class="menuitem-iconic r-source-function-icon" />
     </menupopup>
    </menu>
   </menubar>



More information about the Sciviews-commits mailing list