diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs index f139f65..94d9bb8 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs @@ -27,6 +27,7 @@ using ICSharpCode.AvalonEdit; using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Rendering; +using ICSharpCode.AvalonEdit.Search; using QuickLook.Common.Helpers; using QuickLook.Common.Plugin; using UtfUnknown; @@ -67,6 +68,8 @@ namespace QuickLook.Plugin.TextViewer TextArea.TextView.ElementGenerators.Add(new TruncateLongLines()); + SearchPanel.Install(this); + LoadFileAsync(path); } @@ -106,15 +109,15 @@ namespace QuickLook.Plugin.TextViewer private class TruncateLongLines : VisualLineElementGenerator { - const int maxLength = 10000; - const string ellipsis = "……………"; + const int MAX_LENGTH = 10000; + const string ELLIPSIS = "……………"; public override int GetFirstInterestedOffset(int startOffset) { var line = CurrentContext.VisualLine.LastDocumentLine; - if (line.Length > maxLength) + if (line.Length > MAX_LENGTH) { - int ellipsisOffset = line.Offset + maxLength - ellipsis.Length; + int ellipsisOffset = line.Offset + MAX_LENGTH - ELLIPSIS.Length; if (startOffset <= ellipsisOffset) return ellipsisOffset; } @@ -123,7 +126,7 @@ namespace QuickLook.Plugin.TextViewer public override VisualLineElement ConstructElement(int offset) { - return new FormattedTextElement(ellipsis, CurrentContext.VisualLine.LastDocumentLine.EndOffset - offset); + return new FormattedTextElement(ELLIPSIS, CurrentContext.VisualLine.LastDocumentLine.EndOffset - offset); } }