From 428df19cbc431c06a2b027f4d8263e906aae305f Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 7 Dec 2014 16:43:31 +0000 Subject: [PATCH] [NEW] Document map follows the current text direction (RTL/LTR). git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1303 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/NppCommands.cpp | 8 +++++--- .../src/ScitillaComponent/ScintillaEditView.cpp | 12 ++++++++++++ .../src/ScitillaComponent/ScintillaEditView.h | 2 ++ .../src/WinControls/DocumentMap/documentMap.cpp | 9 +++++++++ .../src/WinControls/DocumentMap/documentMap.h | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 42924cea..04926798 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 4d263d94..ceeeff73 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 55486111..0f5781b2 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 5ff15738..e584a4ab 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 d2361e34..de688eca 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);