mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-13 19:19:10 +00:00
Fix #787: add CTRL-F search bar.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user