I am developing a MonoDevelop Add-in for Xamarin Studio, and I am trying to write to the Tool Output window (aka Pad). The Tool Output window is where the code generators write their output to, so it must be possible.
I've tried Writing to Console, Trace, and Debug, as well as using Workbench.StatusBar.ShowMessage() but none of these write to the Tool Output window.
The following code will update the status bar and write some text to the Tool Output window.
using (var monitor = MonoDevelop.Ide.IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (false)) {
monitor.BeginTask ("Running...", 1);
monitor.Log.WriteLine ("Test");
monitor.EndTask ();
monitor.ReportSuccess ("Done.");
}
The monitor providers a way to update the status bar, using the BeginTask and ReportSuccess, ReportError methods. It also provides a way to write text directly to the Tool Output window with the methods on the Log object.
If you are creating a custom tool you would not need to do all this extra work. You can implement the ISingleFileCustomTool interface which passes you a progress monitor. Then register the custom tool in your addin's xml file:
<Extension path = "/MonoDevelop/Ide/CustomTools">
<Tool name="ResXFileCodeGenerator" type="MonoDevelop.Ide.CustomTools.ResXFileCodeGenerator" />
<Tool name="PublicResXFileCodeGenerator" type="MonoDevelop.Ide.CustomTools.PublicResXFileCodeGenerator" />
</Extension>