Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnkit Jain <radical@corewars.org>2006-12-19 23:09:42 +0300
committerAnkit Jain <radical@corewars.org>2006-12-19 23:09:42 +0300
commit63566a2ba429fac5ab59f6d593b0cccac45e9b81 (patch)
treed7ed37dd7dde4307a58cb1a9a0376b77bc4924bc /Core/src/MonoDevelop.Ide
parentc9fefc1aeaaf90aed4f10c9e99dcb6ba2a5c780a (diff)
In Core/src/MonoDevelop.Ide:
* MonoDevelop.Ide.Gui/HelpOperations.cs (CheckExternalMonodoc): New. Check whether the available monodoc is recent version (supports --remote-mode). This check is done on the first call to ShowHelp. If its unsuccesful, then it falls back to use the integrated HelpViewer. (ShowHelpExternal): New. Show help using the external monodoc. Fall back on HelpViewer in case of any errors. In Core/src/MonoDevelop.Core: * MonoDevelop.Core.Execution/ProcessService.cs (StartProcess): Add a new overload with 'redirectStandardInput' param. svn path=/trunk/monodevelop/; revision=69775
Diffstat (limited to 'Core/src/MonoDevelop.Ide')
-rw-r--r--Core/src/MonoDevelop.Ide/ChangeLog9
-rw-r--r--Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs87
2 files changed, 96 insertions, 0 deletions
diff --git a/Core/src/MonoDevelop.Ide/ChangeLog b/Core/src/MonoDevelop.Ide/ChangeLog
index 6d1ba26585..683143d398 100644
--- a/Core/src/MonoDevelop.Ide/ChangeLog
+++ b/Core/src/MonoDevelop.Ide/ChangeLog
@@ -1,3 +1,12 @@
+2006-12-20 Ankit Jain <jankit@novell.com>
+
+ * MonoDevelop.Ide.Gui/HelpOperations.cs (CheckExternalMonodoc): New. Check
+ whether the available monodoc is recent version (supports --remote-mode).
+ This check is done on the first call to ShowHelp. If its unsuccesful,
+ then it falls back to use the integrated HelpViewer.
+ (ShowHelpExternal): New. Show help using the external monodoc. Fall back
+ on HelpViewer in case of any errors.
+
2006-12-17 Jacob Ilsø Christensen <jacobilsoe@gmail.com>
* options/MonoDevelop-templates.xml: Use standard keywords
diff --git a/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs b/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs
index 81bc42651a..c85e36f8c7 100644
--- a/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs
+++ b/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs
@@ -30,6 +30,9 @@
using System;
using System.Collections;
using Monodoc;
+using MonoDevelop.Core.Execution;
+using System.IO;
+using MonoDevelop.Core;
using MonoDevelop.Core.Gui;
namespace MonoDevelop.Ide.Gui
@@ -37,9 +40,93 @@ namespace MonoDevelop.Ide.Gui
public class HelpOperations
{
HelpViewer helpViewer;
+ ProcessWrapper pw;
+ TextWriter outWriter;
+ TextWriter errWriter;
+ bool firstCall = true;
+ bool useExternalMonodoc = false;
public void ShowHelp (string topic)
{
+ if (topic == null || topic.Trim ().Length == 0)
+ return;
+
+ if (firstCall)
+ CheckExternalMonodoc ();
+
+ if (useExternalMonodoc)
+ ShowHelpExternal (topic);
+ else
+ ShowHelpIntegrated (topic);
+ }
+
+ void CheckExternalMonodoc ()
+ {
+ firstCall = false;
+ try {
+ outWriter = new StringWriter ();
+ errWriter = new StringWriter ();
+ pw = Runtime.ProcessService.StartProcess (
+ "monodoc", "--help", "", outWriter, errWriter,
+ delegate {
+ if (pw.ExitCode != 0)
+ IdeApp.Services.MessageService.ShowError (
+ String.Format (
+ "MonoDoc exited with a exit code = {0}. Error : {1}",
+ pw.ExitCode, errWriter.ToString ()));
+ pw = null;
+ }, true);
+
+ pw.WaitForOutput ();
+ if (outWriter.ToString ().IndexOf ("--about") > 0)
+ useExternalMonodoc = true;
+ pw = null;
+ } catch (Exception e) {
+ IdeApp.Services.MessageService.ShowError (String.Format (
+ "Could not start monodoc : {0}", e.ToString ()));
+ }
+
+ if (!useExternalMonodoc)
+ IdeApp.Services.MessageService.ShowError (
+ "You need a newer monodoc to use it externally from monodevelop. Using the integrated help viewer now.");
+ }
+
+ void ShowHelpExternal (string topic)
+ {
+ try {
+ if (pw == null || pw.HasExited == true) {
+ outWriter = new StringWriter ();
+ errWriter = new StringWriter ();
+ pw = Runtime.ProcessService.StartProcess (
+ "monodoc", "--remote-mode", "", outWriter, errWriter,
+ delegate {
+ if (pw.ExitCode == 0)
+ return;
+
+ IdeApp.Services.MessageService.ShowError (
+ String.Format (
+ "MonoDoc exited with a exit code = {0}. Integrated help viewer will be used now.\nError : {1}",
+ pw.ExitCode, errWriter.ToString ()));
+
+ pw = null;
+ useExternalMonodoc = false;
+ Gtk.Application.Invoke (delegate { ShowHelpIntegrated (topic); });
+ }, true);
+ }
+
+ if (pw != null && !pw.HasExited) {
+ pw.StandardInput.WriteLine (topic);
+ Console.WriteLine (outWriter.ToString ());
+ Console.WriteLine (errWriter.ToString ());
+ }
+ } catch (Exception e) {
+ IdeApp.Services.MessageService.ShowError (e);
+ useExternalMonodoc = false;
+ }
+ }
+
+ void ShowHelpIntegrated (string topic)
+ {
if (helpViewer == null) {
helpViewer = new HelpViewer ();
helpViewer.LoadUrl (topic);