From 004a585efc5532c2dfc119d234f540c023a592e5 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 16 Nov 2019 19:29:12 +0100 Subject: [PATCH] Allow ISmartTextOutput to set the title of the decompilation tab. --- ILSpy/ISmartTextOutput.cs | 5 +++++ ILSpy/TextView/AvalonEditTextOutput.cs | 2 ++ ILSpy/TextView/DecompilerTextView.cs | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/ILSpy/ISmartTextOutput.cs b/ILSpy/ISmartTextOutput.cs index d429a7ae5..62098956e 100644 --- a/ILSpy/ISmartTextOutput.cs +++ b/ILSpy/ISmartTextOutput.cs @@ -38,6 +38,11 @@ namespace ICSharpCode.ILSpy void BeginSpan(HighlightingColor highlightingColor); void EndSpan(); + + /// + /// Gets/sets the title displayed in the document tab's header. + /// + string Title { get; set; } } public static class SmartTextOutputExtensions diff --git a/ILSpy/TextView/AvalonEditTextOutput.cs b/ILSpy/TextView/AvalonEditTextOutput.cs index 6c03a8b2d..79f6698c8 100644 --- a/ILSpy/TextView/AvalonEditTextOutput.cs +++ b/ILSpy/TextView/AvalonEditTextOutput.cs @@ -81,6 +81,8 @@ namespace ICSharpCode.ILSpy.TextView bool needsIndent; public string IndentationString { get; set; } = "\t"; + + public string Title { get; set; } internal readonly List elementGenerators = new List(); diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index 242e8bd47..888fd865d 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -629,6 +629,10 @@ namespace ICSharpCode.ILSpy.TextView foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); Debug.WriteLine(" Updating folding: {0}", w.Elapsed); w.Restart(); } + + if (this.DataContext is PaneModel model) { + model.Title = textOutput.Title; + } } #endregion @@ -751,6 +755,9 @@ namespace ICSharpCode.ILSpy.TextView void DecompileNodes(DecompilationContext context, ITextOutput textOutput) { var nodes = context.TreeNodes; + if (textOutput is ISmartTextOutput smartTextOutput) { + smartTextOutput.Title = string.Join(", ", nodes.Select(n => n.ToString())); + } for (int i = 0; i < nodes.Length; i++) { if (i > 0) textOutput.WriteLine();