浏览代码

Bug 2108: Blocking Windows Rich Edit formatting keyboard shortcuts in Internal Editor

https://winscp.net/tracker/2108

Source commit: c4fa6f22d63222bcf59dbeb1c37f9610bb378cdc
Martin Prikryl 3 年之前
父节点
当前提交
1922719432
共有 1 个文件被更改,包括 25 次插入0 次删除
  1. 25 0
      source/forms/Editor.cpp

+ 25 - 0
source/forms/Editor.cpp

@@ -173,6 +173,7 @@ protected:
   void __fastcall EMStreamIn(TMessage & Message);
   bool __stdcall StreamLoad(TRichEditStreamInfo * StreamInfo,
     unsigned char * Buff, long Read, long & WasRead);
+  DYNAMIC void __fastcall KeyDown(Word & Key, TShiftState Shift);
 
 private:
   HINSTANCE FLibrary;
@@ -572,6 +573,30 @@ bool __fastcall TEditorRichEdit::LoadFromStream(TStream * Stream, TEncoding * En
   return !FStreamLoadError;
 }
 //---------------------------------------------------------------------------
+void __fastcall TEditorRichEdit::KeyDown(Word & Key, TShiftState Shift)
+{
+  if ((// Block Center/Left/Justify alignment (Right alignment is overriden by the Reload command)
+       (Key == L'E') || (Key == L'L') || (Key == L'J') ||
+       // Line spacing
+       (Key == L'1') || (Key == L'2') || (Key == L'5')
+      ) &&
+      Shift.Contains(ssCtrl) && !Shift.Contains(ssAlt) && !Shift.Contains(ssShift))
+  {
+    Key = 0;
+  }
+  // Fiddle bullet style
+  if ((Key == L'L') && Shift.Contains(ssCtrl) && Shift.Contains(ssShift) && !Shift.Contains(ssAlt))
+  {
+    Key = 0;
+  }
+  // Superscript/Subscript (depending on the ssShift => +/=)
+  if ((Key == VK_OEM_PLUS) && Shift.Contains(ssCtrl) && !Shift.Contains(ssAlt))
+  {
+    Key = 0;
+  }
+  TNewRichEdit::KeyDown(Key, Shift);
+}
+//---------------------------------------------------------------------------
 class TFindDialogEx : public TFindDialog
 {
 public: