diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs index 5a449f9..0b65957 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs @@ -66,6 +66,7 @@ public partial class TextViewerPanel : TextEditor, IDisposable ManipulationInertiaStarting += Viewer_ManipulationInertiaStarting; ManipulationStarting += Viewer_ManipulationStarting; ManipulationDelta += Viewer_ManipulationDelta; + KeyDown += Viewer_KeyDown; PreviewMouseWheel += Viewer_MouseWheel; @@ -111,6 +112,20 @@ public partial class TextViewerPanel : TextEditor, IDisposable e.Mode = ManipulationModes.Translate; } + private void Viewer_KeyDown(object sender, KeyEventArgs e) + { + // Support keyboard shortcuts for RTL and LTR text direction + if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) + { + // RTL: Ctrl + RShift + // LTR: Ctrl + LShift + if (Keyboard.IsKeyDown(Key.RightShift)) + FlowDirection = System.Windows.FlowDirection.RightToLeft; + else if (Keyboard.IsKeyDown(Key.LeftShift)) + FlowDirection = System.Windows.FlowDirection.LeftToRight; + } + } + private class TruncateLongLines : VisualLineElementGenerator { private const int MAX_LENGTH = 10000; @@ -206,6 +221,7 @@ public partial class TextViewerPanel : TextEditor, IDisposable : Brushes.Transparent; } + // Support automatic RTL for text files if (extension.Equals(".txt", StringComparison.OrdinalIgnoreCase)) { if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)