[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
This commit is contained in:
Don Ho 2014-12-07 16:43:31 +00:00
parent 134920648d
commit 428df19cbc
5 changed files with 29 additions and 3 deletions

View File

@ -2383,14 +2383,16 @@ void Notepad_plus::command(int id)
case IDM_EDIT_RTL : case IDM_EDIT_RTL :
case IDM_EDIT_LTR : case IDM_EDIT_LTR :
{ {
long exStyle = ::GetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE); _pEditView->changeTextDirection(id == IDM_EDIT_RTL);
exStyle = (id == IDM_EDIT_RTL)?exStyle|WS_EX_LAYOUTRTL:exStyle&(~WS_EX_LAYOUTRTL);
::SetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE, exStyle);
// Wrap then !wrap to fix problem of mirror characters // Wrap then !wrap to fix problem of mirror characters
bool isWraped = _pEditView->isWrap(); bool isWraped = _pEditView->isWrap();
_pEditView->wrap(!isWraped); _pEditView->wrap(!isWraped);
_pEditView->wrap(isWraped); _pEditView->wrap(isWraped);
if (_pDocMap)
{
_pDocMap->changeTextDirection(id == IDM_EDIT_RTL);
}
} }
break; break;

View File

@ -3081,6 +3081,18 @@ void ScintillaEditView::quickSortLines(size_t fromLine, size_t toLine, bool isRe
quickSortLines(pivotIndex + 1, toLine, isReverse); 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) bool ScintillaEditView::swapLines(size_t line1, size_t line2)
{ {

View File

@ -636,6 +636,8 @@ public:
void scrollPosToCenter(int pos); void scrollPosToCenter(int pos);
bool swapLines(size_t line1, size_t line2); bool swapLines(size_t line1, size_t line2);
void quickSortLines(size_t fromLine, size_t toLine, bool isReverse = false); void quickSortLines(size_t fromLine, size_t toLine, bool isReverse = false);
void changeTextDirection(bool isRTL);
bool isTextDirectionRTL() const;
protected: protected:
static HINSTANCE _hLib; static HINSTANCE _hLib;

View File

@ -89,9 +89,18 @@ void DocumentMap::initWrapMap()
::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, rect.right - rect.left, rect.bottom-rect.top, TRUE); ::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, rect.right - rect.left, rect.bottom-rect.top, TRUE);
_pScintillaEditView->wrap(false); _pScintillaEditView->wrap(false);
_pScintillaEditView->redraw(true); _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; double ddd = (double)Xlength1/(double)Xlength2;
char dchar[256]; char dchar[256];

View File

@ -131,6 +131,7 @@ public:
void fold(int line, bool foldOrNot); void fold(int line, bool foldOrNot);
void foldAll(bool mode); void foldAll(bool mode);
void setSyntaxHiliting(); void setSyntaxHiliting();
void changeTextDirection(bool isRTL);
protected: protected:
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);