|
|
@ -45,9 +45,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
QuickClassBrowser quickClassBrowser; |
|
|
|
QuickClassBrowser quickClassBrowser; |
|
|
|
readonly CodeEditorView primaryTextEditor; |
|
|
|
readonly CodeEditorView primaryTextEditor; |
|
|
|
readonly CodeEditorAdapter primaryTextEditorAdapter; |
|
|
|
readonly CodeEditorAdapter primaryTextEditorAdapter; |
|
|
|
CodeEditorView secondaryTextEditor; |
|
|
|
|
|
|
|
CodeEditorView activeTextEditor; |
|
|
|
|
|
|
|
CodeEditorAdapter secondaryTextEditorAdapter; |
|
|
|
|
|
|
|
GridSplitter gridSplitter; |
|
|
|
GridSplitter gridSplitter; |
|
|
|
readonly IconBarManager iconBarManager; |
|
|
|
readonly IconBarManager iconBarManager; |
|
|
|
readonly TextMarkerService textMarkerService; |
|
|
|
readonly TextMarkerService textMarkerService; |
|
|
@ -58,14 +55,9 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
get { return primaryTextEditor; } |
|
|
|
get { return primaryTextEditor; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Obsolete()] |
|
|
|
public CodeEditorView ActiveTextEditor { |
|
|
|
public CodeEditorView ActiveTextEditor { |
|
|
|
get { return activeTextEditor; } |
|
|
|
get { return primaryTextEditor; } |
|
|
|
private set { |
|
|
|
|
|
|
|
if (activeTextEditor != value) { |
|
|
|
|
|
|
|
activeTextEditor = value; |
|
|
|
|
|
|
|
HandleCaretPositionChange(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TextDocument document; |
|
|
|
TextDocument document; |
|
|
@ -114,8 +106,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
this.document.FileName = fileName; |
|
|
|
this.document.FileName = fileName; |
|
|
|
|
|
|
|
|
|
|
|
primaryTextEditorAdapter.FileNameChanged(); |
|
|
|
primaryTextEditorAdapter.FileNameChanged(); |
|
|
|
if (secondaryTextEditorAdapter != null) |
|
|
|
|
|
|
|
secondaryTextEditorAdapter.FileNameChanged(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.errorPainter == null) { |
|
|
|
if (this.errorPainter == null) { |
|
|
|
this.errorPainter = new ErrorPainter(primaryTextEditorAdapter); |
|
|
|
this.errorPainter = new ErrorPainter(primaryTextEditorAdapter); |
|
|
@ -143,12 +133,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
primaryTextEditor.TextArea.TextView.LineTransformers.Insert(0, new HighlightingColorizer(highlighter)); |
|
|
|
primaryTextEditor.TextArea.TextView.LineTransformers.Insert(0, new HighlightingColorizer(highlighter)); |
|
|
|
primaryTextEditor.UpdateCustomizedHighlighting(); |
|
|
|
primaryTextEditor.UpdateCustomizedHighlighting(); |
|
|
|
|
|
|
|
|
|
|
|
if (secondaryTextEditor != null) { |
|
|
|
|
|
|
|
secondaryTextEditor.SyntaxHighlighting = highlighting; |
|
|
|
|
|
|
|
secondaryTextEditor.TextArea.TextView.LineTransformers.RemoveAll(t => t is HighlightingColorizer); |
|
|
|
|
|
|
|
secondaryTextEditor.TextArea.TextView.LineTransformers.Insert(0, new HighlightingColorizer(highlighter)); |
|
|
|
|
|
|
|
secondaryTextEditor.UpdateCustomizedHighlighting(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Dispose the old highlighter; necessary to avoid memory leaks as
|
|
|
|
// Dispose the old highlighter; necessary to avoid memory leaks as
|
|
|
|
// semantic highlighters might attach to global parser events.
|
|
|
|
// semantic highlighters might attach to global parser events.
|
|
|
|
if (oldHighlighter != null) { |
|
|
|
if (oldHighlighter != null) { |
|
|
@ -159,9 +143,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
public void Redraw(ISegment segment, DispatcherPriority priority) |
|
|
|
public void Redraw(ISegment segment, DispatcherPriority priority) |
|
|
|
{ |
|
|
|
{ |
|
|
|
primaryTextEditor.TextArea.TextView.Redraw(segment, priority); |
|
|
|
primaryTextEditor.TextArea.TextView.Redraw(segment, priority); |
|
|
|
if (secondaryTextEditor != null) { |
|
|
|
|
|
|
|
secondaryTextEditor.TextArea.TextView.Redraw(segment, priority); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const double minRowHeight = 40; |
|
|
|
const double minRowHeight = 40; |
|
|
@ -175,7 +156,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
this.FlowDirection = FlowDirection.LeftToRight; // code editing is always left-to-right
|
|
|
|
this.FlowDirection = FlowDirection.LeftToRight; // code editing is always left-to-right
|
|
|
|
this.document = new TextDocument(); |
|
|
|
this.document = new TextDocument(); |
|
|
|
var documentServiceContainer = document.GetRequiredService<IServiceContainer>(); |
|
|
|
var documentServiceContainer = document.GetRequiredService<IServiceContainer>(); |
|
|
|
this.CommandBindings.Add(new CommandBinding(SharpDevelopRoutedCommands.SplitView, OnSplitView)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
textMarkerService = new TextMarkerService(document); |
|
|
|
textMarkerService = new TextMarkerService(document); |
|
|
|
documentServiceContainer.AddService(typeof(ITextMarkerService), textMarkerService); |
|
|
|
documentServiceContainer.AddService(typeof(ITextMarkerService), textMarkerService); |
|
|
@ -189,7 +169,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
primaryTextEditor = CreateTextEditor(); |
|
|
|
primaryTextEditor = CreateTextEditor(); |
|
|
|
primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor)); |
|
|
|
primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor)); |
|
|
|
Debug.Assert(primaryTextEditorAdapter != null); |
|
|
|
Debug.Assert(primaryTextEditorAdapter != null); |
|
|
|
activeTextEditor = primaryTextEditor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.ColumnDefinitions.Add(new ColumnDefinition()); |
|
|
|
this.ColumnDefinitions.Add(new ColumnDefinition()); |
|
|
|
this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); |
|
|
|
this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); |
|
|
@ -210,8 +189,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
// CustomizableHighlightingColorizer loads the new values automatically, we just need
|
|
|
|
// CustomizableHighlightingColorizer loads the new values automatically, we just need
|
|
|
|
// to force a refresh in AvalonEdit.
|
|
|
|
// to force a refresh in AvalonEdit.
|
|
|
|
primaryTextEditor.UpdateCustomizedHighlighting(); |
|
|
|
primaryTextEditor.UpdateCustomizedHighlighting(); |
|
|
|
if (secondaryTextEditor != null) |
|
|
|
|
|
|
|
secondaryTextEditor.UpdateCustomizedHighlighting(); |
|
|
|
|
|
|
|
foreach (var bookmark in SD.BookmarkManager.GetBookmarks(fileName).OfType<SDMarkerBookmark>()) |
|
|
|
foreach (var bookmark in SD.BookmarkManager.GetBookmarks(fileName).OfType<SDMarkerBookmark>()) |
|
|
|
bookmark.SetMarker(); |
|
|
|
bookmark.SetMarker(); |
|
|
|
} |
|
|
|
} |
|
|
@ -251,7 +228,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
codeEditorView.TextArea.MouseRightButtonDown += TextAreaMouseRightButtonDown; |
|
|
|
codeEditorView.TextArea.MouseRightButtonDown += TextAreaMouseRightButtonDown; |
|
|
|
codeEditorView.TextArea.ContextMenuOpening += TextAreaContextMenuOpening; |
|
|
|
codeEditorView.TextArea.ContextMenuOpening += TextAreaContextMenuOpening; |
|
|
|
codeEditorView.TextArea.TextCopied += textEditor_TextArea_TextCopied; |
|
|
|
codeEditorView.TextArea.TextCopied += textEditor_TextArea_TextCopied; |
|
|
|
codeEditorView.GotFocus += textEditor_GotFocus; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return codeEditorView; |
|
|
|
return codeEditorView; |
|
|
|
} |
|
|
|
} |
|
|
@ -275,12 +251,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
textEditor.Dispose(); |
|
|
|
textEditor.Dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void textEditor_GotFocus(object sender, RoutedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Debug.Assert(sender is CodeEditorView); |
|
|
|
|
|
|
|
this.ActiveTextEditor = (CodeEditorView)sender; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TextAreaContextMenuOpening(object sender, ContextMenuEventArgs e) |
|
|
|
void TextAreaContextMenuOpening(object sender, ContextMenuEventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ITextEditor adapter = GetAdapterFromSender(sender); |
|
|
|
ITextEditor adapter = GetAdapterFromSender(sender); |
|
|
@ -376,48 +346,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OnSplitView(object sender, ExecutedRoutedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (secondaryTextEditor == null) { |
|
|
|
|
|
|
|
// create secondary editor
|
|
|
|
|
|
|
|
this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight }); |
|
|
|
|
|
|
|
secondaryTextEditor = CreateTextEditor(); |
|
|
|
|
|
|
|
secondaryTextEditorAdapter = (CodeEditorAdapter)secondaryTextEditor.TextArea.GetService(typeof(ITextEditor)); |
|
|
|
|
|
|
|
Debug.Assert(primaryTextEditorAdapter != null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
secondaryTextEditor.SetBinding(TextEditor.IsReadOnlyProperty, |
|
|
|
|
|
|
|
new Binding(TextEditor.IsReadOnlyProperty.Name) { Source = primaryTextEditor }); |
|
|
|
|
|
|
|
secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting; |
|
|
|
|
|
|
|
secondaryTextEditor.UpdateCustomizedHighlighting(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gridSplitter = new GridSplitter { |
|
|
|
|
|
|
|
Height = 4, |
|
|
|
|
|
|
|
HorizontalAlignment = HorizontalAlignment.Stretch, |
|
|
|
|
|
|
|
VerticalAlignment = VerticalAlignment.Top |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
SetRow(gridSplitter, 2); |
|
|
|
|
|
|
|
this.Children.Add(gridSplitter); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
secondaryTextEditor.Margin = new Thickness(0, 4, 0, 0); |
|
|
|
|
|
|
|
SetRow(secondaryTextEditor, 2); |
|
|
|
|
|
|
|
this.Children.Add(secondaryTextEditor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
secondaryTextEditorAdapter.FileNameChanged(); |
|
|
|
|
|
|
|
FetchParseInformation(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// remove secondary editor
|
|
|
|
|
|
|
|
this.Children.Remove(secondaryTextEditor); |
|
|
|
|
|
|
|
this.Children.Remove(gridSplitter); |
|
|
|
|
|
|
|
secondaryTextEditorAdapter.DetachExtensions(); |
|
|
|
|
|
|
|
DisposeTextEditor(secondaryTextEditor); |
|
|
|
|
|
|
|
secondaryTextEditor = null; |
|
|
|
|
|
|
|
secondaryTextEditorAdapter = null; |
|
|
|
|
|
|
|
gridSplitter = null; |
|
|
|
|
|
|
|
this.RowDefinitions.RemoveAt(this.RowDefinitions.Count - 1); |
|
|
|
|
|
|
|
this.ActiveTextEditor = primaryTextEditor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public event EventHandler CaretPositionChanged; |
|
|
|
public event EventHandler CaretPositionChanged; |
|
|
|
|
|
|
|
|
|
|
|
void TextAreaCaretPositionChanged(object sender, EventArgs e) |
|
|
|
void TextAreaCaretPositionChanged(object sender, EventArgs e) |
|
|
@ -454,15 +382,13 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
|
|
|
|
|
|
|
|
SharpDevelopCompletionWindow CompletionWindow { |
|
|
|
SharpDevelopCompletionWindow CompletionWindow { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return primaryTextEditor.ActiveCompletionWindow |
|
|
|
return primaryTextEditor.ActiveCompletionWindow; |
|
|
|
?? (secondaryTextEditor == null ? null : secondaryTextEditor.ActiveCompletionWindow); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SharpDevelopInsightWindow InsightWindow { |
|
|
|
SharpDevelopInsightWindow InsightWindow { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return primaryTextEditor.ActiveInsightWindow |
|
|
|
return primaryTextEditor.ActiveInsightWindow; |
|
|
|
?? (secondaryTextEditor == null ? null : secondaryTextEditor.ActiveInsightWindow); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -635,8 +561,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
} |
|
|
|
} |
|
|
|
iconBarManager.UpdateClassMemberBookmarks(parseInfo != null ? parseInfo.UnresolvedFile : null, document); |
|
|
|
iconBarManager.UpdateClassMemberBookmarks(parseInfo != null ? parseInfo.UnresolvedFile : null, document); |
|
|
|
primaryTextEditor.UpdateParseInformationForFolding(parseInfo); |
|
|
|
primaryTextEditor.UpdateParseInformationForFolding(parseInfo); |
|
|
|
if (secondaryTextEditor != null) |
|
|
|
|
|
|
|
secondaryTextEditor.UpdateParseInformationForFolding(parseInfo); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
public void Dispose() |
|
|
@ -647,8 +571,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
|
|
|
|
|
|
|
|
if (primaryTextEditorAdapter.Language != null) |
|
|
|
if (primaryTextEditorAdapter.Language != null) |
|
|
|
primaryTextEditorAdapter.DetachExtensions(); |
|
|
|
primaryTextEditorAdapter.DetachExtensions(); |
|
|
|
if (secondaryTextEditorAdapter != null && secondaryTextEditorAdapter.Language != null) |
|
|
|
|
|
|
|
secondaryTextEditorAdapter.DetachExtensions(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (errorPainter != null) |
|
|
|
if (errorPainter != null) |
|
|
|
errorPainter.Dispose(); |
|
|
|
errorPainter.Dispose(); |
|
|
@ -656,8 +578,6 @@ namespace ICSharpCode.AvalonEdit.AddIn |
|
|
|
changeWatcher.Dispose(); |
|
|
|
changeWatcher.Dispose(); |
|
|
|
this.Document = null; |
|
|
|
this.Document = null; |
|
|
|
DisposeTextEditor(primaryTextEditor); |
|
|
|
DisposeTextEditor(primaryTextEditor); |
|
|
|
if (secondaryTextEditor != null) |
|
|
|
|
|
|
|
DisposeTextEditor(secondaryTextEditor); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|