[FIXED_BUG] doc map: Fix moving problem.

doc map: Fix folding/unfolding problem.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@866 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2012-02-20 01:23:07 +00:00
parent 91a40f059b
commit dd2f32bb69
7 changed files with 83 additions and 20 deletions

View File

@ -21,6 +21,7 @@
#include "ImageListSet.h"
#include "ShortcutMapper.h"
#include "VerticalFileSwitcher.h"
#include "documentMap.h"
struct SortTaskListPred
{
@ -430,6 +431,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_MOVING:
{
if (_pDocMap)
{
_pDocMap->doMove();
}
result = FALSE;
}
break;

View File

@ -45,7 +45,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (notification->modificationType & SC_MOD_CHANGEFOLD)
{
if (prevWasEdit) {
if (prevWasEdit)
{
notifyView->foldChanged(notification->line,
notification->foldLevelNow, notification->foldLevelPrev);
prevWasEdit = false;
@ -355,25 +356,37 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{
if (notification->nmhdr.hwndFrom == _mainEditView.getHSelf())
switchEditViewTo(MAIN_VIEW);
else if (notification->nmhdr.hwndFrom == _subEditView.getHSelf())
switchEditViewTo(SUB_VIEW);
int lineClick = int(_pEditView->execute(SCI_LINEFROMPOSITION, notification->position));
if (notification->margin == ScintillaEditView::_SC_MARGE_FOLDER)
{
_pEditView->marginClick(notification->position, notification->modifiers);
if (_pDocMap)
_pDocMap->fold(lineClick, _pEditView->isFolded(lineClick));
}
else if ((notification->margin == ScintillaEditView::_SC_MARGE_SYBOLE) && !notification->modifiers)
{
int lineClick = int(_pEditView->execute(SCI_LINEFROMPOSITION, notification->position));
if (!_pEditView->markerMarginClick(lineClick))
bookmarkToggle(lineClick);
}
break;
}
case SCN_FOLDINGSTATECHANGED :
{
if ((notification->nmhdr.hwndFrom == _mainEditView.getHSelf())
|| (notification->nmhdr.hwndFrom == _subEditView.getHSelf()))
{
int lineClicked = notification->line;
if (_pDocMap)
_pDocMap->fold(lineClicked, _pEditView->isFolded(lineClicked));
}
return TRUE;
}
case SCN_CHARADDED:
{
charAdded(static_cast<TCHAR>(notification->ch));

View File

@ -1484,10 +1484,12 @@ void ScintillaEditView::activateBuffer(BufferID buffer)
for (int i = 0 ; i < nbLineState ; i++)
{
HeaderLineState & hls = lineStateVectorNew.at(i);
bool expanded = (execute(SCI_GETFOLDEXPANDED, hls._headerLineNumber) != 0);
bool expanded = isFolded(hls._headerLineNumber);
// set line to state folded
if (hls._isExpanded != expanded)
execute(SCI_TOGGLEFOLD, hls._headerLineNumber);
{
fold(hls._headerLineNumber, !expanded);
}
}
restoreCurrentPos();
@ -1573,8 +1575,10 @@ void ScintillaEditView::collapse(int level2Collapse, bool mode)
{
level -= SC_FOLDLEVELBASE;
if (level2Collapse == (level & SC_FOLDLEVELNUMBERMASK))
if ((execute(SCI_GETFOLDEXPANDED, line) != 0) != mode)
execute(SCI_TOGGLEFOLD, line);
if (isFolded(line) != mode)
{
fold(line, mode);
}
}
}
@ -1582,6 +1586,12 @@ void ScintillaEditView::collapse(int level2Collapse, bool mode)
}
void ScintillaEditView::foldCurrentPos(bool mode)
{
int currentLine = this->getCurrentLineNumber();
fold(currentLine, mode);
}
void ScintillaEditView::fold(int line, bool mode)
{
// The following code is needed :
execute(SCI_COLOURISE, 0, -1);
@ -1591,22 +1601,31 @@ void ScintillaEditView::foldCurrentPos(bool mode)
// If the "fold" property is set to "1" and your lexer or container supports folding, fold levels are also set.
// This message causes a redraw.
int currentLine = this->getCurrentLineNumber();
int headerLine;
int level = execute(SCI_GETFOLDLEVEL, currentLine);
int level = execute(SCI_GETFOLDLEVEL, line);
if (level & SC_FOLDLEVELHEADERFLAG)
headerLine = currentLine;
headerLine = line;
else
{
headerLine = execute(SCI_GETFOLDPARENT, currentLine);
headerLine = execute(SCI_GETFOLDPARENT, line);
if (headerLine == -1)
return;
}
if ((execute(SCI_GETFOLDEXPANDED, headerLine) != 0) != mode)
if (isFolded(headerLine) != mode)
{
execute(SCI_TOGGLEFOLD, headerLine);
SCNotification scnN;
scnN.nmhdr.code = SCN_FOLDINGSTATECHANGED;
scnN.nmhdr.hwndFrom = _hSelf;
scnN.nmhdr.idFrom = 0;
scnN.line = headerLine;
scnN.foldLevelNow = isFolded(headerLine)?1:0; //folded:1, unfolded:0
::SendMessage(_hParent, WM_NOTIFY, 0, (LPARAM)&scnN);
}
}
void ScintillaEditView::foldAll(bool mode)
@ -1625,8 +1644,8 @@ void ScintillaEditView::foldAll(bool mode)
{
int level = execute(SCI_GETFOLDLEVEL, line);
if (level & SC_FOLDLEVELHEADERFLAG)
if ((execute(SCI_GETFOLDEXPANDED, line) != 0) != mode)
execute(SCI_TOGGLEFOLD, line);
if (isFolded(line) != mode)
fold(line, mode);
}
}
@ -1942,7 +1961,8 @@ void ScintillaEditView::marginClick(int position, int modifiers)
else
{
// Toggle this line
execute(SCI_TOGGLEFOLD, lineClick, 0);
bool mode = isFolded(lineClick);
fold(lineClick, !mode);
runMarkers(true, lineClick, true, false);
}
}

View File

@ -531,6 +531,10 @@ public:
void collapse(int level2Collapse, bool mode);
void foldAll(bool mode);
void fold(int line, bool mode);
bool isFolded(int line){
return (execute(SCI_GETFOLDEXPANDED, line) != 0);
};
void foldCurrentPos(bool mode);
int getCodepage() const {return _codepage;};

View File

@ -67,6 +67,21 @@ void DocumentMap::scrollMap()
}
}
void DocumentMap::doMove()
{
RECT rc;
POINT pt = {0,0};
::ClientToScreen(_pScintillaEditView->getHSelf(), &pt);
_pScintillaEditView->getClientRect(rc);
::MoveWindow(_vzDlg.getHSelf(), pt.x, pt.y, (rc.right - rc.left) -4, (rc.bottom - rc.top) - 4, TRUE);
}
void DocumentMap::fold(int line, bool foldOrNot)
{
//bool isExpanded = _pScintillaEditView->execute(SCI_GETFOLDEXPANDED, line) != 0;
_pScintillaEditView->fold(line, foldOrNot);
}
void DocumentMap::scrollMap(bool direction, moveMode whichMode)
{
// Visible line for the code view

View File

@ -98,9 +98,13 @@ public:
_hParent = parent2set;
};
//void wrapScintilla(bool doWrap);
void reloadMap();
void scrollMap();
void scrollMap(bool direction, moveMode whichMode);
void doMove();
void fold(int line, bool foldOrNot);
protected:
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);

View File

@ -919,6 +919,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCN_AUTOCCHARDELETED 2026
#define SCN_HOTSPOTRELEASECLICK 2027
#define SCN_SCROLLED 2080
#define SCN_FOLDINGSTATECHANGED 2081
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
/* These structures are defined to be exactly the same shape as the Win32