Browse Source

GtkDemo now uses standard text view.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
da0d25b314
  1. 28
      ICSharpCode.NRefactory.GtkDemo/ICSharpCode.NRefactory.GtkDemo.csproj
  2. 35
      ICSharpCode.NRefactory.GtkDemo/MainWindow.cs
  3. BIN
      ICSharpCode.NRefactory.GtkDemo/Mono.TextEditor.dll
  4. 34
      ICSharpCode.NRefactory.GtkDemo/gtk-gui/ICSharpCode.NRefactory.GtkDemo.MainWindow.cs
  5. 9
      ICSharpCode.NRefactory.GtkDemo/gtk-gui/gui.stetic

28
ICSharpCode.NRefactory.GtkDemo/ICSharpCode.NRefactory.GtkDemo.csproj

@ -30,16 +30,25 @@ @@ -30,16 +30,25 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="Mono.Posix" />
<Reference Include="Mono.TextEditor">
<HintPath>Mono.TextEditor.dll</HintPath>
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>gtk-sharp-2.0</Package>
</Reference>
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>gtk-sharp-2.0</Package>
</Reference>
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>glib-sharp-2.0</Package>
</Reference>
<Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>glade-sharp-2.0</Package>
</Reference>
<Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>gtk-sharp-2.0</Package>
</Reference>
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>gtk-sharp-2.0</Package>
</Reference>
<Reference Include="Mono.Posix" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
@ -87,7 +96,6 @@ @@ -87,7 +96,6 @@
<None Include="CSharpDemo.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Mono.TextEditor.dll" />
</ItemGroup>
<ItemGroup>
<Folder Include="pixbuf\" />

35
ICSharpCode.NRefactory.GtkDemo/MainWindow.cs

@ -29,7 +29,6 @@ using Gtk; @@ -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 @@ -46,7 +45,7 @@ namespace ICSharpCode.NRefactory.GtkDemo
{
TreeStore store = new TreeStore (typeof (string), typeof (string), typeof (AstNode), typeof (Pixbuf));
Dictionary<AstNode, TreeIter> iterDict = new Dictionary<AstNode, TreeIter> ();
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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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();

BIN
ICSharpCode.NRefactory.GtkDemo/Mono.TextEditor.dll

Binary file not shown.

34
ICSharpCode.NRefactory.GtkDemo/gtk-gui/ICSharpCode.NRefactory.GtkDemo.MainWindow.cs

@ -6,6 +6,7 @@ namespace ICSharpCode.NRefactory.GtkDemo @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 ();

9
ICSharpCode.NRefactory.GtkDemo/gtk-gui/gui.stetic

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
</configuration>
<import>
<widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<widget-library name="../../../StandAloneTextEditor/StandAloneTextEditor/bin/Debug/Mono.TextEditor.dll" />
<widget-library name="../bin/Debug/ICSharpCode.NRefactory.GtkDemo.exe" internal="true" />
</import>
<widget class="Gtk.Window" id="ICSharpCode.NRefactory.GtkDemo.MainWindow" design-size="400 300">
@ -23,12 +22,10 @@ @@ -23,12 +22,10 @@
<property name="CanFocus">True</property>
<property name="ShadowType">In</property>
<child>
<widget class="Gtk.Viewport" id="GtkViewport">
<widget class="Gtk.TextView" id="textview1">
<property name="MemberName" />
<property name="ShadowType">None</property>
<child>
<placeholder />
</child>
<property name="CanFocus">True</property>
<property name="Text" translatable="yes" />
</widget>
</child>
</widget>

Loading…
Cancel
Save