diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 42924ceac..04926798a 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2383,14 +2383,16 @@ void Notepad_plus::command(int id) case IDM_EDIT_RTL : case IDM_EDIT_LTR : { - long exStyle = ::GetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE); - exStyle = (id == IDM_EDIT_RTL)?exStyle|WS_EX_LAYOUTRTL:exStyle&(~WS_EX_LAYOUTRTL); - ::SetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE, exStyle); + _pEditView->changeTextDirection(id == IDM_EDIT_RTL); // Wrap then !wrap to fix problem of mirror characters bool isWraped = _pEditView->isWrap(); _pEditView->wrap(!isWraped); _pEditView->wrap(isWraped); + if (_pDocMap) + { + _pDocMap->changeTextDirection(id == IDM_EDIT_RTL); + } } break; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 4d263d945..ceeeff73e 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -3081,6 +3081,18 @@ void ScintillaEditView::quickSortLines(size_t fromLine, size_t toLine, bool isRe quickSortLines(pivotIndex + 1, toLine, isReverse); } +bool ScintillaEditView::isTextDirectionRTL() const +{ + long exStyle = ::GetWindowLongPtr(_hSelf, GWL_EXSTYLE); + return (exStyle & WS_EX_LAYOUTRTL) != 0; +} + +void ScintillaEditView::changeTextDirection(bool isRTL) +{ + long exStyle = ::GetWindowLongPtr(_hSelf, GWL_EXSTYLE); + exStyle = isRTL ? exStyle | WS_EX_LAYOUTRTL : exStyle&(~WS_EX_LAYOUTRTL); + ::SetWindowLongPtr(_hSelf, GWL_EXSTYLE, exStyle); +} bool ScintillaEditView::swapLines(size_t line1, size_t line2) { diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 55486111a..0f5781b2e 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -636,6 +636,8 @@ public: void scrollPosToCenter(int pos); bool swapLines(size_t line1, size_t line2); void quickSortLines(size_t fromLine, size_t toLine, bool isReverse = false); + void changeTextDirection(bool isRTL); + bool isTextDirectionRTL() const; protected: static HINSTANCE _hLib; diff --git a/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp b/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp index 5ff15738d..e584a4ab3 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp +++ b/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp @@ -89,9 +89,18 @@ void DocumentMap::initWrapMap() ::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, rect.right - rect.left, rect.bottom-rect.top, TRUE); _pScintillaEditView->wrap(false); _pScintillaEditView->redraw(true); + + bool isRTL = (*_ppEditView)->isTextDirectionRTL(); + if (_pScintillaEditView->isTextDirectionRTL() != isRTL) + _pScintillaEditView->changeTextDirection(isRTL); } } +void DocumentMap::changeTextDirection(bool isRTL) +{ + _pScintillaEditView->changeTextDirection(isRTL); +} + /* double ddd = (double)Xlength1/(double)Xlength2; char dchar[256]; diff --git a/PowerEditor/src/WinControls/DocumentMap/documentMap.h b/PowerEditor/src/WinControls/DocumentMap/documentMap.h index d2361e346..de688eca6 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentMap.h +++ b/PowerEditor/src/WinControls/DocumentMap/documentMap.h @@ -131,6 +131,7 @@ public: void fold(int line, bool foldOrNot); void foldAll(bool mode); void setSyntaxHiliting(); + void changeTextDirection(bool isRTL); protected: virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);