Skip to content

Commit d038676

Browse files
committed
Improvements to OnPluginSelectionChanged functionality
1 parent f5b1c96 commit d038676

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

mushview.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ CMUSHView::CMUSHView()
279279
m_selstart_col = 0;
280280
m_selend_line = 0;
281281
m_selend_col = 0;
282+
m_old_selstart_line = 0;
283+
m_old_selstart_col = 0;
284+
m_old_selend_line = 0;
285+
m_old_selend_col = 0;
286+
282287
m_freeze = FALSE;
283288
m_bAtBufferEnd = false;
284289
m_last_line_drawn = 0;
@@ -7648,14 +7653,27 @@ void CMUSHView::NotifySelectionChanged(void)
76487653
static bool bInSelectionChanged = false;
76497654
if (bInSelectionChanged) // don't recurse into infinite loops
76507655
return;
7656+
7657+
// we seem to get called when there wasn't really a change
7658+
if ((m_selstart_line == m_old_selstart_line) &&
7659+
(m_selstart_col == m_old_selstart_col) &&
7660+
(m_selend_line == m_old_selend_line) &&
7661+
(m_selend_col == m_old_selend_col))
7662+
return; // not really changed
7663+
7664+
m_old_selstart_line = m_selstart_line;
7665+
m_old_selstart_col = m_selstart_col;
7666+
m_old_selend_line = m_selend_line;
7667+
m_old_selend_col = m_selend_col;
7668+
76517669
bInSelectionChanged = true;
7652-
7670+
76537671
CMUSHclientDoc* pDoc = GetDocument();
76547672
ASSERT_VALID(pDoc);
76557673

76567674
if (pDoc->m_ScriptEngine)
76577675
pDoc->SendToAllPluginCallbacks(ON_PLUGIN_SELECTION_CHANGED);
7658-
7676+
76597677
bInSelectionChanged = false;
76607678
// end of notify plugins
76617679
}

mushview.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class CMUSHView : public CView
4646
m_pin_line, // this is where they started a selection (with the initial mouse down)
4747
m_pin_col;
4848

49+
int m_old_selstart_line, // previous start of current selection
50+
m_old_selstart_col,
51+
m_old_selend_line, // previous end of current selection
52+
m_old_selend_col;
53+
4954
int m_iPauseStatus;
5055

5156
BOOL m_freeze;

plugins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ string PluginCallbacksNames [] = {
133133
ON_PLUGIN_PLAYSOUND,
134134
ON_PLUGIN_SAVE_STATE,
135135
ON_PLUGIN_SCREENDRAW,
136-
ON_PLUGIN_SELECTION_CHANGED,
136+
ON_PLUGIN_SELECTION_CHANGED,
137137
ON_PLUGIN_SEND,
138138
ON_PLUGIN_SENT,
139139
ON_PLUGIN_TABCOMPLETE,

0 commit comments

Comments
 (0)