Skip to content

Commit 271469d

Browse files
author
Eugen Kremer
committed
fix: update indicators of entire document
Schedule 200ms chunks to update entire document so that smart highlighter optimization of Npp does not influence functions of indicator panel
1 parent a02b4e5 commit 271469d

File tree

5 files changed

+241
-259
lines changed

5 files changed

+241
-259
lines changed

editor/view/EditorView.cpp

+9-25
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2121
#include "ViewLines.h"
2222

2323
#pragma warning (disable : 4355)
24-
CEditorView::CEditorView(int id):CComDispatch(),m_IndPanel(this), SCIView((((id-1)==0)? nppData._scintillaMainHandle : nppData._scintillaSecondHandle)){
24+
CEditorView::CEditorView(int id):CComDispatch(),m_IndPanel(*this), SCIView((((id-1)==0)? nppData._scintillaMainHandle : nppData._scintillaSecondHandle)){
2525
m_Id = id;
2626

2727
m_Listener = NULL;
2828
}
2929

30-
3130
LRESULT CEditorView::getBufferId(){
3231
int curDoc =(int) NPPM(GETCURRENTDOCINDEX, 0, m_Id-1);
3332
return NPPM(GETBUFFERIDFROMPOS, curDoc, m_Id-1);
@@ -88,47 +87,32 @@ int CEditorView::bytePosToPos(int pos){
8887
return result;
8988
}
9089

91-
void CEditorView::setIndicatorLinesUpdater(int begin, int end){
92-
93-
ForegroundIdleHook::IdleHandler* indicatorPixelsUpdater = &m_IndPanel.m_IndicPixelsUp;
94-
95-
if (indicatorPixelsUpdater != NULL)
96-
ForegroundIdleHook::getInstance()->remove(indicatorPixelsUpdater);
97-
98-
if (m_IndPanel.m_IndicLinesUp.m_Begin > begin || (m_IndPanel.m_IndicLinesUp.m_End == 0 /* first time */))
99-
m_IndPanel.m_IndicLinesUp.m_Begin = begin;
100-
101-
if (m_IndPanel.m_IndicLinesUp.m_End != -1 && (end == -1 || m_IndPanel.m_IndicLinesUp.m_End < end))
102-
m_IndPanel.m_IndicLinesUp.m_End = end;
103-
104-
ForegroundIdleHook::getInstance()->add(&m_IndPanel.m_IndicLinesUp);
105-
}
106-
10790
void CEditorView::DoMessage(SCNotification* eventArgs){
10891
switch(eventArgs->nmhdr.code){
10992
case SCN_MODIFIED:
11093
if (eventArgs->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)){
11194
if (eventArgs->linesAdded != 0) // changes in more than one line
112-
setIndicatorLinesUpdater(eventArgs->position,-1); // from position to bottom
95+
m_IndPanel.updateLines(eventArgs->position,-1); // from position to bottom
11396
else // changes in the single line, update only necessary positions
114-
setIndicatorLinesUpdater(eventArgs->position, eventArgs->position + eventArgs->length);
97+
m_IndPanel.updateLines(eventArgs->position, eventArgs->position + eventArgs->length);
11598
} else if (eventArgs->modificationType & ( SC_MOD_CHANGEINDICATOR)){
11699
// update only necessary positions
117-
setIndicatorLinesUpdater(eventArgs->position, eventArgs->position + eventArgs->length);
100+
m_IndPanel.updateLines(-1, -1);
118101
}
102+
119103
break;
120104
case NPPN_BUFFERACTIVATED:
121105
// update all lines
122-
setIndicatorLinesUpdater(-1,-1);
106+
m_IndPanel.updateLines(-1,-1);
123107
break;
124108
case SCN_ZOOM:{
125109
// update only pixels
126-
ForegroundIdleHook::getInstance()->add(&m_IndPanel.m_IndicPixelsUp);
110+
m_IndPanel.updatePixels();
127111
break;
128112
}
129113
case SCN_MARGINCLICK:
130-
if (eventArgs->margin == 2){ // click above fold symbol
131-
setIndicatorLinesUpdater(-1,-1);
114+
if (eventArgs->margin == SC_MARGIN_FORE){ // click on fold symbol
115+
m_IndPanel.updateLines(-1,-1);
132116
}
133117
break;
134118
}

editor/view/EditorView.h

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ class CEditorView : public CComDispatch<IView>, public SCIView
6161
private:
6262

6363
LRESULT getBufferId();
64-
void setIndicatorLinesUpdater(int begin, int end);
65-
6664
#pragma endregion
6765

6866

0 commit comments

Comments
 (0)