Browse Source

Implemented AvalonEdit split view

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4032 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
1599cfa89e
  1. 15
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 34
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs
  3. 205
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  4. 4
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorAdapter.cs
  5. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IconBarMargin.cs
  6. 6
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.xaml
  7. 11
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/TextMarkerService.cs
  8. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/IBackgroundRenderer.cs
  9. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextArea.cs
  10. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextEditor.cs
  11. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextView.cs
  12. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  13. 21
      src/Main/Base/Project/Src/Commands/SharpDevelopRoutedCommands.cs
  14. 4
      src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs
  15. 1
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  16. 5
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs
  17. 9
      src/Main/ICSharpCode.Core.Presentation/Menu/MenuCommand.cs
  18. 45
      src/Main/ICSharpCode.Core.Presentation/Menu/MenuService.cs

15
AddIns/ICSharpCode.SharpDevelop.addin

@ -1595,6 +1595,10 @@ @@ -1595,6 +1595,10 @@
shortcut = "Shift|Control|Tab"
class = "ICSharpCode.SharpDevelop.Commands.SelectPrevWindow" />
<MenuItem id ="NxtPrvSeparator" type = "Separator" />
<MenuItem id = "SplitView"
label = "${res:XML.MainMenu.WindowMenu.Split}"
icon = "Icons.16x16.SplitWindow"
command = "SplitView"/>
<MenuItem id = "CloseAll"
label = "${res:XML.MainMenu.FileMenu.CloseAll}"
icon = "Icons.16x16.CloseAllDocuments"
@ -1842,17 +1846,6 @@ @@ -1842,17 +1846,6 @@
</MenuItem>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Window">
<Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.ITextEditorControlProvider" action="Disable">
<MenuItem id = "SplitTextEditor"
insertafter="NxtPrvSeparator"
insertbefore="CloseAll"
label = "${res:XML.MainMenu.WindowMenu.Split}"
icon = "Icons.16x16.SplitWindow"
class ="ICSharpCode.SharpDevelop.DefaultEditor.Commands.SplitTextEditor"/>
</Condition>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Edit">
<MenuItem insertafter = "Delete" insertbefore = "SelectAll" id = "Separator2" type = "Separator" />
<MenuItem insertafter = "Separator2" insertbefore = "Separator3" id = "Format" label = "${res:XML.MainMenu.EditMenu.FormatMenu}" type="Menu">

