Author: davidmak
Date: 2007-04-26 09:59:15 -0400 (Thu, 26 Apr 2007)
New Revision: 76322
Modified:
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/ChangeLog
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/EditorBindings.glade
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/Makefile.am
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui.OptionPanels/MarkersTextEditorPanel.cs
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorDisplayBinding.cs
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorView.cs
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Properties/TextEditorProperties.cs
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.mdp
Log:
2007-04-26 David Makovsk?\195?\189 (Yakeen) <[EMAIL PROTECTED]>
* MonoDevelop.SourceEditor.Gui/SourceEditorView.cs: Added highlighting
current line functionality when gtksourceview supports it and
drawing of white spaces.
* EditorBindings.glade: Configuraion checkboxes.
* MonoDevelop.SourceEditor.Gui/SourceEditorDisplayBinding.cs,
* MonoDevelop.SourceEditor.Properties/TextEditorProperties.cs,
* MonoDevelop.SourceEditor.Gui.OptionPanels/MarkersTextEditorPanel.cs:
HighlightCurrentLine and ShowContolCharacters confiuration properties.
* Makefile.am,
* MonoDevelop.SourceEditor.mdp: Added reference to Mono.Cairo.
Modified: trunk/monodevelop/Extras/MonoDevelop.SourceEditor/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.SourceEditor/ChangeLog 2007-04-26
13:36:13 UTC (rev 76321)
+++ trunk/monodevelop/Extras/MonoDevelop.SourceEditor/ChangeLog 2007-04-26
13:59:15 UTC (rev 76322)
@@ -1,3 +1,16 @@
+2007-04-26 David Makovský (Yakeen) <[EMAIL PROTECTED]>
+
+ * MonoDevelop.SourceEditor.Gui/SourceEditorView.cs: Added highlighting
+ current line functionality when gtksourceview supports it and
+ drawing of white spaces.
+ * EditorBindings.glade: Configuraion checkboxes.
+ * MonoDevelop.SourceEditor.Gui/SourceEditorDisplayBinding.cs,
+ * MonoDevelop.SourceEditor.Properties/TextEditorProperties.cs,
+ * MonoDevelop.SourceEditor.Gui.OptionPanels/MarkersTextEditorPanel.cs:
+ HighlightCurrentLine and ShowContolCharacters confiuration properties.
+ * Makefile.am,
+ * MonoDevelop.SourceEditor.mdp: Added reference to Mono.Cairo.
+
2007-04-26 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* MonoDevelop.SourceEditor.addin.xml: Register the editor after the
Modified: trunk/monodevelop/Extras/MonoDevelop.SourceEditor/EditorBindings.glade
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.SourceEditor/EditorBindings.glade
2007-04-26 13:36:13 UTC (rev 76321)
+++ trunk/monodevelop/Extras/MonoDevelop.SourceEditor/EditorBindings.glade
2007-04-26 13:59:15 UTC (rev 76322)
@@ -958,6 +958,44 @@
<property name="fill">False</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkCheckButton"
id="highlightCurrentLineCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Hi_ghlight
current line</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton"
id="showContolCharactersCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Show contol
characters</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
Modified: trunk/monodevelop/Extras/MonoDevelop.SourceEditor/Makefile.am
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.SourceEditor/Makefile.am
2007-04-26 13:36:13 UTC (rev 76321)
+++ trunk/monodevelop/Extras/MonoDevelop.SourceEditor/Makefile.am
2007-04-26 13:59:15 UTC (rev 76322)
@@ -49,6 +49,7 @@
-r:$(top_builddir)/build/AddIns/MonoDevelop.Projects.dll \
-r:$(top_builddir)/build/AddIns/MonoDevelop.Projects.Gui.dll \
-r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \
+ -r:Mono.Cairo \
-r:System \
-r:System.Drawing \
-r:System.Xml
Modified:
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorDisplayBinding.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorDisplayBinding.cs
2007-04-26 13:36:13 UTC (rev 76321)
+++
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorDisplayBinding.cs
2007-04-26 13:59:15 UTC (rev 76322)
@@ -1131,6 +1131,7 @@
se.View.InsertSpacesInsteadOfTabs =
TextEditorProperties.ConvertTabsToSpaces;
se.View.AutoIndent = (TextEditorProperties.IndentStyle
== IndentStyle.Auto);
se.View.AutoInsertTemplates =
TextEditorProperties.AutoInsertTemplates;
+ se.View.HighlightCurrentLine =
TextEditorProperties.HighlightCurrentLine;
se.Buffer.UnderlineErrors =
TextEditorProperties.UnderlineErrors;
se.Buffer.Highlight =
TextEditorProperties.SyntaxHighlight;
se.DisplayBinding.ClassBrowserVisible =
TextEditorProperties.ShowClassBrowser;
@@ -1203,6 +1204,13 @@
case "ShowClassBrowser":
se.DisplayBinding.ClassBrowserVisible =
TextEditorProperties.ShowClassBrowser;
break;
+ case "HighlightCurrentLine":
+ se.View.HighlightCurrentLine =
TextEditorProperties.HighlightCurrentLine;
+ break;
+ case "ShowContolCharacters":
+ SourceEditorView.DrawWhiteSpacesEnabled
= TextEditorProperties.ShowContolCharacters;
+ se.View.QueueDraw ();
+ break;
default:
Console.WriteLine ("unhandled property
change: {0}", e.Key);
break;
Modified:
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorView.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorView.cs
2007-04-26 13:36:13 UTC (rev 76321)
+++
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorView.cs
2007-04-26 13:59:15 UTC (rev 76322)
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Collections.Generic;
using System.Runtime.InteropServices;
using Gtk;
@@ -28,6 +29,9 @@
{
public class SourceEditorView : SourceView, ICompletionWidget,
ITextEditorExtension
{
+ public static readonly bool HighlightCurrentLineSupported;
+ public static bool DrawWhiteSpacesEnabled = true;
+
public readonly SourceEditor ParentEditor;
internal IFormattingStrategy fmtr = new
DefaultFormattingStrategy ();
public SourceEditorBuffer buf;
@@ -37,6 +41,7 @@
LanguageItemWindow languageItemWindow;
ITextEditorExtension extension;
TextEditor thisEditor;
+ DrawControlCharacterImp controlsDrawer;
event EventHandler completionContextChanged;
const int LanguageItemTipTimer = 800;
@@ -55,6 +60,25 @@
set { autoInsertTemplates = value; }
}
+ static SourceEditorView ()
+ {
+ SourceView view = new SourceView ();
+ try
+ {
+ GetHighlightCurrentLine (view.Handle);
+ HighlightCurrentLineSupported = true;
+ }
+ catch
+ {
+ HighlightCurrentLineSupported = false;
+ }
+ finally
+ {
+ view.Destroy ();
+ view = null;
+ }
+ }
+
protected SourceEditorView (IntPtr p): base (p)
{
}
@@ -68,16 +92,19 @@
SmartHomeEnd = true;
ShowLineNumbers = true;
ShowLineMarkers = true;
+ controlsDrawer = new DrawControlCharacterImp (this);
+ HighlightCurrentLine = true;
buf.PlaceCursor (buf.StartIter);
GrabFocus ();
buf.MarkSet += new MarkSetHandler (BufferMarkSet);
buf.Changed += new EventHandler (BufferChanged);
LoadEditActions ();
- this.Events = this.Events | EventMask.PointerMotionMask
| EventMask.LeaveNotifyMask;
+ this.Events = this.Events | EventMask.PointerMotionMask
| EventMask.LeaveNotifyMask | EventMask.ExposureMask;
}
public new void Dispose ()
{
+ controlsDrawer.Detach ();
HideLanguageItemWindow ();
buf.MarkSet -= new MarkSetHandler (BufferMarkSet);
buf.Changed -= new EventHandler (BufferChanged);
@@ -758,5 +785,172 @@
}
}
#endregion
+
+#region HighlightCurrentLine functionality
+ //gboolean gtk_source_view_get_highlight_current_line
(GtkSourceView *view);
+ [DllImport ("gtksourceview-1.0",
EntryPoint="gtk_source_view_get_highlight_current_line")]
+ static extern bool GetHighlightCurrentLine (IntPtr raw);
+
+ //void gtk_source_view_set_highlight_current_line
(GtkSourceView *view, gboolean show);
+ [DllImport("gtksourceview-1.0",
EntryPoint="gtk_source_view_set_highlight_current_line")]
+ static extern void SetHighlightCurrentLine (IntPtr raw, bool
show);
+
+ [GLib.Property ("highlight-current-line")]
+ public bool HighlightCurrentLine {
+ get {
+ if (HighlightCurrentLineSupported)
+ return GetHighlightCurrentLine (Handle);
+ return false;
+ }
+ set {
+ if (HighlightCurrentLineSupported)
+ SetHighlightCurrentLine (Handle, value);
+ }
+ }
+#endregion
+
+#region Drawing control characters functionality
+ class DrawControlCharacterImp
+ {
+ SourceView view;
+
+ public DrawControlCharacterImp (SourceView view)
+ {
+ this.view = view;
+ view.WidgetEventAfter += OnWidgetEvent;
+ }
+
+ public void Detach ()
+ {
+ view.WidgetEventAfter -= OnWidgetEvent;
+ view = null;
+ }
+
+ void OnWidgetEvent (object o, WidgetEventAfterArgs args)
+ {
+ if (args.Event.Type == Gdk.EventType.Expose &&
+ o is TextView &&
+ args.Event.Window == view.GetWindow
(TextWindowType.Text))
+ {
+ int x, y;
+ view.WindowToBufferCoords
(TextWindowType.Text,
+
args.Event.Window.ClipRegion.Clipbox.X,
+
args.Event.Window.ClipRegion.Clipbox.Y,
+ out x, out
y);
+
+ TextIter start, end;
+ int topLine;
+ view.GetLineAtY (out start, y, out
topLine);
+ view.GetLineAtY (out end, y +
args.Event.Window.ClipRegion.Clipbox.Height, out topLine);
+ end.ForwardToLineEnd ();
+ Draw (args.Event.Window, view, start,
end);
+ }
+ }
+
+ static Cairo.Color GetDrawingColorForIter (TextView
view, TextIter iter)
+ {
+ TextIter start, end;
+ Gdk.Color color;
+ if (iter.Buffer.GetSelectionBounds (out start,
out end) && iter.InRange (start, end))
+ {
+ color = view.Style.Text
(StateType.Selected);
+ } else
+ {
+ color = view.Style.Text
(StateType.Normal);
+ }
+
+ return new Cairo.Color ((double)(color.Red) /
UInt16.MaxValue,
+ (double)(color.Green) /
UInt16.MaxValue,
+ (double)(color.Blue) /
UInt16.MaxValue);
+ }
+
+ static void DrawSpaceAtIter (Cairo.Context cntx,
TextView view, TextIter iter)
+ {
+ Gdk.Rectangle rect = view.GetIterLocation
(iter);
+ int x, y;
+ view.BufferToWindowCoords (TextWindowType.Text,
+ rect.X + rect.Width
/ 2,
+ rect.Y + rect.Height
/ 2,
+ out x, out y);
+ cntx.Save ();
+ cntx.Color = GetDrawingColorForIter (view,
iter);
+ cntx.MoveTo (x, y);
+ cntx.Arc (x, y, 0.4, 0, 2 * Math.PI);
+ cntx.Stroke ();
+ cntx.Restore ();
+ }
+
+ static void DrawTabAtIter (Cairo.Context cntx, TextView
view, TextIter iter)
+ {
+ Gdk.Rectangle rect = view.GetIterLocation
(iter);
+ int x, y;
+ view.BufferToWindowCoords (TextWindowType.Text,
+ rect.X,
+ rect.Y + rect.Height
/ 2,
+ out x, out y);
+ cntx.Save ();
+ cntx.Color = GetDrawingColorForIter (view,
iter);
+ cntx.MoveTo (x + 2, y);
+ cntx.RelLineTo (new Cairo.Distance (rect.Width
- 4, 0));
+ cntx.RelLineTo (new Cairo.Distance (-3, -3));
+ cntx.RelLineTo (new Cairo.Distance (3, 3));
+ cntx.RelLineTo (new Cairo.Distance (-3, 3));
+ cntx.Stroke ();
+ cntx.Restore ();
+ }
+
+ static void DrawLineEndAtIter (Cairo.Context cntx,
TextView view, TextIter iter)
+ {
+ Gdk.Rectangle rect = view.GetIterLocation
(iter);
+ int x, y;
+ view.BufferToWindowCoords (TextWindowType.Text,
+ rect.X,
+ rect.Y + rect.Height
/ 2,
+ out x, out y);
+ cntx.Save ();
+ cntx.Color = GetDrawingColorForIter (view,
iter);
+ cntx.MoveTo (x + 10, y);
+ cntx.RelLineTo (new Cairo.Distance (0, -3));
+ cntx.RelLineTo (new Cairo.Distance (0, 3));
+ cntx.RelLineTo (new Cairo.Distance (-8, 0));
+ cntx.RelLineTo (new Cairo.Distance (3, 3));
+ cntx.RelLineTo (new Cairo.Distance (-3, -3));
+ cntx.RelLineTo (new Cairo.Distance (3, -3));
+ cntx.Stroke ();
+ cntx.Restore ();
+ }
+
+ static void Draw (Gdk.Drawable drawable, TextView view,
TextIter start, TextIter end)
+ {
+ if (DrawWhiteSpacesEnabled)
+ {
+ Cairo.Context cntx =
Gdk.CairoHelper.Create (drawable);
+ cntx.LineWidth = 0.3;
+
+ TextIter iter = start;
+ while (iter.Compare (end) <= 0)
+ {
+ switch (iter.Char)
+ {
+ case " ":
+ DrawSpaceAtIter
(cntx, view, iter);
+ break;
+ case "\t":
+ DrawTabAtIter
(cntx, view, iter);
+ break;
+ case "\n":
+ case "\r":
+
DrawLineEndAtIter (cntx, view, iter);
+ break;
+ default:
+ break;
+ }
+ if (! iter.ForwardChar ())
+ break;
+ }
+ }
+ }
+ }
+#endregion
}
}
Modified:
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui.OptionPanels/MarkersTextEditorPanel.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui.OptionPanels/MarkersTextEditorPanel.cs
2007-04-26 13:36:13 UTC (rev 76321)
+++
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui.OptionPanels/MarkersTextEditorPanel.cs
2007-04-26 13:59:15 UTC (rev 76322)
@@ -46,6 +46,8 @@
[Glade.Widget] CheckButton
showBracketHighlighterCheckBox;
[Glade.Widget] CheckButton showErrorsCheckBox;
[Glade.Widget] CheckButton showVRulerCheckBox;
+ [Glade.Widget] CheckButton highlightCurrentLineCheckBox;
+ [Glade.Widget] CheckButton showContolCharactersCheckBox;
[Glade.Widget] SpinButton vRulerRowTextBox;
[Glade.Widget] ComboBox wrapModeComboBox;
@@ -55,7 +57,11 @@
showLineNumberCheckBox.Active =
TextEditorProperties.ShowLineNumbers;
showBracketHighlighterCheckBox.Active =
TextEditorProperties.ShowMatchingBracket;
showErrorsCheckBox.Active =
TextEditorProperties.UnderlineErrors;
+ showContolCharactersCheckBox.Active =
TextEditorProperties.ShowContolCharacters;
+ highlightCurrentLineCheckBox.Active =
TextEditorProperties.HighlightCurrentLine;
+ highlightCurrentLineCheckBox.Sensitive =
MonoDevelop.SourceEditor.Gui.SourceEditorView.HighlightCurrentLineSupported;
+
showVRulerCheckBox.Active =
TextEditorProperties.ShowVerticalRuler;
vRulerRowTextBox.Value =
TextEditorProperties.VerticalRulerRow;
@@ -71,6 +77,8 @@
TextEditorProperties.ShowMatchingBracket =
showBracketHighlighterCheckBox.Active;
TextEditorProperties.UnderlineErrors =
showErrorsCheckBox.Active;
TextEditorProperties.ShowVerticalRuler =
showVRulerCheckBox.Active;
+ TextEditorProperties.HighlightCurrentLine =
highlightCurrentLineCheckBox.Active;
+ TextEditorProperties.ShowContolCharacters =
showContolCharactersCheckBox.Active;
try {
TextEditorProperties.VerticalRulerRow =
(int) vRulerRowTextBox.Value;
}
Modified:
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Properties/TextEditorProperties.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Properties/TextEditorProperties.cs
2007-04-26 13:36:13 UTC (rev 76321)
+++
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Properties/TextEditorProperties.cs
2007-04-26 13:59:15 UTC (rev 76322)
@@ -383,5 +383,23 @@
properties.SetProperty("ShowClassBrowser",
value);
}
}
+
+ public static bool HighlightCurrentLine {
+ get {
+ return properties.GetProperty
("HighlightCurrentLine", true);
+ }
+ set {
+ properties.SetProperty ("HighlightCurrentLine",
value);
+ }
+ }
+
+ public static bool ShowContolCharacters {
+ get {
+ return properties.GetProperty
("ShowContolCharacters", true);
+ }
+ set {
+ properties.SetProperty ("ShowContolCharacters",
value);
+ }
+ }
}
}
Modified:
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.mdp
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.mdp
2007-04-26 13:36:13 UTC (rev 76321)
+++
trunk/monodevelop/Extras/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.mdp
2007-04-26 13:59:15 UTC (rev 76322)
@@ -66,6 +66,7 @@
<ProjectReference type="Gac" localcopy="True" refto="atk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="gdk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Gac" localcopy="True" refto="Mono.Cairo,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
</References>
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True"
RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName=""
SyncReferences="True" IsAutotoolsProject="True"
RelativeConfigureInPath="../../">
<ExcludedFiles>
@@ -82,4 +83,4 @@
<DeploymentInformation strategy="File">
<excludeFiles />
</DeploymentInformation>
-</Project>
\ No newline at end of file
+</Project>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches