#1080: dark theme support for the text viewer

This commit is contained in:
Paddy
2022-02-20 18:55:28 +01:00
parent c93be2cb51
commit 660dc88001
92 changed files with 71 additions and 30 deletions

View File

@@ -39,12 +39,14 @@ namespace QuickLook.Plugin.TextViewer
{
private readonly ContextObject _context;
private bool _disposed;
private HighlightingManager highlightingManager = HighlightingManager.Instance;
public TextViewerPanel(string path, ContextObject context)
{
_context = context;
Background = new SolidColorBrush(Color.FromArgb(0xAA, 255, 255, 255));
SetResourceReference(Control.ForegroundProperty, "WindowTextForeground");
Background = Brushes.Transparent;
FontSize = 14;
ShowLineNumbers = true;
WordWrap = true;
@@ -82,6 +84,12 @@ namespace QuickLook.Plugin.TextViewer
LoadFileAsync(path);
}
public HighlightingManager HighlightingManager
{
get => highlightingManager;
set => highlightingManager = value;
}
public void Dispose()
{
_disposed = true;
@@ -144,7 +152,7 @@ namespace QuickLook.Plugin.TextViewer
Task.Run(() =>
{
const int maxLength = 5 * 1024 * 1024;
const int maxHighlightingLength = (int) (0.5 * 1024 * 1024);
const int maxHighlightingLength = (int)(0.5 * 1024 * 1024);
var buffer = new MemoryStream();
bool fileTooLong;
@@ -185,7 +193,7 @@ namespace QuickLook.Plugin.TextViewer
Encoding = encoding;
SyntaxHighlighting = bufferCopy.Length > maxHighlightingLength
? null
: HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(path));
: HighlightingManager?.GetDefinitionByExtension(Path.GetExtension(path));
Document = doc;
_context.IsBusy = false;