diff options
31 files changed, 1486 insertions, 337 deletions
diff --git a/scintilla/doc/Indicators.png b/scintilla/doc/Indicators.png Binary files differnew file mode 100644 index 0000000..33e31f8 --- /dev/null +++ b/scintilla/doc/Indicators.png diff --git a/scintilla/doc/ScintillaDoc.html b/scintilla/doc/ScintillaDoc.html index cec4dd9..bcd83c8 100644 --- a/scintilla/doc/ScintillaDoc.html +++ b/scintilla/doc/ScintillaDoc.html @@ -82,7 +82,7 @@ <h1>Scintilla Documentation</h1>
- <p>Last edited 22/August/2013 NH</p>
+ <p>Last edited 29 September 2013 NH</p>
<p>There is <a class="jump" href="Design.html">an overview of the internal design of
Scintilla</a>.<br />
@@ -1306,9 +1306,9 @@ struct Sci_TextToFind { <p><b id="SCI_GETLINEENDPOSITION">SCI_GETLINEENDPOSITION(int line)</b><br />
This returns the position at the end of the line, before any line end characters. If <code>line</code>
- is the last line in the document (which does not have any end of line characters), the result is the size of the
- document. If <code>line</code> is negative or <code>line</code> >= <a class="message"
- href="#SCI_GETLINECOUNT"><code>SCI_GETLINECOUNT()</code></a>, the result is undefined.</p>
+ is the last line in the document (which does not have any end of line characters) or greater,
+ the result is the size of the document.
+ If <code>line</code> is negative the result is undefined.</p>
<p><b id="SCI_LINELENGTH">SCI_LINELENGTH(int line)</b><br />
This returns the length of the line, including any line end characters. If <code>line</code>
@@ -3857,7 +3857,9 @@ struct Sci_TextToFind { indicatorStyle)</b><br />
<b id="SCI_INDICGETSTYLE">SCI_INDICGETSTYLE(int indicatorNumber)</b><br />
These two messages set and get the style for a particular indicator. The indicator styles
- currently available are:</p>
+ currently available are:<br />
+
+ <img src="Indicators.png" alt="Indicator samples" /></p>
<table cellpadding="1" cellspacing="2" border="0" summary="Indicators">
<tbody>
@@ -5930,6 +5932,8 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <a class="message" href="#SCI_FREESUBSTYLES">SCI_FREESUBSTYLES</a><br />
<a class="message" href="#SCI_GETSUBSTYLESSTART">SCI_GETSUBSTYLESSTART(int styleBase)</a><br />
<a class="message" href="#SCI_GETSUBSTYLESLENGTH">SCI_GETSUBSTYLESLENGTH(int styleBase)</a><br />
+ <a class="message" href="#SCI_GETSTYLEFROMSUBSTYLE">SCI_GETSTYLEFROMSUBSTYLE(int subStyle)</a><br />
+ <a class="message" href="#SCI_GETPRIMARYSTYLEFROMSTYLE">SCI_GETPRIMARYSTYLEFROMSTYLE(int style)</a><br />
<a class="message" href="#SCI_SETIDENTIFIERS">SCI_SETIDENTIFIERS(int style, const char *identifiers)</a><br />
</div>
@@ -6049,8 +6053,8 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <code>SCI_SETPROPERTY</code></a> will be performed before any numeric interpretation.</p>
<p><b id="SCI_SETKEYWORDS">SCI_SETKEYWORDS(int keyWordSet, const char *keyWordList)</b><br />
- You can set up to 9 lists of keywords for use by the current lexer. This was increased from 6
- at revision 1.50. <code>keyWordSet</code> can be 0 to 8 (actually 0 to <code>KEYWORDSET_MAX</code>)
+ You can set up to 9 lists of keywords for use by the current lexer.
+ <code>keyWordSet</code> can be 0 to 8 (actually 0 to <code>KEYWORDSET_MAX</code>)
and selects which keyword list to replace. <code>keyWordList</code> is a list of keywords
separated by spaces, tabs, <code>"\n"</code> or <code>"\r"</code> or any combination of these.
It is expected that the keywords will be composed of standard ASCII printing characters,
@@ -6105,8 +6109,15 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <b id="SCI_GETSUBSTYLESLENGTH">SCI_GETSUBSTYLESLENGTH(int styleBase)</b><br />
Return the start and length of the substyles allocated for a base style.</p>
+ <p><b id="SCI_GETSTYLEFROMSUBSTYLE">SCI_GETSTYLEFROMSUBSTYLE(int subStyle)</b><br />
+ For a sub style, return the base style, else return the argument.</p>
+
+ <p><b id="SCI_GETPRIMARYSTYLEFROMSTYLE">SCI_GETPRIMARYSTYLEFROMSTYLE(int style)</b><br />
+ For a secondary style, return the primary style, else return the argument.</p>
+
<p><b id="SCI_SETIDENTIFIERS">SCI_SETIDENTIFIERS(int style, const char *identifiers)</b><br />
- Similar to <code>SCI_SETKEYWORDS</code> but for substyles.</p>
+ Similar to <code>SCI_SETKEYWORDS</code> but for substyles.
+ The prefix feature available with <code>SCI_SETKEYWORDS</code> is not implemented for <code>SCI_SETIDENTIFIERS</code>.</p>
</div>
<h2 id="LexerObjects">Lexer Objects</h2>
@@ -6237,6 +6248,8 @@ To allow lexers to report which line ends they support, and to support substyles <span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>AllocateSubStyles<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>styleBase<span class="S10">,</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>numberStyles<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>SubStylesStart<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>styleBase<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>SubStylesLength<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>styleBase<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
+<span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>StyleFromSubStyle<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>subStyle<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
+<span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>PrimaryStyleFromStyle<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>style<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>FreeSubStyles<span class="S10">()</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>SetIdentifiers<span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>style<span class="S10">,</span><span class="S0"> </span><span class="S5">const</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span><span class="S10">*</span>identifiers<span class="S10">)</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0"> </span><span class="S5">virtual</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>SCI_METHOD<span class="S0"> </span>DistanceToSecondaryStyles<span class="S10">()</span><span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
@@ -6425,8 +6438,16 @@ implemented and thus which methods may be called.</p> <h2 id="Notifications">Notifications</h2>
<p>Notifications are sent (fired) from the Scintilla control to its container when an event has
- occurred that may interest the container. Notifications are sent using the
- <code>WM_NOTIFY</code> message on Windows and the "notify" signal on GTK+. The container is
+ occurred that may interest the container.</p>
+ <p>Notifications are sent using the
+ <code>WM_NOTIFY</code> message on Windows.</p>
+ <p>On GTK+, the "sci-notify" signal is sent and the signal handler should have the signature
+ <code>handler(GtkWidget *, gint, SCNotification *notification, gpointer userData)</code>.</p>
+ <p>On Cocoa, a delegate implementing the <code>ScintillaNotificationProtocol</code>
+ may be set to receive notifications or the <code>ScintillaView</code> class may be subclassed and the
+ <code>notification:</code> method overridden. Overriding <code>notification:</code> allows the
+ subclass to control whether default handling is performed.</p>
+ <p>The container is
passed a <code>SCNotification</code> structure containing information about the event.</p>
<pre id="SCNotification">
struct NotifyHeader { // This matches the Win32 NMHDR structure
@@ -6500,6 +6521,8 @@ struct SCNotification { <a class="message" href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</a><br />
<a class="message" href="#SCN_AUTOCCANCELLED">SCN_AUTOCCANCELLED</a><br />
<a class="message" href="#SCN_AUTOCCHARDELETED">SCN_AUTOCCHARDELETED</a><br />
+ <a class="message" href="#SCN_FOCUSIN">SCN_FOCUSIN</a><br />
+ <a class="message" href="#SCN_FOCUSOUT">SCN_FOCUSOUT</a><br />
</code>
<p>The following <code>SCI_*</code> messages are associated with these notifications:</p>
@@ -6511,9 +6534,14 @@ struct SCNotification { <a class="message" href="#SCI_GETIDENTIFIER">SCI_GETIDENTIFIER</a><br />
</code>
- <p>The following additional notifications are sent using the <code>WM_COMMAND</code> message on
- Windows and the "Command" signal on GTK+. This emulates the Windows Edit control. Only the lower
+ <p>The following additional notifications are sent using a secondary "command" method and should
+ be avoided in new code as the primary "notification" method provides all the same events with richer
+ information.
+ The <code>WM_COMMAND</code> message is used on Windows.
+ This emulates the Windows Edit control. Only the lower
16 bits of the control's ID is passed in these notifications.</p>
+ <p>On GTK+, the "command" signal is sent and the signal handler should have the signature
+ <code>handler(GtkWidget *, gint wParam, gpointer lParam, gpointer userData)</code>.</p>
<code><a class="message" href="#SCEN_CHANGE">SCEN_CHANGE</a><br />
<a class="message" href="#SCEN_SETFOCUS">SCEN_SETFOCUS</a><br />
<a class="message" href="#SCEN_KILLFOCUS">SCEN_KILLFOCUS</a><br />
@@ -6956,7 +6984,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); <p><b id="SCEN_CHANGE">SCEN_CHANGE</b><br />
<code>SCEN_CHANGE</code> (768) is fired when the text (not the style) of the document changes.
This notification is sent using the <code>WM_COMMAND</code> message on Windows and the
- "Command" signal on GTK+ as this is the behaviour of the standard Edit control
+ "command" signal on GTK+ as this is the behaviour of the standard Edit control
(<code>SCEN_CHANGE</code> has the same value as the Windows Edit control
<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
@@ -6985,7 +7013,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); <b id="SCEN_KILLFOCUS">SCEN_KILLFOCUS</b><br />
<code>SCEN_SETFOCUS</code> (512) is fired when Scintilla receives focus and
<code>SCEN_KILLFOCUS</code> (256) when it loses focus. These notifications are sent using the
- <code>WM_COMMAND</code> message on Windows and the "Command" signal on GTK+ as this is the
+ <code>WM_COMMAND</code> message on Windows and the "command" signal on GTK+ as this is the
behaviour of the standard Edit control. Unfortunately, these codes do not match the Windows Edit
notification codes <code>EN_SETFOCUS</code> (256) and <code>EN_KILLFOCUS</code> (512). It is
now too late to change the Scintilla codes as clients depend on the current values.</p>
@@ -7249,6 +7277,11 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next The user deleted a character while autocompletion list was active.
There is no other information in SCNotification.</p>
+ <p><b id="SCN_FOCUSIN">SCN_FOCUSIN</b><br />
+ <b id="SCN_FOCUSOUT">SCN_FOCUSOUT</b><br />
+ <code>SCN_FOCUSIN</code> (2028) is fired when Scintilla receives focus and
+ <code>SCN_FOCUSOUT</code> (2029) when it loses focus.</p>
+
<h2 id="Images">Images</h2>
<p>Two formats are supported for images used in margin markers and autocompletion lists, RGBA and XPM.</p>
diff --git a/scintilla/doc/ScintillaDownload.html b/scintilla/doc/ScintillaDownload.html index 6e5092d..a39a060 100644 --- a/scintilla/doc/ScintillaDownload.html +++ b/scintilla/doc/ScintillaDownload.html @@ -25,9 +25,9 @@ <table bgcolor="#CCCCCC" width="100%" cellspacing="0" cellpadding="8" border="0">
<tr>
<td>
- <font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla335.zip?download">
+ <font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla336.zip?download">
Windows</a>
- <a href="http://prdownloads.sourceforge.net/scintilla/scintilla335.tgz?download">
+ <a href="http://prdownloads.sourceforge.net/scintilla/scintilla336.tgz?download">
GTK+/Linux</a>
</font>
</td>
@@ -41,7 +41,7 @@ containing very few restrictions.
</p>
<h3>
- Release 3.3.5
+ Release 3.3.6
</h3>
<h4>
Source Code
@@ -49,8 +49,8 @@ The source code package contains all of the source code for Scintilla but no binary
executable code and is available in
<ul>
- <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla335.zip?download">zip format</a> (1250K) commonly used on Windows</li>
- <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla335.tgz?download">tgz format</a> (1100K) commonly used on Linux and compatible operating systems</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla336.zip?download">zip format</a> (1300K) commonly used on Windows</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla336.tgz?download">tgz format</a> (1200K) commonly used on Linux and compatible operating systems</li>
</ul>
Instructions for building on both Windows and Linux are included in the readme file.
<h4>
diff --git a/scintilla/doc/ScintillaHistory.html b/scintilla/doc/ScintillaHistory.html index b78dd43..dec332e 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -430,6 +430,8 @@ <td>Özgür Emir</td>
<td>Neomi</td>
<td>OmegaPhil</td>
+ </tr><tr>
+ <td>SiegeLord</td>
</tr>
</table>
<p>
@@ -442,6 +444,119 @@ </li>
</ul>
<h3>
+ <a href="http://prdownloads.sourceforge.net/scintilla/scite336.zip?download">Release 3.3.6</a>
+ </h3>
+ <ul>
+ <li>
+ Released 15 October 2013.
+ </li>
+ <li>
+ Added functions to help convert between substyles and base styles and between secondary and primary styles.
+ SCI_GETSTYLEFROMSUBSTYLE finds the base style of substyles.
+ Can be used to treat all substyles of a style equivalent to that style.
+ SCI_GETPRIMARYSTYLEFROMSTYLE finds the primary style of secondary styles.
+ StyleFromSubStyle and PrimaryStyleFromStyle methods were added to ILexerWithSubStyles so each lexer can implement these.
+ </li>
+ <li>
+ Lexer added for Rust language.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1024/">Feature #1024.</a>
+ </li>
+ <li>
+ Avoid false matches in errorlist lexer which is used for the SciTE output pane
+ by stricter checking of ctags lines.
+ </li>
+ <li>
+ Perl lexer fixes bugs with multi-byte characters, including in HEREDOCs and PODs.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1528/">Bug #1528</a>.
+ </li>
+ <li>
+ SQL folder folds 'create view' statements.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1020/">Feature #1020.</a>
+ </li>
+ <li>
+ Visual Prolog lexer updated with better support for string literals and Unicode.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1025/">Feature #1025.</a>
+ </li>
+ <li>
+ For SCI_SETIDENTIFIERS, \t, \r, and \n are allowed as well as space between identifiers.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1521/">Bug #1521</a>.
+ </li>
+ <li>
+ Gaining and losing focus is now reported as a notification with the code set to SCN_FOCUSIN
+ or SCN_FOCUSOUT.
+ This allows clients to uniformly use notifications instead of commands.
+ Since there is no longer a need for commands they will be deprecated in a future version.
+ Clients should switch any code that currently uses SCEN_SETFOCUS or SCEN_KILLFOCUS.
+ </li>
+ <li>
+ On Cocoa, clients should use the delegate mechanism or subclass ScintillaView in preference
+ to registerNotifyCallback: which will be deprecated in the future.
+ </li>
+ <li>
+ On Cocoa, the ScintillaView.h header hides internal implementation details from Platform.h and ScintillaCocoa.h.
+ InnerView was renamed to SCIContentView and MarginView was renamed to SCIMarginView.
+ dealloc removed from @interface.
+ </li>
+ <li>
+ On Cocoa, clients may customize SCIContentView by subclassing both SCIContentView and ScintillaView
+ and implementing the contentViewClass class method on the ScintillaView subclass to return the class of
+ the SCIContentView subclass.
+ </li>
+ <li>
+ On Cocoa, fixed appearance of alpha rectangles to use specified alpha and colour for outline as well as corner size.
+ This makes INDIC_STRAIGHTBOX and INDIC_ROUNDBOX look correct.
+ </li>
+ <li>
+ On Cocoa, memory leak fixed for MarginView.
+ </li>
+ <li>
+ On Cocoa, make drag and drop work when destination view is empty.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1534/">Bug #1534</a>.
+ </li>
+ <li>
+ On Cocoa, drag image fixed when view scrolled.
+ </li>
+ <li>
+ On Cocoa, SCI_POSITIONFROMPOINTCLOSE fixed when view scrolled.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1021/">Feature #1021.</a>
+ </li>
+ <li>
+ On Cocoa, don't send selection change notification when scrolling.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1522/">Bug #1522</a>.
+ </li>
+ <li>
+ On Qt, turn off idle events on destruction to prevent repeatedly calling idle.
+ </li>
+ <li>
+ Qt bindings in ScintillaEdit changed to use signed first parameter.
+ </li>
+ <li>
+ Compilation errors fixed on Windows and GTK+ with SCI_NAMESPACE.
+ </li>
+ <li>
+ On Windows, building with gcc will check if Direct2D headers are available and enable Direct2D if they are.
+ </li>
+ <li>
+ Avoid attempts to redraw empty areas when lexing beyond the currently visible lines.
+ </li>
+ <li>
+ Control more attributes of indicators in SciTE with find.mark.indicator and highlight.current.word.indicator
+ properties.
+ </li>
+ <li>
+ Fix SciTE bug with buffers becoming read-only.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1525/">Bug #1525</a>.
+ </li>
+ <li>
+ Fix linking SciTE on non-Linux Unix systems with GNU toolchain by linking to libdl.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1523/">Bug #1523</a>.
+ </li>
+ <li>
+ Fix SciTE on GTK+ 3.x incremental search to change foreground colour when no match as
+ changing background colour is difficult.
+ </li>
+ </ul>
+ <h3>
<a href="http://prdownloads.sourceforge.net/scintilla/scite335.zip?download">Release 3.3.5</a>
</h3>
<ul>
diff --git a/scintilla/doc/index.html b/scintilla/doc/index.html index c0fd0d3..358c179 100644 --- a/scintilla/doc/index.html +++ b/scintilla/doc/index.html @@ -9,7 +9,7 @@ <meta name="keywords" content="Scintilla, SciTE, Editing Component, Text Editor" />
<meta name="Description"
content="www.scintilla.org is the home of the Scintilla editing component and SciTE text editor application." />
- <meta name="Date.Modified" content="20130831" />
+ <meta name="Date.Modified" content="20131015" />
<style type="text/css">
#versionlist {
margin: 0;
@@ -55,8 +55,8 @@ GTK+, and OS X</font>
</td>
<td width="40%" align="right">
- <font color="#FFCC99" size="3"> Release version 3.3.5<br />
- Site last modified August 31 2013</font>
+ <font color="#FFCC99" size="3"> Release version 3.3.6<br />
+ Site last modified October 15 2013</font>
</td>
<td width="20%">
@@ -71,6 +71,7 @@ </tr>
</table>
<ul id="versionlist">
+ <li>Version 3.3.6 adds support for the Rust language and fixes bugs.</li>
<li>Version 3.3.5 can represent characters with strings. This may be used for modes
which show invisible characters or differentiate characters that appear similar.</li>
<li>Version 3.3.4 better supports Unicode use in lexers.</li>
diff --git a/scintilla/include/ILexer.h b/scintilla/include/ILexer.h index 5b6ed6f..b859cfd 100644 --- a/scintilla/include/ILexer.h +++ b/scintilla/include/ILexer.h @@ -75,6 +75,8 @@ public: virtual int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) = 0;
virtual int SCI_METHOD SubStylesStart(int styleBase) = 0;
virtual int SCI_METHOD SubStylesLength(int styleBase) = 0;
+ virtual int SCI_METHOD StyleFromSubStyle(int subStyle) = 0;
+ virtual int SCI_METHOD PrimaryStyleFromStyle(int style) = 0;
virtual void SCI_METHOD FreeSubStyles() = 0;
virtual void SCI_METHOD SetIdentifiers(int style, const char *identifiers) = 0;
virtual int SCI_METHOD DistanceToSecondaryStyles() = 0;
diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h index 6103301..1d0d321 100644 --- a/scintilla/include/Platform.h +++ b/scintilla/include/Platform.h @@ -345,22 +345,10 @@ typedef void (*CallBackAction)(void*); class Window {
protected:
WindowID wid;
-#if PLAT_MACOSX
- void *windowRef;
- void *control;
-#endif
public:
Window() : wid(0), cursorLast(cursorInvalid) {
-#if PLAT_MACOSX
- windowRef = 0;
- control = 0;
-#endif
}
Window(const Window &source) : wid(source.wid), cursorLast(cursorInvalid) {
-#if PLAT_MACOSX
- windowRef = 0;
- control = 0;
-#endif
}
virtual ~Window();
Window &operator=(WindowID wid_) {
@@ -383,10 +371,6 @@ public: void SetCursor(Cursor curs);
void SetTitle(const char *s);
PRectangle GetMonitorRect(Point pt);
-#if PLAT_MACOSX
- void SetWindow(void *ref) { windowRef = ref; }
- void SetControl(void *_control) { control = _control; }
-#endif
private:
Cursor cursorLast;
};
@@ -528,9 +512,7 @@ public: #endif
#if defined(__GNUC__) && defined(SCINTILLA_QT)
-#pragma GCC diagnostic ignored "-Wmissing-braces"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
-#pragma GCC diagnostic ignored "-Wchar-subscripts"
#endif
#endif
diff --git a/scintilla/include/SciLexer.h b/scintilla/include/SciLexer.h index 4028200..420da02 100644 --- a/scintilla/include/SciLexer.h +++ b/scintilla/include/SciLexer.h @@ -123,6 +123,7 @@ #define SCLEX_LITERATEHASKELL 108
#define SCLEX_STTXT 109
#define SCLEX_KVIRC 110
+#define SCLEX_RUST 111
#define SCLEX_AHK 200
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
@@ -1683,6 +1684,27 @@ #define SCE_KVIRC_OPERATOR 10
#define SCE_KVIRC_STRING_FUNCTION 11
#define SCE_KVIRC_STRING_VARIABLE 12
+#define SCE_RUST_DEFAULT 0
+#define SCE_RUST_COMMENTBLOCK 1
+#define SCE_RUST_COMMENTLINE 2
+#define SCE_RUST_COMMENTBLOCKDOC 3
+#define SCE_RUST_COMMENTLINEDOC 4
+#define SCE_RUST_NUMBER 5
+#define SCE_RUST_WORD 6
+#define SCE_RUST_WORD2 7
+#define SCE_RUST_WORD3 8
+#define SCE_RUST_WORD4 9
+#define SCE_RUST_WORD5 10
+#define SCE_RUST_WORD6 11
+#define SCE_RUST_WORD7 12
+#define SCE_RUST_STRING 13
+#define SCE_RUST_STRINGR 14
+#define SCE_RUST_CHARACTER 15
+#define SCE_RUST_OPERATOR 16
+#define SCE_RUST_IDENTIFIER 17
+#define SCE_RUST_LIFETIME 18
+#define SCE_RUST_MACRO 19
+#define SCE_RUST_LEXERROR 20
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif
diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index 2d81d71..da5cbea 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -987,6 +987,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_AUTOCCANCELLED 2025
#define SCN_AUTOCCHARDELETED 2026
#define SCN_HOTSPOTRELEASECLICK 2027
+#define SCN_FOCUSIN 2028
+#define SCN_FOCUSOUT 2029
#ifndef SCI_DISABLE_PROVISIONAL
#define SC_LINE_END_TYPE_DEFAULT 0
#define SC_LINE_END_TYPE_UNICODE 1
@@ -997,6 +999,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_ALLOCATESUBSTYLES 4020
#define SCI_GETSUBSTYLESSTART 4021
#define SCI_GETSUBSTYLESLENGTH 4022
+#define SCI_GETSTYLEFROMSUBSTYLE 4027
+#define SCI_GETPRIMARYSTYLEFROMSTYLE 4028
#define SCI_FREESUBSTYLES 4023
#define SCI_SETIDENTIFIERS 4024
#define SCI_DISTANCETOSECONDARYSTYLES 4025
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index 12d3384..495bee6 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -2600,6 +2600,7 @@ val SCLEX_VISUALPROLOG=107 val SCLEX_LITERATEHASKELL=108
val SCLEX_STTXT=109
val SCLEX_KVIRC=110
+val SCLEX_RUST=111
## notepad2 custom code for the AHK lexer - start
val SCLEX_AHK=200
## notepad2 custom code for the AHK lexer - end
@@ -4368,6 +4369,29 @@ val SCE_KVIRC_NUMBER=9 val SCE_KVIRC_OPERATOR=10
val SCE_KVIRC_STRING_FUNCTION=11
val SCE_KVIRC_STRING_VARIABLE=12
+# Lexical states for SCLEX_RUST
+lex Rust=SCLEX_RUST SCE_RUST_
+val SCE_RUST_DEFAULT=0
+val SCE_RUST_COMMENTBLOCK=1
+val SCE_RUST_COMMENTLINE=2
+val SCE_RUST_COMMENTBLOCKDOC=3
+val SCE_RUST_COMMENTLINEDOC=4
+val SCE_RUST_NUMBER=5
+val SCE_RUST_WORD=6
+val SCE_RUST_WORD2=7
+val SCE_RUST_WORD3=8
+val SCE_RUST_WORD4=9
+val SCE_RUST_WORD5=10
+val SCE_RUST_WORD6=11
+val SCE_RUST_WORD7=12
+val SCE_RUST_STRING=13
+val SCE_RUST_STRINGR=14
+val SCE_RUST_CHARACTER=15
+val SCE_RUST_OPERATOR=16
+val SCE_RUST_IDENTIFIER=17
+val SCE_RUST_LIFETIME=18
+val SCE_RUST_MACRO=19
+val SCE_RUST_LEXERROR=20
# Events
@@ -4399,6 +4423,8 @@ evt void IndicatorRelease=2024(int modifiers, int position) evt void AutoCCancelled=2025(void)
evt void AutoCCharDeleted=2026(void)
evt void HotSpotReleaseClick=2027(int modifiers, int position)
+evt void FocusIn=2028(void)
+evt void FocusOut=2029(void)
cat Provisional
@@ -4431,6 +4457,12 @@ get int GetSubStylesStart=4021(int styleBase,) # The number of sub styles associated with a base style
get int GetSubStylesLength=4022(int styleBase,)
+# For a sub style, return the base style, else return the argument.
+get int GetStyleFromSubStyle=4027(int subStyle,)
+
+# For a secondary style, return the primary style, else return the argument.
+get int GetPrimaryStyleFromStyle=4028(int style,)
+
# Free allocated sub styles
fun void FreeSubStyles=4023(,)
diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx index 4319b7e..8e26211 100644 --- a/scintilla/lexers/LexCPP.cxx +++ b/scintilla/lexers/LexCPP.cxx @@ -387,6 +387,14 @@ public: int SCI_METHOD SubStylesLength(int styleBase) {
return subStyles.Length(styleBase);
}
+ int SCI_METHOD StyleFromSubStyle(int subStyle) {
+ int styleBase = subStyles.BaseStyle(MaskActive(subStyle));
+ int active = subStyle & activeFlag;
+ return styleBase | active;
+ }
+ int SCI_METHOD PrimaryStyleFromStyle(int style) {
+ return MaskActive(style);
+ }
void SCI_METHOD FreeSubStyles() {
subStyles.Free();
}
diff --git a/scintilla/lexers/LexCoffeeScript.cxx b/scintilla/lexers/LexCoffeeScript.cxx index 3b8d741..2c79aa1 100644 --- a/scintilla/lexers/LexCoffeeScript.cxx +++ b/scintilla/lexers/LexCoffeeScript.cxx @@ -31,16 +31,16 @@ using namespace Scintilla; #endif
static bool IsSpaceEquiv(int state) {
- return (state <= SCE_C_COMMENTDOC
- // including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE
- || state == SCE_C_COMMENTLINEDOC
- || state == SCE_C_COMMENTDOCKEYWORD
- || state == SCE_C_COMMENTDOCKEYWORDERROR
+ return (state <= SCE_COFFEESCRIPT_COMMENTDOC
+ // including SCE_COFFEESCRIPT_DEFAULT, SCE_COFFEESCRIPT_COMMENT, SCE_COFFEESCRIPT_COMMENTLINE
+ || state == SCE_COFFEESCRIPT_COMMENTLINEDOC
+ || state == SCE_COFFEESCRIPT_COMMENTDOCKEYWORD
+ || state == SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR
|| state == SCE_COFFEESCRIPT_COMMENTBLOCK
|| state == SCE_COFFEESCRIPT_VERBOSE_REGEX
|| state == SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT
- || state == SCE_C_WORD
- || state == SCE_C_REGEX);
+ || state == SCE_COFFEESCRIPT_WORD
+ || state == SCE_COFFEESCRIPT_REGEX);
}
// Preconditions: sc.currentPos points to a character after '+' or '-'.
@@ -115,11 +115,11 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init int chPrevNonWhite = ' ';
int visibleChars = 0;
bool lastWordWasUUID = false;
- int styleBeforeDCKeyword = SCE_C_DEFAULT;
+ int styleBeforeDCKeyword = SCE_COFFEESCRIPT_DEFAULT;
bool continuationLine = false;
bool isIncludePreprocessor = false;
- if (initStyle == SCE_C_PREPROCESSOR) {
+ if (initStyle == SCE_COFFEESCRIPT_PREPROCESSOR) {
// Set continuationLine if last character of previous line is '\'
int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0) {
@@ -142,13 +142,13 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init styler.Flush();
while (back > 0 && IsSpaceEquiv(styler.StyleAt(--back)))
;
- if (styler.StyleAt(back) == SCE_C_OPERATOR) {
+ if (styler.StyleAt(back) == SCE_COFFEESCRIPT_OPERATOR) {
chPrevNonWhite = styler.SafeGetCharAt(back);
}
if (startPos != back) {
initStyle = styler.StyleAt(back);
if (IsSpaceEquiv(initStyle)) {
- initStyle = SCE_C_DEFAULT;
+ initStyle = SCE_COFFEESCRIPT_DEFAULT;
}
}
startPos = back;
@@ -180,95 +180,95 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init // Determine if the current state should terminate.
switch (sc.state) {
- case SCE_C_OPERATOR:
- sc.SetState(SCE_C_DEFAULT);
+ case SCE_COFFEESCRIPT_OPERATOR:
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
break;
- case SCE_C_NUMBER:
+ case SCE_COFFEESCRIPT_NUMBER:
// We accept almost anything because of hex. and number suffixes
if (!setWord.Contains(sc.ch)) {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
}
break;
- case SCE_C_IDENTIFIER:
+ case SCE_COFFEESCRIPT_IDENTIFIER:
if (!setWord.Contains(sc.ch) || (sc.ch == '.') || (sc.ch == '$')) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (keywords.InList(s)) {
lastWordWasUUID = strcmp(s, "uuid") == 0;
- sc.ChangeState(SCE_C_WORD);
+ sc.ChangeState(SCE_COFFEESCRIPT_WORD);
} else if (keywords2.InList(s)) {
- sc.ChangeState(SCE_C_WORD2);
+ sc.ChangeState(SCE_COFFEESCRIPT_WORD2);
} else if (keywords4.InList(s)) {
- sc.ChangeState(SCE_C_GLOBALCLASS);
+ sc.ChangeState(SCE_COFFEESCRIPT_GLOBALCLASS);
}
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
}
break;
- case SCE_C_PREPROCESSOR:
+ case SCE_COFFEESCRIPT_PREPROCESSOR:
if (sc.atLineStart && !continuationLine) {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
} else if (stylingWithinPreprocessor) {
if (IsASpace(sc.ch)) {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
}
} else {
if (sc.Match('/', '*') || sc.Match('/', '/')) {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
}
}
break;
- case SCE_C_COMMENT:
+ case SCE_COFFEESCRIPT_COMMENT:
if (sc.Match('*', '/')) {
sc.Forward();
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
}
break;
- case SCE_C_COMMENTDOC:
+ case SCE_COFFEESCRIPT_COMMENTDOC:
if (sc.Match('*', '/')) {
sc.Forward();
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
// Verify that we have the conditions to mark a comment-doc-keyword
if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) {
- styleBeforeDCKeyword = SCE_C_COMMENTDOC;
- sc.SetState(SCE_C_COMMENTDOCKEYWORD);
+ styleBeforeDCKeyword = SCE_COFFEESCRIPT_COMMENTDOC;
+ sc.SetState(SCE_COFFEESCRIPT_COMMENTDOCKEYWORD);
}
}
break;
- case SCE_C_COMMENTLINE:
+ case SCE_COFFEESCRIPT_COMMENTLINE:
if (sc.atLineStart) {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
}
break;
- case SCE_C_COMMENTLINEDOC:
+ case SCE_COFFEESCRIPT_COMMENTLINEDOC:
if (sc.atLineStart) {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
// Verify that we have the conditions to mark a comment-doc-keyword
if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) {
- styleBeforeDCKeyword = SCE_C_COMMENTLINEDOC;
- sc.SetState(SCE_C_COMMENTDOCKEYWORD);
+ styleBeforeDCKeyword = SCE_COFFEESCRIPT_COMMENTLINEDOC;
+ sc.SetState(SCE_COFFEESCRIPT_COMMENTDOCKEYWORD);
}
}
break;
- case SCE_C_COMMENTDOCKEYWORD:
- if ((styleBeforeDCKeyword == SCE_C_COMMENTDOC) && sc.Match('*', '/')) {
- sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
+ case SCE_COFFEESCRIPT_COMMENTDOCKEYWORD:
+ if ((styleBeforeDCKeyword == SCE_COFFEESCRIPT_COMMENTDOC) && sc.Match('*', '/')) {
+ sc.ChangeState(SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR);
sc.Forward();
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
} else if (!setDoxygen.Contains(sc.ch)) {
char s[100];
sc.GetCurrent(s, sizeof(s));
if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) {
- sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
+ sc.ChangeState(SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR);
}
sc.SetState(styleBeforeDCKeyword);
}
break;
- case SCE_C_STRING:
+ case SCE_COFFEESCRIPT_STRING:
if (isIncludePreprocessor) {
if (sc.ch == '>') {
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
isIncludePreprocessor = false;
}
} else if (sc.ch == '\\') {
@@ -276,26 +276,26 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.Forward();
}
} else if (sc.ch == '\"') {
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
}
break;
- case SCE_C_CHARACTER:
+ case SCE_COFFEESCRIPT_CHARACTER:
if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\'') {
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
}
break;
- case SCE_C_REGEX:
+ case SCE_COFFEESCRIPT_REGEX:
if (sc.atLineStart) {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
} else if (sc.ch == '/') {
sc.Forward();
while ((sc.ch < 0x80) && islower(sc.ch))
sc.Forward(); // gobble regex flags
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
} else if (sc.ch == '\\') {
// Gobble up the quoted character
if (sc.chNext == '\\' || sc.chNext == '/') {
@@ -303,30 +303,30 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init }
}
break;
- case SCE_C_STRINGEOL:
+ case SCE_COFFEESCRIPT_STRINGEOL:
if (sc.atLineStart) {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
}
break;
- case SCE_C_VERBATIM:
+ case SCE_COFFEESCRIPT_VERBATIM:
if (sc.ch == '\"') {
if (sc.chNext == '\"') {
sc.Forward();
} else {
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
}
}
break;
- case SCE_C_UUID:
+ case SCE_COFFEESCRIPT_UUID:
if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') {
- sc.SetState(SCE_C_DEFAULT);
+ sc.SetState(SCE_COFFEESCRIPT_DEFAULT);
}
break;
case SCE_COFFEESCRIPT_COMMENTBLOCK:
if (sc.Match("###")) {
sc.Forward();
sc.Forward();
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
} else if (sc.ch == '\\') {
sc.Forward();
}
@@ -335,7 +335,7 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init if (sc.Match("///")) {
sc.Forward();
sc.Forward();
- sc.ForwardSetState(SCE_C_DEFAULT);
+ sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT);
} else if (sc.Match('#')) {
sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT);
} else if (sc.ch == '\\') {
@@ -350,29 +350,29 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init }
// Determine if a new state should be entered.
- if (sc.state == SCE_C_DEFAULT) {
+ if (sc.state == SCE_COFFEESCRIPT_DEFAULT) {
if (sc.Match('@', '\"')) {
- sc.SetState(SCE_C_VERBATIM);
+ sc.SetState(SCE_COFFEESCRIPT_VERBATIM);
sc.Forward();
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
if (lastWordWasUUID) {
- sc.SetState(SCE_C_UUID);
+ sc.SetState(SCE_COFFEESCRIPT_UUID);
lastWordWasUUID = false;
} else {
- sc.SetState(SCE_C_NUMBER);
+ sc.SetState(SCE_COFFEESCRIPT_NUMBER);
}
} else if (setWordStart.Contains(sc.ch) || (sc.ch == '@') || (sc.ch == '$')) {
if (lastWordWasUUID) {
- sc.SetState(SCE_C_UUID);
+ sc.SetState(SCE_COFFEESCRIPT_UUID);
lastWordWasUUID = false;
} else {
- sc.SetState(SCE_C_IDENTIFIER);
+ sc.SetState(SCE_COFFEESCRIPT_IDENTIFIER);
}
} else if (sc.Match('/', '*')) {
if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style
- sc.SetState(SCE_C_COMMENTDOC);
+ sc.SetState(SCE_COFFEESCRIPT_COMMENTDOC);
} else {
- sc.SetState(SCE_C_COMMENT);
+ sc.SetState(SCE_COFFEESCRIPT_COMMENT);
}
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match("///")) {
@@ -384,14 +384,14 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init || followsReturnKeyword(sc, styler))
&& (!setCouldBePostOp.Contains(chPrevNonWhite)
|| !FollowsPostfixOperator(sc, styler))) {
- sc.SetState(SCE_C_REGEX); // JavaScript's RegEx
+ sc.SetState(SCE_COFFEESCRIPT_REGEX); // JavaScript's RegEx
} else if (sc.ch == '\"') {
- sc.SetState(SCE_C_STRING);
+ sc.SetState(SCE_COFFEESCRIPT_STRING);
isIncludePreprocessor = false; // ensure that '>' won't end the string
} else if (isIncludePreprocessor && sc.ch == '<') {
- sc.SetState(SCE_C_STRING);
+ sc.SetState(SCE_COFFEESCRIPT_STRING);
} else if (sc.ch == '\'') {
- sc.SetState(SCE_C_CHARACTER);
+ sc.SetState(SCE_COFFEESCRIPT_CHARACTER);
} else if (sc.ch == '#') {
if (sc.Match("###")) {
sc.SetState(SCE_COFFEESCRIPT_COMMENTBLOCK);
@@ -399,10 +399,10 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.Forward();
} else {
- sc.SetState(SCE_C_COMMENTLINE);
+ sc.SetState(SCE_COFFEESCRIPT_COMMENTLINE);
}
} else if (isoperator(static_cast<char>(sc.ch))) {
- sc.SetState(SCE_C_OPERATOR);
+ sc.SetState(SCE_COFFEESCRIPT_OPERATOR);
}
}
diff --git a/scintilla/lexers/LexOthers.cxx b/scintilla/lexers/LexOthers.cxx index 0e08b18..46d448b 100644 --- a/scintilla/lexers/LexOthers.cxx +++ b/scintilla/lexers/LexOthers.cxx @@ -954,15 +954,16 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin // Common: <filename>(<line>): warning|error|note|remark|catastrophic|fatal
// Common: <filename>(<line>) warning|error|note|remark|catastrophic|fatal
// Microsoft: <filename>(<line>,<column>)<message>
- // CTags: \t<message>
+ // CTags: <identifier>\t<filename>\t<message>
// Lua 5 traceback: \t<filename>:<line>:<message>
// Lua 5.1: <exe>: <filename>:<line>:<message>
bool initialTab = (lineBuffer[0] == '\t');
bool initialColonPart = false;
+ bool canBeCtags = !initialTab; // For ctags must have an identifier with no spaces then a tab
enum { stInitial,
stGccStart, stGccDigit, stGccColumn, stGcc,
stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
- stCtagsStart, stCtagsStartString, stCtagsStringDollar, stCtags,
+ stCtagsStart, stCtagsFile, stCtagsStartString, stCtagsStringDollar, stCtags,
stUnrecognized
} state = stInitial;
for (unsigned int i = 0; i < lengthLine; i++) {
@@ -984,9 +985,11 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin // May be Microsoft
// Check against '0' often removes phone numbers
state = stMsStart;
- } else if ((ch == '\t') && (!initialTab)) {
+ } else if ((ch == '\t') && canBeCtags) {
// May be CTags
state = stCtagsStart;
+ } else if (ch == ' ') {
+ canBeCtags = false;
}
} else if (state == stGccStart) { // <filename>:
state = Is1To9(ch) ? stGccDigit : stUnrecognized;
@@ -1047,6 +1050,10 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin state = stUnrecognized;
}
} else if (state == stCtagsStart) {
+ if (ch == '\t') {
+ state = stCtagsFile;
+ }
+ } else if (state == stCtagsFile) {
if ((lineBuffer[i - 1] == '\t') &&
((ch == '/' && chNext == '^') || Is0To9(ch))) {
state = stCtags;
diff --git a/scintilla/lexers/LexPascal.cxx b/scintilla/lexers/LexPascal.cxx index 9817db0..adebb77 100644 --- a/scintilla/lexers/LexPascal.cxx +++ b/scintilla/lexers/LexPascal.cxx @@ -12,7 +12,7 @@ A few words about features of the new completely rewritten LexPascal...
Generally speaking LexPascal tries to support all available Delphi features (up
-to Delphi 2009 at this time), including .NET specific features.
+to Delphi XE4 at this time).
~ HIGHLIGHTING:
@@ -89,17 +89,18 @@ would be folded. ~ KEYWORDS:
The list of keywords that can be used in pascal.properties file (up to Delphi
-2009):
+XE4):
- Keywords: absolute abstract and array as asm assembler automated begin case
-cdecl class const constructor deprecated destructor dispid dispinterface div do
-downto dynamic else end except export exports external far file final
-finalization finally for forward function goto if implementation in inherited
-initialization inline interface is label library message mod near nil not object
-of on or out overload override packed pascal platform private procedure program
-property protected public published raise record register reintroduce repeat
-resourcestring safecall sealed set shl shr static stdcall strict string then
-threadvar to try type unit unsafe until uses var varargs virtual while with xor
+cdecl class const constructor delayed deprecated destructor dispid dispinterface
+div do downto dynamic else end except experimental export exports external far
+file final finalization finally for forward function goto helper if
+implementation in inherited initialization inline interface is label library
+message mod near nil not object of on operator or out overload override packed
+pascal platform private procedure program property protected public published
+raise record reference register reintroduce repeat resourcestring safecall
+sealed set shl shr static stdcall strict string then threadvar to try type unit
+unsafe until uses var varargs virtual while winapi with xor
- Keywords related to the "smart highlithing" feature: add default implements
index name nodefault read readonly remove stored write writeonly
diff --git a/scintilla/lexers/LexPerl.cxx b/scintilla/lexers/LexPerl.cxx index a4aa71c..ce713b1 100644 --- a/scintilla/lexers/LexPerl.cxx +++ b/scintilla/lexers/LexPerl.cxx @@ -191,9 +191,9 @@ static int styleCheckIdentifier(LexAccessor &styler, unsigned int bk) { static int podLineScan(LexAccessor &styler, unsigned int &pos, unsigned int endPos) {
// forward scan the current line to classify line for POD style
int state = -1;
- while (pos <= endPos) {
+ while (pos < endPos) {
int ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
- if (ch == '\n' || ch == '\r' || pos >= endPos) {
+ if (ch == '\n' || ch == '\r') {
if (ch == '\r' && styler.SafeGetCharAt(pos + 1) == '\n') pos++;
break;
}
@@ -861,10 +861,14 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, sc.Forward();
}
if (sc.ch != '\r') { // skip CR if CRLF
- HereDoc.Append(sc.ch);
+ int i = 0; // else append char, possibly an extended char
+ while (i < sc.width) {
+ HereDoc.Append(static_cast<unsigned char>(styler.SafeGetCharAt(sc.currentPos + i)));
+ i++;
+ }
}
}
- } else { // an unquoted here-doc delimiter
+ } else { // an unquoted here-doc delimiter, no extended charsets
if (setHereDocDelim.Contains(sc.ch)) {
HereDoc.Append(sc.ch);
} else {
@@ -885,7 +889,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, if (HereDoc.DelimiterLength == 0 || sc.Match(HereDoc.Delimiter)) {
int c = sc.GetRelative(HereDoc.DelimiterLength);
if (c == '\r' || c == '\n') { // peek first, do not consume match
- sc.Forward(HereDoc.DelimiterLength);
+ sc.ForwardBytes(HereDoc.DelimiterLength);
sc.SetState(SCE_PL_DEFAULT);
backFlag = BACK_NONE;
HereDoc.State = 0;
@@ -939,7 +943,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, if (pod == SCE_PL_DEFAULT) {
if (sc.state == SCE_PL_POD_VERB) {
unsigned int fw2 = fw;
- while (fw2 <= endPos && pod == SCE_PL_DEFAULT) {
+ while (fw2 < (endPos - 1) && pod == SCE_PL_DEFAULT) {
fw = fw2++; // penultimate line (last blank line)
pod = podLineScan(styler, fw2, endPos);
styler.SetLineState(styler.GetLine(fw2), pod);
@@ -961,7 +965,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, }
sc.SetState(pod);
}
- sc.Forward(fw - sc.currentPos); // commit style
+ sc.ForwardBytes(fw - sc.currentPos); // commit style
}
break;
case SCE_PL_REGEX:
@@ -1021,7 +1025,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, // For '#', if no whitespace in between, it's a delimiter.
if (IsASpace(c)) {
// Keep going
- } else if (c == '#' && IsASpaceOrTab(sc.GetRelative(sLen - 1))) {
+ } else if (c == '#' && IsASpaceOrTab(sc.GetRelativeCharacter(sLen - 1))) {
endType = 3;
} else
Quote.Open(c);
@@ -1109,7 +1113,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, while (setSubPrototype.Contains(sc.GetRelative(i)))
i++;
if (sc.GetRelative(i) == ')') { // valid sub prototype
- sc.Forward(i);
+ sc.ForwardBytes(i);
sc.ForwardSetState(SCE_PL_DEFAULT);
} else {
// abandon prototype, restart from '('
@@ -1322,7 +1326,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, if (setArray.Contains(sc.chNext)) {
// no special treatment
} else if (sc.chNext == ':' && sc.GetRelative(2) == ':') {
- sc.Forward(2);
+ sc.ForwardBytes(2);
} else if (sc.chNext == '{' || sc.chNext == '[') {
sc.ForwardSetState(SCE_PL_OPERATOR);
} else {
@@ -1445,7 +1449,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, if (preferRE) {
sc.SetState(SCE_PL_SYMBOLTABLE);
if (sc.chNext == ':' && sc.GetRelative(2) == ':') {
- sc.Forward(2);
+ sc.ForwardBytes(2);
} else if (sc.chNext == '{') {
sc.ForwardSetState(SCE_PL_OPERATOR);
} else {
@@ -1462,7 +1466,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, if (setHash.Contains(sc.chNext)) {
sc.Forward();
} else if (sc.chNext == ':' && sc.GetRelative(2) == ':') {
- sc.Forward(2);
+ sc.ForwardBytes(2);
} else if (sc.chNext == '{') {
sc.ForwardSetState(SCE_PL_OPERATOR);
} else {
diff --git a/scintilla/lexers/LexRust.cxx b/scintilla/lexers/LexRust.cxx new file mode 100644 index 0000000..0d9aa1e --- /dev/null +++ b/scintilla/lexers/LexRust.cxx @@ -0,0 +1,768 @@ +/** @file LexRust.cxx + ** Lexer for Rust. + ** + ** Copyright (c) 2013 by SiegeLord <slabode@aim.com> + ** Converted to lexer object and added further folding features/properties by "Udo Lechner" <dlchnr(at)gmx(dot)net> + **/ +// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org> +// The License.txt file describes the conditions under which this software may be distributed. + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <stdarg.h> +#include <assert.h> +#include <ctype.h> + +#include <string> +#include <map> + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "PropSetSimple.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +static bool IsStreamCommentStyle(int style) { + return style == SCE_RUST_COMMENTBLOCK || + style == SCE_RUST_COMMENTBLOCKDOC; +} + +// Options used for LexerRust +struct OptionsRust { + bool fold; + bool foldSyntaxBased; + bool foldComment; + bool foldCommentMultiline; + bool foldCommentExplicit; + std::string foldExplicitStart; + std::string foldExplicitEnd; + bool foldExplicitAnywhere; + bool foldCompact; + int foldAtElseInt; + bool foldAtElse; + OptionsRust() { + fold = false; + foldSyntaxBased = true; + foldComment = false; + foldCommentMultiline = true; + foldCommentExplicit = true; + foldExplicitStart = ""; + foldExplicitEnd = ""; + foldExplicitAnywhere = false; + foldCompact = true; + foldAtElseInt = -1; + foldAtElse = false; + } +}; + +static const char * const rustWordLists[] = { + "Primary keywords and identifiers", + "Built in types", + "Other keywords", + "Keywords 4", + "Keywords 5", + "Keywords 6", + "Keywords 7", + 0, + }; + +struct OptionSetRust : public OptionSet<OptionsRust> { + OptionSetRust() { + DefineProperty("fold", &OptionsRust::fold); + + DefineProperty("fold.comment", &OptionsRust::foldComment); + + DefineProperty("fold.compact", &OptionsRust::foldCompact); + + DefineProperty("fold.at.else", &OptionsRust::foldAtElse); + + DefineProperty("fold.rust.syntax.based", &OptionsRust::foldSyntaxBased, + "Set this property to 0 to disable syntax based folding."); + + DefineProperty("fold.rust.comment.multiline", &OptionsRust::foldCommentMultiline, + "Set this property to 0 to disable folding multi-line comments when fold.comment=1."); + + DefineProperty("fold.rust.comment.explicit", &OptionsRust::foldCommentExplicit, + "Set this property to 0 to disable folding explicit fold points when fold.comment=1."); + + DefineProperty("fold.rust.explicit.start", &OptionsRust::foldExplicitStart, + "The string to use for explicit fold start points, replacing the standard //{."); + + DefineProperty("fold.rust.explicit.end", &OptionsRust::foldExplicitEnd, + "The string to use for explicit fold end points, replacing the standard //}."); + + DefineProperty("fold.rust.explicit.anywhere", &OptionsRust::foldExplicitAnywhere, + "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + + DefineProperty("lexer.rust.fold.at.else", &OptionsRust::foldAtElseInt, + "This option enables Rust folding on a \"} else {\" line of an if statement."); + + DefineWordListSets(rustWordLists); + } +}; + +class LexerRust : public ILexer { + WordList keywords[7]; + OptionsRust options; + OptionSetRust osRust; +public: + virtual ~LexerRust() { + } + void SCI_METHOD Release() { + delete this; + } + int SCI_METHOD Version() const { + return lvOriginal; + } + const char * SCI_METHOD PropertyNames() { + return osRust.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) { + return osRust.PropertyType(name); + } + const char * SCI_METHOD DescribeProperty(const char *name) { + return osRust.DescribeProperty(name); + } + int SCI_METHOD PropertySet(const char *key, const char *val); + const char * SCI_METHOD DescribeWordListSets() { + return osRust.DescribeWordListSets(); + } + int SCI_METHOD WordListSet(int n, const char *wl); + void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + void * SCI_METHOD PrivateCall(int, void *) { + return 0; + } + static ILexer *LexerFactoryRust() { + return new LexerRust(); + } +}; + +int SCI_METHOD LexerRust::PropertySet(const char *key, const char *val) { + if (osRust.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +int SCI_METHOD LexerRust::WordListSet(int n, const char *wl) { + int firstModification = -1; + if (n < 7) { + WordList *wordListN = &keywords[n]; + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; +} + +static bool IsWhitespace(int c) { + return c == ' ' || c == '\t' || c == '\r' || c == '\n'; +} + +/* This isn't quite right for Unicode identifiers */ +static bool IsIdentifierStart(int ch) { + return (IsASCII(ch) && (isalpha(ch) || ch == '_')) || !IsASCII(ch); +} + +/* This isn't quite right for Unicode identifiers */ +static bool IsIdentifierContinue(int ch) { + return (IsASCII(ch) && (isalnum(ch) || ch == '_')) || !IsASCII(ch); +} + +static void ScanWhitespace(Accessor& styler, int& pos, int max) { + while (IsWhitespace(styler.SafeGetCharAt(pos, '\0')) && pos < max) { + if (pos == styler.LineEnd(styler.GetLine(pos))) + styler.SetLineState(styler.GetLine(pos), 0); + pos++; + } + styler.ColourTo(pos-1, SCE_RUST_DEFAULT); +} + +static void GrabString(char* s, Accessor& styler, int start, int len) { + for (int ii = 0; ii < len; ii++) + s[ii] = styler[ii + start]; + s[len] = '\0'; +} + +static void ScanIdentifier(Accessor& styler, int& pos, WordList *keywords) { + int start = pos; + while (IsIdentifierContinue(styler.SafeGetCharAt(pos, '\0'))) + pos++; + + if (styler.SafeGetCharAt(pos, '\0') == '!') { + pos++; + styler.ColourTo(pos - 1, SCE_RUST_MACRO); + } else { + char s[1024]; + int len = pos - start; + len = len > 1024 ? 1024 : len; + GrabString(s, styler, start, len); + bool keyword = false; + for (int ii = 0; ii < 7; ii++) { + if (keywords[ii].InList(s)) { + styler.ColourTo(pos - 1, SCE_RUST_WORD + ii); + keyword = true; + break; + } + } + if (!keyword) { + styler.ColourTo(pos - 1, SCE_RUST_IDENTIFIER); + } + } +} + +static void ScanDigits(Accessor& styler, int& pos, int base) { + for (;;) { + int c = styler.SafeGetCharAt(pos, '\0'); + if (IsADigit(c, base) || c == '_') + pos++; + else + break; + } +} + +static bool ScanExponent(Accessor& styler, int& pos) { + int c = styler.SafeGetCharAt(pos, '\0'); + if (c == 'e' || c == 'E') { + pos++; + c = styler.SafeGetCharAt(pos, '\0'); + if (c == '-' || c == '+') + pos++; + int old_pos = pos; + ScanDigits(styler, pos, 10); + if (old_pos == pos) { + return false; + } + } + return true; +} + +static void ScanNumber(Accessor& styler, int& pos) { + int base = 10; + int c = styler.SafeGetCharAt(pos, '\0'); + int n = styler.SafeGetCharAt(pos + 1, '\0'); + bool error = false; + if (c == '0' && n == 'x') { + pos += 2; + base = 16; + } else if (c == '0' && n == 'b') { + pos += 2; + base = 2; + } + int old_pos = pos; + ScanDigits(styler, pos, base); + c = styler.SafeGetCharAt(pos, '\0'); + if (c == 'u' || c == 'i') { + pos++; + c = styler.SafeGetCharAt(pos, '\0'); + int n = styler.SafeGetCharAt(pos + 1, '\0'); + if (c == '8') { + pos++; + } else if (c == '1' && n == '6') { + pos += 2; + } else if (c == '3' && n == '2') { + pos += 2; + } else if (c == '6' && n == '4') { + pos += 2; + } + } else if (c == '.') { + error = base != 10; + pos++; + ScanDigits(styler, pos, 10); + error |= !ScanExponent(styler, pos); + c = styler.SafeGetCharAt(pos, '\0'); + if (c == 'f') { + pos++; + c = styler.SafeGetCharAt(pos, '\0'); + int n = styler.SafeGetCharAt(pos + 1, '\0'); + if (c == '3' && n == '2') { + pos += 2; + } else if (c == '6' && n == '4') { + pos += 2; + } else { + error = true; + } + } + } + if (old_pos == pos) { + error = true; + } + if (error) + styler.ColourTo(pos - 1, SCE_RUST_LEXERROR); + else + styler.ColourTo(pos - 1, SCE_RUST_NUMBER); +} + +static bool IsOneCharOperator(int c) { + return c == ';' || c == ',' || c == '(' || c == ')' + || c == '{' || c == '}' || c == '[' || c == ']' + || c == '@' || c == '#' || c == '~' || c == '+' + || c == '*' || c == '/' || c == '^' || c == '%' + || c == '.' || c == ':' || c == '!' || c == '<' + || c == '>' || c == '=' || c == '-' || c == '&' + || c == '|' || c == '$'; +} + +static bool IsTwoCharOperator(int c, int n) { + return (c == '.' && n == '.') || (c == ':' && n == ':') + || (c == '!' && n == '=') || (c == '<' && n == '<') + || (c == '<' && n == '=') || (c == '>' && n == '>') + || (c == '>' && n == '=') || (c == '=' && n == '=') + || (c == '=' && n == '>') || (c == '-' && n == '>') + || (c == '&' && n == '&') || (c == '|' && n == '|') + || (c == '-' && n == '=') || (c == '&' && n == '=') + || (c == '|' && n == '=') || (c == '+' && n == '=') + || (c == '*' && n == '=') || (c == '/' && n == '=') + || (c == '^' && n == '=') || (c == '%' && n == '='); +} + +static bool IsThreeCharOperator(int c, int n, int n2) { + return (c == '<' && n == '<' && n2 == '=') + || (c == '>' && n == '>' && n2 == '='); +} + +static bool IsValidCharacterEscape(int c) { + return c == 'n' || c == 'r' || c == 't' || c == '\\' + || c == '\'' || c == '"' || c == '0'; +} + +static bool IsValidStringEscape(int c) { + return IsValidCharacterEscape(c) || c == '\n'; +} + +static bool ScanNumericEscape(Accessor &styler, int& pos, int num_digits, bool stop_asap) { + for (;;) { + int c = styler.SafeGetCharAt(pos, '\0'); + if (!IsADigit(c, 16)) + break; + num_digits--; + pos++; + if (num_digits == 0 && stop_asap) + return true; + } + if (num_digits == 0) { + return true; + } else { + return false; + } +} + +/* This is overly permissive for character literals in order to accept UTF-8 encoded + * character literals. */ +static void ScanCharacterLiteralOrLifetime(Accessor &styler, int& pos) { + pos++; + int c = styler.SafeGetCharAt(pos, '\0'); + int n = styler.SafeGetCharAt(pos + 1, '\0'); + bool done = false; + bool valid_lifetime = IsIdentifierStart(c); + bool valid_char = true; + bool first = true; + while (!done) { + switch (c) { + case '\\': + done = true; + if (IsValidCharacterEscape(n)) { + pos += 2; + } else if (n == 'x') { + pos += 2; + valid_char = ScanNumericEscape(styler, pos, 2, false); + } else if (n == 'u') { + pos += 2; + valid_char = ScanNumericEscape(styler, pos, 4, false); + } else if (n == 'U') { + pos += 2; + valid_char = ScanNumericEscape(styler, pos, 8, false); + } else { + valid_char = false; + } + break; + case '\'': + valid_char = !first; + done = true; + break; + case '\t': + case '\n': + case '\r': + case '\0': + valid_char = false; + done = true; + break; + default: + if (!IsIdentifierContinue(c) && !first) { + done = true; + } else { + pos++; + } + break; + } + c = styler.SafeGetCharAt(pos, '\0'); + n = styler.SafeGetCharAt(pos + 1, '\0'); + + first = false; + } + if (styler.SafeGetCharAt(pos, '\0') == '\'') { + valid_lifetime = false; + } else { + valid_char = false; + } + if (valid_lifetime) { + styler.ColourTo(pos - 1, SCE_RUST_LIFETIME); + } else if (valid_char) { + pos++; + styler.ColourTo(pos - 1, SCE_RUST_CHARACTER); + } else { + styler.ColourTo(pos - 1, SCE_RUST_LEXERROR); + } +} + +enum CommentState { + UnknownComment, + DocComment, + NotDocComment +}; + +/* + * The rule for block-doc comments is as follows (use x for asterisk)... /xx and /x! start doc comments + * unless the entire comment is x's. + */ +static void ResumeBlockComment(Accessor &styler, int& pos, int max, CommentState state) { + int c = styler.SafeGetCharAt(pos, '\0'); + bool maybe_doc_comment = false; + bool any_non_asterisk = false; + if (c == '*' || c == '!') { + maybe_doc_comment = true; + } + for (;;) { + if (pos == styler.LineEnd(styler.GetLine(pos))) + styler.SetLineState(styler.GetLine(pos), 0); + if (c == '*') { + int n = styler.SafeGetCharAt(pos + 1, '\0'); + if (n == '/') { + pos += 2; + if (state == DocComment || (state == UnknownComment && maybe_doc_comment && any_non_asterisk)) + styler.ColourTo(pos - 1, SCE_RUST_COMMENTBLOCKDOC); + else + styler.ColourTo(pos - 1, SCE_RUST_COMMENTBLOCK); + break; + } + } else { + any_non_asterisk = true; + } + if (c == '\0' || pos >= max) { + if (state == DocComment || (state == UnknownComment && maybe_doc_comment)) + styler.ColourTo(pos - 1, SCE_RUST_COMMENTBLOCKDOC); + else + styler.ColourTo(pos - 1, SCE_RUST_COMMENTBLOCK); + break; + } + pos++; + c = styler.SafeGetCharAt(pos, '\0'); + } +} + +/* + * The rule for line-doc comments is as follows... /// and //! start doc comments + * unless the comment is composed entirely of /'s followed by whitespace. That is: + * // - comment + * /// - doc-comment + * //// - comment + * ////a - doc-comment + */ +static void ResumeLineComment(Accessor &styler, int& pos, int max, CommentState state) { + bool maybe_doc_comment = false; + int num_leading_slashes = 0; + int c = styler.SafeGetCharAt(pos, '\0'); + if (c == '/') { + num_leading_slashes = 1; + while (pos < max) { + pos++; + c = styler.SafeGetCharAt(pos, '\0'); + if (c == '/') { + num_leading_slashes++; + } else { + break; + } + } + } else if (c == '!') { + maybe_doc_comment = true; + } + + bool non_white_space = false; + while (pos < max && c != '\n' && c != '\0') { + if (!IsWhitespace(c)) + non_white_space = true; + if (pos == styler.LineEnd(styler.GetLine(pos))) + styler.SetLineState(styler.GetLine(pos), 0); + pos++; + c = styler.SafeGetCharAt(pos, '\0'); + } + + maybe_doc_comment |= num_leading_slashes == 1 || (num_leading_slashes > 1 && non_white_space); + + if (state == DocComment || (state == UnknownComment && maybe_doc_comment)) + styler.ColourTo(pos - 1, SCE_RUST_COMMENTLINEDOC); + else + styler.ColourTo(pos - 1, SCE_RUST_COMMENTLINE); +} + +static void ScanComments(Accessor &styler, int& pos, int max) { + pos++; + int c = styler.SafeGetCharAt(pos, '\0'); + pos++; + if (c == '/') + ResumeLineComment(styler, pos, max, UnknownComment); + else if (c == '*') + ResumeBlockComment(styler, pos, max, UnknownComment); +} + +static void ResumeString(Accessor &styler, int& pos, int max) { + int c = styler.SafeGetCharAt(pos, '\0'); + bool error = false; + while (c != '"' && !error) { + if (c == '\0' || pos >= max) { + error = true; + break; + } + if (pos == styler.LineEnd(styler.GetLine(pos))) + styler.SetLineState(styler.GetLine(pos), 0); + if (c == '\\') { + int n = styler.SafeGetCharAt(pos + 1, '\0'); + if (IsValidStringEscape(n)) { + pos += 2; + } else if (n == 'x') { + pos += 2; + error = !ScanNumericEscape(styler, pos, 2, true); + } else if (n == 'u') { + pos += 2; + error = !ScanNumericEscape(styler, pos, 4, true); + } else if (n == 'U') { + pos += 2; + error = !ScanNumericEscape(styler, pos, 8, true); + } else { + pos += 1; + error = true; + } + } else { + pos++; + } + c = styler.SafeGetCharAt(pos, '\0'); + } + if (!error) + pos++; + styler.ColourTo(pos - 1, SCE_RUST_STRING); +} + +static void ResumeRawString(Accessor &styler, int& pos, int max, int num_hashes) { + for (;;) { + int c = styler.SafeGetCharAt(pos, '\0'); + if (c == '"') { + pos++; + int trailing_num_hashes = 0; + while (styler.SafeGetCharAt(pos, '\0') == '#' && trailing_num_hashes < num_hashes) { + trailing_num_hashes++; + pos++; + } + if (trailing_num_hashes == num_hashes) { + styler.SetLineState(styler.GetLine(pos), 0); + styler.ColourTo(pos - 1, SCE_RUST_STRINGR); + break; + } + } else if (c == '\0' || pos >= max) { + styler.ColourTo(pos - 1, SCE_RUST_STRINGR); + break; + } + if (pos == styler.LineEnd(styler.GetLine(pos))) + styler.SetLineState(styler.GetLine(pos), num_hashes); + pos++; + } +} + +static void ScanRawString(Accessor &styler, int& pos, int max) { + pos++; + int num_hashes = 0; + while (styler.SafeGetCharAt(pos, '\0') == '#') { + num_hashes++; + pos++; + } + if (styler.SafeGetCharAt(pos, '\0') != '"') { + styler.ColourTo(pos - 1, SCE_RUST_LEXERROR); + } else { + pos++; + ResumeRawString(styler, pos, max, num_hashes); + } +} + +void SCI_METHOD LexerRust::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { + PropSetSimple props; + Accessor styler(pAccess, &props); + int pos = startPos; + int max = pos + length; + + styler.StartAt(pos); + styler.StartSegment(pos); + + if (initStyle == SCE_RUST_COMMENTBLOCK || initStyle == SCE_RUST_COMMENTBLOCKDOC) { + ResumeBlockComment(styler, pos, max, initStyle == SCE_RUST_COMMENTBLOCKDOC ? DocComment : NotDocComment); + } else if (initStyle == SCE_RUST_COMMENTLINE || initStyle == SCE_RUST_COMMENTLINEDOC) { + ResumeLineComment(styler, pos, max, initStyle == SCE_RUST_COMMENTLINEDOC ? DocComment : NotDocComment); + } else if (initStyle == SCE_RUST_STRING) { + ResumeString(styler, pos, max); + } else if (initStyle == SCE_RUST_STRINGR) { + ResumeRawString(styler, pos, max, styler.GetLineState(styler.GetLine(pos) - 1)); + } + + while (pos < max) { + int c = styler.SafeGetCharAt(pos, '\0'); + int n = styler.SafeGetCharAt(pos + 1, '\0'); + int n2 = styler.SafeGetCharAt(pos + 2, '\0'); + + if (pos == 0 && c == '#' && n == '!') { + pos += 2; + ResumeLineComment(styler, pos, max, NotDocComment); + } else if (IsWhitespace(c)) { + ScanWhitespace(styler, pos, max); + } else if (c == '/' && (n == '/' || n == '*')) { + ScanComments(styler, pos, max); + } else if (c == 'r' && (n == '#' || n == '"')) { + ScanRawString(styler, pos, max); + } else if (IsIdentifierStart(c)) { + ScanIdentifier(styler, pos, keywords); + } else if (IsADigit(c)) { + ScanNumber(styler, pos); + } else if (IsThreeCharOperator(c, n, n2)) { + pos += 3; + styler.ColourTo(pos - 1, SCE_RUST_OPERATOR); + } else if (IsTwoCharOperator(c, n)) { + pos += 2; + styler.ColourTo(pos - 1, SCE_RUST_OPERATOR); + } else if (IsOneCharOperator(c)) { + pos++; + styler.ColourTo(pos - 1, SCE_RUST_OPERATOR); + } else if (c == '\'') { + ScanCharacterLiteralOrLifetime(styler, pos); + } else if (c == '"') { + pos++; + ResumeString(styler, pos, max); + } else { + pos++; + styler.ColourTo(pos - 1, SCE_RUST_LEXERROR); + } + } + styler.ColourTo(pos - 1, SCE_RUST_DEFAULT); + styler.Flush(); +} + +void SCI_METHOD LexerRust::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { + + if (!options.fold) + return; + + LexAccessor styler(pAccess); + + unsigned int endPos = startPos + length; + int visibleChars = 0; + bool inLineComment = false; + int lineCurrent = styler.GetLine(startPos); + int levelCurrent = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; + unsigned int lineStartNext = styler.LineStart(lineCurrent+1); + int levelMinCurrent = levelCurrent; + int levelNext = levelCurrent; + char chNext = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); + for (unsigned int i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + int stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 1); + bool atEOL = i == (lineStartNext-1); + if ((style == SCE_RUST_COMMENTLINE) || (style == SCE_RUST_COMMENTLINEDOC)) + inLineComment = true; + if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style) && !inLineComment) { + if (!IsStreamCommentStyle(stylePrev)) { + levelNext++; + } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { + // Comments don't end at end of line and the next character may be unstyled. + levelNext--; + } + } + if (options.foldComment && options.foldCommentExplicit && ((style == SCE_RUST_COMMENTLINE) || options.foldExplicitAnywhere)) { + if (userDefinedFoldMarkers) { + if (styler.Match(i, options.foldExplicitStart.c_str())) { + levelNext++; + } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { + levelNext--; + } + } else { + if ((ch == '/') && (chNext == '/')) { + char chNext2 = styler.SafeGetCharAt(i + 2); + if (chNext2 == '{') { + levelNext++; + } else if (chNext2 == '}') { + levelNext--; + } + } + } + } + if (options.foldSyntaxBased && (style == SCE_RUST_OPERATOR)) { + if (ch == '{') { + // Measure the minimum before a '{' to allow + // folding on "} else {" + if (levelMinCurrent > levelNext) { + levelMinCurrent = levelNext; + } + levelNext++; + } else if (ch == '}') { + levelNext--; + } + } + if (!IsASpace(ch)) + visibleChars++; + if (atEOL || (i == endPos-1)) { + int levelUse = levelCurrent; + if (options.foldSyntaxBased && options.foldAtElse) { + levelUse = levelMinCurrent; + } + int lev = levelUse | levelNext << 16; + if (visibleChars == 0 && options.foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelUse < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + lineStartNext = styler.LineStart(lineCurrent+1); + levelCurrent = levelNext; + levelMinCurrent = levelCurrent; + if (atEOL && (i == static_cast<unsigned int>(styler.Length()-1))) { + // There is an empty line at end of file so give it same level and empty + styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); + } + visibleChars = 0; + inLineComment = false; + } + } +} + +LexerModule lmRust(SCLEX_RUST, LexerRust::LexerFactoryRust, "rust", rustWordLists); diff --git a/scintilla/lexers/LexSQL.cxx b/scintilla/lexers/LexSQL.cxx index 6d97789..6a024e5 100644 --- a/scintilla/lexers/LexSQL.cxx +++ b/scintilla/lexers/LexSQL.cxx @@ -62,6 +62,7 @@ static inline bool IsANumberChar(int ch) { ch == '.' || ch == '-' || ch == '+');
}
+typedef unsigned int sql_state_t;
class SQLStates {
public :
@@ -69,7 +70,7 @@ public : sqlStatement.Set(lineNumber, sqlStatesLine);
}
- unsigned short int IgnoreWhen (unsigned short int sqlStatesLine, bool enable) {
+ sql_state_t IgnoreWhen (sql_state_t sqlStatesLine, bool enable) {
if (enable)
sqlStatesLine |= MASK_IGNORE_WHEN;
else
@@ -78,7 +79,7 @@ public : return sqlStatesLine;
}
- unsigned short int IntoCondition (unsigned short int sqlStatesLine, bool enable) {
+ sql_state_t IntoCondition (sql_state_t sqlStatesLine, bool enable) {
if (enable)
sqlStatesLine |= MASK_INTO_CONDITION;
else
@@ -87,7 +88,7 @@ public : return sqlStatesLine;
}
- unsigned short int IntoExceptionBlock (unsigned short int sqlStatesLine, bool enable) {
+ sql_state_t IntoExceptionBlock (sql_state_t sqlStatesLine, bool enable) {
if (enable)
sqlStatesLine |= MASK_INTO_EXCEPTION;
else
@@ -96,7 +97,7 @@ public : return sqlStatesLine;
}
- unsigned short int IntoDeclareBlock (unsigned short int sqlStatesLine, bool enable) {
+ sql_state_t IntoDeclareBlock (sql_state_t sqlStatesLine, bool enable) {
if (enable)
sqlStatesLine |= MASK_INTO_DECLARE;
else
@@ -105,7 +106,7 @@ public : return sqlStatesLine;
}
- unsigned short int IntoMergeStatement (unsigned short int sqlStatesLine, bool enable) {
+ sql_state_t IntoMergeStatement (sql_state_t sqlStatesLine, bool enable) {
if (enable)
sqlStatesLine |= MASK_MERGE_STATEMENT;
else
@@ -114,7 +115,7 @@ public : return sqlStatesLine;
}
- unsigned short int CaseMergeWithoutWhenFound (unsigned short int sqlStatesLine, bool found) {
+ sql_state_t CaseMergeWithoutWhenFound (sql_state_t sqlStatesLine, bool found) {
if (found)
sqlStatesLine |= MASK_CASE_MERGE_WITHOUT_WHEN_FOUND;
else
@@ -122,7 +123,7 @@ public : return sqlStatesLine;
}
- unsigned short int IntoSelectStatementOrAssignment (unsigned short int sqlStatesLine, bool found) {
+ sql_state_t IntoSelectStatementOrAssignment (sql_state_t sqlStatesLine, bool found) {
if (found)
sqlStatesLine |= MASK_INTO_SELECT_STATEMENT_OR_ASSIGNEMENT;
else
@@ -130,67 +131,109 @@ public : return sqlStatesLine;
}
- unsigned short int BeginCaseBlock (unsigned short int sqlStatesLine) {
+ sql_state_t BeginCaseBlock (sql_state_t sqlStatesLine) {
if ((sqlStatesLine & MASK_NESTED_CASES) < MASK_NESTED_CASES) {
sqlStatesLine++;
}
return sqlStatesLine;
}
- unsigned short int EndCaseBlock (unsigned short int sqlStatesLine) {
+ sql_state_t EndCaseBlock (sql_state_t sqlStatesLine) {
if ((sqlStatesLine & MASK_NESTED_CASES) > 0) {
sqlStatesLine--;
}
return sqlStatesLine;
}
- bool IsIgnoreWhen (unsigned short int sqlStatesLine) {
+ sql_state_t IntoCreateStatement (sql_state_t sqlStatesLine, bool enable) {
+ if (enable)
+ sqlStatesLine |= MASK_INTO_CREATE;
+ else
+ sqlStatesLine &= ~MASK_INTO_CREATE;
+
+ return sqlStatesLine;
+ }
+
+ sql_state_t IntoCreateViewStatement (sql_state_t sqlStatesLine, bool enable) {
+ if (enable)
+ sqlStatesLine |= MASK_INTO_CREATE_VIEW;
+ else
+ sqlStatesLine &= ~MASK_INTO_CREATE_VIEW;
+
+ return sqlStatesLine;
+ }
+
+ sql_state_t IntoCreateViewAsStatement (sql_state_t sqlStatesLine, bool enable) {
+ if (enable)
+ sqlStatesLine |= MASK_INTO_CREATE_VIEW_AS_STATEMENT;
+ else
+ sqlStatesLine &= ~MASK_INTO_CREATE_VIEW_AS_STATEMENT;
+
+ return sqlStatesLine;
+ }
+
+ bool IsIgnoreWhen (sql_state_t sqlStatesLine) {
return (sqlStatesLine & MASK_IGNORE_WHEN) != 0;
}
- bool IsIntoCondition (unsigned short int sqlStatesLine) {
+ bool IsIntoCondition (sql_state_t sqlStatesLine) {
return (sqlStatesLine & MASK_INTO_CONDITION) != 0;
}
- bool IsIntoCaseBlock (unsigned short int sqlStatesLine) {
+ bool IsIntoCaseBlock (sql_state_t sqlStatesLine) {
return (sqlStatesLine & MASK_NESTED_CASES) != 0;
}
- bool IsIntoExceptionBlock (unsigned short int sqlStatesLine) {
+ bool IsIntoExceptionBlock (sql_state_t sqlStatesLine) {
return (sqlStatesLine & MASK_INTO_EXCEPTION) != 0;
}
- bool IsIntoSelectStatementOrAssignment (unsigned short int sqlStatesLine) {
+ bool IsIntoSelectStatementOrAssignment (sql_state_t sqlStatesLine) {
return (sqlStatesLine & MASK_INTO_SELECT_STATEMENT_OR_ASSIGNEMENT) != 0;
}
- bool IsCaseMergeWithoutWhenFound (unsigned short int sqlStatesLine) {
+ bool IsCaseMergeWithoutWhenFound (sql_state_t sqlStatesLine) {
return (sqlStatesLine & MASK_CASE_MERGE_WITHOUT_WHEN_FOUND) != 0;
}
- bool IsIntoDeclareBlock (unsigned short int sqlStatesLine) {
+ bool IsIntoDeclareBlock (sql_state_t sqlStatesLine) {
return (sqlStatesLine & MASK_INTO_DECLARE) != 0;
}
- bool IsIntoMergeStatement (unsigned short int sqlStatesLine) {
+ bool IsIntoMergeStatement (sql_state_t sqlStatesLine) {
return (sqlStatesLine & MASK_MERGE_STATEMENT) != 0;
}
- unsigned short int ForLine(int lineNumber) {
+ bool IsIntoCreateStatement (sql_state_t sqlStatesLine) {
+ return (sqlStatesLine & MASK_INTO_CREATE) != 0;
+ }
+
+ bool IsIntoCreateViewStatement (sql_state_t sqlStatesLine) {
+ return (sqlStatesLine & MASK_INTO_CREATE_VIEW) != 0;
+ }
+
+ bool IsIntoCreateViewAsStatement (sql_state_t sqlStatesLine) {
+ return (sqlStatesLine & MASK_INTO_CREATE_VIEW_AS_STATEMENT) != 0;
+ }
+
+ sql_state_t ForLine(int lineNumber) {
return sqlStatement.ValueAt(lineNumber);
}
SQLStates() {}
private :
- SparseState <unsigned short int> sqlStatement;
+ SparseState <sql_state_t> sqlStatement;
enum {
- MASK_NESTED_CASES = 0x01FF,
- MASK_INTO_SELECT_STATEMENT_OR_ASSIGNEMENT = 0x0200,
- MASK_CASE_MERGE_WITHOUT_WHEN_FOUND = 0x0400,
- MASK_MERGE_STATEMENT = 0x0800,
- MASK_INTO_DECLARE = 0x1000,
- MASK_INTO_EXCEPTION = 0x2000,
- MASK_INTO_CONDITION = 0x4000,
- MASK_IGNORE_WHEN = 0x8000
+ MASK_NESTED_CASES = 0x0001FF,
+ MASK_INTO_SELECT_STATEMENT_OR_ASSIGNEMENT = 0x000200,
+ MASK_CASE_MERGE_WITHOUT_WHEN_FOUND = 0x000400,
+ MASK_MERGE_STATEMENT = 0x000800,
+ MASK_INTO_DECLARE = 0x001000,
+ MASK_INTO_EXCEPTION = 0x002000,
+ MASK_INTO_CONDITION = 0x004000,
+ MASK_IGNORE_WHEN = 0x008000,
+ MASK_INTO_CREATE = 0x010000,
+ MASK_INTO_CREATE_VIEW = 0x020000,
+ MASK_INTO_CREATE_VIEW_AS_STATEMENT = 0x040000
};
};
@@ -561,12 +604,46 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle, if (lineCurrent > 0) {
// Backtrack to previous line in case need to fix its fold status for folding block of single-line comments (i.e. '--').
- lineCurrent -= 1;
- startPos = styler.LineStart(lineCurrent);
-
+ int lastNLPos = -1;
+ // And keep going back until we find an operator ';' followed
+ // by white-space and/or comments. This will improve folding.
+ while (--startPos > 0) {
+ char ch = styler[startPos];
+ if (ch == '\n' || (ch == '\r' && styler[startPos + 1] != '\n')) {
+ lastNLPos = startPos;
+ } else if (ch == ';' &&
+ styler.StyleAt(startPos) == SCE_SQL_OPERATOR) {
+ bool isAllClear = true;
+ for (int tempPos = startPos + 1;
+ tempPos < lastNLPos;
+ ++tempPos) {
+ int tempStyle = styler.StyleAt(tempPos);
+ if (!IsCommentStyle(tempStyle)
+ && tempStyle != SCE_SQL_DEFAULT) {
+ isAllClear = false;
+ break;
+ }
+ }
+ if (isAllClear) {
+ startPos = lastNLPos + 1;
+ break;
+ }
+ }
+ }
+ lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16;
}
+ // And because folding ends at ';', keep going until we find one
+ // Otherwise if create ... view ... as is split over multiple
+ // lines the folding won't always update immediately.
+ unsigned int docLength = styler.Length();
+ for (; endPos < docLength; ++endPos) {
+ if (styler.SafeGetCharAt(endPos) == ';') {
+ break;
+ }
+ }
+
int levelNext = levelCurrent;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
@@ -576,7 +653,7 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle, // this statementFound flag avoids to fold when the statement is on only one line by ignoring ELSE or ELSIF
// eg. "IF condition1 THEN ... ELSIF condition2 THEN ... ELSE ... END IF;"
bool statementFound = false;
- unsigned short int sqlStatesCurrentLine = 0;
+ sql_state_t sqlStatesCurrentLine = 0;
if (!options.foldOnlyBegin) {
sqlStatesCurrentLine = sqlStates.ForLine(lineCurrent);
}
@@ -606,6 +683,16 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle, }
if (sqlStates.IsIntoSelectStatementOrAssignment(sqlStatesCurrentLine))
sqlStatesCurrentLine = sqlStates.IntoSelectStatementOrAssignment(sqlStatesCurrentLine, false);
+ if (sqlStates.IsIntoCreateStatement(sqlStatesCurrentLine)) {
+ if (sqlStates.IsIntoCreateViewStatement(sqlStatesCurrentLine)) {
+ if (sqlStates.IsIntoCreateViewAsStatement(sqlStatesCurrentLine)) {
+ levelNext--;
+ sqlStatesCurrentLine = sqlStates.IntoCreateViewAsStatement(sqlStatesCurrentLine, false);
+ }
+ sqlStatesCurrentLine = sqlStates.IntoCreateViewStatement(sqlStatesCurrentLine, false);
+ }
+ sqlStatesCurrentLine = sqlStates.IntoCreateStatement(sqlStatesCurrentLine, false);
+ }
}
if (ch == ':' && chNext == '=' && !IsCommentStyle(style))
sqlStatesCurrentLine = sqlStates.IntoSelectStatementOrAssignment(sqlStatesCurrentLine, true);
@@ -805,6 +892,19 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle, sqlStatesCurrentLine = sqlStates.CaseMergeWithoutWhenFound(sqlStatesCurrentLine, true);
levelNext++;
statementFound = true;
+ } else if ((!options.foldOnlyBegin) &&
+ strcmp(s, "create") == 0) {
+ sqlStatesCurrentLine = sqlStates.IntoCreateStatement(sqlStatesCurrentLine, true);
+ } else if ((!options.foldOnlyBegin) &&
+ strcmp(s, "view") == 0 &&
+ sqlStates.IsIntoCreateStatement(sqlStatesCurrentLine)) {
+ sqlStatesCurrentLine = sqlStates.IntoCreateViewStatement(sqlStatesCurrentLine, true);
+ } else if ((!options.foldOnlyBegin) &&
+ strcmp(s, "as") == 0 &&
+ sqlStates.IsIntoCreateViewStatement(sqlStatesCurrentLine) &&
+ ! sqlStates.IsIntoCreateViewAsStatement(sqlStatesCurrentLine)) {
+ sqlStatesCurrentLine = sqlStates.IntoCreateViewAsStatement(sqlStatesCurrentLine, true);
+ levelNext++;
}
}
if (atEOL) {
diff --git a/scintilla/lexers/LexVisualProlog.cxx b/scintilla/lexers/LexVisualProlog.cxx index 634d155..f3a3e3f 100644 --- a/scintilla/lexers/LexVisualProlog.cxx +++ b/scintilla/lexers/LexVisualProlog.cxx @@ -7,6 +7,10 @@ // Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+// The line state contains:
+// In SCE_VISUALPROLOG_STRING_VERBATIM_EOL (i.e. multiline string literal): The closingQuote.
+// else (for SCE_VISUALPROLOG_COMMENT_BLOCK): The comment nesting level
+
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
@@ -32,6 +36,7 @@ #include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
+#include "CharacterCategory.h"
#include "LexerModule.h"
#include "OptionSet.h"
@@ -144,15 +149,73 @@ struct After { After(int line_) : line(line_) {}
};
+static bool isLowerLetter(int ch){
+ return ccLl == CategoriseCharacter(ch);
+}
+
+static bool isUpperLetter(int ch){
+ return ccLu == CategoriseCharacter(ch);
+}
+
+static bool isAlphaNum(int ch){
+ CharacterCategory cc = CategoriseCharacter(ch);
+ return (ccLu == cc || ccLl == cc || ccLt == cc || ccLm == cc || ccLo == cc || ccNd == cc || ccNl == cc || ccNo == cc);
+}
+
+static bool isIdChar(int ch){
+ return ('_') == ch || isAlphaNum(ch);
+}
+
+static bool isOpenStringVerbatim(int next, int &closingQuote){
+ switch (next) {
+ case L'<':
+ closingQuote = L'>';
+ return true;
+ case L'>':
+ closingQuote = L'<';
+ return true;
+ case L'(':
+ closingQuote = L')';
+ return true;
+ case L')':
+ closingQuote = L'(';
+ return true;
+ case L'[':
+ closingQuote = L']';
+ return true;
+ case L']':
+ closingQuote = L'[';
+ return true;
+ case L'{':
+ closingQuote = L'}';
+ return true;
+ case L'}':
+ closingQuote = L'{';
+ return true;
+ case L'_':
+ case L'.':
+ case L',':
+ case L';':
+ return false;
+ default:
+ if (isAlphaNum(next)) {
+ return false;
+ } else {
+ closingQuote = next;
+ return true;
+ }
+ }
+}
+
// Look ahead to see which colour "end" should have (takes colour after the following keyword)
-static void endLookAhead(char s[], LexAccessor &styler, int start, CharacterSet &setIdentifier) {
+static void endLookAhead(char s[], LexAccessor &styler, int start) {
char ch = styler.SafeGetCharAt(start, '\n');
while (' ' == ch) {
start++;
ch = styler.SafeGetCharAt(start, '\n');
}
int i = 0;
- while (i < 100 && setIdentifier.Contains(ch)){
+ while (i < 100 && isLowerLetter(ch)){
s[i] = ch;
i++;
ch = styler.SafeGetCharAt(start + i, '\n');
@@ -160,11 +223,11 @@ static void endLookAhead(char s[], LexAccessor &styler, int start, CharacterSet s[i] = '\0';
}
-static void forwardEscapeLiteral(StyleContext &sc, int OwnChar, int EscapeState) {
+static void forwardEscapeLiteral(StyleContext &sc, int EscapeState) {
sc.Forward();
- if (sc.ch == OwnChar || sc.ch == '\\' || sc.ch == 'n' || sc.ch == 'l' || sc.ch == 'r' || sc.ch == 't') {
+ if (sc.Match('"') || sc.Match('\'') || sc.Match('\\') || sc.Match('n') || sc.Match('l') || sc.Match('r') || sc.Match('t')) {
sc.ChangeState(EscapeState);
- } else if (sc.ch == 'u') {
+ } else if (sc.Match('u')) {
if (IsADigit(sc.chNext, 16)) {
sc.Forward();
if (IsADigit(sc.chNext, 16)) {
@@ -183,45 +246,26 @@ static void forwardEscapeLiteral(StyleContext &sc, int OwnChar, int EscapeState) void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
LexAccessor styler(pAccess);
+ CharacterSet setDoxygen(CharacterSet::setAlpha, "");
+ CharacterSet setNumber(CharacterSet::setNone, "+-.0123456789abcdefABCDEFxoXO");
- CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]");
-
- CharacterSet setLowerStart(CharacterSet::setLower);
- CharacterSet setVariableStart(CharacterSet::setUpper);
- CharacterSet setIdentifier(CharacterSet::setAlphaNum, "_", 0x80, true);
+ StyleContext sc(startPos, length, initStyle, styler, 0x7f);
int styleBeforeDocKeyword = SCE_VISUALPROLOG_DEFAULT;
-
int currentLine = styler.GetLine(startPos);
+ int closingQuote = '"';
int nestLevel = 0;
if (currentLine >= 1)
{
nestLevel = styler.GetLineState(currentLine - 1);
+ closingQuote = nestLevel;
}
- StyleContext sc(startPos, length, initStyle, styler, 0x7f);
-
// Truncate ppDefineHistory before current line
for (; sc.More(); sc.Forward()) {
- if (sc.atLineEnd) {
- // Update the line state, so it can be seen by next line
- styler.SetLineState(currentLine, nestLevel);
- currentLine++;
- }
-
- if (sc.atLineStart) {
- if ((sc.state == SCE_VISUALPROLOG_STRING) || (sc.state == SCE_VISUALPROLOG_CHARACTER)) {
- // Prevent SCE_VISUALPROLOG_STRING_EOL from leaking back to previous line which
- // ends with a line continuation by locking in the state upto this position.
- sc.SetState(sc.state);
- }
- }
-
- const bool atLineEndBeforeSwitch = sc.atLineEnd;
-
// Determine if the current state should terminate.
switch (sc.state) {
case SCE_VISUALPROLOG_OPERATOR:
@@ -229,16 +273,16 @@ void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int in break;
case SCE_VISUALPROLOG_NUMBER:
// We accept almost anything because of hex. and number suffixes
- if (!(setIdentifier.Contains(sc.ch) || (sc.ch == '.') || ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) {
+ if (!(setNumber.Contains(sc.ch))) {
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
}
break;
case SCE_VISUALPROLOG_IDENTIFIER:
- if (!setIdentifier.Contains(sc.ch)) {
+ if (!isIdChar(sc.ch)) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (0 == strcmp(s, "end")) {
- endLookAhead(s, styler, sc.currentPos, setIdentifier);
+ endLookAhead(s, styler, sc.currentPos);
}
if (majorKeywords.InList(s)) {
sc.ChangeState(SCE_VISUALPROLOG_KEY_MAJOR);
@@ -250,12 +294,12 @@ void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int in break;
case SCE_VISUALPROLOG_VARIABLE:
case SCE_VISUALPROLOG_ANONYMOUS:
- if (!setIdentifier.Contains(sc.ch)) {
+ if (!isIdChar(sc.ch)) {
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
}
break;
case SCE_VISUALPROLOG_KEY_DIRECTIVE:
- if (!setLowerStart.Contains(sc.ch)) {
+ if (!isLowerLetter(sc.ch)) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (!directiveKeywords.InList(s+1)) {
@@ -273,9 +317,7 @@ void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int in } else if (sc.Match('/', '*')) {
sc.Forward();
nestLevel++;
- } else if (sc.ch == '%') {
- sc.SetState(SCE_VISUALPROLOG_COMMENT_LINE);
- } else if (sc.ch == '@') {
+ } else if (sc.Match('@')) {
styleBeforeDocKeyword = sc.state;
sc.SetState(SCE_VISUALPROLOG_COMMENT_KEY_ERROR);
}
@@ -284,24 +326,34 @@ void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int in if (sc.atLineEnd) {
int nextState = (nestLevel == 0) ? SCE_VISUALPROLOG_DEFAULT : SCE_VISUALPROLOG_COMMENT_BLOCK;
sc.SetState(nextState);
- } else if (sc.ch == '@') {
+ } else if (sc.Match('@')) {
styleBeforeDocKeyword = sc.state;
sc.SetState(SCE_VISUALPROLOG_COMMENT_KEY_ERROR);
}
break;
case SCE_VISUALPROLOG_COMMENT_KEY_ERROR:
- if (!setDoxygen.Contains(sc.ch)) {
+ if (!setDoxygen.Contains(sc.ch) || sc.atLineEnd) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (docKeywords.InList(s+1)) {
sc.ChangeState(SCE_VISUALPROLOG_COMMENT_KEY);
}
- sc.SetState(styleBeforeDocKeyword);
- }
- if (SCE_VISUALPROLOG_COMMENT_LINE == styleBeforeDocKeyword && sc.atLineStart) {
- sc.SetState(SCE_VISUALPROLOG_DEFAULT);
- } else if (SCE_VISUALPROLOG_COMMENT_BLOCK == styleBeforeDocKeyword && sc.atLineStart) {
- sc.SetState(SCE_VISUALPROLOG_COMMENT_BLOCK);
+ if (SCE_VISUALPROLOG_COMMENT_LINE == styleBeforeDocKeyword && sc.atLineEnd) {
+ // end line comment
+ int nextState = (nestLevel == 0) ? SCE_VISUALPROLOG_DEFAULT : SCE_VISUALPROLOG_COMMENT_BLOCK;
+ sc.SetState(nextState);
+ } else {
+ sc.SetState(styleBeforeDocKeyword);
+ if (SCE_VISUALPROLOG_COMMENT_BLOCK == styleBeforeDocKeyword && sc.Match('*', '/')) {
+ // we have consumed the '*' if it comes immediately after the docKeyword
+ sc.Forward();
+ sc.Forward();
+ nestLevel--;
+ if (0 == nestLevel) {
+ sc.SetState(SCE_VISUALPROLOG_DEFAULT);
+ }
+ }
+ }
}
break;
case SCE_VISUALPROLOG_STRING_ESCAPE:
@@ -311,38 +363,11 @@ void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int in case SCE_VISUALPROLOG_STRING:
if (sc.atLineEnd) {
sc.SetState(SCE_VISUALPROLOG_STRING_EOL_OPEN);
- } else if (sc.ch == '"') {
+ } else if (sc.Match(closingQuote)) {
sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
- } else if (sc.ch == '\\') {
+ } else if (sc.Match('\\')) {
sc.SetState(SCE_VISUALPROLOG_STRING_ESCAPE_ERROR);
- forwardEscapeLiteral(sc, '"', SCE_VISUALPROLOG_STRING_ESCAPE);
- }
- break;
- case SCE_VISUALPROLOG_CHARACTER_TOO_MANY:
- if (sc.atLineStart) {
- sc.SetState(SCE_VISUALPROLOG_DEFAULT);
- } else if (sc.ch == '\'') {
- sc.SetState(SCE_VISUALPROLOG_CHARACTER);
- sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
- }
- break;
- case SCE_VISUALPROLOG_CHARACTER:
- if (sc.atLineEnd) {
- sc.SetState(SCE_VISUALPROLOG_STRING_EOL_OPEN); // reuse STRING_EOL_OPEN for this
- } else if (sc.ch == '\'') {
- sc.SetState(SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR);
- sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
- } else {
- if (sc.ch == '\\') {
- sc.SetState(SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR);
- forwardEscapeLiteral(sc, '\'', SCE_VISUALPROLOG_CHARACTER);
- }
- sc.ForwardSetState(SCE_VISUALPROLOG_CHARACTER);
- if (sc.ch == '\'') {
- sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
- } else {
- sc.SetState(SCE_VISUALPROLOG_CHARACTER_TOO_MANY);
- }
+ forwardEscapeLiteral(sc, SCE_VISUALPROLOG_STRING_ESCAPE);
}
break;
case SCE_VISUALPROLOG_STRING_EOL_OPEN:
@@ -357,8 +382,8 @@ void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int in case SCE_VISUALPROLOG_STRING_VERBATIM:
if (sc.atLineEnd) {
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM_EOL);
- } else if (sc.ch == '\"') {
- if (sc.chNext == '\"') {
+ } else if (sc.Match(closingQuote)) {
+ if (closingQuote == sc.chNext) {
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL);
sc.Forward();
} else {
@@ -368,37 +393,46 @@ void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int in break;
}
- if (sc.atLineEnd && !atLineEndBeforeSwitch) {
- // State exit processing consumed characters up to end of line.
+ if (sc.atLineEnd) {
+ // Update the line state, so it can be seen by next line
+ int lineState = 0;
+ if (SCE_VISUALPROLOG_STRING_VERBATIM_EOL == sc.state) {
+ lineState = closingQuote;
+ } else if (SCE_VISUALPROLOG_COMMENT_BLOCK == sc.state) {
+ lineState = nestLevel;
+ }
+ styler.SetLineState(currentLine, lineState);
currentLine++;
}
// Determine if a new state should be entered.
if (sc.state == SCE_VISUALPROLOG_DEFAULT) {
- if (sc.Match('@', '\"')) {
+ if (sc.Match('@') && isOpenStringVerbatim(sc.chNext, closingQuote)) {
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM);
sc.Forward();
- } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+ } else if (IsADigit(sc.ch) || (sc.Match('.') && IsADigit(sc.chNext))) {
sc.SetState(SCE_VISUALPROLOG_NUMBER);
- } else if (setLowerStart.Contains(sc.ch)) {
+ } else if (isLowerLetter(sc.ch)) {
sc.SetState(SCE_VISUALPROLOG_IDENTIFIER);
- } else if (setVariableStart.Contains(sc.ch)) {
+ } else if (isUpperLetter(sc.ch)) {
sc.SetState(SCE_VISUALPROLOG_VARIABLE);
- } else if (sc.ch == '_') {
+ } else if (sc.Match('_')) {
sc.SetState(SCE_VISUALPROLOG_ANONYMOUS);
} else if (sc.Match('/', '*')) {
sc.SetState(SCE_VISUALPROLOG_COMMENT_BLOCK);
nestLevel = 1;
sc.Forward(); // Eat the * so it isn't used for the end of the comment
- } else if (sc.ch == '%') {
+ } else if (sc.Match('%')) {
sc.SetState(SCE_VISUALPROLOG_COMMENT_LINE);
- } else if (sc.ch == '\"') {
+ } else if (sc.Match('\'')) {
+ closingQuote = '\'';
+ sc.SetState(SCE_VISUALPROLOG_STRING);
+ } else if (sc.Match('"')) {
+ closingQuote = '"';
sc.SetState(SCE_VISUALPROLOG_STRING);
- } else if (sc.ch == '\'') {
- sc.SetState(SCE_VISUALPROLOG_CHARACTER);
- } else if (sc.ch == '#') {
+ } else if (sc.Match('#')) {
sc.SetState(SCE_VISUALPROLOG_KEY_DIRECTIVE);
- } else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '\\') {
+ } else if (isoperator(static_cast<char>(sc.ch)) || sc.Match('\\')) {
sc.SetState(SCE_VISUALPROLOG_OPERATOR);
}
}
diff --git a/scintilla/lexlib/StyleContext.h b/scintilla/lexlib/StyleContext.h index abd69e9..7c4dbaf 100644 --- a/scintilla/lexlib/StyleContext.h +++ b/scintilla/lexlib/StyleContext.h @@ -172,11 +172,11 @@ public: }
int diffRelative = n - offsetRelative;
int posNew = multiByteAccess->GetRelativePosition(posRelative, diffRelative);
- int ch = multiByteAccess->GetCharacterAndWidth(posNew, 0);
+ int chReturn = multiByteAccess->GetCharacterAndWidth(posNew, 0);
posRelative = posNew;
currentPosLastRelative = currentPos;
offsetRelative = n;
- return ch;
+ return chReturn;
} else {
// fast version for single byte encodings
return static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + n, 0));
diff --git a/scintilla/lexlib/SubStyles.h b/scintilla/lexlib/SubStyles.h index e6c34e0..961715c 100644 --- a/scintilla/lexlib/SubStyles.h +++ b/scintilla/lexlib/SubStyles.h @@ -13,13 +13,14 @@ namespace Scintilla { #endif class WordClassifier { + int baseStyle; int firstStyle; int lenStyles; std::map<std::string, int> wordToStyle; public: - WordClassifier() : firstStyle(0), lenStyles(0) { + WordClassifier(int baseStyle_) : baseStyle(baseStyle_), firstStyle(0), lenStyles(0) { } void Allocate(int firstStyle_, int lenStyles_) { @@ -28,6 +29,10 @@ public: wordToStyle.clear(); } + int Base() const { + return baseStyle; + } + int Start() const { return firstStyle; } @@ -57,10 +62,12 @@ public: void SetIdentifiers(int style, const char *identifiers) { while (*identifiers) { const char *cpSpace = identifiers; - while (*cpSpace && *cpSpace != ' ') + while (*cpSpace && !(*cpSpace == ' ' || *cpSpace == '\t' || *cpSpace == '\r' || *cpSpace == '\n')) cpSpace++; - std::string word(identifiers, cpSpace - identifiers); - wordToStyle[word] = style; + if (cpSpace > identifiers) { + std::string word(identifiers, cpSpace - identifiers); + wordToStyle[word] = style; + } identifiers = cpSpace; if (*identifiers) identifiers++; @@ -105,8 +112,8 @@ public: secondaryDistance(secondaryDistance_), allocated(0) { while (baseStyles[classifications]) { + classifiers.push_back(WordClassifier(baseStyles[classifications])); classifications++; - classifiers.push_back(WordClassifier()); } } @@ -134,6 +141,14 @@ public: return (block >= 0) ? classifiers[block].Length() : 0; } + int BaseStyle(int subStyle) const { + int block = BlockFromStyle(subStyle); + if (block >= 0) + return classifiers[block].Base(); + else + return subStyle; + } + int DistanceToSecondaryStyles() const { return secondaryDistance; } diff --git a/scintilla/lexlib/WordList.cxx b/scintilla/lexlib/WordList.cxx index 6dbc710..d3a3274 100644 --- a/scintilla/lexlib/WordList.cxx +++ b/scintilla/lexlib/WordList.cxx @@ -32,11 +32,11 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa for (int i=0; i<256; i++) {
wordSeparator[i] = false;
}
- wordSeparator['\r'] = true;
- wordSeparator['\n'] = true;
+ wordSeparator[static_cast<unsigned int>('\r')] = true;
+ wordSeparator[static_cast<unsigned int>('\n')] = true;
if (!onlyLineEnds) {
- wordSeparator[' '] = true;
- wordSeparator['\t'] = true;
+ wordSeparator[static_cast<unsigned int>(' ')] = true;
+ wordSeparator[static_cast<unsigned int>('\t')] = true;
}
for (int j = 0; wordlist[j]; j++) {
int curr = static_cast<unsigned char>(wordlist[j]);
@@ -45,22 +45,24 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa prev = curr;
}
char **keywords = new char *[words + 1];
- words = 0;
- prev = '\0';
- size_t slen = strlen(wordlist);
- for (size_t k = 0; k < slen; k++) {
- if (!wordSeparator[static_cast<unsigned char>(wordlist[k])]) {
- if (!prev) {
- keywords[words] = &wordlist[k];
- words++;
+ int wordsStore = 0;
+ const size_t slen = strlen(wordlist);
+ if (words) {
+ prev = '\0';
+ for (size_t k = 0; k < slen; k++) {
+ if (!wordSeparator[static_cast<unsigned char>(wordlist[k])]) {
+ if (!prev) {
+ keywords[wordsStore] = &wordlist[k];
+ wordsStore++;
+ }
+ } else {
+ wordlist[k] = '\0';
}
- } else {
- wordlist[k] = '\0';
+ prev = wordlist[k];
}
- prev = wordlist[k];
}
- keywords[words] = &wordlist[slen];
- *len = words;
+ keywords[wordsStore] = &wordlist[slen];
+ *len = wordsStore;
return keywords;
}
@@ -161,7 +163,7 @@ bool WordList::InList(const char *s) const { j++;
}
}
- j = starts['^'];
+ j = starts[static_cast<unsigned int>('^')];
if (j >= 0) {
while (words[j][0] == '^') {
const char *a = words[j] + 1;
@@ -213,7 +215,7 @@ bool WordList::InListAbbreviated(const char *s, const char marker) const { j++;
}
}
- j = starts['^'];
+ j = starts[static_cast<unsigned int>('^')];
if (j >= 0) {
while (words[j][0] == '^') {
const char *a = words[j] + 1;
diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx index c9e3114..0bfbd2e 100644 --- a/scintilla/src/Catalogue.cxx +++ b/scintilla/src/Catalogue.cxx @@ -161,6 +161,7 @@ int Scintilla_LinkLexers() { //LINK_LEXER(lmR);
//LINK_LEXER(lmREBOL);
LINK_LEXER(lmRuby);
+ //LINK_LEXER(lmRust);
//LINK_LEXER(lmScriptol);
//LINK_LEXER(lmSmalltalk);
//LINK_LEXER(lmSML);
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index 9ee5e32..fd6cb71 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -279,7 +279,7 @@ int SCI_METHOD Document::LineStart(int line) const { }
int SCI_METHOD Document::LineEnd(int line) const {
- if (line == LinesTotal() - 1) {
+ if (line >= LinesTotal() - 1) {
return LineStart(line + 1);
} else {
int position = LineStart(line + 1);
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index a8dcfaf..acb0fa5 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -542,6 +542,9 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, RefreshStyleData();
if (canReturnInvalid) {
PRectangle rcClient = GetTextRectangle();
+ // May be in scroll view coordinates so translate back to main view
+ Point ptOrigin = GetVisibleOriginInMain();
+ rcClient.Move(-ptOrigin.x, -ptOrigin.y);
if (!rcClient.Contains(pt))
return SelectionPosition(INVALID_POSITION);
if (pt.x < vs.textStart)
@@ -720,6 +723,8 @@ void Editor::RedrawSelMargin(int line, bool allAfter) { rcSelMargin.top = rcLine.top;
if (!allAfter)
rcSelMargin.bottom = rcLine.bottom;
+ if (rcSelMargin.Empty())
+ return;
}
if (wMargin.GetID()) {
Point ptOrigin = GetVisibleOriginInMain();
@@ -4409,14 +4414,18 @@ void Editor::DelCharBack(bool allowLineStartDeletion) { ShowCaretAtCurrentPosition();
}
-void Editor::NotifyFocus(bool) {}
+void Editor::NotifyFocus(bool focus) {
+ SCNotification scn = {};
+ scn.nmhdr.code = focus ? SCN_FOCUSIN : SCN_FOCUSOUT;
+ NotifyParent(scn);
+}
void Editor::SetCtrlID(int identifier) {
ctrlID = identifier;
}
void Editor::NotifyStyleToNeeded(int endStyleNeeded) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_STYLENEEDED;
scn.position = endStyleNeeded;
NotifyParent(scn);
@@ -4434,14 +4443,14 @@ void Editor::NotifyErrorOccurred(Document *, void *, int status) { }
void Editor::NotifyChar(int ch) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_CHARADDED;
scn.ch = ch;
NotifyParent(scn);
}
void Editor::NotifySavePoint(bool isSavePoint) {
- SCNotification scn = {0};
+ SCNotification scn = {};
if (isSavePoint) {
scn.nmhdr.code = SCN_SAVEPOINTREACHED;
} else {
@@ -4451,13 +4460,13 @@ void Editor::NotifySavePoint(bool isSavePoint) { }
void Editor::NotifyModifyAttempt() {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_MODIFYATTEMPTRO;
NotifyParent(scn);
}
void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_DOUBLECLICK;
scn.line = LineFromLocation(pt);
scn.position = PositionFromLocation(pt, true);
@@ -4467,7 +4476,7 @@ void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) { }
void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK;
scn.position = position;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
@@ -4476,7 +4485,7 @@ void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, boo }
void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_HOTSPOTCLICK;
scn.position = position;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
@@ -4485,7 +4494,7 @@ void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) }
void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_HOTSPOTRELEASECLICK;
scn.position = position;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
@@ -4495,7 +4504,7 @@ void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool bool Editor::NotifyUpdateUI() {
if (needUpdateUI) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_UPDATEUI;
scn.updated = needUpdateUI;
NotifyParent(scn);
@@ -4506,7 +4515,7 @@ bool Editor::NotifyUpdateUI() { }
void Editor::NotifyPainted() {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_PAINTED;
NotifyParent(scn);
}
@@ -4514,7 +4523,7 @@ void Editor::NotifyPainted() { void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) {
int mask = pdoc->decorations.AllOnFor(position);
if ((click && mask) || pdoc->decorations.clickNotified) {
- SCNotification scn = {0};
+ SCNotification scn = {};
pdoc->decorations.clickNotified = click;
scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0);
@@ -4553,7 +4562,7 @@ bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { }
return true;
}
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_MARGINCLICK;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
(alt ? SCI_ALT : 0);
@@ -4567,7 +4576,7 @@ bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { }
void Editor::NotifyNeedShown(int pos, int len) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_NEEDSHOWN;
scn.position = pos;
scn.length = len;
@@ -4575,7 +4584,7 @@ void Editor::NotifyNeedShown(int pos, int len) { }
void Editor::NotifyDwelling(Point pt, bool state) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND;
scn.position = PositionFromLocation(pt, true);
scn.x = pt.x + vs.ExternalMarginWidth();
@@ -4584,7 +4593,7 @@ void Editor::NotifyDwelling(Point pt, bool state) { }
void Editor::NotifyZoom() {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_ZOOM;
NotifyParent(scn);
}
@@ -4776,7 +4785,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { NotifyChange(); // Send EN_CHANGE
}
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_MODIFIED;
scn.position = mh.position;
scn.modificationType = mh.modificationType;
@@ -4918,7 +4927,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar }
// Send notification
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_MACRORECORD;
scn.message = iMessage;
scn.wParam = wParam;
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx index 53b05a0..f14157f 100644 --- a/scintilla/src/ScintillaBase.cxx +++ b/scintilla/src/ScintillaBase.cxx @@ -289,7 +289,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { void ScintillaBase::AutoCompleteCancel() {
if (ac.Active()) {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_AUTOCCANCELLED;
scn.wParam = 0;
scn.listType = 0;
@@ -325,7 +325,7 @@ void ScintillaBase::AutoCompleteCharacterDeleted() { } else {
AutoCompleteMoveToCurrentWord();
}
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_AUTOCCHARDELETED;
scn.wParam = 0;
scn.listType = 0;
@@ -342,7 +342,7 @@ void ScintillaBase::AutoCompleteCompleted() { ac.Show(false);
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION;
scn.message = 0;
scn.wParam = listType;
@@ -434,7 +434,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) { }
void ScintillaBase::CallTipClick() {
- SCNotification scn = {0};
+ SCNotification scn = {};
scn.nmhdr.code = SCN_CALLTIPCLICK;
scn.position = ct.clickPlace;
NotifyParent(scn);
@@ -503,6 +503,8 @@ public: int AllocateSubStyles(int styleBase, int numberStyles);
int SubStylesStart(int styleBase);
int SubStylesLength(int styleBase);
+ int StyleFromSubStyle(int subStyle);
+ int PrimaryStyleFromStyle(int style);
void FreeSubStyles();
void SetIdentifiers(int style, const char *identifiers);
int DistanceToSecondaryStyles();
@@ -678,6 +680,20 @@ int LexState::SubStylesLength(int styleBase) { return 0;
}
+int LexState::StyleFromSubStyle(int subStyle) {
+ if (instance && (interfaceVersion >= lvSubStyles)) {
+ return static_cast<ILexerWithSubStyles *>(instance)->StyleFromSubStyle(subStyle);
+ }
+ return 0;
+}
+
+int LexState::PrimaryStyleFromStyle(int style) {
+ if (instance && (interfaceVersion >= lvSubStyles)) {
+ return static_cast<ILexerWithSubStyles *>(instance)->PrimaryStyleFromStyle(style);
+ }
+ return 0;
+}
+
void LexState::FreeSubStyles() {
if (instance && (interfaceVersion >= lvSubStyles)) {
static_cast<ILexerWithSubStyles *>(instance)->FreeSubStyles();
@@ -983,6 +999,12 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_GETSUBSTYLESLENGTH:
return DocumentLexState()->SubStylesLength(wParam);
+ case SCI_GETSTYLEFROMSUBSTYLE:
+ return DocumentLexState()->StyleFromSubStyle(wParam);
+
+ case SCI_GETPRIMARYSTYLEFROMSTYLE:
+ return DocumentLexState()->PrimaryStyleFromStyle(wParam);
+
case SCI_FREESUBSTYLES:
DocumentLexState()->FreeSubStyles();
break;
diff --git a/scintilla/src/ScintillaBase.h b/scintilla/src/ScintillaBase.h index 0fc2d4e..25d0dd3 100644 --- a/scintilla/src/ScintillaBase.h +++ b/scintilla/src/ScintillaBase.h @@ -57,7 +57,7 @@ protected: ScintillaBase();
virtual ~ScintillaBase();
virtual void Initialise() = 0;
- virtual void Finalise() = 0;
+ virtual void Finalise();
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void Command(int cmdId);
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index 4ac2b8e..b0723c2 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -324,7 +324,7 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) { }
maxAscent = 1;
maxDescent = 1;
- FindMaxAscentDescent(maxAscent, maxDescent);
+ FindMaxAscentDescent();
maxAscent += extraAscent;
maxDescent += extraDescent;
lineHeight = maxAscent + maxDescent;
@@ -514,7 +514,7 @@ FontRealised *ViewStyle::Find(const FontSpecification &fs) { return 0;
}
-void ViewStyle::FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent) {
+void ViewStyle::FindMaxAscentDescent() {
for (FontMap::const_iterator it = fonts.begin(); it != fonts.end(); ++it) {
if (maxAscent < it->second->ascent)
maxAscent = it->second->ascent;
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h index f795993..3384f11 100644 --- a/scintilla/src/ViewStyle.h +++ b/scintilla/src/ViewStyle.h @@ -180,7 +180,7 @@ private: void AllocStyles(size_t sizeNew);
void CreateFont(const FontSpecification &fs);
FontRealised *Find(const FontSpecification &fs);
- void FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent);
+ void FindMaxAscentDescent();
// Private so can only be copied through copy constructor which ensures font names initialised correctly
ViewStyle &operator=(const ViewStyle &);
};
diff --git a/scintilla/version.txt b/scintilla/version.txt index ebf9bc9..e36c1c5 100644 --- a/scintilla/version.txt +++ b/scintilla/version.txt @@ -1 +1 @@ -335
+336
diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx index 9d45735..2885f0b 100644 --- a/scintilla/win32/PlatWin.cxx +++ b/scintilla/win32/PlatWin.cxx @@ -103,14 +103,14 @@ static BOOL (WINAPI *GetMonitorInfoFn)(HMONITOR, LPMONITORINFO) = 0; static HCURSOR reverseArrowCursor = NULL;
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
bool IsNT() {
return onNT;
}
-#ifdef SCI_NAMESPACE
-using namespace Scintilla;
-#endif
-
Point Point::FromLong(long lpoint) {
return Point(static_cast<short>(LOWORD(lpoint)), static_cast<short>(HIWORD(lpoint)));
}
@@ -212,8 +212,7 @@ struct FormatAndMetrics { };
HFONT FormatAndMetrics::HFont() {
- LOGFONTW lf;
- memset(&lf, 0, sizeof(lf));
+ LOGFONTW lf = {};
#if defined(USE_D2D)
if (technology == SCWIN_TECH_GDI) {
if (0 == ::GetObjectW(hfont, sizeof(lf), &lf)) {
@@ -498,10 +497,6 @@ public: };
typedef VarBuffer<XYPOSITION, stackBufferLength> TextPositions;
-#ifdef SCI_NAMESPACE
-namespace Scintilla {
-#endif
-
class SurfaceGDI : public Surface {
bool unicodeMode;
HDC hdc;
@@ -574,10 +569,6 @@ public: void SetDBCSMode(int codePage_);
};
-#ifdef SCI_NAMESPACE
-} //namespace Scintilla
-#endif
-
SurfaceGDI::SurfaceGDI() :
unicodeMode(false),
hdc(0), hdcOwned(false),
@@ -790,7 +781,7 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil int height = rc.Height();
// Ensure not distorted too much by corners when small
cornerSize = Platform::Minimum(cornerSize, (Platform::Minimum(width, height) / 2) - 2);
- BITMAPINFO bpih = {sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0};
+ BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}};
void *image = 0;
HBITMAP hbmMem = CreateDIBSection(reinterpret_cast<HDC>(hMemDC), &bpih,
DIB_RGB_COLORS, &image, NULL, 0);
@@ -853,7 +844,7 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig rc.top += static_cast<int>((rc.Height() - height) / 2);
rc.bottom = rc.top + height;
- BITMAPINFO bpih = {sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0};
+ BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}};
unsigned char *image = 0;
HBITMAP hbmMem = CreateDIBSection(reinterpret_cast<HDC>(hMemDC), &bpih,
DIB_RGB_COLORS, reinterpret_cast<void **>(&image), NULL, 0);
@@ -1147,10 +1138,6 @@ void SurfaceGDI::SetDBCSMode(int codePage_) { #if defined(USE_D2D)
-#ifdef SCI_NAMESPACE
-namespace Scintilla {
-#endif
-
class SurfaceD2D : public Surface {
bool unicodeMode;
int x, y;
@@ -1230,10 +1217,6 @@ public: void SetDBCSMode(int codePage_);
};
-#ifdef SCI_NAMESPACE
-} //namespace Scintilla
-#endif
-
SurfaceD2D::SurfaceD2D() :
unicodeMode(false),
x(0), y(0) {
@@ -3262,3 +3245,7 @@ void Platform_Finalise() { ListBoxX_Unregister();
::DeleteCriticalSection(&crPlatformLock);
}
+
+#ifdef SCI_NAMESPACE
+}
+#endif
diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index e0da04f..8645316 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -1429,6 +1429,7 @@ void ScintillaWin::NotifyFocus(bool focus) { ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
MAKELONG(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
reinterpret_cast<LPARAM>(MainHWND()));
+ Editor::NotifyFocus(focus);
}
void ScintillaWin::SetCtrlID(int identifier) {
@@ -2283,8 +2284,7 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) { //DWORD dwStart = timeGetTime();
//Platform::DebugPrintf("Scroll %x %d\n", wParam, lParam);
- SCROLLINFO sci;
- memset(&sci, 0, sizeof(sci));
+ SCROLLINFO sci = {};
sci.cbSize = sizeof(sci);
sci.fMask = SIF_ALL;
|