aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/ScintillaCocoa.mm2
-rw-r--r--doc/ScintillaDoc.html14
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--gtk/ScintillaGTK.cxx7
-rw-r--r--include/Scintilla.h2
-rw-r--r--include/Scintilla.iface6
-rw-r--r--qt/ScintillaEditBase/ScintillaQt.cpp10
-rw-r--r--src/Editor.cxx16
-rw-r--r--src/Editor.h1
-rw-r--r--win32/ScintillaWin.cxx8
10 files changed, 55 insertions, 15 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index b21dbb102..ec78479b9 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -2058,7 +2058,7 @@ void ScintillaCocoa::NotifyChange()
void ScintillaCocoa::NotifyFocus(bool focus)
{
- if (notifyProc != NULL)
+ if (commandEvents && notifyProc)
notifyProc(notifyObj, WM_COMMAND, Platform::LongFromTwoShorts(static_cast<short>(GetCtrlID()),
(focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS)),
(uintptr_t) this);
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 29cba5cef..fdf1e36c0 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -7290,6 +7290,8 @@ struct SCNotification {
<p>The following <code>SCI_*</code> messages are associated with these notifications:</p>
<code><a class="message" href="#SCI_SETMODEVENTMASK">SCI_SETMODEVENTMASK(int eventMask)</a><br />
<a class="message" href="#SCI_GETMODEVENTMASK">SCI_GETMODEVENTMASK &rarr; int</a><br />
+ <a class="message" href="#SCI_SETCOMMANDEVENTS">SCI_SETCOMMANDEVENTS(bool commandEvents)</a><br />
+ <a class="message" href="#SCI_GETCOMMANDEVENTS">SCI_GETCOMMANDEVENTS &rarr; bool</a><br />
<a class="message" href="#SCI_SETMOUSEDWELLTIME">SCI_SETMOUSEDWELLTIME(int periodMilliseconds)</a><br />
<a class="message" href="#SCI_GETMOUSEDWELLTIME">SCI_GETMOUSEDWELLTIME &rarr; int</a><br />
<a class="message" href="#SCI_SETIDENTIFIER">SCI_SETIDENTIFIER(int identifier)</a><br />
@@ -7776,7 +7778,9 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<code>EN_CHANGE</code>). No other information is sent. If you need more detailed information
use <a class="message" href="#SCN_MODIFIED"><code>SCN_MODIFIED</code></a>. You can filter the
types of changes you are notified about with <a class="message"
- href="#SCI_SETMODEVENTMASK"><code>SCI_SETMODEVENTMASK</code></a>.</p>
+ href="#SCI_SETMODEVENTMASK"><code>SCI_SETMODEVENTMASK</code></a> and
+ <a class="message"
+ href="#SCI_SETCOMMANDEVENTS"><code>SCI_SETCOMMANDEVENTS</code></a>.</p>
<p><b id="SCI_SETMODEVENTMASK">SCI_SETMODEVENTMASK(int eventMask)</b><br />
<b id="SCI_GETMODEVENTMASK">SCI_GETMODEVENTMASK &rarr; int</b><br />
@@ -7796,6 +7800,14 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<code>SC_MOD_BEFOREINSERT</code>, <code>SC_MOD_BEFOREDELETE</code>,
<code>SC_MULTILINEUNDOREDO</code>, and <code>SC_MODEVENTMASKALL</code>.</p>
+ <p><b id="SCI_SETCOMMANDEVENTS">SCI_SETCOMMANDEVENTS(bool commandEvents)</b><br />
+ <b id="SCI_GETCOMMANDEVENTS">SCI_GETCOMMANDEVENTS &rarr; bool</b><br />
+ These messages set and get whether <code>SCEN_*</code> command events are
+ sent to the container. For <code>SCEN_CHANGE</code> this acts as an additional filter over
+ <a class="message" href="#SCI_SETMODEVENTMASK"><code>SCI_SETMODEVENTMASK</code></a>.
+ Most applications should set this off to avoid overhead and only use
+ <a class="message" href="#SCN_MODIFIED"><code>SCN_MODIFIED</code></a>.</p>
+
<p><b id="SCEN_SETFOCUS">SCEN_SETFOCUS</b><br />
<b id="SCEN_KILLFOCUS">SCEN_KILLFOCUS</b><br />
<code>SCEN_SETFOCUS</code> (512) is fired when Scintilla receives focus and
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index d01a3a8b1..67b3be17c 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -547,6 +547,10 @@
Released 19 June 2018.
</li>
<li>
+ Add SCI_SETCOMMANDEVENTS API to allow turning off command events as they
+ can be a significant performance cost.
+ </li>
+ <li>
Optional indexing of line starts in UTF-8 documents by UTF-32 code points and UTF-16 code units added.
This can improve performance for clients that provide UTF-32 or UTF-16 interfaces or that need to interoperate
with UTF-32 or UTF-16 components.
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 6a115994b..b1dbd9bfe 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -1075,9 +1075,10 @@ void ScintillaGTK::NotifyChange() {
}
void ScintillaGTK::NotifyFocus(bool focus) {
- g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0,
- Platform::LongFromTwoShorts
- (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain));
+ if (commandEvents)
+ g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0,
+ Platform::LongFromTwoShorts
+ (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain));
Editor::NotifyFocus(focus);
}
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 305e64c88..298103cea 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -699,6 +699,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_RELEASEDOCUMENT 2377
#define SCI_GETDOCUMENTOPTIONS 2379
#define SCI_GETMODEVENTMASK 2378
+#define SCI_SETCOMMANDEVENTS 2717
+#define SCI_GETCOMMANDEVENTS 2718
#define SCI_SETFOCUS 2380
#define SCI_GETFOCUS 2381
#define SC_STATUS_OK 0
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index a966d6bf4..0281f92f5 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1806,6 +1806,12 @@ get int GetDocumentOptions=2379(,)
# Get which document modification events are sent to the container.
get int GetModEventMask=2378(,)
+# Set whether command events are sent to the container.
+set void SetCommandEvents=2717(bool commandEvents,)
+
+# Get whether command events are sent to the container.
+get bool GetCommandEvents=2718(,)
+
# Change internal focus flag.
set void SetFocus=2380(bool focus,)
# Get internal focus flag.
diff --git a/qt/ScintillaEditBase/ScintillaQt.cpp b/qt/ScintillaEditBase/ScintillaQt.cpp
index cf4709a0e..8aebb9521 100644
--- a/qt/ScintillaEditBase/ScintillaQt.cpp
+++ b/qt/ScintillaEditBase/ScintillaQt.cpp
@@ -380,10 +380,12 @@ void ScintillaQt::NotifyChange()
void ScintillaQt::NotifyFocus(bool focus)
{
- emit command(
- Platform::LongFromTwoShorts
- (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
- reinterpret_cast<sptr_t>(wMain.GetID()));
+ if (commandEvents) {
+ emit command(
+ Platform::LongFromTwoShorts
+ (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
+ reinterpret_cast<sptr_t>(wMain.GetID()));
+ }
Editor::NotifyFocus(focus);
}
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 581e71918..607b541ed 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -181,6 +181,7 @@ Editor::Editor() {
needIdleStyling = false;
modEventMask = SC_MODEVENTMASKALL;
+ commandEvents = true;
pdoc->AddWatcher(this, 0);
@@ -2674,9 +2675,11 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
// If client wants to see this modification
if (mh.modificationType & modEventMask) {
- if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) {
- // Real modification made to text of document.
- NotifyChange(); // Send EN_CHANGE
+ if (commandEvents) {
+ if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) {
+ // Real modification made to text of document.
+ NotifyChange(); // Send EN_CHANGE
+ }
}
SCNotification scn = {};
@@ -7639,6 +7642,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETMODEVENTMASK:
return modEventMask;
+ case SCI_SETCOMMANDEVENTS:
+ commandEvents = static_cast<bool>(wParam);
+ return 0;
+
+ case SCI_GETCOMMANDEVENTS:
+ return commandEvents;
+
case SCI_CONVERTEOLS:
pdoc->ConvertLineEnds(static_cast<int>(wParam));
SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document
diff --git a/src/Editor.h b/src/Editor.h
index e9a0bbf8f..428211a58 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -229,6 +229,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool needIdleStyling;
int modEventMask;
+ bool commandEvents;
SelectionText drag;
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index f81c89173..b5b47dbd2 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1972,9 +1972,11 @@ void ScintillaWin::NotifyChange() {
}
void ScintillaWin::NotifyFocus(bool focus) {
- ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
- MAKELONG(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
- reinterpret_cast<LPARAM>(MainHWND()));
+ if (commandEvents) {
+ ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
+ MAKELONG(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
+ reinterpret_cast<LPARAM>(MainHWND()));
+ }
Editor::NotifyFocus(focus);
}