[mapguide-commits] r7163 - in trunk/Tools/Maestro: Maestro.AddIn.Scripting/Lang/Python Maestro.Editors/Common
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Oct 29 06:48:49 PDT 2012
Author: jng
Date: 2012-10-29 06:48:49 -0700 (Mon, 29 Oct 2012)
New Revision: 7163
Modified:
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs
trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs
trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs
Log:
#2161: Add some color to any warnings and errors that IronPython throws up
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs 2012-10-29 13:32:01 UTC (rev 7162)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs 2012-10-29 13:48:49 UTC (rev 7163)
@@ -34,6 +34,7 @@
using Microsoft.Scripting.Hosting.Shell;
using System;
using System.Collections.Generic;
+using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
@@ -158,7 +159,12 @@
#if DEBUG
Console.WriteLine("PythonConsole.Write(text, style): " + text);
#endif
- textEditor.Write(text);
+ if (style == Style.Error)
+ textEditor.Write(text, Color.Red, Color.White);
+ else if (style == Style.Warning)
+ textEditor.Write(text, Color.Yellow, Color.Black);
+ else
+ textEditor.Write(text);
if (style == Style.Prompt)
{
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs 2012-10-29 13:32:01 UTC (rev 7162)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs 2012-10-29 13:48:49 UTC (rev 7163)
@@ -81,6 +81,11 @@
void Write(string text, Color backgroundColor);
/// <summary>
+ /// Inserts text at the current cursor location with the specified colour.
+ /// </summary>
+ void Write(string text, Color backgroundColor, Color foregroundColor);
+
+ /// <summary>
/// Replaces the text at the specified index on the current line with the specified text.
/// </summary>
void Replace(int index, int length, string text);
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs 2012-10-29 13:32:01 UTC (rev 7162)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs 2012-10-29 13:48:49 UTC (rev 7163)
@@ -43,7 +43,7 @@
public class TextEditor : ITextEditor
{
delegate string GetLineInvoker(int index);
- delegate void WriteInvoker(string text, Color color);
+ delegate void WriteInvoker(string text, Color color, Color fore);
TextEditorControl textEditorControl;
TextArea textArea;
@@ -84,15 +84,20 @@
public void Write(string text)
{
- Write(text, Color.Empty);
+ Write(text, Color.Empty, default(Color));
}
public void Write(string text, Color backgroundColour)
{
+ Write(text, backgroundColour, default(Color));
+ }
+
+ public void Write(string text, Color backgroundColour, Color foregroundColor)
+ {
if (textEditorControl.InvokeRequired)
{
WriteInvoker invoker = new WriteInvoker(Write);
- textEditorControl.Invoke(invoker, new object[] { text, backgroundColour });
+ textEditorControl.Invoke(invoker, new object[] { text, backgroundColour, foregroundColor });
}
else
{
@@ -101,7 +106,7 @@
if (!backgroundColour.IsEmpty)
{
- TextMarker marker = new TextMarker(offset, text.Length, TextMarkerType.SolidBlock, backgroundColour);
+ TextMarker marker = new TextMarker(offset, text.Length, TextMarkerType.SolidBlock, backgroundColour, foregroundColor);
textEditorControl.Document.MarkerStrategy.AddMarker(marker);
textEditorControl.Refresh();
}
More information about the mapguide-commits
mailing list