34
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -51,7 +51,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
if (file != PrimaryFile)
return;
codeEditor.TextEditor.Save(stream);
codeEditor.Save(stream);
}
bool isLoading;
@ -64,10 +64,10 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -64,10 +64,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
try {
BookmarksDetach();
codeEditor.FileName = file.FileName;
codeEditor.TextEditor.SyntaxHighlighting =
codeEditor.PrimaryTextEditor.SyntaxHighlighting =
HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(file.FileName));
LoadFormatter();
codeEditor.TextEditor.Load(stream);
codeEditor.Load(stream);
BookmarksAttach();
} finally {
isLoading = false;
@ -78,8 +78,8 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -78,8 +78,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
const string formatingStrategyPath = "/AddIns/DefaultTextEditor/Formatter";
if (codeEditor.TextEditor.SyntaxHighlighting != null) {
string formatterPath = formatingStrategyPath + "/" + codeEditor.TextEditor.SyntaxHighlighting.Name;
if (codeEditor.SyntaxHighlighting != null) {
string formatterPath = formatingStrategyPath + "/" + codeEditor.SyntaxHighlighting.Name;
var formatter = AddInTree.BuildItems<IFormattingStrategy>(formatterPath, this, false);
if (formatter != null && formatter.Count > 0) {
codeEditor.FormattingStrategy = formatter[0];
@ -100,7 +100,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -100,7 +100,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
void BookmarksAttach()
{
foreach (SDBookmark bookmark in BookmarkManager.GetBookmarks(codeEditor.FileName)) {
bookmark.Document = codeEditor.TextEditorAdapter.Document;
bookmark.Document = codeEditor.DocumentAdapter;
codeEditor.IconBarMargin.Bookmarks.Add(bookmark);
}
BookmarkManager.Added += BookmarkManager_Added;
@ -112,7 +112,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -112,7 +112,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
BookmarkManager.Added -= BookmarkManager_Added;
BookmarkManager.Removed -= BookmarkManager_Removed;
foreach (SDBookmark bookmark in codeEditor.IconBarMargin.Bookmarks.OfType<SDBookmark>()) {
if (bookmark.Document == codeEditor.TextEditorAdapter.Document) {
if (bookmark.Document == codeEditor.DocumentAdapter) {
bookmark.Document = null;
}
}
@ -122,7 +122,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -122,7 +122,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
void BookmarkManager_Removed(object sender, BookmarkEventArgs e)
{
codeEditor.IconBarMargin.Bookmarks.Remove(e.Bookmark);
if (e.Bookmark.Document == codeEditor.TextEditorAdapter.Document) {
if (e.Bookmark.Document == codeEditor.DocumentAdapter) {
e.Bookmark.Document = null;
}
}
@ -131,7 +131,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -131,7 +131,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
if (FileUtility.IsEqualFileName(this.PrimaryFileName, e.Bookmark.FileName)) {
codeEditor.IconBarMargin.Bookmarks.Add(e.Bookmark);
e.Bookmark.Document = codeEditor.TextEditorAdapter.Document;
e.Bookmark.Document = codeEditor.DocumentAdapter;
}
}
@ -171,16 +171,16 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -171,16 +171,16 @@ namespace ICSharpCode.AvalonEdit.AddIn
public Properties CreateMemento()
{
Properties memento = new Properties();
memento.Set("CaretOffset", codeEditor.TextEditor.CaretOffset);
memento.Set("ScrollPositionY", codeEditor.TextEditor.VerticalOffset);
memento.Set("CaretOffset", codeEditor.ActiveTextEditor.CaretOffset);
memento.Set("ScrollPositionY", codeEditor.ActiveTextEditor.VerticalOffset);
return memento;
}
public void SetMemento(Properties memento)
{
codeEditor.TextEditor.ScrollToVerticalOffset(memento.Get("ScrollPositionY", 0.0));
codeEditor.PrimaryTextEditor.ScrollToVerticalOffset(memento.Get("ScrollPositionY", 0.0));
try {
codeEditor.TextEditor.CaretOffset = memento.Get("CaretOffset", 0);
codeEditor.PrimaryTextEditor.CaretOffset = memento.Get("CaretOffset", 0);
} catch (ArgumentOutOfRangeException) {
// ignore caret out of range - maybe file was changed externally?
}
@ -189,13 +189,13 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -189,13 +189,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
#region ITextEditorProvider
public ITextEditor TextEditor {
get { return codeEditor.TextEditorAdapter; }
get { return codeEditor.ActiveTextEditorAdapter; }
}
public IDocument GetDocumentForFile(OpenedFile file)
{
if (file == this.PrimaryFile)
return codeEditor.TextEditorAdapter.Document;
return codeEditor.DocumentAdapter;
else
return null;
}
@ -203,11 +203,11 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -203,11 +203,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
#region IPositionable
public int Line {
get { return codeEditor.TextEditor.TextArea.Caret.Line; }
get { return this.TextEditor.Caret.Line; }
}
public int Column {
get { return codeEditor.TextEditor.TextArea.Caret.Column; }
get { return this.TextEditor.Caret.Column; }
}
public void JumpTo(int line, int column)

205
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

@ -7,46 +7,83 @@ @@ -7,46 +7,83 @@
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Gui;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Indentation;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using System.Windows.Threading;
namespace ICSharpCode.AvalonEdit.AddIn
{
/// <summary>
/// Integrates AvalonEdit with SharpDevelop.
/// </summary>
public class CodeEditor : DockPanel
public class CodeEditor : Grid
{
readonly QuickClassBrowser quickClassBrowser = new QuickClassBrowser();
readonly TextEditor textEditor = new TextEditor();
readonly CodeEditorAdapter textEditorAdapter;
QuickClassBrowser quickClassBrowser;
readonly TextEditor primaryTextEditor;
readonly CodeEditorAdapter primaryTextEditorAdapter;
TextEditor secondaryTextEditor;
CodeEditorAdapter secondaryTextEditorAdapter;
readonly IconBarMargin iconBarMargin;
readonly TextMarkerService textMarkerService;
public TextEditor TextEditor {
get { return textEditor; }
public TextEditor PrimaryTextEditor {
get { return primaryTextEditor; }
}
public TextEditor ActiveTextEditor {
get { return primaryTextEditor; }
}
TextDocument document;
public TextDocument Document {
get { return textEditor.Document; }
set { textEditor.Document = value; }
get {
return document;
}
set {
if (document != value) {
document = value;
if (DocumentChanged != null) {
DocumentChanged(this, EventArgs.Empty);
}
}
}
}
public event EventHandler DocumentChanged;
public IDocument DocumentAdapter {
get { return primaryTextEditorAdapter.Document; }
}
public CodeEditorAdapter TextEditorAdapter {
get { return textEditorAdapter; }
public CodeEditorAdapter ActiveTextEditorAdapter {
get { return GetAdapter(this.ActiveTextEditor); }
}
CodeEditorAdapter GetAdapter(TextEditor editor)
{
if (editor == secondaryTextEditor)
return secondaryTextEditorAdapter;
else
return primaryTextEditorAdapter;
}
public IconBarMargin IconBarMargin {
@ -66,11 +103,44 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -66,11 +103,44 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
public void Redraw(ISegment segment, DispatcherPriority priority)
{
primaryTextEditor.TextArea.TextView.Redraw(segment, priority);
if (secondaryTextEditor != null) {
secondaryTextEditor.TextArea.TextView.Redraw(segment, priority);
}
}
public CodeEditor()
{
textEditorAdapter = new CodeEditorAdapter(this);
this.CommandBindings.Add(new CommandBinding(SharpDevelopRoutedCommands.SplitView, OnSplitView));
textMarkerService = new TextMarkerService(this);
primaryTextEditor = CreateTextEditor();
primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor));
Debug.Assert(primaryTextEditorAdapter != null);
this.Document = primaryTextEditor.Document;
primaryTextEditor.SetBinding(TextEditor.DocumentProperty, new Binding("Document") { Source = this });
// TODO: support iconbarmargin in split view
this.iconBarMargin = new IconBarMargin { TextView = primaryTextEditor.TextArea.TextView };
primaryTextEditor.TextArea.LeftMargins.Insert(0, iconBarMargin);
primaryTextEditor.TextArea.TextView.Services.AddService(typeof(IBookmarkMargin), iconBarMargin);
this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
SetRow(primaryTextEditor, 1);
this.Children.Add(primaryTextEditor);
}
protected virtual TextEditor CreateTextEditor()
{
TextEditor textEditor = new TextEditor();
CodeEditorAdapter adapter = new CodeEditorAdapter(this, textEditor);
TextView textView = textEditor.TextArea.TextView;
textView.Services.AddService(typeof(ITextEditor), textEditorAdapter);
textView.Services.AddService(typeof(ITextEditor), adapter);
textView.Services.AddService(typeof(CodeEditor), this);
textEditor.Background = Brushes.White;
@ -85,21 +155,51 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -85,21 +155,51 @@ namespace ICSharpCode.AvalonEdit.AddIn
textEditor.TextArea.DefaultInputHandler.CommandBindings.Add(
new CommandBinding(CustomCommands.DeleteLine, OnDeleteLine));
this.iconBarMargin = new IconBarMargin { TextView = textView };
textEditor.TextArea.LeftMargins.Insert(0, iconBarMargin);
textView.Services.AddService(typeof(IBookmarkMargin), iconBarMargin);
textMarkerService = new TextMarkerService(this);
textView.BackgroundRenderers.Add(textMarkerService);
textView.LineTransformers.Add(textMarkerService);
textView.Services.AddService(typeof(ITextMarkerService), textMarkerService);
quickClassBrowser.JumpAction = JumpTo;
SetDock(quickClassBrowser, Dock.Top);
this.Children.Add(quickClassBrowser);
this.Children.Add(textEditor);
return textEditor;
}
// always use primary text editor for loading/saving
// (the file encoding is stored only there)
public void Load(Stream stream)
{
primaryTextEditor.Load(stream);
}
public void Save(Stream stream)
{
primaryTextEditor.Save(stream);
}
void OnSplitView(object sender, ExecutedRoutedEventArgs e)
{
if (secondaryTextEditor == null) {
// create secondary editor
this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
secondaryTextEditor = CreateTextEditor();
secondaryTextEditorAdapter = (CodeEditorAdapter)secondaryTextEditor.TextArea.GetService(typeof(ITextEditor));
Debug.Assert(primaryTextEditorAdapter != null);
secondaryTextEditor.SetBinding(TextEditor.DocumentProperty,
new Binding(TextEditor.DocumentProperty.Name) { Source = primaryTextEditor });
secondaryTextEditor.TextArea.SetBinding(TextArea.IndentationStrategyProperty,
new Binding(TextArea.IndentationStrategyProperty.Name) { Source = primaryTextEditor.TextArea });
secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting;
SetRow(secondaryTextEditor, 2);
this.Children.Add(secondaryTextEditor);
} else {
// remove secondary editor
this.Children.Remove(secondaryTextEditor);
secondaryTextEditor = null;
secondaryTextEditorAdapter = null;
this.RowDefinitions.RemoveAt(this.RowDefinitions.Count - 1);
}
}
void caret_PositionChanged(object sender, EventArgs e)
{
InvalidateQuickClassBrowserCaretPosition();
@ -120,7 +220,9 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -120,7 +220,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
new Action(
delegate {
quickClassBrowserCaretPositionInvalid = false;
quickClassBrowser.SelectItemAtCaretPosition(textEditorAdapter.Caret.Position);
if (quickClassBrowser != null) {
quickClassBrowser.SelectItemAtCaretPosition(this.ActiveTextEditorAdapter.Caret.Position);
}
}));
}
}
@ -128,15 +230,16 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -128,15 +230,16 @@ namespace ICSharpCode.AvalonEdit.AddIn
public void JumpTo(int line, int column)
{
// the adapter sets the caret position and takes care of scrolling
textEditorAdapter.JumpTo(line, column);
textEditor.Focus();
this.ActiveTextEditorAdapter.JumpTo(line, column);
this.ActiveTextEditor.Focus();
}
ToolTip toolTip;
void textEditor_MouseHover(object sender, MouseEventArgs e)
{
ToolTipRequestEventArgs args = new ToolTipRequestEventArgs(textEditorAdapter);
TextEditor textEditor = (TextEditor)sender;
ToolTipRequestEventArgs args = new ToolTipRequestEventArgs(GetAdapter(textEditor));
var pos = textEditor.GetPositionFromPoint(e.GetPosition(this));
args.InDocument = pos.HasValue;
if (pos.HasValue) {
@ -184,9 +287,13 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -184,9 +287,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (completionWindow != null)
return;
TextArea textArea = (TextArea)sender;
ITextEditor adapter = (ITextEditor)textArea.GetService(typeof(ITextEditor));
Debug.Assert(adapter != null);
foreach (char c in e.Text) {
foreach (ICodeCompletionBinding cc in CodeCompletionBindings) {
CodeCompletionKeyPressResult result = cc.HandleKeyPress(textEditorAdapter, c);
CodeCompletionKeyPressResult result = cc.HandleKeyPress(adapter, c);
if (result == CodeCompletionKeyPressResult.Completed) {
if (completionWindow != null) {
// a new CompletionWindow was shown, but does not eat the input
@ -211,10 +318,11 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -211,10 +318,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
void OnCodeCompletion(object sender, ExecutedRoutedEventArgs e)
{
TextEditor textEditor = (TextEditor)sender;
if (completionWindow != null)
completionWindow.Close();
foreach (ICodeCompletionBinding cc in CodeCompletionBindings) {
if (cc.CtrlSpace(textEditorAdapter)) {
if (cc.CtrlSpace(GetAdapter(textEditor))) {
e.Handled = true;
break;
}
@ -223,9 +331,10 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -223,9 +331,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
void OnDeleteLine(object sender, ExecutedRoutedEventArgs e)
{
TextEditor textEditor = (TextEditor)sender;
e.Handled = true;
using (this.Document.RunUpdate()) {
DocumentLine currentLine = this.Document.GetLineByNumber(textEditor.TextArea.Caret.Line);
using (textEditor.Document.RunUpdate()) {
DocumentLine currentLine = textEditor.Document.GetLineByNumber(textEditor.TextArea.Caret.Line);
textEditor.Select(currentLine.Offset, currentLine.TotalLength);
textEditor.SelectedText = string.Empty;
}
@ -253,9 +362,21 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -253,9 +362,21 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (formattingStrategy != value) {
formattingStrategy = value;
if (value != null)
textEditor.TextArea.IndentationStrategy = new IndentationStrategyAdapter(textEditorAdapter, value);
primaryTextEditor.TextArea.IndentationStrategy = new IndentationStrategyAdapter(primaryTextEditorAdapter, value);
else
textEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy();
primaryTextEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy();
// no need to update the secondary text editor - its IndentationStrategy property will
// update using a binding.
}
}
}
public IHighlightingDefinition SyntaxHighlighting {
get { return primaryTextEditor.SyntaxHighlighting; }
set {
primaryTextEditor.SyntaxHighlighting = value;
if (secondaryTextEditor != null) {
secondaryTextEditor.SyntaxHighlighting = value;
}
}
}
@ -267,11 +388,21 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -267,11 +388,21 @@ namespace ICSharpCode.AvalonEdit.AddIn
public void ParseInformationUpdated(ParseInformation parseInfo)
{
if (parseInfo != null)
if (parseInfo != null) {
if (quickClassBrowser == null) {
quickClassBrowser = new QuickClassBrowser();
quickClassBrowser.JumpAction = JumpTo;
SetRow(quickClassBrowser, 0);
this.Children.Add(quickClassBrowser);
}
quickClassBrowser.Update(parseInfo.MostRecentCompilationUnit);
else
quickClassBrowser.Update(null);
InvalidateQuickClassBrowserCaretPosition();
InvalidateQuickClassBrowserCaretPosition();
} else {
if (quickClassBrowser != null) {
this.Children.Remove(quickClassBrowser);
quickClassBrowser = null;
}
}
}
}
}

4
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorAdapter.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -20,7 +20,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
readonly CodeEditor codeEditor;
public CodeEditorAdapter(CodeEditor codeEditor) : base(codeEditor.TextEditor)
public CodeEditorAdapter(CodeEditor codeEditor, TextEditor textEditor) : base(textEditor)
{
if (codeEditor == null)
throw new ArgumentNullException("codeEditor");
@ -35,7 +35,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -35,7 +35,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
if (data == null || !data.Items.Any())
return;
CompletionWindow window = new SharpDevelopCompletionWindow(this, codeEditor.TextEditor.TextArea, data);
CompletionWindow window = new SharpDevelopCompletionWindow(this, this.TextEditor.TextArea, data);
codeEditor.NotifyCompletionWindowOpened(window);
window.Show();
}

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IconBarMargin.cs

@ -114,7 +114,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -114,7 +114,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
base.OnMouseDown(e);
TextView textView = this.TextView;
if (!e.Handled && textView != null) {
VisualLine visualLine = textView.GetVisualLineFromVisualTop(e.GetPosition(textView).Y - textView.VerticalOffset);
VisualLine visualLine = textView.GetVisualLineFromVisualTop(e.GetPosition(textView).Y + textView.VerticalOffset);
if (visualLine != null) {
int line = visualLine.FirstDocumentLine.LineNumber;
foreach (IBookmark bm in bookmarks) {

6
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.xaml

@ -16,19 +16,19 @@ @@ -16,19 +16,19 @@
</DataTemplate.Triggers>
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<ComboBox Name="classComboBox"
Grid.Column="0"
Margin="0,0,4,0"
Margin="0,0,4,1"
ItemTemplate="{StaticResource comboBoxItemTemplate}"
SelectionChanged="classComboBoxSelectionChanged"/>
<ComboBox Name="membersComboBox"
Grid.Column="1"
Margin="0,0,4,0"
Margin="0,0,4,1"
ItemTemplate="{StaticResource comboBoxItemTemplate}"
SelectionChanged="membersComboBoxSelectionChanged"/>
</Grid>

11
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/TextMarkerService.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -30,7 +30,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (codeEditor == null)
throw new ArgumentNullException("codeEditor");
this.codeEditor = codeEditor;
codeEditor.TextEditor.DocumentChanged += codeEditor_DocumentChanged;
codeEditor.DocumentChanged += codeEditor_DocumentChanged;
codeEditor_DocumentChanged(null, null);
}
@ -73,7 +73,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -73,7 +73,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// </summary>
internal void Redraw(ISegment segment)
{
codeEditor.TextEditor.TextArea.TextView.Redraw(segment, DispatcherPriority.Normal);
codeEditor.Redraw(segment, DispatcherPriority.Normal);
}
#endregion
@ -111,9 +111,12 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -111,9 +111,12 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
public void Draw(DrawingContext drawingContext)
public void Draw(TextView textView, DrawingContext drawingContext)
{
TextView textView = codeEditor.TextEditor.TextArea.TextView;
if (textView == null)
throw new ArgumentNullException("textView");
if (drawingContext == null)
throw new ArgumentNullException("drawingContext");
if (markers == null || !textView.VisualLinesValid)
return;
var visualLines = textView.VisualLines;

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/IBackgroundRenderer.cs

@ -28,6 +28,6 @@ namespace ICSharpCode.AvalonEdit.Gui @@ -28,6 +28,6 @@ namespace ICSharpCode.AvalonEdit.Gui
/// <summary>
/// Causes the background renderer to draw.
/// </summary>
void Draw(DrawingContext drawingContext);
void Draw(TextView textView, DrawingContext drawingContext);
}
}

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextArea.cs

@ -59,8 +59,8 @@ namespace ICSharpCode.AvalonEdit @@ -59,8 +59,8 @@ namespace ICSharpCode.AvalonEdit
throw new ArgumentNullException("textView");
this.textView = textView;
this.Options = textView.Options;
textView.SetBinding(TextView.DocumentProperty, new Binding("Document") { Source = this });
textView.SetBinding(TextView.OptionsProperty, new Binding("Options") { Source = this });
textView.SetBinding(TextView.DocumentProperty, new Binding(DocumentProperty.Name) { Source = this });
textView.SetBinding(TextView.OptionsProperty, new Binding(OptionsProperty.Name) { Source = this });
textView.Services.AddService(typeof(TextArea), this);

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextEditor.cs

@ -68,8 +68,8 @@ namespace ICSharpCode.AvalonEdit @@ -68,8 +68,8 @@ namespace ICSharpCode.AvalonEdit
this.textArea = textArea;
this.Options = textArea.Options;
this.Document = new TextDocument();
textArea.SetBinding(TextArea.DocumentProperty, new Binding("Document") { Source = this });
textArea.SetBinding(TextArea.OptionsProperty, new Binding("Options") { Source = this });
textArea.SetBinding(TextArea.DocumentProperty, new Binding(DocumentProperty.Name) { Source = this });
textArea.SetBinding(TextArea.OptionsProperty, new Binding(OptionsProperty.Name) { Source = this });
}
#region Document property

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextView.cs

@ -829,7 +829,7 @@ namespace ICSharpCode.AvalonEdit.Gui @@ -829,7 +829,7 @@ namespace ICSharpCode.AvalonEdit.Gui
{
foreach (IBackgroundRenderer bg in backgroundRenderers) {
if (bg.Layer == layer) {
bg.Draw(drawingContext);
bg.Draw(this, drawingContext);
}
}
}

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -67,6 +67,7 @@ @@ -67,6 +67,7 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="Src\Commands\SharpDevelopRoutedCommands.cs" />
<Compile Include="Src\Editor\AvalonEdit\AvalonEditDocumentAdapter.cs" />
<Compile Include="Src\Editor\AvalonEdit\AvalonEditTextEditorAdapter.cs" />
<Compile Include="Src\Editor\AvalonEdit\IndentationStrategyAdapter.cs" />

21
src/Main/Base/Project/Src/Commands/SharpDevelopRoutedCommands.cs

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Input;
namespace ICSharpCode.SharpDevelop
{
/// <summary>
/// Contains WPF routed commands for SharpDevelop-specific commands.
/// </summary>
public static class SharpDevelopRoutedCommands
{
public static readonly RoutedCommand SplitView = new RoutedCommand(
"SplitView", typeof(SharpDevelopRoutedCommands));
}
}

4
src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs

@ -23,6 +23,10 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -23,6 +23,10 @@ namespace ICSharpCode.SharpDevelop.Editor
readonly TextEditor textEditor;
AvalonEditDocumentAdapter document;
public TextEditor TextEditor {
get { return textEditor; }
}
public AvalonEditTextEditorAdapter(TextEditor textEditor)
{
if (textEditor == null)

1
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -93,6 +93,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -93,6 +93,7 @@ namespace ICSharpCode.SharpDevelop.Gui
{
WorkbenchSingleton.workbench = workbench;
Core.Presentation.MenuService.RegisterCommandClass(typeof(SharpDevelopRoutedCommands));
DisplayBindingService.InitializeService();
LayoutConfiguration.LoadLayoutConfiguration();
FileService.InitializeService();

5
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs

@ -33,6 +33,11 @@ namespace ICSharpCode.Core @@ -33,6 +33,11 @@ namespace ICSharpCode.Core
/// <attribute name="class" use="optional">
/// Command class that is run when item is clicked.
/// </attribute>
/// <attribute name="command" use="optional">
/// A WPF routed command that is executed when item is clicked.
/// Currently, this property is supported only for WPF Menus.
/// Only one of the "class" and "command" attributes can be used on a menu entry.
/// </attribute>
/// <attribute name="link" use="optional">
/// Only for the type "Item"/"Command". Opens a webpage instead of running a command when
/// clicking the item.

9
src/Main/ICSharpCode.Core.Presentation/Menu/MenuCommand.cs

@ -22,12 +22,9 @@ namespace ICSharpCode.Core.Presentation @@ -22,12 +22,9 @@ namespace ICSharpCode.Core.Presentation
{
string commandName = codon.Properties["command"];
if (!string.IsNullOrEmpty(commandName)) {
PropertyInfo p = typeof(ApplicationCommands).GetProperty(commandName);
if (p == null) {
p = typeof(NavigationCommands).GetProperty(commandName);
}
if (p != null) {
return (System.Windows.Input.ICommand)p.GetValue(null, null);
var wpfCommand = MenuService.GetRegisteredCommand(commandName);
if (wpfCommand != null) {
return wpfCommand;
} else {
MessageService.ShowError("Could not find WPF command '" + commandName + "'.");
// return dummy command

45
src/Main/ICSharpCode.Core.Presentation/Menu/MenuService.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@ -19,6 +20,48 @@ namespace ICSharpCode.Core.Presentation @@ -19,6 +20,48 @@ namespace ICSharpCode.Core.Presentation
/// </summary>
public static class MenuService
{
static List<Type> commandClasses = new List<Type> {
typeof(ApplicationCommands),
typeof(NavigationCommands)
};
/// <summary>
/// Gets a known WPF command.
/// </summary>
/// <param name="commandName">The name of the command, e.g. "Copy".</param>
/// <returns>The WPF ICommand with the given name, or null if thecommand was not found.</returns>
public static System.Windows.Input.ICommand GetRegisteredCommand(string commandName)
{
if (commandName == null)
throw new ArgumentNullException("commandName");
lock (commandClasses) {
foreach (Type t in commandClasses) {
PropertyInfo p = t.GetProperty(commandName, BindingFlags.Public | BindingFlags.Static);
if (p != null) {
return (System.Windows.Input.ICommand)(p.GetValue(null, null));
}
FieldInfo f = t.GetField(commandName, BindingFlags.Public | BindingFlags.Static);
if (f != null) {
return (System.Windows.Input.ICommand)(f.GetValue(null));
}
}
return null;
}
}
/// <summary>
///
/// </summary>
public static void RegisterCommandClass(Type commandClass)
{
if (commandClass == null)
throw new ArgumentNullException("commandClass");
lock (commandClasses) {
if (!commandClasses.Contains(commandClass))
commandClasses.Add(commandClass);
}
}
public static void UpdateStatus(IEnumerable menuItems)
{
if (menuItems == null)
@ -86,7 +129,7 @@ namespace ICSharpCode.Core.Presentation @@ -86,7 +129,7 @@ namespace ICSharpCode.Core.Presentation
return result;
}
internal static IList ExpandMenuBuilders(ICollection input)
static IList ExpandMenuBuilders(ICollection input)
{
ArrayList result = new ArrayList(input.Count);
foreach (object o in input) {

Loading…
Cancel
Save