diff options
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 2 | ||||
-rw-r--r-- | doc/ScintillaDoc.html | 14 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | gtk/ScintillaGTK.cxx | 7 | ||||
-rw-r--r-- | include/Scintilla.h | 2 | ||||
-rw-r--r-- | include/Scintilla.iface | 6 | ||||
-rw-r--r-- | qt/ScintillaEditBase/ScintillaQt.cpp | 10 | ||||
-rw-r--r-- | src/Editor.cxx | 16 | ||||
-rw-r--r-- | src/Editor.h | 1 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 8 |
10 files changed, 55 insertions, 15 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index d88e0e3ed..1338a66fa 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1969,7 +1969,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 bfda8622a..891b4ce7d 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -7263,6 +7263,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 → int</a><br /> + <a class="message" href="#SCI_SETCOMMANDEVENTS">SCI_SETCOMMANDEVENTS(bool commandEvents)</a><br /> + <a class="message" href="#SCI_GETCOMMANDEVENTS">SCI_GETCOMMANDEVENTS → bool</a><br /> <a class="message" href="#SCI_SETMOUSEDWELLTIME">SCI_SETMOUSEDWELLTIME(int periodMilliseconds)</a><br /> <a class="message" href="#SCI_GETMOUSEDWELLTIME">SCI_GETMOUSEDWELLTIME → int</a><br /> <a class="message" href="#SCI_SETIDENTIFIER">SCI_SETIDENTIFIER(int identifier)</a><br /> @@ -7749,7 +7751,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 → int</b><br /> @@ -7769,6 +7773,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 → 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 4b6b8926d..7e2fc7e2e 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -552,6 +552,10 @@ </h3> <ul> <li> + Add SCI_SETCOMMANDEVENTS API to allow turning off command events as they + can be a significant performance cost. + </li> + <li> Fixed a crash on Cocoa in bidirectional mode where some patterns of invalid UTF-8 caused failures to create Unicode strings. </li> diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 6bcb1ae29..1df3ed4b9 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1076,9 +1076,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 ccbeef99e..ea8654ce8 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -697,6 +697,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 00a4c4ac1..57a2c3b11 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1799,6 +1799,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 ad26a62d8..83cb6fec6 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); @@ -2677,9 +2678,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 = {}; @@ -7651,6 +7654,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 fb892bdcb..a75461afe 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 f7f1f7e2c..71b6d9e5e 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -2001,9 +2001,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); } |