diff --git a/ICSharpCode.NRefactory.GtkDemo/ICSharpCode.NRefactory.GtkDemo.csproj b/ICSharpCode.NRefactory.GtkDemo/ICSharpCode.NRefactory.GtkDemo.csproj index 14df915849..a772c27252 100644 --- a/ICSharpCode.NRefactory.GtkDemo/ICSharpCode.NRefactory.GtkDemo.csproj +++ b/ICSharpCode.NRefactory.GtkDemo/ICSharpCode.NRefactory.GtkDemo.csproj @@ -30,16 +30,25 @@ - - - - - - - - - Mono.TextEditor.dll + + gtk-sharp-2.0 + + + gtk-sharp-2.0 + + + glib-sharp-2.0 + + + glade-sharp-2.0 + + gtk-sharp-2.0 + + + gtk-sharp-2.0 + + @@ -87,7 +96,6 @@ PreserveNewest - diff --git a/ICSharpCode.NRefactory.GtkDemo/MainWindow.cs b/ICSharpCode.NRefactory.GtkDemo/MainWindow.cs index 7ae1c3368f..81b85edbd5 100644 --- a/ICSharpCode.NRefactory.GtkDemo/MainWindow.cs +++ b/ICSharpCode.NRefactory.GtkDemo/MainWindow.cs @@ -29,7 +29,6 @@ using Gtk; using System.IO; using System.Text; using System.Reflection; -using Mono.TextEditor; using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.Semantics; using System.Collections.Generic; @@ -46,7 +45,7 @@ namespace ICSharpCode.NRefactory.GtkDemo { TreeStore store = new TreeStore (typeof (string), typeof (string), typeof (AstNode), typeof (Pixbuf)); Dictionary iterDict = new Dictionary (); - TextEditor editor = new TextEditor (); +// TextEditor editor = new TextEditor (); CompilationUnit unit; Pixbuf comment = new Pixbuf (typeof (MainWindow).Assembly, "comment.png"); @@ -76,13 +75,10 @@ namespace ICSharpCode.NRefactory.GtkDemo this.treeviewNodes.AppendColumn ("ResolveResult", new CellRendererText (), "text", 1); this.treeviewNodes.Selection.Changed += SelectionChanged; // this.treeviewNodes.HeadersVisible = false; - this.scrolledwindow1.Child = editor; - this.scrolledwindow1.Child.ShowAll (); - this.editor.Document.MimeType = "text/x-csharp"; - this.editor.Options.FontName = "Mono 14"; - this.editor.Caret.PositionChanged += HandlePositionChanged; + this.textview1.ModifyFont (Pango.FontDescription.FromString ("Mono 14")); + this.textview1.MoveCursor += HandleMoveCursor; string path = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location), "CSharpDemo.cs"); - this.editor.Text = File.ReadAllText (path); + this.textview1.Buffer.Text = File.ReadAllText (path); buttonParse.Clicked += HandleClicked; buttonGenerate.Clicked += CSharpGenerateCodeButtonClick; HandleClicked (this, EventArgs.Empty); @@ -93,9 +89,11 @@ namespace ICSharpCode.NRefactory.GtkDemo Application.Quit (); } - void HandlePositionChanged (object sender, DocumentLocationEventArgs e) + void HandleMoveCursor (object o, MoveCursorArgs args) { - var node = unit.GetNodeAt (editor.Caret.Line, editor.Caret.Column); + int cp = textview1.Buffer.CursorPosition; + var textIter = textview1.Buffer.GetIterAtOffset (cp); + var node = unit.GetNodeAt (textIter.Line + 1, textIter.LineOffset + 1); if (node == null) return; TreeIter iter; @@ -110,7 +108,7 @@ namespace ICSharpCode.NRefactory.GtkDemo void CSharpGenerateCodeButtonClick(object sender, EventArgs e) { - editor.Text = unit.GetText(); + this.textview1.Buffer.Text = unit.GetText(); } void SelectionChanged (object sender, EventArgs e) @@ -122,12 +120,15 @@ namespace ICSharpCode.NRefactory.GtkDemo var node = store.GetValue (iter, 2) as AstNode; if (node == null) return; - this.editor.Caret.PositionChanged -= HandlePositionChanged; - this.editor.SetCaretTo (node.StartLocation.Line, node.StartLocation.Column); - this.editor.SetSelection (node.StartLocation.Line, node.StartLocation.Column, node.EndLocation.Line, node.EndLocation.Column); - this.editor.Caret.PositionChanged += HandlePositionChanged; + this.textview1.MoveCursor -= HandleMoveCursor; + var textIter = this.textview1.Buffer.GetIterAtLineOffset (node.StartLocation.Line - 1, node.StartLocation.Column - 1); + this.textview1.ScrollToIter (textIter, 0, false, 0, 0); + this.textview1.Buffer.PlaceCursor (textIter); + this.textview1.Buffer.SelectRange (textIter, this.textview1.Buffer.GetIterAtLineOffset (node.EndLocation.Line -1, node.EndLocation.Column - 1)); + this.textview1.MoveCursor += HandleMoveCursor; } - + + public void ShowUnit (CompilationUnit unit, CSharpAstResolver visitor) { this.unit = unit; @@ -220,7 +221,7 @@ namespace ICSharpCode.NRefactory.GtkDemo void HandleClicked (object sender, EventArgs e) { var parser = new CSharpParser (); - var unit = parser.Parse (editor.Text, "dummy.cs"); + var unit = parser.Parse (textview1.Buffer.Text, "dummy.cs"); var parsedFile = unit.ToTypeSystem(); diff --git a/ICSharpCode.NRefactory.GtkDemo/Mono.TextEditor.dll b/ICSharpCode.NRefactory.GtkDemo/Mono.TextEditor.dll deleted file mode 100755 index 3983c55147..0000000000 Binary files a/ICSharpCode.NRefactory.GtkDemo/Mono.TextEditor.dll and /dev/null differ diff --git a/ICSharpCode.NRefactory.GtkDemo/gtk-gui/ICSharpCode.NRefactory.GtkDemo.MainWindow.cs b/ICSharpCode.NRefactory.GtkDemo/gtk-gui/ICSharpCode.NRefactory.GtkDemo.MainWindow.cs index 96f548aa7e..2dc4928af1 100644 --- a/ICSharpCode.NRefactory.GtkDemo/gtk-gui/ICSharpCode.NRefactory.GtkDemo.MainWindow.cs +++ b/ICSharpCode.NRefactory.GtkDemo/gtk-gui/ICSharpCode.NRefactory.GtkDemo.MainWindow.cs @@ -6,6 +6,7 @@ namespace ICSharpCode.NRefactory.GtkDemo { private global::Gtk.VBox vbox1; private global::Gtk.ScrolledWindow scrolledwindow1; + private global::Gtk.TextView textview1; private global::Gtk.HBox hbox1; private global::Gtk.Button buttonParse; private global::Gtk.Button buttonGenerate; @@ -28,9 +29,14 @@ namespace ICSharpCode.NRefactory.GtkDemo this.scrolledwindow1.CanFocus = true; this.scrolledwindow1.Name = "scrolledwindow1"; this.scrolledwindow1.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledwindow1.Gtk.Container+ContainerChild + this.textview1 = new global::Gtk.TextView (); + this.textview1.CanFocus = true; + this.textview1.Name = "textview1"; + this.scrolledwindow1.Add (this.textview1); this.vbox1.Add (this.scrolledwindow1); - global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.scrolledwindow1])); - w1.Position = 0; + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.scrolledwindow1])); + w2.Position = 0; // Container child vbox1.Gtk.Box+BoxChild this.hbox1 = new global::Gtk.HBox (); this.hbox1.Name = "hbox1"; @@ -42,10 +48,10 @@ namespace ICSharpCode.NRefactory.GtkDemo this.buttonParse.UseUnderline = true; this.buttonParse.Label = global::Mono.Unix.Catalog.GetString ("Parse"); this.hbox1.Add (this.buttonParse); - global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.buttonParse])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.buttonParse])); + w3.Position = 0; + w3.Expand = false; + w3.Fill = false; // Container child hbox1.Gtk.Box+BoxChild this.buttonGenerate = new global::Gtk.Button (); this.buttonGenerate.CanFocus = true; @@ -53,15 +59,15 @@ namespace ICSharpCode.NRefactory.GtkDemo this.buttonGenerate.UseUnderline = true; this.buttonGenerate.Label = global::Mono.Unix.Catalog.GetString ("Generate"); this.hbox1.Add (this.buttonGenerate); - global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.buttonGenerate])); - w3.Position = 1; - w3.Expand = false; - w3.Fill = false; - this.vbox1.Add (this.hbox1); - global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox1])); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.buttonGenerate])); w4.Position = 1; w4.Expand = false; w4.Fill = false; + this.vbox1.Add (this.hbox1); + global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox1])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.GtkScrolledWindow1 = new global::Gtk.ScrolledWindow (); this.GtkScrolledWindow1.Name = "GtkScrolledWindow1"; @@ -72,8 +78,8 @@ namespace ICSharpCode.NRefactory.GtkDemo this.treeviewNodes.Name = "treeviewNodes"; this.GtkScrolledWindow1.Add (this.treeviewNodes); this.vbox1.Add (this.GtkScrolledWindow1); - global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.GtkScrolledWindow1])); - w6.Position = 2; + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.GtkScrolledWindow1])); + w7.Position = 2; this.Add (this.vbox1); if ((this.Child != null)) { this.Child.ShowAll (); diff --git a/ICSharpCode.NRefactory.GtkDemo/gtk-gui/gui.stetic b/ICSharpCode.NRefactory.GtkDemo/gtk-gui/gui.stetic index ef905a55d4..498ab55f1a 100644 --- a/ICSharpCode.NRefactory.GtkDemo/gtk-gui/gui.stetic +++ b/ICSharpCode.NRefactory.GtkDemo/gtk-gui/gui.stetic @@ -6,7 +6,6 @@ - @@ -23,12 +22,10 @@ True In - + - None - - - + True +