From 9bc790b014a7e0ea5b935d2ef963d02b6793cd2b Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 19 Nov 2023 18:26:56 +0100 Subject: [PATCH] Prevent Direct Write being set if user uses RTL Ref: https://github.com/notepad-plus-plus/notepad-plus-plus/commit/975d29b30bfd624b6392541b133c2bd32f3212b0#commitcomment-132946815 Close #14374 --- PowerEditor/installer/nativeLang/english.xml | 3 ++- .../installer/nativeLang/english_customizable.xml | 3 ++- PowerEditor/installer/nativeLang/french.xml | 3 ++- .../installer/nativeLang/taiwaneseMandarin.xml | 5 +++-- PowerEditor/src/NppCommands.cpp | 15 ++++++++++++++- .../src/ScintillaComponent/ScintillaEditView.cpp | 14 +++++++++++--- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 978d68c31..4eafa417e 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -5,7 +5,7 @@ Translation note: 2. All the comments are for explanation, they are not for translation. --> - +
@@ -1505,6 +1505,7 @@ NOTE: Choosing not to create the placeholders or closing them later, your manual Would you like to create those placeholders? NOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your "session.xml" now."/> + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 32a6643bf..6cd3bbb71 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -5,7 +5,7 @@ Translation note: 2. All the comments are for explanation, they are not for translation. --> - +
@@ -1505,6 +1505,7 @@ NOTE: Choosing not to create the placeholders or closing them later, your manual Would you like to create those placeholders? NOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your "session.xml" now."/> + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index c94b4bac2..558f28323 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -5,7 +5,7 @@ Translation note: 2. All the comments are for explanation, they are not for translation. --> - +
@@ -1505,6 +1505,7 @@ Notez que si vous choisissez de ne pas créer d'espaces réservés ou de les fer Voulez-vous créer des espaces réservés pour eux ? NOTE : Si vous choisissez de ne pas créer d'espaces réservés ou de les fermer plus tard, votre fichier de session sera modifié à la sortie. Nous vous suggérons de faire une sauvegarde du fichier de session "session.xml" maintenant."/> + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index d9e0ddf13..712c6a8a9 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -1,6 +1,6 @@ - +
@@ -1233,7 +1233,7 @@ - + @@ -1390,6 +1390,7 @@ 你想為它們創建佔位欄嗎? 請注意,如果你選擇不創建佔位欄或稍後關閉它們,工作階段檔案將在 Notepad++ 關閉時被修改。我們建議你現在備份工作階段檔案 "session.xml" 。"/> + diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index c00cf62f9..f1672f6a6 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -3802,13 +3802,26 @@ void Notepad_plus::command(int id) case IDM_EDIT_LTR : { bool toRTL = id == IDM_EDIT_RTL; + bool isRTL = _pEditView->isTextDirectionRTL(); if ((toRTL && isRTL) || (!toRTL && !isRTL)) { if (! ((NppParameters::getInstance()).getNppGUI())._muteSounds) ::MessageBeep(MB_OK); - break; + + return; + } + + if (toRTL && (NppParameters::getInstance()).getNppGUI()._writeTechnologyEngine == directWriteTechnology) + { + _nativeLangSpeaker.messageBox("RTLvsDirectWrite", + _pPublicInterface->getHSelf(), + TEXT("RTL is not compatible with Direct Write mode. Please disable DirectWrite mode in MISC. section of Preferences dialog, restart Notepad++, and try this command again."), + TEXT("Cannot run RTL"), + MB_OK | MB_APPLMODAL); + + return; } _pEditView->changeTextDirection(toRTL); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 41e2f1af4..3272e8f23 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -312,10 +312,18 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_FOUND_STYLE_EXT4, true); execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_FOUND_STYLE_EXT5, true); + NppGUI& nppGui = (NppParameters::getInstance()).getNppGUI(); + HMODULE hNtdllModule = ::GetModuleHandle(L"ntdll.dll"); - FARPROC isWINE = ::GetProcAddress(hNtdllModule, "wine_get_version"); - if ((NppParameters::getInstance()).getNppGUI()._writeTechnologyEngine == directWriteTechnology && !isWINE) // There is a performance issue under WINE when DirectWright is ON, - // so we turn it off if user uses Notepad++ under WINE + FARPROC isWINE = nullptr; + if (hNtdllModule) + isWINE = ::GetProcAddress(hNtdllModule, "wine_get_version"); + + if (isWINE || // There is a performance issue under WINE when DirectWright is ON, so we turn it off if user uses Notepad++ under WINE + isTextDirectionRTL()) // RTL is not compatible with Direct Write Technology + nppGui._writeTechnologyEngine = defaultTechnology; + + if (nppGui._writeTechnologyEngine == directWriteTechnology) { execute(SCI_SETTECHNOLOGY, SC_TECHNOLOGY_DIRECTWRITE); // If useDirectWrite is turned off, leave the technology setting untouched,