mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 17:59:17 +00:00
Add keyboard shortcuts for text direction #1612
Implemented Ctrl+LShift and Ctrl+RShift shortcuts to switch text flow direction between LTR and RTL in TextViewerPanel
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user