Skip to content

Commit

Permalink
Prevent Direct Write being set if user uses RTL
Browse files Browse the repository at this point in the history
  • Loading branch information
donho committed Nov 22, 2023
1 parent c62e222 commit 9bc790b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
3 changes: 2 additions & 1 deletion PowerEditor/installer/nativeLang/english.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Translation note:
2. All the comments are for explanation, they are not for translation.
-->
<NotepadPlus>
<Native-Langue name="English" filename="english.xml" version="8.5.9">
<Native-Langue name="English" filename="english.xml" version="8.6">
<Menu>
<Main>
<!-- Main Menu Entries -->
Expand Down Expand Up @@ -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 &quot;session.xml&quot; now."/>
<RTLvsDirectWrite title="Cannot run RTL" message="RTL is not compatible with DirectWrite mode. Please disable DirectWrite mode in MISC. section of Preferences dialog, restart Notepad++, and try this command again."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Clipboard History"/>
Expand Down
3 changes: 2 additions & 1 deletion PowerEditor/installer/nativeLang/english_customizable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Translation note:
2. All the comments are for explanation, they are not for translation.
-->
<NotepadPlus>
<Native-Langue name="English" filename="english_customizable.xml" version="8.5.9">
<Native-Langue name="English" filename="english_customizable.xml" version="8.6">
<Menu>
<Main>
<!-- Main Menu Entries -->
Expand Down Expand Up @@ -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 &quot;session.xml&quot; now."/>
<RTLvsDirectWrite title="Cannot run RTL" message="RTL is not compatible with DirectWrite mode. Please disable DirectWrite mode in MISC. section of Preferences dialog, restart Notepad++, and try this command again."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Clipboard History"/>
Expand Down
3 changes: 2 additions & 1 deletion PowerEditor/installer/nativeLang/french.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Translation note:
2. All the comments are for explanation, they are not for translation.
-->
<NotepadPlus>
<Native-Langue name="français" filename="french.xml" version="8.5.9">
<Native-Langue name="français" filename="french.xml" version="8.6">
<Menu>
<Main>
<!-- Main Menu Entries -->
Expand Down Expand Up @@ -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 &quot;session.xml&quot; maintenant."/>
<RTLvsDirectWrite title="Exécution de la commande &quot;Texte de droite à gauche&quot; impossible" message="&quot;Texte de droite à gauche&quot; n'est pas compatible avec le mode &quot;DirectWrite&quot;. Veuillez désactiver ce mode dans la section &quot;Divers&quot; du dialogue Préférences, redémarer Notepad++, pour exécuter la commande de nouveau."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Historique du presse-papier"/>
Expand Down
5 changes: 3 additions & 2 deletions PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<NotepadPlus>
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="8.5.9">
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="8.6">
<Menu>
<Main>
<!-- Main Menu Entries -->
Expand Down Expand Up @@ -1233,7 +1233,7 @@
<Item id="6324" name="文件切換器(Ctrl + TAB)"/>
<Item id="6331" name="在標題列僅顯示檔案名稱(隱藏資料夾路徑)"/>
<Item id="6334" name="自動偵測檔案編碼"/>
<Item id="6349" name="使用 DirectWrite(可改善特殊字符的呈現,需要重新啟動 Notepad++)"/>
<Item id="6349" name="使用「直接寫入」模式(可改善特殊字符的呈現,需要重新啟動 Notepad++)"/>
<Item id="6337" name="資料夾工作區檔案副檔名:"/>
<Item id="6114" name="啟動"/>
<Item id="6117" name="開啟「最近使用的檔案」功能"/>
Expand Down Expand Up @@ -1390,6 +1390,7 @@
你想為它們創建佔位欄嗎?
請注意,如果你選擇不創建佔位欄或稍後關閉它們,工作階段檔案將在 Notepad++ 關閉時被修改。我們建議你現在備份工作階段檔案 &quot;session.xml&quot;"/>
<RTLvsDirectWrite title="無法執行「文字由右至左」指令" message="「文字由右至左」指令與「直接寫入」模式不相容。 請在偏好設定對話框的「其他」中停用「直接寫入」模式,然後重新​​啟動 Notepad++,重試此指令。"/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="剪貼簿記錄"/>
Expand Down
15 changes: 14 additions & 1 deletion PowerEditor/src/NppCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9bc790b

Please sign in to comment.