diff options
author | XhmikosR <xhmikosr@gmail.com> | 2015-03-07 12:05:41 +0200 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2015-03-09 08:44:41 +0200 |
commit | 4ac30880a3dd4769bb5f1287e90aa0db9ede212c (patch) | |
tree | 7d237930bb68fc714efc6945eae98ae7df3f6dbe | |
parent | 12949f79fc6487022b0ffea17dd9eadd43d5b1c0 (diff) | |
download | notepad2-mod-4ac30880a3dd4769bb5f1287e90aa0db9ede212c.zip notepad2-mod-4ac30880a3dd4769bb5f1287e90aa0db9ede212c.tar.gz notepad2-mod-4ac30880a3dd4769bb5f1287e90aa0db9ede212c.tar.bz2 |
Update Scintilla to v3.5.4.4.2.25.945
40 files changed, 1609 insertions, 759 deletions
diff --git a/build/makefile.deps.mak b/build/makefile.deps.mak index 02af416..f30ed17 100644 --- a/build/makefile.deps.mak +++ b/build/makefile.deps.mak @@ -481,6 +481,11 @@ $(SCI_SRC_OBJDIR)\XPM.obj: \ #######################
## scintilla\win32 ##
#######################
+$(SCI_WIN_OBJDIR)\HanjaDic.obj: \
+ $(SCI_WIN)\HanjaDic.cxx \
+ $(SCI_WIN)\HanjaDic.h \
+ $(SCI_SRC)\UniConversion.h
+
$(SCI_WIN_OBJDIR)\PlatWin.obj: \
$(SCI_WIN)\PlatWin.cxx \
$(SCI_INC)\Platform.h \
diff --git a/build/makefile.mak b/build/makefile.mak index 78a2dce..e518dad 100644 --- a/build/makefile.mak +++ b/build/makefile.mak @@ -192,6 +192,7 @@ SCI_SRC_OBJ = \ $(SCI_SRC_OBJDIR)\XPM.obj
SCI_WIN_OBJ = \
+ $(SCI_WIN_OBJDIR)\HanjaDic.obj \
$(SCI_WIN_OBJDIR)\PlatWin.obj \
$(SCI_WIN_OBJDIR)\ScintillaWin.obj
diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index 1b2ae0f..c99dea7 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -223,6 +223,7 @@ <ClCompile Include="src\UniConversion.cxx" /> <ClCompile Include="src\ViewStyle.cxx" /> <ClCompile Include="src\XPM.cxx" /> + <ClCompile Include="win32\HanjaDic.cxx" /> <ClCompile Include="win32\PlatWin.cxx" /> <ClCompile Include="win32\ScintillaWin.cxx" /> </ItemGroup> diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters index ee3aaa7..540e09d 100644 --- a/scintilla/Scintilla.vcxproj.filters +++ b/scintilla/Scintilla.vcxproj.filters @@ -213,6 +213,9 @@ <ClCompile Include="src\XPM.cxx"> <Filter>src</Filter> </ClCompile> + <ClCompile Include="win32\HanjaDic.cxx"> + <Filter>win32</Filter> + </ClCompile> <ClCompile Include="win32\PlatWin.cxx"> <Filter>win32</Filter> </ClCompile> @@ -374,6 +377,9 @@ <ClInclude Include="src\XPM.h"> <Filter>src</Filter> </ClInclude> + <ClInclude Include="win32\HanjaDic.h"> + <Filter>win32</Filter> + </ClInclude> <ClInclude Include="win32\PlatWin.h"> <Filter>win32</Filter> </ClInclude> diff --git a/scintilla/doc/ScintillaDoc.html b/scintilla/doc/ScintillaDoc.html index ed66afa..0a91350 100644 --- a/scintilla/doc/ScintillaDoc.html +++ b/scintilla/doc/ScintillaDoc.html @@ -82,7 +82,7 @@ <h1>Scintilla Documentation</h1> - <p>Last edited 10 January 2015 NH</p> + <p>Last edited 22 February 2015 NH</p> <p>There is <a class="jump" href="Design.html">an overview of the internal design of Scintilla</a>.<br /> @@ -585,12 +585,14 @@ struct Sci_TextRange { }; </pre> - <h3 id="EncodedAccess">GTK+-specific: Access to encoded text</h3> + <h3 id="EncodedAccess">Specific to GTK+ and Cocoa only: Access to encoded text</h3> <p><b id="SCI_TARGETASUTF8">SCI_TARGETASUTF8(<unused>, char *s)</b><br /> This method retrieves the value of the target encoded as UTF-8 which is the default encoding of GTK+ so is useful for retrieving text for use in other parts of the user interface, such as find and replace dialogs. The length of the encoded text in bytes is returned. + Cocoa uses UTF-16 which is easily converted from UTF-8 so this method can be used to perform the + more complex work of transcoding from the various of encodings supported. </p> <p><b id="SCI_ENCODEDFROMUTF8">SCI_ENCODEDFROMUTF8(const char *utf8, char *encoded)</b><br /> @@ -635,11 +637,14 @@ struct Sci_TextRange { <a class="message" href="#SCI_GETTARGETSTART">SCI_GETTARGETSTART</a><br /> <a class="message" href="#SCI_SETTARGETEND">SCI_SETTARGETEND(int pos)</a><br /> <a class="message" href="#SCI_GETTARGETEND">SCI_GETTARGETEND</a><br /> + <a class="message" href="#SCI_SETTARGETRANGE">SCI_SETTARGETRANGE(int start, int end)</a><br /> <a class="message" href="#SCI_TARGETFROMSELECTION">SCI_TARGETFROMSELECTION</a><br /> <a class="message" href="#SCI_SETSEARCHFLAGS">SCI_SETSEARCHFLAGS(int searchFlags)</a><br /> <a class="message" href="#SCI_GETSEARCHFLAGS">SCI_GETSEARCHFLAGS</a><br /> <a class="message" href="#SCI_SEARCHINTARGET">SCI_SEARCHINTARGET(int length, const char *text)</a><br /> + <a class="message" href="#SCI_GETTARGETTEXT">SCI_GETTARGETTEXT(<unused>, + char *text)</a><br /> <a class="message" href="#SCI_REPLACETARGET">SCI_REPLACETARGET(int length, const char *text)</a><br /> <a class="message" href="#SCI_REPLACETARGETRE">SCI_REPLACETARGETRE(int length, const char @@ -651,6 +656,7 @@ struct Sci_TextRange { <b id="SCI_GETTARGETSTART">SCI_GETTARGETSTART</b><br /> <b id="SCI_SETTARGETEND">SCI_SETTARGETEND(int pos)</b><br /> <b id="SCI_GETTARGETEND">SCI_GETTARGETEND</b><br /> + <b id="SCI_SETTARGETRANGE">SCI_SETTARGETRANGE(int start, int end)</b><br /> These functions set and return the start and end of the target. When searching you can set start greater than end to find the last matching text in the target rather than the first matching text. The target is also set by a successful @@ -673,6 +679,9 @@ struct Sci_TextRange { text and the return value is the position of the start of the matching text. If the search fails, the result is -1.</p> + <p><b id="SCI_GETTARGETTEXT">SCI_GETTARGETTEXT(<unused>, char *text)</b><br /> + Retrieve the value in the target.</p> + <p><b id="SCI_REPLACETARGET">SCI_REPLACETARGET(int length, const char *text)</b><br /> If <code>length</code> is -1, <code>text</code> is a zero terminated string, otherwise <code>length</code> sets the number of character to replace the target with. @@ -3900,8 +3909,12 @@ struct Sci_TextToFind { They can be used to show, for example, syntax errors, deprecated names and bad indentation by drawing underlines under text or boxes around text.</p> + <p>Indicators may have a different "hover" colour and style when the mouse is over them or the caret is moved into them. + This may be used, for example, to indicate that a URL can be clicked.</p> + <p>Indicators may be displayed as simple underlines, squiggly underlines, a - line of small 'T' shapes, a line of diagonal hatching, a strike-out or a rectangle around the text.</p> + line of small 'T' shapes, a line of diagonal hatching, a strike-out or a rectangle around the text. + They may also be invisible when used to track pieces of content for the application as <code>INDIC_HIDDEN</code>.</p> <p>The <code>SCI_INDIC*</code> messages allow you to get and set the visual appearance of the indicators. They all use an <code>indicatorNumber</code> argument in the range 0 to INDIC_MAX(35) @@ -3910,6 +3923,11 @@ struct Sci_TextToFind { (8=<code>INDIC_CONTAINER</code> .. 31=<code>INDIC_IME-1</code>) and a range for IME indicators (32=<code>INDIC_IME</code> .. 35=<code>INDIC_IME_MAX</code>).</p> + <p>Indicators are stored in a format similar to run length encoding which is efficient in both + speed and storage for sparse information.</p> + <p>An indicator may store different values for each range but currently all values are drawn the same. + In the future, it may be possible to draw different values in different styles.</p> + <p>Originally, Scintilla used a different technique for indicators but this has been <a href="#RemovedFeatures">removed</a> and the APIs perform <a href="#StyleByteIndicators">no action</a>. @@ -3928,6 +3946,15 @@ struct Sci_TextToFind { <a class="message" href="#SCI_INDICGETOUTLINEALPHA">SCI_INDICGETOUTLINEALPHA(int indicatorNumber)</a><br /> <a class="message" href="#SCI_INDICSETUNDER">SCI_INDICSETUNDER(int indicatorNumber, bool under)</a><br /> <a class="message" href="#SCI_INDICGETUNDER">SCI_INDICGETUNDER(int indicatorNumber)</a><br /> + <a class="message" href="#SCI_INDICSETHOVERSTYLE">SCI_INDICSETHOVERSTYLE(int indicatorNumber, int + indicatorStyle)</a><br /> + <a class="message" href="#SCI_INDICGETHOVERSTYLE">SCI_INDICGETHOVERSTYLE(int indicatorNumber)</a><br /> + <a class="message" href="#SCI_INDICSETHOVERFORE">SCI_INDICSETHOVERFORE(int indicatorNumber, int + colour)</a><br /> + <a class="message" href="#SCI_INDICGETHOVERFORE">SCI_INDICGETHOVERFORE(int indicatorNumber)</a><br /> + <a class="message" href="#SCI_INDICSETFLAGS">SCI_INDICSETFLAGS(int indicatorNumber, int flags)</a><br /> + <a class="message" href="#SCI_INDICGETFLAGS">SCI_INDICGETFLAGS(int indicatorNumber)</a><br /> + <br /> <a class="message" href="#SCI_SETINDICATORCURRENT">SCI_SETINDICATORCURRENT(int indicator)</a><br /> <a class="message" href="#SCI_GETINDICATORCURRENT">SCI_GETINDICATORCURRENT</a><br /> @@ -4042,7 +4069,18 @@ struct Sci_TextToFind { interior usually more transparent than the border. You can use <a class="message" href="#SCI_INDICSETALPHA">SCI_INDICSETALPHA</a> and <a class="message" href="#SCI_INDICSETOUTLINEALPHA">SCI_INDICSETOUTLINEALPHA</a> - to control the alpha transparency values. The default alpha values are 30 for fill colour and 50 for outline colour.</td> + to control the alpha transparency values. The default alpha values are 30 for fill colour and 50 for outline colour. + This indicator does not colour the top pixel of the line so that indicators on contiguous lines are visually distinct + and disconnected.</td> + </tr> + + <tr> + <td align="left"><code>INDIC_FULLBOX</code></td> + + <td align="center">16</td> + + <td>A rectangle around the text using translucent drawing similar to <code>INDIC_STRAIGHTBOX</code> + but covering the entire character area.</td> </tr> <tr> @@ -4101,7 +4139,25 @@ struct Sci_TextToFind { <td>A 2-pixel thick underline located at the bottom of the line to try to avoid touching the character base. Each side is inset 1 pixel so that different indicators in this style covering a range appear isolated. - This is similar to an appearance used for Asian language input composition.</td> + This is similar to an appearance used for the target in Asian language input composition.</td> + </tr> + + <tr> + <td align="left"><code>INDIC_COMPOSITIONTHIN</code></td> + + <td align="center">15</td> + + <td>A 1-pixel thick underline located just before the bottom of the line. + Each side is inset 1 pixel so that different indicators in this style covering a range appear isolated. + This is similar to an appearance used for non-target ranges in Asian language input composition.</td> + </tr> + + <tr> + <td align="left"><code>INDIC_TEXTFORE</code></td> + + <td align="center">17</td> + + <td>Change the colour of the text to the indicator's fore colour.</td> </tr> </tbody> @@ -4140,10 +4196,29 @@ struct Sci_TextToFind { Drawing under text works only for indicators when <a class="message" href="#SCI_SETTWOPHASEDRAW">two phase drawing</a> is enabled.</p> - <p>Indicators are stored in a format similar to run length encoding which is efficient in both - speed and storage for sparse information.</p> - <p>An indicator may store different values for each range but currently all values are drawn the same. - In the future, it may be possible to draw different values in different styles.</p> + <p><b id="SCI_INDICSETHOVERSTYLE">SCI_INDICSETHOVERSTYLE(int indicatorNumber, int + indicatorStyle)</b><br /> + <b id="SCI_INDICGETHOVERSTYLE">SCI_INDICGETHOVERSTYLE(int indicatorNumber)</b><br /> + <b id="SCI_INDICSETHOVERFORE">SCI_INDICSETHOVERFORE(int indicatorNumber, int <a class="jump" href="#colour">colour</a>)</b><br /> + <b id="SCI_INDICGETHOVERFORE">SCI_INDICGETHOVERFORE(int indicatorNumber)</b><br /> + These messages set and get the colour and style used to draw indicators when the mouse is over them or the caret moved into them. + The mouse cursor also changes when an indicator is drawn in hover style. + The default is for the hover appearance to be the same as the normal appearance and calling + <a class="message" href="#SCI_INDICSETFORE">SCI_INDICSETFORE</a> or + <a class="message" href="#SCI_INDICSETSTYLE">SCI_INDICSETSTYLE</a> will + also reset the hover attribute.</p> + + <p><b id="SCI_INDICSETFLAGS">SCI_INDICSETFLAGS(int indicatorNumber, int flags)</b><br /> + <b id="SCI_INDICGETFLAGS">SCI_INDICGETFLAGS(int indicatorNumber)</b><br /> + These messages set and get the flags associated with an indicator. + There is currently one flag defined, <code>SC_INDICFLAG_VALUEFORE</code>: when this flag is set + the colour used by the indicator is not from the indicator's fore setting but instead from the value of the indicator at + that point in the file. This allows many colours to be displayed for a single indicator. The value is an <a class="jump" + href="#colour">RGB integer colour</a> that has been ored with <code>SC_INDICVALUEBIT</code>(0x1000000) + when calling <a class="message" href="#SCI_SETINDICATORVALUE">SCI_SETINDICATORVALUE</a>. + To find the colour from the value, and the value with <code>SC_INDICVALUEMASK<code>(0xFFFFFF). + </p> + <p> <b id="SCI_SETINDICATORCURRENT">SCI_SETINDICATORCURRENT(int indicator)</b><br /> <b id="SCI_GETINDICATORCURRENT">SCI_GETINDICATORCURRENT</b><br /> diff --git a/scintilla/doc/ScintillaDownload.html b/scintilla/doc/ScintillaDownload.html index c272a48..2fdcf00 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/scintilla353.zip?download">
+ <font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla354.zip?download">
Windows</a>
- <a href="http://prdownloads.sourceforge.net/scintilla/scintilla353.tgz?download">
+ <a href="http://prdownloads.sourceforge.net/scintilla/scintilla354.tgz?download">
GTK+/Linux</a>
</font>
</td>
@@ -41,7 +41,7 @@ containing very few restrictions.
</p>
<h3>
- Release 3.5.3
+ Release 3.5.4
</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/scintilla353.zip?download">zip format</a> (1450K) commonly used on Windows</li>
- <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla353.tgz?download">tgz format</a> (1300K) commonly used on Linux and compatible operating systems</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla354.zip?download">zip format</a> (1450K) commonly used on Windows</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla354.tgz?download">tgz format</a> (1300K) 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 4360b28..9705e5a 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -465,6 +465,10 @@ <td>Yusuf Ramazan Karagöz</td>
<td>Markus Heidelberg</td>
<td>Joe Mueller</td>
+ </tr><tr>
+ <td>Mika Attila</td>
+ <td>JoMazM</td>
+ <td>Markus Moser</td>
</tr>
</table>
<p>
@@ -477,6 +481,84 @@ </li>
</ul>
<h3>
+ <a href="http://prdownloads.sourceforge.net/scintilla/scite354.zip?download">Release 3.5.4</a>
+ </h3>
+ <ul>
+ <li>
+ Released 8 March 2015.
+ </li>
+ <li>
+ Indicators may have a different colour and style when the mouse is over them or the caret is moved into them.
+ </li>
+ <li>
+ An indicator may display in a large variety of colours with the SC_INDICFLAG_VALUEFORE
+ flag taking the colour from the indicator's value, which may differ for every character, instead of its
+ foreground colour attribute.
+ </li>
+ <li>
+ On Cocoa, additional IME methods implemented so that more commands are enabled.
+ For Japanese: Reverse Conversion, Convert to Related Character, and Search Similar Kanji
+ can now be performed.
+ The global definition hotkey Command+Control+D and the equivalent three finger tap gesture
+ can be used.
+ </li>
+ <li>
+ Minimum version of Qt supported is now 4.8 due to the use of QElapsedTimer::nsecsElapsed.
+ </li>
+ <li>
+ On Windows, for Korean, the VK_HANJA key is implemented to choose Hanja for Hangul and
+ to convert from Hanja to Hangul.
+ </li>
+ <li>
+ C++ lexer adds lexer.cpp.verbatim.strings.allow.escapes option that allows verbatim (@") strings
+ to contain escape sequences. This should remain off (0) for C# and be turned on (1) for Objective C.
+ </li>
+ <li>
+ Rust lexer accepts new 'is'/'us' integer suffixes instead of 'i'/'u'.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1098/">Bug #1098</a>.
+ </li>
+ <li>
+ Ruby folder can fold multiline comments.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1697/">Bug #1697</a>.
+ </li>
+ <li>
+ SQL lexer fixes a bug with the q-quote operator.
+ </li>
+ <li>
+ TCL lexer fixes a bug with some strings.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1642/">Bug #1642</a>.
+ </li>
+ <li>
+ Verilog lexer handles escaped identifiers that begin with \ and end with space like \reset* .
+ Verilog folder fixes one bug with inconsistent folding when fold.comment is on and another
+ with typedef class statements creating a fold point, expecting an endclass statement.
+ </li>
+ <li>
+ VHDL folder fixes hang in folding when document starts with "entity".
+ </li>
+ <li>
+ Add new indicators INDIC_COMPOSITIONTHIN, INDIC_FULLBOX, and INDIC_TEXTFORE.
+ INDIC_COMPOSITIONTHIN is a thin underline that mimics the appearance of non-target segments in OS X IME.
+ INDIC_FULLBOX is similar to INDIC_STRAIGHTBOX but covers the entire character area which means that
+ indicators with this style on contiguous lines may touch. INDIC_TEXTFORE changes the text foreground colour.
+ </li>
+ <li>
+ Fix adaptive scrolling speed for GTK+ on OS X with GTK Quartz backend (as opposed to X11 backend).
+ <a href="http://sourceforge.net/p/scintilla/bugs/1696/">Bug #1696</a>.
+ </li>
+ <li>
+ Fix crash in SciTE when saving large files in background when closing application.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1691/">Bug #1691</a>.
+ </li>
+ <li>
+ Fix decoding of MSVC warnings in SciTE so that files in the C:\Program Files (x86)\ directory can be opened.
+ This is a common location of system include files.
+ </li>
+ <li>
+ Fix compilation failure of C++11 <regex> on Windows using gcc.
+ </li>
+ </ul>
+ <h3>
<a href="http://prdownloads.sourceforge.net/scintilla/scite353.zip?download">Release 3.5.3</a>
</h3>
<ul>
diff --git a/scintilla/doc/index.html b/scintilla/doc/index.html index 900b1b6..fbe80e6 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="20150120" />
+ <meta name="Date.Modified" content="20150308" />
<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.5.3<br />
- Site last modified January 20 2015</font>
+ <font color="#FFCC99" size="3"> Release version 3.5.4<br />
+ Site last modified March 8 2015</font>
</td>
<td width="20%">
@@ -71,6 +71,7 @@ </tr>
</table>
<ul id="versionlist">
+ <li>Version 3.5.4 improves indicators to be able to change appearance on mouse-over and to use a wide variety of colours together.</li>
<li>Version 3.5.3 removes support for Windows 95, 98, and ME.</li>
<li>Version 3.5.2 only supports 64-bit builds for OS X 10.7+ Cocoa. Provisional support of C++11 <regex>.</li>
<li>Version 3.5.1 fixes minor bugs and includes a lexer for BibTeX.</li>
diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index 3abc72b..6179122 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -274,6 +274,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_DOTBOX 12
#define INDIC_SQUIGGLEPIXMAP 13
#define INDIC_COMPOSITIONTHICK 14
+#define INDIC_COMPOSITIONTHIN 15
+#define INDIC_FULLBOX 16
+#define INDIC_TEXTFORE 17
#define INDIC_IME 32
#define INDIC_IME_MAX 35
#define INDIC_MAX 35
@@ -288,6 +291,15 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_INDICGETFORE 2083
#define SCI_INDICSETUNDER 2510
#define SCI_INDICGETUNDER 2511
+#define SCI_INDICSETHOVERSTYLE 2680
+#define SCI_INDICGETHOVERSTYLE 2681
+#define SCI_INDICSETHOVERFORE 2682
+#define SCI_INDICGETHOVERFORE 2683
+#define SC_INDICVALUEBIT 0x1000000
+#define SC_INDICVALUEMASK 0xFFFFFF
+#define SC_INDICFLAG_VALUEFORE 1
+#define SCI_INDICSETFLAGS 2684
+#define SCI_INDICGETFLAGS 2685
#define SCI_SETWHITESPACEFORE 2084
#define SCI_SETWHITESPACEBACK 2085
#define SCI_SETWHITESPACESIZE 2086
@@ -420,6 +432,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETTARGETSTART 2191
#define SCI_SETTARGETEND 2192
#define SCI_GETTARGETEND 2193
+#define SCI_SETTARGETRANGE 2686
+#define SCI_GETTARGETTEXT 2687
#define SCI_REPLACETARGET 2194
#define SCI_REPLACETARGETRE 2195
#define SCI_SEARCHINTARGET 2197
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index d300ba6..adc6d3e 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -605,6 +605,9 @@ val INDIC_SQUIGGLELOW=11 val INDIC_DOTBOX=12
val INDIC_SQUIGGLEPIXMAP=13
val INDIC_COMPOSITIONTHICK=14
+val INDIC_COMPOSITIONTHIN=15
+val INDIC_FULLBOX=16
+val INDIC_TEXTFORE=17
val INDIC_IME=32
val INDIC_IME_MAX=35
val INDIC_MAX=35
@@ -632,6 +635,30 @@ set void IndicSetUnder=2510(int indic, bool under) # Retrieve whether indicator drawn under or over text.
get bool IndicGetUnder=2511(int indic,)
+# Set a hover indicator to plain, squiggle or TT.
+set void IndicSetHoverStyle=2680(int indic, int style)
+
+# Retrieve the hover style of an indicator.
+get int IndicGetHoverStyle=2681(int indic,)
+
+# Set the foreground hover colour of an indicator.
+set void IndicSetHoverFore=2682(int indic, colour fore)
+
+# Retrieve the foreground hover colour of an indicator.
+get colour IndicGetHoverFore=2683(int indic,)
+
+val SC_INDICVALUEBIT=0x1000000
+val SC_INDICVALUEMASK=0xFFFFFF
+
+enu IndicFlag=SC_INDICFLAG_
+val SC_INDICFLAG_VALUEFORE=1
+
+# Set the attributes of an indicator.
+set void IndicSetFlags=2684(int indic, int flags)
+
+# Retrieve the attributes of an indicator.
+get int IndicGetFlags=2685(int indic,)
+
# Set the foreground colour of all whitespace and whether to use this setting.
fun void SetWhitespaceFore=2084(bool useSetting, colour fore)
@@ -1032,6 +1059,12 @@ set void SetTargetEnd=2192(position pos,) # Get the position that ends the target.
get position GetTargetEnd=2193(,)
+# Sets both the start and end of the target in one call.
+fun void SetTargetRange=2686(position start, position end)
+
+# Retrieve the text in the target.
+get int GetTargetText=2687(, stringresult characters)
+
# Replace the target text with the argument text.
# Text is counted so it can contain NULs.
# Returns the length of the replacement text.
diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx index a78fcc0..ab982bb 100644 --- a/scintilla/lexers/LexCPP.cxx +++ b/scintilla/lexers/LexCPP.cxx @@ -306,6 +306,7 @@ struct OptionsCPP { bool identifiersAllowDollars; bool trackPreprocessor; bool updatePreprocessor; + bool verbatimStringsAllowEscapes; bool triplequotedStrings; bool hashquotedStrings; bool backQuotedStrings; @@ -326,6 +327,7 @@ struct OptionsCPP { identifiersAllowDollars = true; trackPreprocessor = true; updatePreprocessor = true; + verbatimStringsAllowEscapes = false; triplequotedStrings = false; hashquotedStrings = false; backQuotedStrings = false; @@ -370,6 +372,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> { DefineProperty("lexer.cpp.update.preprocessor", &OptionsCPP::updatePreprocessor, "Set to 1 to update preprocessor definitions when #define found."); + DefineProperty("lexer.cpp.verbatim.strings.allow.escapes", &OptionsCPP::verbatimStringsAllowEscapes, + "Set to 1 to allow verbatim strings to contain escape sequences."); + DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings, "Set to 1 to enable highlighting of triple-quoted strings."); @@ -1036,7 +1041,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, } break; case SCE_C_VERBATIM: - if (sc.ch == '\"') { + if (options.verbatimStringsAllowEscapes && (sc.ch == '\\')) { + sc.Forward(); // Skip all characters after the backslash + } else if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); } else { diff --git a/scintilla/lexers/LexRuby.cxx b/scintilla/lexers/LexRuby.cxx index bb45c75..7918d4b 100644 --- a/scintilla/lexers/LexRuby.cxx +++ b/scintilla/lexers/LexRuby.cxx @@ -29,7 +29,7 @@ using namespace Scintilla; //XXX Identical to Perl, put in common area
static inline bool isEOLChar(char ch) {
- return (ch == '\r') || (ch == '\n');
+ return (ch == '\r') || (ch == '\n');
}
#define isSafeASCII(ch) ((unsigned int)(ch) <= 127)
@@ -60,7 +60,7 @@ static inline bool isSafeWordcharOrHigh(char ch) { }
static bool inline iswhitespace(char ch) {
- return ch == ' ' || ch == '\t';
+ return ch == ' ' || ch == '\t';
}
#define MAX_KEYWORD_LENGTH 200
@@ -74,20 +74,20 @@ static bool followsDot(unsigned int pos, Accessor &styler) { int style = actual_style(styler.StyleAt(pos));
char ch;
switch (style) {
- case SCE_RB_DEFAULT:
- ch = styler[pos];
- if (ch == ' ' || ch == '\t') {
- //continue
- } else {
- return false;
- }
- break;
+ case SCE_RB_DEFAULT:
+ ch = styler[pos];
+ if (ch == ' ' || ch == '\t') {
+ //continue
+ } else {
+ return false;
+ }
+ break;
- case SCE_RB_OPERATOR:
- return styler[pos] == '.';
+ case SCE_RB_OPERATOR:
+ return styler[pos] == '.';
- default:
- return false;
+ default:
+ return false;
}
}
return false;
@@ -102,26 +102,26 @@ static bool keywordIsModifier(const char *word, Accessor &styler);
static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
- char s[MAX_KEYWORD_LENGTH];
+ char s[MAX_KEYWORD_LENGTH];
unsigned int i, j;
- unsigned int lim = end - start + 1; // num chars to copy
- if (lim >= MAX_KEYWORD_LENGTH) {
- lim = MAX_KEYWORD_LENGTH - 1;
- }
- for (i = start, j = 0; j < lim; i++, j++) {
- s[j] = styler[i];
- }
+ unsigned int lim = end - start + 1; // num chars to copy
+ if (lim >= MAX_KEYWORD_LENGTH) {
+ lim = MAX_KEYWORD_LENGTH - 1;
+ }
+ for (i = start, j = 0; j < lim; i++, j++) {
+ s[j] = styler[i];
+ }
s[j] = '\0';
- int chAttr;
- if (0 == strcmp(prevWord, "class"))
- chAttr = SCE_RB_CLASSNAME;
- else if (0 == strcmp(prevWord, "module"))
- chAttr = SCE_RB_MODULE_NAME;
- else if (0 == strcmp(prevWord, "def"))
- chAttr = SCE_RB_DEFNAME;
+ int chAttr;
+ if (0 == strcmp(prevWord, "class"))
+ chAttr = SCE_RB_CLASSNAME;
+ else if (0 == strcmp(prevWord, "module"))
+ chAttr = SCE_RB_MODULE_NAME;
+ else if (0 == strcmp(prevWord, "def"))
+ chAttr = SCE_RB_DEFNAME;
else if (keywords.InList(s) && ((start == 0) || !followsDot(start - 1, styler))) {
if (keywordIsAmbiguous(s)
- && keywordIsModifier(s, start, styler)) {
+ && keywordIsModifier(s, start, styler)) {
// Demoted keywords are colored as keywords,
// but do not affect changes in indentation.
@@ -136,37 +136,37 @@ static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywor } else {
chAttr = SCE_RB_WORD;
}
- } else
+ } else
chAttr = SCE_RB_IDENTIFIER;
- styler.ColourTo(end, chAttr);
- if (chAttr == SCE_RB_WORD) {
- strcpy(prevWord, s);
- } else {
- prevWord[0] = 0;
- }
+ styler.ColourTo(end, chAttr);
+ if (chAttr == SCE_RB_WORD) {
+ strcpy(prevWord, s);
+ } else {
+ prevWord[0] = 0;
+ }
return chAttr;
}
//XXX Identical to Perl, put in common area
static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
- if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
- return false;
- }
- while (*val) {
- if (*val != styler[pos++]) {
- return false;
- }
- val++;
- }
- return true;
+ if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
+ return false;
+ }
+ while (*val) {
+ if (*val != styler[pos++]) {
+ return false;
+ }
+ val++;
+ }
+ return true;
}
// Do Ruby better -- find the end of the line, work back,
// and then check for leading white space
// Precondition: the here-doc target can be indented
-static bool lookingAtHereDocDelim(Accessor &styler,
+static bool lookingAtHereDocDelim(Accessor &styler,
int pos,
int lengthDoc,
const char *HereDocDelim)
@@ -187,15 +187,15 @@ static bool lookingAtHereDocDelim(Accessor &styler, //XXX Identical to Perl, put in common area
static char opposite(char ch) {
- if (ch == '(')
- return ')';
- if (ch == '[')
- return ']';
- if (ch == '{')
- return '}';
- if (ch == '<')
- return '>';
- return ch;
+ if (ch == '(')
+ return ')';
+ if (ch == '[')
+ return ']';
+ if (ch == '{')
+ return '}';
+ if (ch == '<')
+ return '>';
+ return ch;
}
// Null transitions when we see we've reached the end
@@ -216,7 +216,7 @@ static void advance_char(int &i, char &ch, char &chNext, char &chNext2) { }
// precondition: startPos points to one after the EOL char
-static bool currLineContainsHereDelims(int& startPos,
+static bool currLineContainsHereDelims(int &startPos,
Accessor &styler) {
if (startPos <= 1)
return false;
@@ -249,7 +249,7 @@ static bool currLineContainsHereDelims(int& startPos, // to be hoisted out of the function.
class QuoteCls {
- public:
+public:
int Count;
char Up;
char Down;
@@ -266,19 +266,19 @@ class QuoteCls { Up = u;
Down = opposite(Up);
}
- QuoteCls(const QuoteCls& q) {
+ QuoteCls(const QuoteCls &q) {
// copy constructor -- use this for copying in
Count = q.Count;
Up = q.Up;
Down = q.Down;
}
- QuoteCls& operator=(const QuoteCls& q) { // assignment constructor
+ QuoteCls &operator=(const QuoteCls &q) { // assignment constructor
if (this != &q) {
Count = q.Count;
Up = q.Up;
Down = q.Down;
}
- return *this;
+ return *this;
}
};
@@ -287,11 +287,11 @@ class QuoteCls { static void enterInnerExpression(int *p_inner_string_types,
int *p_inner_expn_brace_counts,
QuoteCls *p_inner_quotes,
- int& inner_string_count,
- int& state,
- int& brace_counts,
+ int &inner_string_count,
+ int &state,
+ int &brace_counts,
QuoteCls curr_quote
- ) {
+ ) {
p_inner_string_types[inner_string_count] = state;
state = SCE_RB_DEFAULT;
p_inner_expn_brace_counts[inner_string_count] = brace_counts;
@@ -301,13 +301,13 @@ static void enterInnerExpression(int *p_inner_string_types, }
static void exitInnerExpression(int *p_inner_string_types,
- int *p_inner_expn_brace_counts,
- QuoteCls *p_inner_quotes,
- int& inner_string_count,
- int& state,
- int& brace_counts,
- QuoteCls& curr_quote
- ) {
+ int *p_inner_expn_brace_counts,
+ QuoteCls *p_inner_quotes,
+ int &inner_string_count,
+ int &state,
+ int &brace_counts,
+ QuoteCls &curr_quote
+ ) {
--inner_string_count;
state = p_inner_string_types[inner_string_count];
brace_counts = p_inner_expn_brace_counts[inner_string_count];
@@ -316,28 +316,28 @@ static void exitInnerExpression(int *p_inner_string_types, static bool isEmptyLine(int pos,
Accessor &styler) {
- int spaceFlags = 0;
- int lineCurrent = styler.GetLine(pos);
- int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
+ int spaceFlags = 0;
+ int lineCurrent = styler.GetLine(pos);
+ int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
return (indentCurrent & SC_FOLDLEVELWHITEFLAG) != 0;
}
static bool RE_CanFollowKeyword(const char *keyword) {
if (!strcmp(keyword, "and")
- || !strcmp(keyword, "begin")
- || !strcmp(keyword, "break")
- || !strcmp(keyword, "case")
- || !strcmp(keyword, "do")
- || !strcmp(keyword, "else")
- || !strcmp(keyword, "elsif")
- || !strcmp(keyword, "if")
- || !strcmp(keyword, "next")
- || !strcmp(keyword, "return")
- || !strcmp(keyword, "when")
- || !strcmp(keyword, "unless")
- || !strcmp(keyword, "until")
- || !strcmp(keyword, "not")
- || !strcmp(keyword, "or")) {
+ || !strcmp(keyword, "begin")
+ || !strcmp(keyword, "break")
+ || !strcmp(keyword, "case")
+ || !strcmp(keyword, "do")
+ || !strcmp(keyword, "else")
+ || !strcmp(keyword, "elsif")
+ || !strcmp(keyword, "if")
+ || !strcmp(keyword, "next")
+ || !strcmp(keyword, "return")
+ || !strcmp(keyword, "when")
+ || !strcmp(keyword, "unless")
+ || !strcmp(keyword, "until")
+ || !strcmp(keyword, "not")
+ || !strcmp(keyword, "or")) {
return true;
}
return false;
@@ -347,8 +347,8 @@ static bool RE_CanFollowKeyword(const char *keyword) { // Don't look at styles in case we're looking forward
static int skipWhitespace(int startPos,
- int endPos,
- Accessor &styler) {
+ int endPos,
+ Accessor &styler) {
for (int i = startPos; i < endPos; i++) {
if (!iswhitespace(styler[i])) {
return i;
@@ -378,8 +378,8 @@ static bool sureThisIsHeredoc(int iPrev, int firstWordPosn = skipWhitespace(lineStartPosn, iPrev, styler);
if (firstWordPosn >= iPrev) {
// Have something like {^ <<}
- //XXX Look at the first previous non-comment non-white line
- // to establish the context. Not too likely though.
+ //XXX Look at the first previous non-comment non-white line
+ // to establish the context. Not too likely though.
return true;
} else {
switch (prevStyle = styler.StyleAt(firstWordPosn)) {
@@ -395,7 +395,7 @@ static bool sureThisIsHeredoc(int iPrev, char *dst = prevWord;
for (;;) {
if (firstWordEndPosn >= iPrev ||
- styler.StyleAt(firstWordEndPosn) != prevStyle) {
+ styler.StyleAt(firstWordEndPosn) != prevStyle) {
*dst = 0;
break;
}
@@ -404,8 +404,8 @@ static bool sureThisIsHeredoc(int iPrev, }
//XXX Write a style-aware thing to regex scintilla buffer objects
if (!strcmp(prevWord, "undef")
- || !strcmp(prevWord, "def")
- || !strcmp(prevWord, "alias")) {
+ || !strcmp(prevWord, "def")
+ || !strcmp(prevWord, "alias")) {
// These keywords are what we were looking for
return false;
}
@@ -424,8 +424,8 @@ static bool haveTargetMatch(int currPos, }
int i, j;
for (i = targetStartPos, j = currPos;
- i < targetEndPos && j < lengthDoc;
- i++, j++) {
+ i < targetEndPos && j < lengthDoc;
+ i++, j++) {
if (styler[i] != styler[j]) {
return false;
}
@@ -450,7 +450,7 @@ static bool haveTargetMatch(int currPos, static bool sureThisIsNotHeredoc(int lt2StartPos,
Accessor &styler) {
int prevStyle;
- // Use full document, not just part we're styling
+ // Use full document, not just part we're styling
int lengthDoc = styler.Length();
int lineStart = styler.GetLine(lt2StartPos);
int lineStartPosn = styler.LineStart(lineStart);
@@ -466,8 +466,8 @@ static bool sureThisIsNotHeredoc(int lt2StartPos, prevStyle = styler.StyleAt(firstWordPosn);
// If we have '<<' following a keyword, it's not a heredoc
if (prevStyle != SCE_RB_IDENTIFIER
- && prevStyle != SCE_RB_INSTANCE_VAR
- && prevStyle != SCE_RB_CLASS_VAR) {
+ && prevStyle != SCE_RB_INSTANCE_VAR
+ && prevStyle != SCE_RB_CLASS_VAR) {
return definitely_not_a_here_doc;
}
int newStyle = prevStyle;
@@ -508,7 +508,7 @@ static bool sureThisIsNotHeredoc(int lt2StartPos, return definitely_not_a_here_doc;
}
// OK, now 'j' will point to the current spot moving ahead
- int j = firstWordPosn + 1;
+ int j = firstWordPosn + 1;
if (styler.StyleAt(j) != SCE_RB_OPERATOR || styler[j] != '<') {
// This shouldn't happen
return definitely_not_a_here_doc;
@@ -560,10 +560,10 @@ static bool sureThisIsNotHeredoc(int lt2StartPos, // don't handle arbitrary expressions yet
target_end = j;
- if (target_quote) {
- // Now we can move to the character after the string delimiter.
- j += 1;
- }
+ if (target_quote) {
+ // Now we can move to the character after the string delimiter.
+ j += 1;
+ }
j = skipWhitespace(j, lengthDoc, styler);
if (j >= lengthDoc) {
return definitely_not_a_here_doc;
@@ -604,7 +604,7 @@ static bool sureThisIsNotHeredoc(int lt2StartPos, // move to the start of the first line that is not in a
// multi-line construct
-static void synchronizeDocStart(unsigned int& startPos,
+static void synchronizeDocStart(unsigned int &startPos,
int &length,
int &initStyle,
Accessor &styler,
@@ -613,11 +613,11 @@ static void synchronizeDocStart(unsigned int& startPos, styler.Flush();
int style = actual_style(styler.StyleAt(startPos));
switch (style) {
- case SCE_RB_STDIN:
- case SCE_RB_STDOUT:
- case SCE_RB_STDERR:
- // Don't do anything else with these.
- return;
+ case SCE_RB_STDIN:
+ case SCE_RB_STDOUT:
+ case SCE_RB_STDERR:
+ // Don't do anything else with these.
+ return;
}
int pos = startPos;
@@ -655,66 +655,67 @@ static void synchronizeDocStart(unsigned int& startPos, }
static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) {
- // Lexer for Ruby often has to backtrack to start of current style to determine
- // which characters are being used as quotes, how deeply nested is the
- // start position and what the termination string is for here documents
+ // Lexer for Ruby often has to backtrack to start of current style to determine
+ // which characters are being used as quotes, how deeply nested is the
+ // start position and what the termination string is for here documents
- WordList &keywords = *keywordlists[0];
+ WordList &keywords = *keywordlists[0];
- class HereDocCls {
- public:
- int State;
+ class HereDocCls {
+ public:
+ int State;
// States
// 0: '<<' encountered
- // 1: collect the delimiter
+ // 1: collect the delimiter
// 1b: text between the end of the delimiter and the EOL
- // 2: here doc text (lines after the delimiter)
- char Quote; // the char after '<<'
- bool Quoted; // true if Quote in ('\'','"','`')
- int DelimiterLength; // strlen(Delimiter)
- char Delimiter[256]; // the Delimiter, limit of 256: from Perl
+ // 2: here doc text (lines after the delimiter)
+ char Quote; // the char after '<<'
+ bool Quoted; // true if Quote in ('\'','"','`')
+ int DelimiterLength; // strlen(Delimiter)
+ char Delimiter[256]; // the Delimiter, limit of 256: from Perl
bool CanBeIndented;
- HereDocCls() {
- State = 0;
- DelimiterLength = 0;
- Delimiter[0] = '\0';
+ HereDocCls() {
+ State = 0;
+ DelimiterLength = 0;
+ Delimiter[0] = '\0';
CanBeIndented = false;
- }
- };
- HereDocCls HereDoc;
+ }
+ };
+ HereDocCls HereDoc;
- QuoteCls Quote;
+ QuoteCls Quote;
int numDots = 0; // For numbers --
- // Don't start lexing in the middle of a num
+ // Don't start lexing in the middle of a num
synchronizeDocStart(startPos, length, initStyle, styler, // ref args
false);
- bool preferRE = true;
+ bool preferRE = true;
int state = initStyle;
- int lengthDoc = startPos + length;
+ int lengthDoc = startPos + length;
- char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
- prevWord[0] = '\0';
- if (length == 0)
- return;
+ char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
+ prevWord[0] = '\0';
+ if (length == 0)
+ return;
- char chPrev = styler.SafeGetCharAt(startPos - 1);
- char chNext = styler.SafeGetCharAt(startPos);
- bool is_real_number = true; // Differentiate between constants and ?-sequences.
- styler.StartAt(startPos);
- styler.StartSegment(startPos);
+ char chPrev = styler.SafeGetCharAt(startPos - 1);
+ char chNext = styler.SafeGetCharAt(startPos);
+ bool is_real_number = true; // Differentiate between constants and ?-sequences.
+ styler.StartAt(startPos);
+ styler.StartSegment(startPos);
static int q_states[] = {SCE_RB_STRING_Q,
SCE_RB_STRING_QQ,
SCE_RB_STRING_QR,
SCE_RB_STRING_QW,
SCE_RB_STRING_QW,
- SCE_RB_STRING_QX};
- static const char* q_chars = "qQrwWx";
+ SCE_RB_STRING_QX
+ };
+ static const char *q_chars = "qQrwWx";
// In most cases a value of 2 should be ample for the code in the
// Ruby library, and the code the user is likely to enter.
@@ -743,113 +744,113 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, int brace_counts = 0; // Number of #{ ... } things within an expression
int i;
- for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
+ for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
inner_string_types[i] = 0;
inner_expn_brace_counts[i] = 0;
}
- for (i = startPos; i < lengthDoc; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
- char chNext2 = styler.SafeGetCharAt(i + 2);
+ for (i = startPos; i < lengthDoc; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ char chNext2 = styler.SafeGetCharAt(i + 2);
if (styler.IsLeadByte(ch)) {
- chNext = chNext2;
- chPrev = ' ';
- i += 1;
- continue;
- }
+ chNext = chNext2;
+ chPrev = ' ';
+ i += 1;
+ continue;
+ }
// skip on DOS/Windows
//No, don't, because some things will get tagged on,
// so we won't recognize keywords, for example
#if 0
- if (ch == '\r' && chNext == '\n') {
- continue;
+ if (ch == '\r' && chNext == '\n') {
+ continue;
}
#endif
if (HereDoc.State == 1 && isEOLChar(ch)) {
- // Begin of here-doc (the line after the here-doc delimiter):
- HereDoc.State = 2;
- styler.ColourTo(i-1, state);
+ // Begin of here-doc (the line after the here-doc delimiter):
+ HereDoc.State = 2;
+ styler.ColourTo(i-1, state);
// Don't check for a missing quote, just jump into
// the here-doc state
state = SCE_RB_HERE_Q;
}
// Regular transitions
- if (state == SCE_RB_DEFAULT) {
+ if (state == SCE_RB_DEFAULT) {
if (isSafeDigit(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_NUMBER;
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_NUMBER;
is_real_number = true;
numDots = 0;
} else if (isHighBitChar(ch) || iswordstart(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_WORD;
- } else if (ch == '#') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_COMMENTLINE;
- } else if (ch == '=') {
- // =begin indicates the start of a comment (doc) block
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_WORD;
+ } else if (ch == '#') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_COMMENTLINE;
+ } else if (ch == '=') {
+ // =begin indicates the start of a comment (doc) block
if ((i == 0 || isEOLChar(chPrev))
- && chNext == 'b'
- && styler.SafeGetCharAt(i + 2) == 'e'
- && styler.SafeGetCharAt(i + 3) == 'g'
- && styler.SafeGetCharAt(i + 4) == 'i'
- && styler.SafeGetCharAt(i + 5) == 'n'
- && !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6))) {
+ && chNext == 'b'
+ && styler.SafeGetCharAt(i + 2) == 'e'
+ && styler.SafeGetCharAt(i + 3) == 'g'
+ && styler.SafeGetCharAt(i + 4) == 'i'
+ && styler.SafeGetCharAt(i + 5) == 'n'
+ && !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6))) {
styler.ColourTo(i - 1, state);
state = SCE_RB_POD;
- } else {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_RB_OPERATOR);
- preferRE = true;
- }
- } else if (ch == '"') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_STRING;
- Quote.New();
- Quote.Open(ch);
- } else if (ch == '\'') {
+ } else {
+ styler.ColourTo(i - 1, state);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
+ preferRE = true;
+ }
+ } else if (ch == '"') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_STRING;
+ Quote.New();
+ Quote.Open(ch);
+ } else if (ch == '\'') {
styler.ColourTo(i - 1, state);
state = SCE_RB_CHARACTER;
Quote.New();
Quote.Open(ch);
- } else if (ch == '`') {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_BACKTICKS;
- Quote.New();
- Quote.Open(ch);
- } else if (ch == '@') {
+ } else if (ch == '`') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_BACKTICKS;
+ Quote.New();
+ Quote.Open(ch);
+ } else if (ch == '@') {
// Instance or class var
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
if (chNext == '@') {
state = SCE_RB_CLASS_VAR;
advance_char(i, ch, chNext, chNext2); // pass by ref
} else {
state = SCE_RB_INSTANCE_VAR;
}
- } else if (ch == '$') {
+ } else if (ch == '$') {
// Check for a builtin global
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
// Recognize it bit by bit
state = SCE_RB_GLOBAL;
} else if (ch == '/' && preferRE) {
// Ambigous operator
- styler.ColourTo(i - 1, state);
- state = SCE_RB_REGEX;
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_REGEX;
Quote.New();
Quote.Open(ch);
- } else if (ch == '<' && chNext == '<' && chNext2 != '=') {
+ } else if (ch == '<' && chNext == '<' && chNext2 != '=') {
// Recognise the '<<' symbol - either a here document or a binary op
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
i++;
chNext = chNext2;
- styler.ColourTo(i, SCE_RB_OPERATOR);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
- if (! (strchr("\"\'`_-", chNext2) || isSafeAlpha(chNext2))) {
+ if (!(strchr("\"\'`_-", chNext2) || isSafeAlpha(chNext2))) {
// It's definitely not a here-doc,
// based on Ruby's lexer/parser in the
// heredoc_identifier routine.
@@ -873,17 +874,17 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, }
preferRE = (state != SCE_RB_HERE_DELIM);
} else if (ch == ':') {
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, state);
if (chNext == ':') {
// Mark "::" as an operator, not symbol start
styler.ColourTo(i + 1, SCE_RB_OPERATOR);
advance_char(i, ch, chNext, chNext2); // pass by ref
state = SCE_RB_DEFAULT;
- preferRE = false;
+ preferRE = false;
} else if (isSafeWordcharOrHigh(chNext)) {
- state = SCE_RB_SYMBOL;
+ state = SCE_RB_SYMBOL;
} else if ((chNext == '@' || chNext == '$') &&
- isSafeWordcharOrHigh(chNext2)) {
+ isSafeWordcharOrHigh(chNext2)) {
// instance and global variable followed by an identifier
advance_char(i, ch, chNext, chNext2);
state = SCE_RB_SYMBOL;
@@ -913,7 +914,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, bool doColoring = true;
switch (chNext) {
case '[':
- if (chNext2 == ']' ) {
+ if (chNext2 == ']') {
char ch_tmp = styler.SafeGetCharAt(i + 3);
if (ch_tmp == '=') {
i += 3;
@@ -979,11 +980,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, styler.ColourTo(i, SCE_RB_SYMBOL);
state = SCE_RB_DEFAULT;
}
- } else if (!preferRE) {
- // Don't color symbol strings (yet)
- // Just color the ":" and color rest as string
- styler.ColourTo(i, SCE_RB_SYMBOL);
- state = SCE_RB_DEFAULT;
+ } else if (!preferRE) {
+ // Don't color symbol strings (yet)
+ // Just color the ":" and color rest as string
+ styler.ColourTo(i, SCE_RB_SYMBOL);
+ state = SCE_RB_DEFAULT;
} else {
styler.ColourTo(i, SCE_RB_OPERATOR);
state = SCE_RB_DEFAULT;
@@ -1000,7 +1001,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, Quote.Open(chNext2);
i += 2;
ch = chNext2;
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = styler.SafeGetCharAt(i + 1);
have_string = true;
}
} else if (preferRE && !isSafeWordcharOrHigh(chNext)) {
@@ -1036,8 +1037,8 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, is_real_number = false;
}
} else if (isoperator(ch) || ch == '.') {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_RB_OPERATOR);
+ styler.ColourTo(i - 1, state);
+ styler.ColourTo(i, SCE_RB_OPERATOR);
// If we're ending an expression or block,
// assume it ends an object, and the ambivalent
// constructs are binary operators
@@ -1064,7 +1065,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, } else if (isEOLChar(ch)) {
// Make sure it's a true line-end, with no backslash
if ((ch == '\r' || (ch == '\n' && chPrev != '\r'))
- && chPrev != '\\') {
+ && chPrev != '\\') {
// Assume we've hit the end of the statement.
preferRE = true;
}
@@ -1079,11 +1080,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, // but we don't for now.
if (ch == '='
- && isSafeWordcharOrHigh(chPrev)
- && (chNext == '('
- || strchr(" \t\n\r", chNext) != NULL)
- && (!strcmp(prevWord, "def")
- || followsDot(styler.GetStartSegment(), styler))) {
+ && isSafeWordcharOrHigh(chPrev)
+ && (chNext == '('
+ || strchr(" \t\n\r", chNext) != NULL)
+ && (!strcmp(prevWord, "def")
+ || followsDot(styler.GetStartSegment(), styler))) {
// <name>= is a name only when being def'd -- Get it the next time
// This means that <name>=<name> is always lexed as
// <name>, (op, =), <name>
@@ -1102,28 +1103,28 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, // No need to handle this state -- we'll just move to the end
preferRE = false;
} else {
- int wordStartPos = styler.GetStartSegment();
+ int wordStartPos = styler.GetStartSegment();
int word_style = ClassifyWordRb(wordStartPos, i - 1, keywords, styler, prevWord);
switch (word_style) {
- case SCE_RB_WORD:
- preferRE = RE_CanFollowKeyword(prevWord);
- break;
+ case SCE_RB_WORD:
+ preferRE = RE_CanFollowKeyword(prevWord);
+ break;
- case SCE_RB_WORD_DEMOTED:
- preferRE = true;
- break;
+ case SCE_RB_WORD_DEMOTED:
+ preferRE = true;
+ break;
- case SCE_RB_IDENTIFIER:
- if (isMatch(styler, lengthDoc, wordStartPos, "print")) {
- preferRE = true;
- } else if (isEOLChar(ch)) {
- preferRE = true;
- } else {
- preferRE = false;
- }
- break;
- default:
+ case SCE_RB_IDENTIFIER:
+ if (isMatch(styler, lengthDoc, wordStartPos, "print")) {
+ preferRE = true;
+ } else if (isEOLChar(ch)) {
+ preferRE = true;
+ } else {
preferRE = false;
+ }
+ break;
+ default:
+ preferRE = false;
}
if (ch == '.') {
// We might be redefining an operator-method
@@ -1178,7 +1179,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, preferRE = false;
}
} else if (state == SCE_RB_COMMENTLINE) {
- if (isEOLChar(ch)) {
+ if (isEOLChar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_RB_DEFAULT;
// Use whatever setting we had going into the comment
@@ -1188,8 +1189,8 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, // Slightly different: if we find an immediate '-',
// the target can appear indented.
- if (HereDoc.State == 0) { // '<<' encountered
- HereDoc.State = 1;
+ if (HereDoc.State == 0) { // '<<' encountered
+ HereDoc.State = 1;
HereDoc.DelimiterLength = 0;
if (ch == '-') {
HereDoc.CanBeIndented = true;
@@ -1214,7 +1215,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, HereDoc.DelimiterLength = 1;
}
}
- } else if (HereDoc.State == 1) { // collect the delimiter
+ } else if (HereDoc.State == 1) { // collect the delimiter
if (isEOLChar(ch)) {
// End the quote now, and go back for more
styler.ColourTo(i - 1, state);
@@ -1223,32 +1224,32 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, chNext = ch;
preferRE = false;
} else if (HereDoc.Quoted) {
- if (ch == HereDoc.Quote) { // closing quote => end of delimiter
- styler.ColourTo(i, state);
- state = SCE_RB_DEFAULT;
+ if (ch == HereDoc.Quote) { // closing quote => end of delimiter
+ styler.ColourTo(i, state);
+ state = SCE_RB_DEFAULT;
preferRE = false;
} else {
- if (ch == '\\' && !isEOLChar(chNext)) {
+ if (ch == '\\' && !isEOLChar(chNext)) {
advance_char(i, ch, chNext, chNext2);
- }
- HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
- HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+ }
+ HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
+ HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
}
} else { // an unquoted here-doc delimiter
- if (isSafeAlnumOrHigh(ch) || ch == '_') {
- HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
- HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
- } else {
- styler.ColourTo(i - 1, state);
+ if (isSafeAlnumOrHigh(ch) || ch == '_') {
+ HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
+ HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
+ } else {
+ styler.ColourTo(i - 1, state);
redo_char(i, ch, chNext, chNext2, state);
preferRE = false;
- }
+ }
}
- if (HereDoc.DelimiterLength >= static_cast<int>(sizeof(HereDoc.Delimiter)) - 1) {
- styler.ColourTo(i - 1, state);
- state = SCE_RB_ERROR;
+ if (HereDoc.DelimiterLength >= static_cast<int>(sizeof(HereDoc.Delimiter)) - 1) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_RB_ERROR;
preferRE = false;
- }
+ }
}
} else if (state == SCE_RB_HERE_Q) {
// Not needed: HereDoc.State == 2
@@ -1259,7 +1260,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, if (!HereDoc.CanBeIndented) {
if (isEOLChar(chPrev)
- && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
+ && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
styler.ColourTo(i - 1, state);
i += HereDoc.DelimiterLength - 1;
chNext = styler.SafeGetCharAt(i + 1);
@@ -1286,11 +1287,11 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, || state == SCE_RB_INSTANCE_VAR
|| state == SCE_RB_SYMBOL) {
if (state == SCE_RB_SYMBOL &&
- // FIDs suffices '?' and '!'
- (((ch == '!' || ch == '?') && chNext != '=') ||
- // identifier suffix '='
- (ch == '=' && (chNext != '~' && chNext != '>' &&
- (chNext != '=' || chNext2 == '>'))))) {
+ // FIDs suffices '?' and '!'
+ (((ch == '!' || ch == '?') && chNext != '=') ||
+ // identifier suffix '='
+ (ch == '=' && (chNext != '~' && chNext != '>' &&
+ (chNext != '=' || chNext2 == '>'))))) {
styler.ColourTo(i, state);
state = SCE_RB_DEFAULT;
preferRE = false;
@@ -1318,9 +1319,9 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, } else if (state == SCE_RB_POD) {
// PODs end with ^=end\s, -- any whitespace can follow =end
if (strchr(" \t\n\r", ch) != NULL
- && i > 5
- && isEOLChar(styler[i - 5])
- && isMatch(styler, lengthDoc, i - 4, "=end")) {
+ && i > 5
+ && isEOLChar(styler[i - 5])
+ && isMatch(styler, lengthDoc, i - 4, "=end")) {
styler.ColourTo(i - 1, state);
state = SCE_RB_DEFAULT;
preferRE = false;
@@ -1335,7 +1336,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, // Include the options
while (isSafeAlpha(chNext)) {
i++;
- ch = chNext;
+ ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
styler.ColourTo(i, state);
@@ -1346,9 +1347,9 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, // Only if close quoter != open quoter
Quote.Count++;
- } else if (ch == '#' ) {
+ } else if (ch == '#') {
if (chNext == '{'
- && inner_string_count < INNER_STRINGS_MAX_COUNT) {
+ && inner_string_count < INNER_STRINGS_MAX_COUNT) {
// process #{ ... }
styler.ColourTo(i - 1, state);
styler.ColourTo(i + 1, SCE_RB_OPERATOR);
@@ -1388,7 +1389,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, chNext = styler.SafeGetCharAt(i + 1);
}
}
- // Quotes of all kinds...
+ // Quotes of all kinds...
} else if (state == SCE_RB_STRING_Q || state == SCE_RB_STRING_QQ ||
state == SCE_RB_STRING_QX || state == SCE_RB_STRING_QW ||
state == SCE_RB_STRING || state == SCE_RB_CHARACTER ||
@@ -1463,7 +1464,7 @@ static void getPrevWord(int pos, for (; i <= pos; i++) {
*dst++ = styler[i];
}
- *dst = 0;
+ *dst = 0;
}
static bool keywordIsAmbiguous(const char *prevWord)
@@ -1471,11 +1472,11 @@ static bool keywordIsAmbiguous(const char *prevWord) // Order from most likely used to least likely
// Lots of ways to do a loop in Ruby besides 'while/until'
if (!strcmp(prevWord, "if")
- || !strcmp(prevWord, "do")
- || !strcmp(prevWord, "while")
- || !strcmp(prevWord, "unless")
- || !strcmp(prevWord, "until")
- || !strcmp(prevWord, "for")) {
+ || !strcmp(prevWord, "do")
+ || !strcmp(prevWord, "while")
+ || !strcmp(prevWord, "unless")
+ || !strcmp(prevWord, "until")
+ || !strcmp(prevWord, "for")) {
return true;
} else {
return false;
@@ -1495,7 +1496,7 @@ static bool keywordIsModifier(const char *word, }
char ch, chPrev, chPrev2;
int style = SCE_RB_DEFAULT;
- int lineStart = styler.GetLine(pos);
+ int lineStart = styler.GetLine(pos);
int lineStartPosn = styler.LineStart(lineStart);
// We want to step backwards until we don't care about the current
// position. But first move lineStartPosn back behind any
@@ -1515,20 +1516,20 @@ static bool keywordIsModifier(const char *word, break;
}
} else {
- break;
+ break;
}
}
styler.Flush();
while (--pos >= lineStartPosn) {
style = actual_style(styler.StyleAt(pos));
- if (style == SCE_RB_DEFAULT) {
- if (iswhitespace(ch = styler[pos])) {
- //continue
- } else if (ch == '\r' || ch == '\n') {
- // Scintilla's LineStart() and GetLine() routines aren't
- // platform-independent, so if we have text prepared with
- // a different system we can't rely on it.
+ if (style == SCE_RB_DEFAULT) {
+ if (iswhitespace(ch = styler[pos])) {
+ //continue
+ } else if (ch == '\r' || ch == '\n') {
+ // Scintilla's LineStart() and GetLine() routines aren't
+ // platform-independent, so if we have text prepared with
+ // a different system we can't rely on it.
// Also, lineStartPosn may have been moved to more than one
// line above word's line while pushing past continuations.
@@ -1541,40 +1542,40 @@ static bool keywordIsModifier(const char *word, pos-=2; // gloss over the "\\\r"
//continue
} else {
- return false;
+ return false;
}
- }
- } else {
+ }
+ } else {
break;
- }
+ }
}
if (pos < lineStartPosn) {
return false;
}
// First things where the action is unambiguous
switch (style) {
- case SCE_RB_DEFAULT:
- case SCE_RB_COMMENTLINE:
- case SCE_RB_POD:
- case SCE_RB_CLASSNAME:
- case SCE_RB_DEFNAME:
- case SCE_RB_MODULE_NAME:
- return false;
- case SCE_RB_OPERATOR:
- break;
- case SCE_RB_WORD:
- // Watch out for uses of 'else if'
- //XXX: Make a list of other keywords where 'if' isn't a modifier
- // and can appear legitimately
- // Formulate this to avoid warnings from most compilers
- if (strcmp(word, "if") == 0) {
- char prevWord[MAX_KEYWORD_LENGTH + 1];
- getPrevWord(pos, prevWord, styler, SCE_RB_WORD);
- return strcmp(prevWord, "else") != 0;
- }
- return true;
- default:
- return true;
+ case SCE_RB_DEFAULT:
+ case SCE_RB_COMMENTLINE:
+ case SCE_RB_POD:
+ case SCE_RB_CLASSNAME:
+ case SCE_RB_DEFNAME:
+ case SCE_RB_MODULE_NAME:
+ return false;
+ case SCE_RB_OPERATOR:
+ break;
+ case SCE_RB_WORD:
+ // Watch out for uses of 'else if'
+ //XXX: Make a list of other keywords where 'if' isn't a modifier
+ // and can appear legitimately
+ // Formulate this to avoid warnings from most compilers
+ if (strcmp(word, "if") == 0) {
+ char prevWord[MAX_KEYWORD_LENGTH + 1];
+ getPrevWord(pos, prevWord, styler, SCE_RB_WORD);
+ return strcmp(prevWord, "else") != 0;
+ }
+ return true;
+ default:
+ return true;
}
// Assume that if the keyword follows an operator,
// usually it's a block assignment, like
@@ -1582,12 +1583,12 @@ static bool keywordIsModifier(const char *word, ch = styler[pos];
switch (ch) {
- case ')':
- case ']':
- case '}':
- return true;
- default:
- return false;
+ case ')':
+ case ']':
+ case '}':
+ return true;
+ default:
+ return false;
}
}
@@ -1603,27 +1604,27 @@ static bool keywordDoStartsLoop(int pos, {
char ch;
int style;
- int lineStart = styler.GetLine(pos);
+ int lineStart = styler.GetLine(pos);
int lineStartPosn = styler.LineStart(lineStart);
styler.Flush();
while (--pos >= lineStartPosn) {
style = actual_style(styler.StyleAt(pos));
- if (style == SCE_RB_DEFAULT) {
- if ((ch = styler[pos]) == '\r' || ch == '\n') {
- // Scintilla's LineStart() and GetLine() routines aren't
- // platform-independent, so if we have text prepared with
- // a different system we can't rely on it.
- return false;
- }
- } else if (style == SCE_RB_WORD) {
+ if (style == SCE_RB_DEFAULT) {
+ if ((ch = styler[pos]) == '\r' || ch == '\n') {
+ // Scintilla's LineStart() and GetLine() routines aren't
+ // platform-independent, so if we have text prepared with
+ // a different system we can't rely on it.
+ return false;
+ }
+ } else if (style == SCE_RB_WORD) {
// Check for while or until, but write the word in backwards
char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
char *dst = prevWord;
int wordLen = 0;
int start_word;
for (start_word = pos;
- start_word >= lineStartPosn && actual_style(styler.StyleAt(start_word)) == SCE_RB_WORD;
- start_word--) {
+ start_word >= lineStartPosn && actual_style(styler.StyleAt(start_word)) == SCE_RB_WORD;
+ start_word--) {
if (++wordLen < MAX_KEYWORD_LENGTH) {
*dst++ = styler[start_word];
}
@@ -1631,8 +1632,8 @@ static bool keywordDoStartsLoop(int pos, *dst = 0;
// Did we see our keyword?
if (!strcmp(prevWord, WHILE_BACKWARDS)
- || !strcmp(prevWord, UNTIL_BACKWARDS)
- || !strcmp(prevWord, FOR_BACKWARDS)) {
+ || !strcmp(prevWord, UNTIL_BACKWARDS)
+ || !strcmp(prevWord, FOR_BACKWARDS)) {
return true;
}
// We can move pos to the beginning of the keyword, and then
@@ -1650,6 +1651,19 @@ static bool keywordDoStartsLoop(int pos, return false;
}
+static bool IsCommentLine(int line, Accessor &styler) {
+ int pos = styler.LineStart(line);
+ int eol_pos = styler.LineStart(line + 1) - 1;
+ for (int i = pos; i < eol_pos; i++) {
+ char ch = styler[i];
+ if (ch == '#')
+ return true;
+ else if (ch != ' ' && ch != '\t')
+ return false;
+ }
+ return false;
+}
+
/*
* Folding Ruby
*
@@ -1706,44 +1720,55 @@ static bool keywordDoStartsLoop(int pos, static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
- const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
- bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
synchronizeDocStart(startPos, length, initStyle, styler, // ref args
false);
- unsigned int endPos = startPos + length;
- int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
- int levelPrev = startPos == 0 ? 0 : (styler.LevelAt(lineCurrent)
+ unsigned int endPos = startPos + length;
+ int visibleChars = 0;
+ int lineCurrent = styler.GetLine(startPos);
+ int levelPrev = startPos == 0 ? 0 : (styler.LevelAt(lineCurrent)
& SC_FOLDLEVELNUMBERMASK
& ~SC_FOLDLEVELBASE);
- int levelCurrent = levelPrev;
- char chNext = styler[startPos];
- int styleNext = styler.StyleAt(startPos);
- int stylePrev = startPos <= 1 ? SCE_RB_DEFAULT : styler.StyleAt(startPos - 1);
+ int levelCurrent = levelPrev;
+ char chNext = styler[startPos];
+ int styleNext = styler.StyleAt(startPos);
+ int stylePrev = startPos <= 1 ? SCE_RB_DEFAULT : styler.StyleAt(startPos - 1);
bool buffer_ends_with_eol = false;
- for (unsigned int i = startPos; i < endPos; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
- int style = styleNext;
- styleNext = styler.StyleAt(i + 1);
- bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ int style = styleNext;
+ styleNext = styler.StyleAt(i + 1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+ /*Mutiline comment patch*/
+ if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) {
+ if (!IsCommentLine(lineCurrent - 1, styler)
+ && IsCommentLine(lineCurrent + 1, styler))
+ levelCurrent++;
+ else if (IsCommentLine(lineCurrent - 1, styler)
+ && !IsCommentLine(lineCurrent + 1, styler))
+ levelCurrent--;
+ }
+
if (style == SCE_RB_COMMENTLINE) {
if (foldComment && stylePrev != SCE_RB_COMMENTLINE) {
if (chNext == '{') {
- levelCurrent++;
- } else if (chNext == '}' && levelCurrent > 0) {
- levelCurrent--;
- }
+ levelCurrent++;
+ } else if (chNext == '}' && levelCurrent > 0) {
+ levelCurrent--;
+ }
}
} else if (style == SCE_RB_OPERATOR) {
- if (strchr("[{(", ch)) {
- levelCurrent++;
- } else if (strchr(")}]", ch)) {
+ if (strchr("[{(", ch)) {
+ levelCurrent++;
+ } else if (strchr(")}]", ch)) {
// Don't decrement below 0
if (levelCurrent > 0)
levelCurrent--;
- }
+ }
} else if (style == SCE_RB_WORD && styleNext != SCE_RB_WORD) {
// Look at the keyword on the left and decide what to do
char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
@@ -1753,7 +1778,7 @@ static void FoldRbDoc(unsigned int startPos, int length, int initStyle, // Don't decrement below 0
if (levelCurrent > 0)
levelCurrent--;
- } else if ( !strcmp(prevWord, "if")
+ } else if (!strcmp(prevWord, "if")
|| !strcmp(prevWord, "def")
|| !strcmp(prevWord, "class")
|| !strcmp(prevWord, "module")
@@ -1764,49 +1789,49 @@ static void FoldRbDoc(unsigned int startPos, int length, int initStyle, || !strcmp(prevWord, "unless")
|| !strcmp(prevWord, "until")
|| !strcmp(prevWord, "for")
- ) {
- levelCurrent++;
+ ) {
+ levelCurrent++;
+ }
+ } else if (style == SCE_RB_HERE_DELIM) {
+ if (styler.SafeGetCharAt(i-2) == '<' && styler.SafeGetCharAt(i-1) == '<') {
+ levelCurrent++;
+ } else if (styleNext == SCE_RB_DEFAULT) {
+ levelCurrent--;
}
- } else if (style == SCE_RB_HERE_DELIM) {
- if (styler.SafeGetCharAt(i-2) == '<' && styler.SafeGetCharAt(i-1) == '<') {
- levelCurrent++;
- } else if (styleNext == SCE_RB_DEFAULT) {
- levelCurrent--;
- }
- }
- if (atEOL) {
- int lev = levelPrev;
- if (visibleChars == 0 && foldCompact)
- lev |= SC_FOLDLEVELWHITEFLAG;
- if ((levelCurrent > levelPrev) && (visibleChars > 0))
- lev |= SC_FOLDLEVELHEADERFLAG;
+ }
+ if (atEOL) {
+ int lev = levelPrev;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev|SC_FOLDLEVELBASE);
- lineCurrent++;
- levelPrev = levelCurrent;
- visibleChars = 0;
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
buffer_ends_with_eol = true;
- } else if (!isspacechar(ch)) {
- visibleChars++;
+ } else if (!isspacechar(ch)) {
+ visibleChars++;
buffer_ends_with_eol = false;
}
- stylePrev = style;
+ stylePrev = style;
}
- // Fill in the real level of the next line, keeping the current flags as they will be filled in later
+ // Fill in the real level of the next line, keeping the current flags as they will be filled in later
if (!buffer_ends_with_eol) {
lineCurrent++;
int new_lev = levelCurrent;
if (visibleChars == 0 && foldCompact)
new_lev |= SC_FOLDLEVELWHITEFLAG;
- if ((levelCurrent > levelPrev) && (visibleChars > 0))
- new_lev |= SC_FOLDLEVELHEADERFLAG;
- levelCurrent = new_lev;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ new_lev |= SC_FOLDLEVELHEADERFLAG;
+ levelCurrent = new_lev;
}
- styler.SetLevel(lineCurrent, levelCurrent|SC_FOLDLEVELBASE);
+ styler.SetLevel(lineCurrent, levelCurrent|SC_FOLDLEVELBASE);
}
-static const char * const rubyWordListDesc[] = {
- "Keywords",
- 0
+static const char *const rubyWordListDesc[] = {
+ "Keywords",
+ 0
};
LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc);
diff --git a/scintilla/lexers/LexRust.cxx b/scintilla/lexers/LexRust.cxx index 3b1201c..80ec014 100644 --- a/scintilla/lexers/LexRust.cxx +++ b/scintilla/lexers/LexRust.cxx @@ -271,7 +271,7 @@ static void ScanNumber(Accessor& styler, int& pos) { pos++; c = styler.SafeGetCharAt(pos, '\0'); n = styler.SafeGetCharAt(pos + 1, '\0'); - if (c == '8') { + if (c == '8' || c == 's') { pos++; } else if (c == '1' && n == '6') { pos += 2; @@ -279,6 +279,8 @@ static void ScanNumber(Accessor& styler, int& pos) { pos += 2; } else if (c == '6' && n == '4') { pos += 2; + } else { + error = true; } /* See if it's a floating point literal. These literals have to be base 10. */ diff --git a/scintilla/lexers/LexSQL.cxx b/scintilla/lexers/LexSQL.cxx index 3c3ded0..713a3c0 100644 --- a/scintilla/lexers/LexSQL.cxx +++ b/scintilla/lexers/LexSQL.cxx @@ -444,7 +444,6 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle, StyleContext sc(startPos, length, initStyle, styler);
int styleBeforeDCKeyword = SCE_SQL_DEFAULT;
int offset = 0;
- char qOperator = 0x00;
for (; sc.More(); sc.Forward(), offset++) {
// Determine if the current state should terminate.
@@ -559,29 +558,34 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle, }
break;
case SCE_SQL_QOPERATOR:
- if (qOperator == 0x00) {
- qOperator = sc.ch;
- } else {
- char qComplement = 0x00;
-
- if (qOperator == '<') {
- qComplement = '>';
- } else if (qOperator == '(') {
- qComplement = ')';
- } else if (qOperator == '{') {
- qComplement = '}';
- } else if (qOperator == '[') {
- qComplement = ']';
- } else {
- qComplement = qOperator;
- }
-
- if (sc.Match(qComplement, '\'')) {
- sc.Forward();
- sc.ForwardSetState(SCE_SQL_DEFAULT);
- qOperator = 0x00;
+ // Locate the unique Q operator character
+ sc.Complete();
+ char qOperator = 0x00;
+ for (int styleStartPos = sc.currentPos; styleStartPos > 0; --styleStartPos) {
+ if (styler.StyleAt(styleStartPos - 1) != SCE_SQL_QOPERATOR) {
+ qOperator = styler.SafeGetCharAt(styleStartPos + 2);
+ break;
}
- }
+ }
+
+ char qComplement = 0x00;
+
+ if (qOperator == '<') {
+ qComplement = '>';
+ } else if (qOperator == '(') {
+ qComplement = ')';
+ } else if (qOperator == '{') {
+ qComplement = '}';
+ } else if (qOperator == '[') {
+ qComplement = ']';
+ } else {
+ qComplement = qOperator;
+ }
+
+ if (sc.Match(qComplement, '\'')) {
+ sc.Forward();
+ sc.ForwardSetState(SCE_SQL_DEFAULT);
+ }
break;
}
diff --git a/scintilla/lexers/LexTCL.cxx b/scintilla/lexers/LexTCL.cxx index d684d3b..e6991e1 100644 --- a/scintilla/lexers/LexTCL.cxx +++ b/scintilla/lexers/LexTCL.cxx @@ -30,7 +30,7 @@ using namespace Scintilla; // Extended to accept accented characters
static inline bool IsAWordChar(int ch) {
return ch >= 0x80 ||
- (isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator
+ (isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator
}
static inline bool IsAWordStart(int ch) {
@@ -49,17 +49,18 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k #define isComment(s) (s==SCE_TCL_COMMENT || s==SCE_TCL_COMMENTLINE || s==SCE_TCL_COMMENT_BOX || s==SCE_TCL_BLOCK_COMMENT)
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool commentLevel = false;
- bool subBrace = false; // substitution begin with a brace ${.....}
+ bool subBrace = false; // substitution begin with a brace ${.....}
enum tLineState {LS_DEFAULT, LS_OPEN_COMMENT, LS_OPEN_DOUBLE_QUOTE, LS_COMMENT_BOX, LS_MASK_STATE = 0xf,
- LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32 } lineState = LS_DEFAULT;
+ LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32
+ } lineState = LS_DEFAULT;
bool prevSlash = false;
int currentLevel = 0;
- bool expected = 0;
- bool subParen = 0;
+ bool expected = 0;
+ bool subParen = 0;
int currentLine = styler.GetLine(startPos);
- if (currentLine > 0)
- currentLine--;
+ if (currentLine > 0)
+ currentLine--;
length += startPos - styler.LineStart(currentLine);
// make sure lines overlap
startPos = styler.LineStart(currentLine);
@@ -71,14 +72,14 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k WordList &keywords5 = *keywordlists[4];
WordList &keywords6 = *keywordlists[5];
WordList &keywords7 = *keywordlists[6];
- WordList &keywords8 = *keywordlists[7];
- WordList &keywords9 = *keywordlists[8];
+ WordList &keywords8 = *keywordlists[7];
+ WordList &keywords9 = *keywordlists[8];
if (currentLine > 0) {
- int ls = styler.GetLineState(currentLine - 1);
+ int ls = styler.GetLineState(currentLine - 1);
lineState = tLineState(ls & LS_MASK_STATE);
expected = LS_COMMAND_EXPECTED == tLineState(ls & LS_COMMAND_EXPECTED);
- subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY);
+ subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY);
currentLevel = styler.LevelAt(currentLine - 1) >> 17;
commentLevel = (styler.LevelAt(currentLine - 1) >> 16) & 1;
} else
@@ -86,105 +87,104 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k bool visibleChars = false;
int previousLevel = currentLevel;
- StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler);
+ StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler);
for (; ; sc.Forward()) {
next:
- if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac
- continue;
- bool atEnd = !sc.More(); // make sure we coloured the last word
- if (lineState != LS_DEFAULT) {
- sc.SetState(SCE_TCL_DEFAULT);
- if (lineState == LS_OPEN_COMMENT)
- sc.SetState(SCE_TCL_COMMENTLINE);
- else if (lineState == LS_OPEN_DOUBLE_QUOTE)
- sc.SetState(SCE_TCL_IN_QUOTE);
- else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#')))
- sc.SetState(SCE_TCL_COMMENT_BOX);
- lineState = LS_DEFAULT;
- }
- if (subBrace) { // ${ overrides every thing even \ except }
- if (sc.ch == '}') {
- subBrace = false;
- sc.SetState(SCE_TCL_OPERATOR);
- sc.ForwardSetState(SCE_TCL_DEFAULT);
- goto next;
- }
- else
- sc.SetState(SCE_TCL_SUB_BRACE);
- if (!sc.atLineEnd)
- continue;
- } else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) {
- expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#';
- } else if (sc.state == SCE_TCL_SUBSTITUTION) {
- switch(sc.ch) {
- case '(':
- subParen=true;
- sc.SetState(SCE_TCL_OPERATOR);
- sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
- continue;
- case ')':
- sc.SetState(SCE_TCL_OPERATOR);
- subParen=false;
- continue;
- case '$':
- continue;
- case ',':
- sc.SetState(SCE_TCL_OPERATOR);
- if (subParen)
- sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
- continue;
- default :
- // maybe spaces should be allowed ???
- if (!IsAWordChar(sc.ch)) { // probably the code is wrong
- sc.SetState(SCE_TCL_DEFAULT);
- subParen = 0;
- }
- break;
- }
- } else if (isComment(sc.state)) {
- } else if (!IsAWordChar(sc.ch)) {
- if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) {
- char w[100];
- char *s=w;
- sc.GetCurrent(w, sizeof(w));
- if (w[strlen(w)-1]=='\r')
- w[strlen(w)-1]=0;
- while(*s == ':') // ignore leading : like in ::set a 10
- ++s;
- bool quote = sc.state == SCE_TCL_IN_QUOTE;
- if (commentLevel || expected) {
- if (keywords.InList(s)) {
- sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD);
- } else if (keywords2.InList(s)) {
- sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2);
- } else if (keywords3.InList(s)) {
- sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3);
- } else if (keywords4.InList(s)) {
- sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4);
- } else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' &&
- keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces
- sc.ChangeState(SCE_TCL_EXPAND);
- }
- if (keywords6.InList(s)) {
- sc.ChangeState(SCE_TCL_WORD5);
- } else if (keywords7.InList(s)) {
- sc.ChangeState(SCE_TCL_WORD6);
- } else if (keywords8.InList(s)) {
- sc.ChangeState(SCE_TCL_WORD7);
- } else if (keywords9.InList(s)) {
- sc.ChangeState(SCE_TCL_WORD8);
- }
- }
- expected = false;
- sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT);
- } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) {
- sc.SetState(SCE_TCL_DEFAULT);
- }
- }
+ if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac
+ continue;
+ bool atEnd = !sc.More(); // make sure we coloured the last word
+ if (lineState != LS_DEFAULT) {
+ sc.SetState(SCE_TCL_DEFAULT);
+ if (lineState == LS_OPEN_COMMENT)
+ sc.SetState(SCE_TCL_COMMENTLINE);
+ else if (lineState == LS_OPEN_DOUBLE_QUOTE)
+ sc.SetState(SCE_TCL_IN_QUOTE);
+ else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#')))
+ sc.SetState(SCE_TCL_COMMENT_BOX);
+ lineState = LS_DEFAULT;
+ }
+ if (subBrace) { // ${ overrides every thing even \ except }
+ if (sc.ch == '}') {
+ subBrace = false;
+ sc.SetState(SCE_TCL_OPERATOR);
+ sc.ForwardSetState(SCE_TCL_DEFAULT);
+ goto next;
+ } else
+ sc.SetState(SCE_TCL_SUB_BRACE);
+ if (!sc.atLineEnd)
+ continue;
+ } else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) {
+ expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#';
+ } else if (sc.state == SCE_TCL_SUBSTITUTION) {
+ switch (sc.ch) {
+ case '(':
+ subParen=true;
+ sc.SetState(SCE_TCL_OPERATOR);
+ sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
+ continue;
+ case ')':
+ sc.SetState(SCE_TCL_OPERATOR);
+ subParen=false;
+ continue;
+ case '$':
+ continue;
+ case ',':
+ sc.SetState(SCE_TCL_OPERATOR);
+ if (subParen)
+ sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
+ continue;
+ default :
+ // maybe spaces should be allowed ???
+ if (!IsAWordChar(sc.ch)) { // probably the code is wrong
+ sc.SetState(SCE_TCL_DEFAULT);
+ subParen = 0;
+ }
+ break;
+ }
+ } else if (isComment(sc.state)) {
+ } else if (!IsAWordChar(sc.ch)) {
+ if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) {
+ char w[100];
+ char *s=w;
+ sc.GetCurrent(w, sizeof(w));
+ if (w[strlen(w)-1]=='\r')
+ w[strlen(w)-1]=0;
+ while (*s == ':') // ignore leading : like in ::set a 10
+ ++s;
+ bool quote = sc.state == SCE_TCL_IN_QUOTE;
+ if (commentLevel || expected) {
+ if (keywords.InList(s)) {
+ sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD);
+ } else if (keywords2.InList(s)) {
+ sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2);
+ } else if (keywords3.InList(s)) {
+ sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3);
+ } else if (keywords4.InList(s)) {
+ sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4);
+ } else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' &&
+ keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces
+ sc.ChangeState(SCE_TCL_EXPAND);
+ }
+ if (keywords6.InList(s)) {
+ sc.ChangeState(SCE_TCL_WORD5);
+ } else if (keywords7.InList(s)) {
+ sc.ChangeState(SCE_TCL_WORD6);
+ } else if (keywords8.InList(s)) {
+ sc.ChangeState(SCE_TCL_WORD7);
+ } else if (keywords9.InList(s)) {
+ sc.ChangeState(SCE_TCL_WORD8);
+ }
+ }
+ expected = false;
+ sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT);
+ } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) {
+ sc.SetState(SCE_TCL_DEFAULT);
+ }
+ }
if (atEnd)
break;
- if (sc.atLineEnd) {
- lineState = LS_DEFAULT;
+ if (sc.atLineEnd) {
+ lineState = LS_DEFAULT;
currentLine = styler.GetLine(sc.currentPos);
if (foldComment && sc.state!=SCE_TCL_COMMENT && isComment(sc.state)) {
if (currentLevel == 0) {
@@ -206,45 +206,45 @@ next: styler.SetLevel(currentLine, flag + previousLevel + SC_FOLDLEVELBASE + (currentLevel << 17) + (commentLevel << 16));
// Update the line state, so it can be seen by next line
- if (sc.state == SCE_TCL_IN_QUOTE)
+ if (sc.state == SCE_TCL_IN_QUOTE) {
lineState = LS_OPEN_DOUBLE_QUOTE;
- else {
- if (prevSlash) {
- if (isComment(sc.state))
- lineState = LS_OPEN_COMMENT;
- } else if (sc.state == SCE_TCL_COMMENT_BOX)
- lineState = LS_COMMENT_BOX;
+ } else {
+ if (prevSlash) {
+ if (isComment(sc.state))
+ lineState = LS_OPEN_COMMENT;
+ } else if (sc.state == SCE_TCL_COMMENT_BOX)
+ lineState = LS_COMMENT_BOX;
}
- styler.SetLineState(currentLine,
- (subBrace ? LS_BRACE_ONLY : 0) |
- (expected ? LS_COMMAND_EXPECTED : 0) | lineState);
- if (lineState == LS_COMMENT_BOX)
- sc.ForwardSetState(SCE_TCL_COMMENT_BOX);
- else if (lineState == LS_OPEN_DOUBLE_QUOTE)
- sc.ForwardSetState(SCE_TCL_IN_QUOTE);
- else
- sc.ForwardSetState(SCE_TCL_DEFAULT);
+ styler.SetLineState(currentLine,
+ (subBrace ? LS_BRACE_ONLY : 0) |
+ (expected ? LS_COMMAND_EXPECTED : 0) | lineState);
+ if (lineState == LS_COMMENT_BOX)
+ sc.ForwardSetState(SCE_TCL_COMMENT_BOX);
+ else if (lineState == LS_OPEN_DOUBLE_QUOTE)
+ sc.ForwardSetState(SCE_TCL_IN_QUOTE);
+ else
+ sc.ForwardSetState(SCE_TCL_DEFAULT);
prevSlash = false;
previousLevel = currentLevel;
goto next;
}
if (prevSlash) {
- prevSlash = false;
- if (sc.ch == '#' && IsANumberChar(sc.chNext))
- sc.ForwardSetState(SCE_TCL_NUMBER);
- continue;
+ prevSlash = false;
+ if (sc.ch == '#' && IsANumberChar(sc.chNext))
+ sc.ForwardSetState(SCE_TCL_NUMBER);
+ continue;
}
- prevSlash = sc.ch == '\\';
- if (isComment(sc.state))
- continue;
+ prevSlash = sc.ch == '\\';
+ if (isComment(sc.state))
+ continue;
if (sc.atLineStart) {
visibleChars = false;
if (sc.state!=SCE_TCL_IN_QUOTE && !isComment(sc.state))
- {
+ {
sc.SetState(SCE_TCL_DEFAULT);
- expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch));
- }
+ expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch));
+ }
}
switch (sc.state) {
@@ -257,30 +257,30 @@ next: sc.ForwardSetState(SCE_TCL_DEFAULT);
visibleChars = true; // necessary if a " is the first and only character on a line
goto next;
- } else if (sc.ch == '[' || sc.ch == ']' || sc.ch == '$') {
+ } else if (sc.ch == '[' || sc.ch == ']' || sc.ch == '$' || sc.ch == '(') {
sc.SetState(SCE_TCL_OPERATOR);
- expected = sc.ch == '[';
- sc.ForwardSetState(SCE_TCL_IN_QUOTE);
+ expected = sc.ch == '[';
+ sc.ForwardSetState(SCE_TCL_IN_QUOTE);
goto next;
}
- continue;
- case SCE_TCL_OPERATOR:
+ continue;
+ case SCE_TCL_OPERATOR:
sc.SetState(SCE_TCL_DEFAULT);
break;
}
if (sc.ch == '#') {
if (visibleChars) {
- if (sc.state != SCE_TCL_IN_QUOTE && expected)
+ if (sc.state != SCE_TCL_IN_QUOTE && expected)
sc.SetState(SCE_TCL_COMMENT);
} else {
- sc.SetState(SCE_TCL_COMMENTLINE);
- if (sc.chNext == '~')
- sc.SetState(SCE_TCL_BLOCK_COMMENT);
- if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-'))
- sc.SetState(SCE_TCL_COMMENT_BOX);
- }
- }
+ sc.SetState(SCE_TCL_COMMENTLINE);
+ if (sc.chNext == '~')
+ sc.SetState(SCE_TCL_BLOCK_COMMENT);
+ if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-'))
+ sc.SetState(SCE_TCL_COMMENT_BOX);
+ }
+ }
if (!isspacechar(static_cast<unsigned char>(sc.ch))) {
visibleChars = true;
@@ -293,7 +293,7 @@ next: // Determine if a new state should be entered.
if (sc.state == SCE_TCL_DEFAULT) {
- if (IsAWordStart(sc.ch)) {
+ if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_TCL_IDENTIFIER);
} else if (IsADigit(sc.ch) && !IsAWordChar(sc.chPrev)) {
sc.SetState(SCE_TCL_NUMBER);
@@ -313,39 +313,41 @@ next: --currentLevel;
break;
case '[':
- expected = true;
+ expected = true;
case ']':
case '(':
case ')':
sc.SetState(SCE_TCL_OPERATOR);
break;
case ';':
- expected = true;
+ expected = true;
+ break;
+ case '$':
+ subParen = 0;
+ if (sc.chNext == '(') {
+ //$("") jquery selector?!
+ sc.SetState(SCE_TCL_OPERATOR);
+ } else if (sc.chNext != '{') {
+ sc.SetState(SCE_TCL_SUBSTITUTION);
+ } else {
+ sc.SetState(SCE_TCL_OPERATOR); // $
+ sc.Forward(); // {
+ sc.ForwardSetState(SCE_TCL_SUB_BRACE);
+ subBrace = true;
+ }
+ break;
+ case '#':
+ if ((isspacechar(static_cast<unsigned char>(sc.chPrev))||
+ isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10))
+ sc.SetState(SCE_TCL_NUMBER);
+ break;
+ case '-':
+ sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER);
break;
- case '$':
- subParen = 0;
- if (sc.chNext != '{') {
- sc.SetState(SCE_TCL_SUBSTITUTION);
- }
- else {
- sc.SetState(SCE_TCL_OPERATOR); // $
- sc.Forward(); // {
- sc.ForwardSetState(SCE_TCL_SUB_BRACE);
- subBrace = true;
- }
- break;
- case '#':
- if ((isspacechar(static_cast<unsigned char>(sc.chPrev))||
- isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10))
- sc.SetState(SCE_TCL_NUMBER);
- break;
- case '-':
- sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER);
- break;
- default:
- if (isoperator(static_cast<char>(sc.ch))) {
- sc.SetState(SCE_TCL_OPERATOR);
- }
+ default:
+ if (isoperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_TCL_OPERATOR);
+ }
}
}
}
@@ -353,18 +355,18 @@ next: sc.Complete();
}
-static const char * const tclWordListDesc[] = {
- "TCL Keywords",
- "TK Keywords",
- "iTCL Keywords",
- "tkCommands",
- "expand",
- "user1",
- "user2",
- "user3",
- "user4",
- 0
- };
+static const char *const tclWordListDesc[] = {
+ "TCL Keywords",
+ "TK Keywords",
+ "iTCL Keywords",
+ "tkCommands",
+ "expand",
+ "user1",
+ "user2",
+ "user3",
+ "user4",
+ 0
+};
// this code supports folding in the colourizer
LexerModule lmTCL(SCLEX_TCL, ColouriseTCLDoc, "tcl", 0, tclWordListDesc);
diff --git a/scintilla/lexers/LexVHDL.cxx b/scintilla/lexers/LexVHDL.cxx index 2752d2c..786d06c 100644 --- a/scintilla/lexers/LexVHDL.cxx +++ b/scintilla/lexers/LexVHDL.cxx @@ -388,13 +388,14 @@ static void FoldNoBoxVHDLDoc( strcmp(s, "entity") == 0 ||
strcmp(s, "configuration") == 0 )
{
- if (strcmp(prevWord, "end") != 0)
+ if (strcmp(prevWord, "end") != 0 && lastStart)
{ // check for instantiated unit by backward searching for the colon.
- unsigned pos = lastStart-1;
+ unsigned pos = lastStart;
char chAtPos, styleAtPos;
do{// skip white spaces
+ pos--;
styleAtPos = styler.StyleAt(pos);
- chAtPos = styler.SafeGetCharAt(pos--);
+ chAtPos = styler.SafeGetCharAt(pos);
}while(pos>0 &&
(chAtPos == ' ' || chAtPos == '\t' ||
chAtPos == '\n' || chAtPos == '\r' ||
diff --git a/scintilla/lexers/LexVerilog.cxx b/scintilla/lexers/LexVerilog.cxx index d41ea84..7b0134f 100644 --- a/scintilla/lexers/LexVerilog.cxx +++ b/scintilla/lexers/LexVerilog.cxx @@ -198,6 +198,15 @@ class LexerVerilog : public ILexerWithSubStyles { OptionSetVerilog osVerilog;
enum { activeFlag = 0x40 };
SubStyles subStyles;
+
+ // states at end of line (EOL) during fold operations:
+ // foldExternFlag: EOL while parsing an extern function/task declaration terminated by ';'
+ // foldWaitDisableFlag: EOL while parsing wait or disable statement, terminated by "fork" or '('
+ // typdefFlag: EOL while parsing typedef statement, terminated by ';'
+ enum {foldExternFlag = 0x01, foldWaitDisableFlag = 0x02, typedefFlag = 0x04};
+ // map using line number as key to store fold state information
+ std::map<int, int> foldState;
+
public:
LexerVerilog() :
setWord(CharacterSet::setAlphaNum, "._", 0x80, true),
@@ -431,6 +440,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty int activitySet = preproc.IsInactive() ? activeFlag : 0;
int lineEndNext = styler.LineEnd(curLine);
+ bool isEscapedId = false; // true when parsing an escaped Identifier
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
@@ -453,6 +463,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty vlls.Add(curLine, preproc);
// Update the line state, so it can be seen by next line
styler.SetLineState(curLine, lineState);
+ isEscapedId = false; // EOL terminates an escaped Identifier
}
// Handle line continuation generically.
@@ -500,7 +511,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty }
break;
case SCE_V_IDENTIFIER:
- if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
+ if (!isEscapedId &&(!IsAWordChar(sc.ch) || (sc.ch == '.'))) {
char s[100];
lineState &= 0xff00;
sc.GetCurrent(s, sizeof(s));
@@ -581,6 +592,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty vlls.Add(curLine, preproc);
// Update the line state, so it can be seen by next line
styler.SetLineState(curLine, lineState);
+ isEscapedId = false; // EOL terminates an escaped Identifier
}
// Determine if a new state should be entered.
@@ -713,12 +725,19 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty }
}
}
+ } else if (sc.ch == '\\') {
+ // escaped identifier, everything is ok up to whitespace
+ isEscapedId = true;
+ sc.SetState(SCE_V_IDENTIFIER|activitySet);
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '#') {
sc.SetState(SCE_V_OPERATOR|activitySet);
if (sc.ch == '.') lineState = kwDot;
if (sc.ch == ';') lineState = kwOther;
}
}
+ if (isEscapedId && isspacechar(sc.ch)) {
+ isEscapedId = false;
+ }
}
if (definitionsChanged) {
styler.ChangeLexerState(startPos, startPos + length);
@@ -756,9 +775,20 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt bool foldAtBrace = 1;
bool foldAtParenthese = 1;
+ int lineCurrent = styler.GetLine(startPos);
+ // Move back one line to be compatible with LexerModule::Fold behavior, fixes problem with foldComment behavior
+ if (lineCurrent > 0) {
+ lineCurrent--;
+ int newStartPos = styler.LineStart(lineCurrent);
+ length += startPos - newStartPos;
+ startPos = newStartPos;
+ initStyle = 0;
+ if (startPos > 0) {
+ initStyle = styler.StyleAt(startPos - 1);
+ }
+ }
unsigned int endPos = startPos + length;
int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
@@ -767,6 +797,20 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt char chNext = styler[startPos];
int styleNext = MaskActive(styler.StyleAt(startPos));
int style = MaskActive(initStyle);
+
+ // restore fold state (if it exists) for prior line
+ int stateCurrent = 0;
+ std::map<int,int>::iterator foldStateIterator = foldState.find(lineCurrent-1);
+ if (foldStateIterator != foldState.end()) {
+ stateCurrent = foldStateIterator->second;
+ }
+
+ // remove all foldState entries after lineCurrent-1
+ foldStateIterator = foldState.upper_bound(lineCurrent-1);
+ if (foldStateIterator != foldState.end()) {
+ foldState.erase(foldStateIterator, foldState.end());
+ }
+
for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
@@ -822,6 +866,28 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt levelNext--;
}
}
+ // semicolons terminate external declarations
+ if (ch == ';') {
+ // extern and pure virtual declarations terminated by semicolon
+ if (stateCurrent & foldExternFlag) {
+ levelNext--;
+ stateCurrent &= ~foldExternFlag;
+ }
+ // wait and disable statements terminated by semicolon
+ if (stateCurrent & foldWaitDisableFlag) {
+ stateCurrent &= ~foldWaitDisableFlag;
+ }
+ // typedef statements terminated by semicolon
+ if (stateCurrent & typedefFlag) {
+ stateCurrent &= ~typedefFlag;
+ }
+ }
+ // wait and disable statements containing '(' will not contain "fork" keyword, special processing is not needed
+ if (ch == '(') {
+ if (stateCurrent & foldWaitDisableFlag) {
+ stateCurrent &= ~foldWaitDisableFlag;
+ }
+ }
}
if (style == SCE_V_OPERATOR) {
if (foldAtBrace) {
@@ -837,7 +903,6 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt if (styler.Match(j, "case") ||
styler.Match(j, "casex") ||
styler.Match(j, "casez") ||
- styler.Match(j, "class") ||
styler.Match(j, "function") ||
styler.Match(j, "generate") ||
styler.Match(j, "covergroup") ||
@@ -848,10 +913,19 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt styler.Match(j, "specify") ||
styler.Match(j, "table") ||
styler.Match(j, "task") ||
- styler.Match(j, "fork") ||
(styler.Match(j, "module") && options.foldAtModule) ||
styler.Match(j, "begin")) {
levelNext++;
+ } else if (styler.Match(j, "class")) {
+ // class does not introduce a block when used in a typedef statement
+ if (!(stateCurrent & typedefFlag))
+ levelNext++;
+ } else if (styler.Match(j, "fork")) {
+ // fork does not introduce a block when used in a wait or disable statement
+ if (stateCurrent & foldWaitDisableFlag) {
+ stateCurrent &= ~foldWaitDisableFlag;
+ } else
+ levelNext++;
} else if (styler.Match(j, "endcase") ||
styler.Match(j, "endclass") ||
styler.Match(j, "endfunction") ||
@@ -870,6 +944,16 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt (styler.Match(j, "endmodule") && options.foldAtModule) ||
(styler.Match(j, "end") && !IsAWordChar(styler.SafeGetCharAt(j + 3)))) {
levelNext--;
+ } else if (styler.Match(j, "extern") ||
+ styler.Match(j, "pure")) {
+ // extern and pure virtual functions/tasks are terminated by ';' not endfunction/endtask
+ stateCurrent |= foldExternFlag;
+ } else if (styler.Match(j, "disable") ||
+ styler.Match(j, "wait")) {
+ // fork does not introduce a block when used in a wait or disable statement
+ stateCurrent |= foldWaitDisableFlag;
+ } else if (styler.Match(j, "typedef")) {
+ stateCurrent |= typedefFlag;
}
}
if (atEOL) {
@@ -882,6 +966,9 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt lev |= SC_FOLDLEVELWHITEFLAG;
if (levelUse < levelNext)
lev |= SC_FOLDLEVELHEADERFLAG;
+ if (stateCurrent) {
+ foldState[lineCurrent] = stateCurrent;
+ }
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
diff --git a/scintilla/scripts/HeaderOrder.txt b/scintilla/scripts/HeaderOrder.txt index 4ab980c..67854c5 100644 --- a/scintilla/scripts/HeaderOrder.txt +++ b/scintilla/scripts/HeaderOrder.txt @@ -27,6 +27,7 @@ #include <new> #include <string> #include <vector> +#include <deque> #include <map> #include <set> #include <algorithm> @@ -123,6 +124,7 @@ // win32 #include "PlatWin.h" +#include "HanjaDic.h" // gtk #include "Converter.h" diff --git a/scintilla/src/CellBuffer.cxx b/scintilla/src/CellBuffer.cxx index f69ab62..4203f0a 100644 --- a/scintilla/src/CellBuffer.cxx +++ b/scintilla/src/CellBuffer.cxx @@ -10,6 +10,7 @@ #include <stdio.h>
#include <stdarg.h>
+#include <stdexcept>
#include <algorithm>
#include "Platform.h"
@@ -786,6 +787,10 @@ const Action &CellBuffer::GetUndoStep() const { void CellBuffer::PerformUndoStep() {
const Action &actionStep = uh.GetUndoStep();
if (actionStep.at == insertAction) {
+ if (substance.Length() < actionStep.lenData) {
+ throw std::runtime_error(
+ "CellBuffer::PerformUndoStep: deletion must be less than document length.");
+ }
BasicDeleteChars(actionStep.position, actionStep.lenData);
} else if (actionStep.at == removeAction) {
BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index 1770657..47c2302 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -787,6 +787,27 @@ int SCI_METHOD Document::GetRelativePosition(int positionStart, int characterOff return pos;
}
+int Document::GetRelativePositionUTF16(int positionStart, int characterOffset) const {
+ int pos = positionStart;
+ if (dbcsCodePage) {
+ const int increment = (characterOffset > 0) ? 1 : -1;
+ while (characterOffset != 0) {
+ const int posNext = NextPosition(pos, increment);
+ if (posNext == pos)
+ return INVALID_POSITION;
+ if (abs(pos-posNext) > 3) // 4 byte character = 2*UTF16.
+ characterOffset -= increment;
+ pos = posNext;
+ characterOffset -= increment;
+ }
+ } else {
+ pos = positionStart + characterOffset;
+ if ((pos < 0) || (pos > Length()))
+ return INVALID_POSITION;
+ }
+ return pos;
+}
+
int SCI_METHOD Document::GetCharacterAndWidth(int position, int *pWidth) const {
int character;
int bytesInCharacter = 1;
@@ -1308,6 +1329,21 @@ int Document::CountCharacters(int startPos, int endPos) const { return count;
}
+int Document::CountUTF16(int startPos, int endPos) const {
+ startPos = MovePositionOutsideChar(startPos, 1, false);
+ endPos = MovePositionOutsideChar(endPos, -1, false);
+ int count = 0;
+ int i = startPos;
+ while (i < endPos) {
+ count++;
+ const int next = NextPosition(i, 1);
+ if ((next - i) > 3)
+ count++;
+ i = next;
+ }
+ return count;
+}
+
int Document::FindColumn(int line, int column) {
int position = LineStart(line);
if ((line >= 0) && (line < LinesTotal())) {
@@ -2347,6 +2383,9 @@ public: doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0) {
buffered[0] = 0;
buffered[1] = 0;
+ if (doc) {
+ ReadCharacter();
+ }
}
UTF8Iterator(const UTF8Iterator &other) {
doc = other.doc;
@@ -2369,10 +2408,8 @@ public: }
return *this;
}
- wchar_t operator*() {
- if (lenCharacters == 0) {
- ReadCharacter();
- }
+ wchar_t operator*() const {
+ assert(lenCharacters != 0);
return buffered[characterIndex];
}
UTF8Iterator &operator++() {
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h index a518c94..23e5636 100644 --- a/scintilla/src/Document.h +++ b/scintilla/src/Document.h @@ -279,6 +279,7 @@ public: int NextPosition(int pos, int moveDir) const;
bool NextCharacter(int &pos, int moveDir) const; // Returns true if pos changed
int SCI_METHOD GetRelativePosition(int positionStart, int characterOffset) const;
+ int GetRelativePositionUTF16(int positionStart, int characterOffset) const;
int SCI_METHOD GetCharacterAndWidth(int position, int *pWidth) const;
int SCI_METHOD CodePage() const;
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
@@ -322,6 +323,7 @@ public: int GetLineIndentPosition(int line) const;
int GetColumn(int position);
int CountCharacters(int startPos, int endPos) const;
+ int CountUTF16(int startPos, int endPos) const;
int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop);
static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);
diff --git a/scintilla/src/EditModel.cxx b/scintilla/src/EditModel.cxx index fe65a8b..b50ade2 100644 --- a/scintilla/src/EditModel.cxx +++ b/scintilla/src/EditModel.cxx @@ -65,6 +65,7 @@ EditModel::EditModel() { imeInteraction = imeWindowed; foldFlags = 0; hotspot = Range(invalidPosition); + hoverIndicatorPos = invalidPosition; wrapWidth = LineLayout::wrapWidthInfinite; pdoc = new Document(); pdoc->AddRef(); diff --git a/scintilla/src/EditModel.h b/scintilla/src/EditModel.h index d8def32..fce26bd 100644 --- a/scintilla/src/EditModel.h +++ b/scintilla/src/EditModel.h @@ -48,6 +48,7 @@ public: ContractionState cs; // Hotspot support Range hotspot; + int hoverIndicatorPos; // Wrapping support int wrapWidth; diff --git a/scintilla/src/EditView.cxx b/scintilla/src/EditView.cxx index 4976d36..9d940f7 100644 --- a/scintilla/src/EditView.cxx +++ b/scintilla/src/EditView.cxx @@ -445,7 +445,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co ll->positions[0] = 0; bool lastSegItalics = false; - BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs); + BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, NULL); while (bfLayout.More()) { const TextSegment ts = bfLayout.Next(); @@ -793,7 +793,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle XYPOSITION xEol = static_cast<XYPOSITION>(ll->positions[lineEnd] - subLineStart); // Fill the virtual space and show selections within it - if (virtualSpace) { + if (virtualSpace > 0.0f) { rcSegment.left = xEol + xStart; rcSegment.right = xEol + xStart + virtualSpace; surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[ll->styles[ll->numCharsInLine]].back); @@ -940,18 +940,18 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle } static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw, - const LineLayout *ll, int xStart, PRectangle rcLine, int subLine) { + const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Indicator::DrawState drawState, int value) { const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; PRectangle rcIndic( ll->positions[startPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent, ll->positions[endPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent + 3); - vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine); + vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, drawState, value); } static void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, int xStart, PRectangle rcLine, int subLine, int lineEnd, bool under) { + int line, int xStart, PRectangle rcLine, int subLine, int lineEnd, bool under, int hoverIndicatorPos) { // Draw decorators const int posLineStart = model.pdoc->LineStart(line); const int lineStart = ll->LineStart(subLine); @@ -967,8 +967,12 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS int endPos = deco->rs.EndRun(startPos); if (endPos > posLineEnd) endPos = posLineEnd; + const bool hover = vsDraw.indicators[deco->indicator].IsDynamic() && + ((hoverIndicatorPos >= startPos) && (hoverIndicatorPos <= endPos)); + const int value = deco->rs.ValueAt(startPos); + Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal; DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart, - surface, vsDraw, ll, xStart, rcLine, subLine); + surface, vsDraw, ll, xStart, rcLine, subLine, drawState, value); startPos = endPos; if (!deco->rs.ValueAt(startPos)) { startPos = deco->rs.EndRun(startPos); @@ -986,13 +990,13 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS if (rangeLine.ContainsCharacter(model.braces[0])) { int braceOffset = model.braces[0] - posLineStart; if (braceOffset < ll->numCharsInLine) { - DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine); + DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1); } } if (rangeLine.ContainsCharacter(model.braces[1])) { int braceOffset = model.braces[1] - posLineStart; if (braceOffset < ll->numCharsInLine) { - DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine); + DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1); } } } @@ -1247,7 +1251,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi // Does not take margin into account but not significant const int xStartVisible = static_cast<int>(subLineStart)-xStart; - BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs); + BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs, NULL); const bool drawWhitespaceBackground = vsDraw.WhitespaceBackgroundDrawn() && !background.isSet; @@ -1424,7 +1428,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi // Foreground drawing loop BreakFinder bfFore(ll, &model.sel, lineRange, posLineStart, xStartVisible, - (((phasesDraw == phasesOne) && selBackDrawn) || vsDraw.selColours.fore.isSet), model.pdoc, &model.reprs); + (((phasesDraw == phasesOne) && selBackDrawn) || vsDraw.selColours.fore.isSet), model.pdoc, &model.reprs, &vsDraw); while (bfFore.More()) { @@ -1447,6 +1451,30 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (vsDraw.hotspotColours.fore.isSet) textFore = vsDraw.hotspotColours.fore; } + if (vsDraw.indicatorsSetFore > 0) { + // At least one indicator sets the text colour so see if it applies to this segment + for (Decoration *deco = model.pdoc->decorations.root; deco; deco = deco->next) { + const int indicatorValue = deco->rs.ValueAt(ts.start + posLineStart); + if (indicatorValue) { + const Indicator &indicator = vsDraw.indicators[deco->indicator]; + const bool hover = indicator.IsDynamic() && + ((model.hoverIndicatorPos >= ts.start + posLineStart) && + (model.hoverIndicatorPos <= ts.end() + posLineStart)); + if (hover) { + if (indicator.sacHover.style == INDIC_TEXTFORE) { + textFore = indicator.sacHover.fore; + } + } else { + if (indicator.sacNormal.style == INDIC_TEXTFORE) { + if (indicator.Flags() & SC_INDICFLAG_VALUEFORE) + textFore = indicatorValue & SC_INDICVALUEMASK; + else + textFore = indicator.sacNormal.fore; + } + } + } + } + } const int inSelection = hideSelection ? 0 : model.sel.CharacterInSelection(iDoc); if (inSelection && (vsDraw.selColours.fore.isSet)) { textFore = (inSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground; @@ -1662,7 +1690,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl } if (phase & drawIndicatorsBack) { - DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, true); + DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, true, model.hoverIndicatorPos); DrawEdgeLine(surface, vsDraw, ll, rcLine, lineRange, xStart); DrawMarkUnderline(surface, model, vsDraw, line, rcLine); } @@ -1677,7 +1705,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl } if (phase & drawIndicatorsFore) { - DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, false); + DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, false, model.hoverIndicatorPos); } // End of the drawing of the current line @@ -1975,11 +2003,11 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, vsPrint.Refresh(*surfaceMeasure, model.pdoc->tabInChars); // Recalculate fixedColumnWidth } - int linePrintStart = model.pdoc->LineFromPosition(pfr->chrg.cpMin); + int linePrintStart = model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMin)); int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1; if (linePrintLast < linePrintStart) linePrintLast = linePrintStart; - int linePrintMax = model.pdoc->LineFromPosition(pfr->chrg.cpMax); + int linePrintMax = model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMax)); if (linePrintLast > linePrintMax) linePrintLast = linePrintMax; //Platform::DebugPrintf("Formatting lines=[%0d,%0d,%0d] top=%0d bottom=%0d line=%0d %0d\n", @@ -1997,7 +2025,7 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, int lineDoc = linePrintStart; - int nPrintPos = pfr->chrg.cpMin; + int nPrintPos = static_cast<int>(pfr->chrg.cpMin); int visibleLine = 0; int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth; if (printParameters.wrapState == eWrapNone) diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 99119a6..147e888 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -630,6 +630,7 @@ void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition ancho sel.RangeMain() = rangeNew;
SetRectangularRange();
ClaimSelection();
+ SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
@@ -657,6 +658,7 @@ void Editor::SetSelection(SelectionPosition currentPos_) { SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor);
}
ClaimSelection();
+ SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
@@ -678,6 +680,7 @@ void Editor::SetEmptySelection(SelectionPosition currentPos_) { sel.RangeMain() = rangeNew;
SetRectangularRange();
ClaimSelection();
+ SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
@@ -1869,28 +1872,9 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
// characters representing themselves.
} else {
- // Unroll 1 to 3 byte UTF-8 sequences. See reference data at:
- // http://www.cl.cam.ac.uk/~mgk25/unicode.html
- // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
- if (byte < 0xE0) {
- int byte2 = static_cast<unsigned char>(s[1]);
- if ((byte2 & 0xC0) == 0x80) {
- // Two-byte-character lead-byte followed by a trail-byte.
- byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F));
- }
- // A two-byte-character lead-byte not followed by trail-byte
- // represents itself.
- } else if (byte < 0xF0) {
- int byte2 = static_cast<unsigned char>(s[1]);
- int byte3 = static_cast<unsigned char>(s[2]);
- if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) {
- // Three-byte-character lead byte followed by two trail bytes.
- byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
- (byte3 & 0x3F));
- }
- // A three-byte-character lead-byte not followed by two trail-bytes
- // represents itself.
- }
+ unsigned int utf32[1] = { 0 };
+ UTF32FromUTF8(s, len, utf32, ELEMENTS(utf32));
+ byte = utf32[0];
}
NotifyChar(byte);
}
@@ -1988,6 +1972,7 @@ void Editor::ClearSelection(bool retainMultipleSelections) { ThinRectangularRange();
sel.RemoveDuplicates();
ClaimSelection();
+ SetHoverIndicatorPosition(sel.MainCaret());
}
void Editor::ClearAll() {
@@ -3669,7 +3654,10 @@ long Editor::FindText( if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
- int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText,
+ long pos = pdoc->FindText(
+ static_cast<int>(ft->chrg.cpMin),
+ static_cast<int>(ft->chrg.cpMax),
+ ft->lpstrText,
(wParam & SCFIND_MATCHCASE) != 0,
(wParam & SCFIND_WHOLEWORD) != 0,
(wParam & SCFIND_WORDSTART) != 0,
@@ -3680,7 +3668,7 @@ long Editor::FindText( ft->chrgText.cpMin = pos;
ft->chrgText.cpMax = pos + lengthFound;
}
- return pos;
+ return static_cast<int>(pos);
} catch (RegexError &) {
errorStatus = SC_STATUS_WARN_REGEX;
return -1;
@@ -3714,7 +3702,7 @@ long Editor::SearchText( sptr_t lParam) { ///< The text to search for.
const char *txt = reinterpret_cast<char *>(lParam);
- int pos;
+ long pos;
int lengthFound = istrlen(txt);
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
@@ -3741,7 +3729,7 @@ long Editor::SearchText( return -1;
}
if (pos != -1) {
- SetSelection(pos, pos + lengthFound);
+ SetSelection(static_cast<int>(pos), static_cast<int>(pos + lengthFound));
}
return pos;
@@ -3774,7 +3762,7 @@ long Editor::SearchInTarget(const char *text, int length) { if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
- int pos = pdoc->FindText(targetStart, targetEnd, text,
+ long pos = pdoc->FindText(targetStart, targetEnd, text,
(searchFlags & SCFIND_MATCHCASE) != 0,
(searchFlags & SCFIND_WHOLEWORD) != 0,
(searchFlags & SCFIND_WORDSTART) != 0,
@@ -3782,8 +3770,8 @@ long Editor::SearchInTarget(const char *text, int length) { searchFlags,
&lengthFound);
if (pos != -1) {
- targetStart = pos;
- targetEnd = pos + lengthFound;
+ targetStart = static_cast<int>(pos);
+ targetEnd = static_cast<int>(pos + lengthFound);
}
return pos;
} catch (RegexError &) {
@@ -4133,6 +4121,7 @@ static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) { }
void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) {
+ SetHoverIndicatorPoint(pt);
//Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop);
ptMouseLast = pt;
const bool ctrl = (modifiers & SCI_CTRL) != 0;
@@ -4331,6 +4320,36 @@ bool Editor::PointIsHotspot(Point pt) { return PositionIsHotspot(pos);
}
+void Editor::SetHoverIndicatorPosition(int position) {
+ int hoverIndicatorPosPrev = hoverIndicatorPos;
+ hoverIndicatorPos = INVALID_POSITION;
+ if (vs.indicatorsDynamic == 0)
+ return;
+ if (position != INVALID_POSITION) {
+ for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
+ if (vs.indicators[deco->indicator].IsDynamic()) {
+ if (pdoc->decorations.ValueAt(deco->indicator, position)) {
+ hoverIndicatorPos = position;
+ }
+ }
+ }
+ }
+ if (hoverIndicatorPosPrev != hoverIndicatorPos) {
+ if (hoverIndicatorPosPrev != INVALID_POSITION)
+ InvalidateRange(hoverIndicatorPosPrev, hoverIndicatorPosPrev + 1);
+ if (hoverIndicatorPos != INVALID_POSITION)
+ InvalidateRange(hoverIndicatorPos, hoverIndicatorPos + 1);
+ }
+}
+
+void Editor::SetHoverIndicatorPoint(Point pt) {
+ if (vs.indicatorsDynamic == 0) {
+ SetHoverIndicatorPosition(INVALID_POSITION);
+ } else {
+ SetHoverIndicatorPosition(PositionFromLocation(pt, true, true));
+ }
+}
+
void Editor::SetHotSpotRange(Point *pt) {
if (pt) {
int pos = PositionFromLocation(*pt, false, true);
@@ -4473,12 +4492,18 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { // Display regular (drag) cursor over selection
if (PointInSelection(pt) && !SelectionEmpty()) {
DisplayCursor(Window::cursorArrow);
- } else if (PointIsHotspot(pt)) {
- DisplayCursor(Window::cursorHand);
- SetHotSpotRange(&pt);
} else {
- DisplayCursor(Window::cursorText);
- SetHotSpotRange(NULL);
+ SetHoverIndicatorPoint(pt);
+ if (PointIsHotspot(pt)) {
+ DisplayCursor(Window::cursorHand);
+ SetHotSpotRange(&pt);
+ } else {
+ if (hoverIndicatorPos != invalidPosition)
+ DisplayCursor(Window::cursorHand);
+ else
+ DisplayCursor(Window::cursorText);
+ SetHotSpotRange(NULL);
+ }
}
}
}
@@ -4491,6 +4516,8 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { //Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
SelectionPosition newPos = SPositionFromLocation(pt, false, false,
AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
+ if (hoverIndicatorPos != INVALID_POSITION)
+ InvalidateRange(newPos.Position(), newPos.Position() + 1);
newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position());
if (inDragDrop == ddInitial) {
inDragDrop = ddNone;
@@ -4806,6 +4833,7 @@ void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) { void Editor::SetAnnotationHeights(int start, int end) {
if (vs.annotationVisible) {
+ RefreshStyleData();
bool changedHeight = false;
for (int line=start; line<end && line<pdoc->LinesTotal(); line++) {
int linesWrapped = 1;
@@ -4856,6 +4884,9 @@ void Editor::SetDocPointer(Document *document) { view.llc.Deallocate();
NeedWrapping();
+ hotspot = Range(invalidPosition);
+ hoverIndicatorPos = invalidPosition;
+
view.ClearAllTabstops();
pdoc->AddWatcher(this, 0);
@@ -5309,7 +5340,7 @@ sptr_t Editor::StringResult(sptr_t lParam, const char *val) { sptr_t Editor::BytesResult(sptr_t lParam, const unsigned char *val, size_t len) {
// No NUL termination: len is number of valid/displayed bytes
- if (lParam) {
+ if ((lParam) && (len > 0)) {
char *ptr = CharPtrFromSPtr(lParam);
if (val)
memcpy(ptr, val, len);
@@ -5527,6 +5558,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETTARGETEND:
return targetEnd;
+ case SCI_SETTARGETRANGE:
+ targetStart = static_cast<int>(wParam);
+ targetEnd = static_cast<int>(lParam);
+ break;
+
case SCI_TARGETFROMSELECTION:
if (sel.MainCaret() < sel.MainAnchor()) {
targetStart = sel.MainCaret();
@@ -5537,6 +5573,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { }
break;
+ case SCI_GETTARGETTEXT: {
+ std::string text = RangeText(targetStart, targetEnd);
+ return BytesResult(lParam, reinterpret_cast<const unsigned char *>(text.c_str()), text.length());
+ }
+
case SCI_REPLACETARGET:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<int>(wParam));
@@ -5625,12 +5666,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam == 0)
return 0;
Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam);
- int cpMax = tr->chrg.cpMax;
+ int cpMax = static_cast<int>(tr->chrg.cpMax);
if (cpMax == -1)
cpMax = pdoc->Length();
PLATFORM_ASSERT(cpMax <= pdoc->Length());
- int len = cpMax - tr->chrg.cpMin; // No -1 as cpMin and cpMax are referring to inter character positions
- pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len);
+ int len = static_cast<int>(cpMax - tr->chrg.cpMin); // No -1 as cpMin and cpMax are referring to inter character positions
+ pdoc->GetCharRange(tr->lpstrText, static_cast<int>(tr->chrg.cpMin), len);
// Spec says copied text is terminated with a NUL
tr->lpstrText[len] = '\0';
return len; // Not including NUL
@@ -5868,9 +5909,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0;
Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam);
int iPlace = 0;
- for (int iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) {
- tr->lpstrText[iPlace++] = pdoc->CharAt(iChar);
- tr->lpstrText[iPlace++] = pdoc->StyleAt(iChar);
+ for (long iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) {
+ tr->lpstrText[iPlace++] = pdoc->CharAt(static_cast<int>(iChar));
+ tr->lpstrText[iPlace++] = pdoc->StyleAt(static_cast<int>(iChar));
}
tr->lpstrText[iPlace] = '\0';
tr->lpstrText[iPlace + 1] = '\0';
@@ -6781,23 +6822,55 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETSTYLE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].style = static_cast<int>(lParam);
+ vs.indicators[wParam].sacNormal.style = static_cast<int>(lParam);
+ vs.indicators[wParam].sacHover.style = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETSTYLE:
- return (wParam <= INDIC_MAX) ? vs.indicators[wParam].style : 0;
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.style : 0;
case SCI_INDICSETFORE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].fore = ColourDesired(static_cast<long>(lParam));
+ vs.indicators[wParam].sacNormal.fore = ColourDesired(static_cast<long>(lParam));
+ vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<long>(lParam));
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETFORE:
- return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.AsLong() : 0;
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.fore.AsLong() : 0;
+
+ case SCI_INDICSETHOVERSTYLE:
+ if (wParam <= INDIC_MAX) {
+ vs.indicators[wParam].sacHover.style = static_cast<int>(lParam);
+ InvalidateStyleRedraw();
+ }
+ break;
+
+ case SCI_INDICGETHOVERSTYLE:
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.style : 0;
+
+ case SCI_INDICSETHOVERFORE:
+ if (wParam <= INDIC_MAX) {
+ vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<long>(lParam));
+ InvalidateStyleRedraw();
+ }
+ break;
+
+ case SCI_INDICGETHOVERFORE:
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.fore.AsLong() : 0;
+
+ case SCI_INDICSETFLAGS:
+ if (wParam <= INDIC_MAX) {
+ vs.indicators[wParam].SetFlags(static_cast<int>(lParam));
+ InvalidateStyleRedraw();
+ }
+ break;
+
+ case SCI_INDICGETFLAGS:
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].Flags() : 0;
case SCI_INDICSETUNDER:
if (wParam <= INDIC_MAX) {
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index d65d0b8..82640fb 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -545,6 +545,8 @@ protected: // ScintillaBase subclass needs access to much of Editor bool PointIsHotspot(Point pt);
void SetHotSpotRange(Point *pt);
Range GetHotSpotRange() const;
+ void SetHoverIndicatorPosition(int position);
+ void SetHoverIndicatorPoint(Point pt);
int CodePage() const;
virtual bool ValidCodePage(int /* codePage */) const { return true; }
diff --git a/scintilla/src/Indicator.cxx b/scintilla/src/Indicator.cxx index f6e81f8..ec5db53 100644 --- a/scintilla/src/Indicator.cxx +++ b/scintilla/src/Indicator.cxx @@ -23,10 +23,17 @@ static PRectangle PixelGridAlign(const PRectangle &rc) { return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom));
}
-void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const {
- surface->PenColour(fore);
+void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const {
+ StyleAndColour sacDraw = sacNormal;
+ if (Flags() & SC_INDICFLAG_VALUEFORE) {
+ sacDraw.fore = value & SC_INDICVALUEMASK;
+ }
+ if (drawState == drawHover) {
+ sacDraw = sacHover;
+ }
+ surface->PenColour(sacDraw.fore);
int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
- if (style == INDIC_SQUIGGLE) {
+ if (sacDraw.style == INDIC_SQUIGGLE) {
int x = int(rc.left+0.5);
int xLast = int(rc.right+0.5);
int y = 0;
@@ -42,7 +49,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r }
surface->LineTo(x, static_cast<int>(rc.top) + y);
}
- } else if (style == INDIC_SQUIGGLEPIXMAP) {
+ } else if (sacDraw.style == INDIC_SQUIGGLEPIXMAP) {
PRectangle rcSquiggle = PixelGridAlign(rc);
int width = Platform::Minimum(4000, static_cast<int>(rcSquiggle.Width()));
@@ -51,17 +58,17 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r for (int x = 0; x < width; x++) {
if (x%2) {
// Two halfway columns have a full pixel in middle flanked by light pixels
- image.SetPixel(x, 0, fore, alphaSide);
- image.SetPixel(x, 1, fore, alphaFull);
- image.SetPixel(x, 2, fore, alphaSide);
+ image.SetPixel(x, 0, sacDraw.fore, alphaSide);
+ image.SetPixel(x, 1, sacDraw.fore, alphaFull);
+ image.SetPixel(x, 2, sacDraw.fore, alphaSide);
} else {
// Extreme columns have a full pixel at bottom or top and a mid-tone pixel in centre
- image.SetPixel(x, (x%4) ? 0 : 2, fore, alphaFull);
- image.SetPixel(x, 1, fore, alphaSide2);
+ image.SetPixel(x, (x % 4) ? 0 : 2, sacDraw.fore, alphaFull);
+ image.SetPixel(x, 1, sacDraw.fore, alphaSide2);
}
}
surface->DrawRGBAImage(rcSquiggle, image.GetWidth(), image.GetHeight(), image.Pixels());
- } else if (style == INDIC_SQUIGGLELOW) {
+ } else if (sacDraw.style == INDIC_SQUIGGLELOW) {
surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top));
int x = static_cast<int>(rc.left) + 3;
int y = 0;
@@ -72,7 +79,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r x += 3;
}
surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) + y); // Finish the line
- } else if (style == INDIC_TT) {
+ } else if (sacDraw.style == INDIC_TT) {
surface->MoveTo(static_cast<int>(rc.left), ymid);
int x = static_cast<int>(rc.left) + 5;
while (x < rc.right) {
@@ -88,7 +95,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r surface->MoveTo(x-3, ymid);
surface->LineTo(x-3, ymid+2);
}
- } else if (style == INDIC_DIAGONAL) {
+ } else if (sacDraw.style == INDIC_DIAGONAL) {
int x = static_cast<int>(rc.left);
while (x < rc.right) {
surface->MoveTo(x, static_cast<int>(rc.top) + 2);
@@ -101,24 +108,28 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r surface->LineTo(endX, endY);
x += 4;
}
- } else if (style == INDIC_STRIKE) {
+ } else if (sacDraw.style == INDIC_STRIKE) {
surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top) - 4);
surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) - 4);
- } else if (style == INDIC_HIDDEN) {
+ } else if ((sacDraw.style == INDIC_HIDDEN) || (sacDraw.style == INDIC_TEXTFORE)) {
// Draw nothing
- } else if (style == INDIC_BOX) {
+ } else if (sacDraw.style == INDIC_BOX) {
surface->MoveTo(static_cast<int>(rc.left), ymid + 1);
surface->LineTo(static_cast<int>(rc.right), ymid + 1);
surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rcLine.top) + 1);
surface->LineTo(static_cast<int>(rc.left), static_cast<int>(rcLine.top) + 1);
surface->LineTo(static_cast<int>(rc.left), ymid + 1);
- } else if (style == INDIC_ROUNDBOX || style == INDIC_STRAIGHTBOX) {
+ } else if (sacDraw.style == INDIC_ROUNDBOX ||
+ sacDraw.style == INDIC_STRAIGHTBOX ||
+ sacDraw.style == INDIC_FULLBOX) {
PRectangle rcBox = rcLine;
- rcBox.top = rcLine.top + 1;
+ if (sacDraw.style != INDIC_FULLBOX)
+ rcBox.top = rcLine.top + 1;
rcBox.left = rc.left;
rcBox.right = rc.right;
- surface->AlphaRectangle(rcBox, (style == INDIC_ROUNDBOX) ? 1 : 0, fore, fillAlpha, fore, outlineAlpha, 0);
- } else if (style == INDIC_DOTBOX) {
+ surface->AlphaRectangle(rcBox, (sacDraw.style == INDIC_ROUNDBOX) ? 1 : 0,
+ sacDraw.fore, fillAlpha, sacDraw.fore, outlineAlpha, 0);
+ } else if (sacDraw.style == INDIC_DOTBOX) {
PRectangle rcBox = PixelGridAlign(rc);
rcBox.top = rcLine.top + 1;
rcBox.bottom = rcLine.bottom;
@@ -128,36 +139,42 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r // Draw horizontal lines top and bottom
for (int x=0; x<width; x++) {
for (int y = 0; y<static_cast<int>(rcBox.Height()); y += static_cast<int>(rcBox.Height()) - 1) {
- image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
+ image.SetPixel(x, y, sacDraw.fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
// Draw vertical lines left and right
for (int y = 1; y<static_cast<int>(rcBox.Height()); y++) {
for (int x=0; x<width; x += width-1) {
- image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
+ image.SetPixel(x, y, sacDraw.fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels());
- } else if (style == INDIC_DASH) {
+ } else if (sacDraw.style == INDIC_DASH) {
int x = static_cast<int>(rc.left);
while (x < rc.right) {
surface->MoveTo(x, ymid);
surface->LineTo(Platform::Minimum(x + 4, static_cast<int>(rc.right)), ymid);
x += 7;
}
- } else if (style == INDIC_DOTS) {
+ } else if (sacDraw.style == INDIC_DOTS) {
int x = static_cast<int>(rc.left);
while (x < static_cast<int>(rc.right)) {
PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1);
- surface->FillRectangle(rcDot, fore);
+ surface->FillRectangle(rcDot, sacDraw.fore);
x += 2;
}
- } else if (style == INDIC_COMPOSITIONTHICK) {
+ } else if (sacDraw.style == INDIC_COMPOSITIONTHICK) {
PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom);
- surface->FillRectangle(rcComposition, fore);
+ surface->FillRectangle(rcComposition, sacDraw.fore);
+ } else if (sacDraw.style == INDIC_COMPOSITIONTHIN) {
+ PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1);
+ surface->FillRectangle(rcComposition, sacDraw.fore);
} else { // Either INDIC_PLAIN or unknown
surface->MoveTo(static_cast<int>(rc.left), ymid);
surface->LineTo(static_cast<int>(rc.right), ymid);
}
}
+void Indicator::SetFlags(int attributes_) {
+ attributes = attributes_;
+}
diff --git a/scintilla/src/Indicator.h b/scintilla/src/Indicator.h index 8f2c170..d6f88ba 100644 --- a/scintilla/src/Indicator.h +++ b/scintilla/src/Indicator.h @@ -12,21 +12,45 @@ namespace Scintilla {
#endif
+struct StyleAndColour {
+ int style;
+ ColourDesired fore;
+ StyleAndColour() : style(INDIC_PLAIN), fore(0, 0, 0) {
+ }
+ StyleAndColour(int style_, ColourDesired fore_ = ColourDesired(0, 0, 0)) : style(style_), fore(fore_) {
+ }
+ bool operator==(const StyleAndColour &other) const {
+ return (style == other.style) && (fore == other.fore);
+ }
+};
+
/**
*/
class Indicator {
public:
- int style;
- ColourDesired fore;
+ enum DrawState { drawNormal, drawHover };
+ StyleAndColour sacNormal;
+ StyleAndColour sacHover;
bool under;
int fillAlpha;
int outlineAlpha;
- Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)), under(false), fillAlpha(30), outlineAlpha(50) {
+ int attributes;
+ Indicator() : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) {
}
Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) :
- style(style_), fore(fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_) {
+ sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(0) {
+ }
+ void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const;
+ bool IsDynamic() const {
+ return !(sacNormal == sacHover);
+ }
+ bool OverridesTextFore() const {
+ return sacNormal.style == INDIC_TEXTFORE || sacHover.style == INDIC_TEXTFORE;
+ }
+ int Flags() const {
+ return attributes;
}
- void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const;
+ void SetFlags(int attributes_);
};
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx index 7418389..930e898 100644 --- a/scintilla/src/PositionCache.cxx +++ b/scintilla/src/PositionCache.cxx @@ -440,7 +440,7 @@ void BreakFinder::Insert(int val) { }
BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, int posLineStart_,
- int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_) :
+ int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) :
ll(ll_),
lineRange(lineRange_),
posLineStart(posLineStart_),
@@ -475,7 +475,17 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin }
}
}
-
+ if (pvsDraw && pvsDraw->indicatorsSetFore > 0) {
+ for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
+ if (pvsDraw->indicators[deco->indicator].OverridesTextFore()) {
+ int startPos = deco->rs.EndRun(posLineStart);
+ while (startPos < (posLineStart + lineRange.end)) {
+ Insert(startPos - posLineStart);
+ startPos = deco->rs.EndRun(startPos);
+ }
+ }
+ }
+ }
Insert(ll->edgeColumn);
Insert(lineRange.end);
saeNext = (!selAndEdge.empty()) ? selAndEdge[0] : -1;
diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h index ae3528a..2c4443c 100644 --- a/scintilla/src/PositionCache.h +++ b/scintilla/src/PositionCache.h @@ -168,7 +168,7 @@ public: // Try to make each subdivided run lengthEachSubdivision or shorter.
enum { lengthEachSubdivision = 100 };
BreakFinder(const LineLayout *ll_, const Selection *psel, Range rangeLine_, int posLineStart_,
- int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_);
+ int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw);
~BreakFinder();
TextSegment Next();
bool More() const;
diff --git a/scintilla/src/RESearch.cxx b/scintilla/src/RESearch.cxx index e0fb9ca..4c60f55 100644 --- a/scintilla/src/RESearch.cxx +++ b/scintilla/src/RESearch.cxx @@ -342,8 +342,8 @@ static int GetHexaChar(unsigned char hd1, unsigned char hd2) { /**
* Called when the parser finds a backslash not followed
* by a valid expression (like \( in non-Posix mode).
- * @param pattern: pointer on the char after the backslash.
- * @param incr: (out) number of chars to skip after expression evaluation.
+ * @param pattern : pointer on the char after the backslash.
+ * @param incr : (out) number of chars to skip after expression evaluation.
* @return the char if it resolves to a simple char,
* or -1 for a char class. In this case, bittab is changed.
*/
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx index 906f764..914b54d 100644 --- a/scintilla/src/ScintillaBase.cxx +++ b/scintilla/src/ScintillaBase.cxx @@ -587,7 +587,7 @@ void LexState::SetLexerModule(const LexerModule *lex) { }
void LexState::SetLexer(uptr_t wParam) {
- lexLanguage = wParam;
+ lexLanguage = static_cast<int>(wParam);
if (lexLanguage == SCLEX_CONTAINER) {
SetLexerModule(0);
} else {
@@ -999,7 +999,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam), static_cast<int>(lParam));
case SCI_SETKEYWORDS:
- DocumentLexState()->SetWordList(wParam, reinterpret_cast<const char *>(lParam));
+ DocumentLexState()->SetWordList(static_cast<int>(wParam), reinterpret_cast<const char *>(lParam));
break;
case SCI_SETLEXERLANGUAGE:
@@ -1011,7 +1011,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_PRIVATELEXERCALL:
return reinterpret_cast<sptr_t>(
- DocumentLexState()->PrivateCall(wParam, reinterpret_cast<void *>(lParam)));
+ DocumentLexState()->PrivateCall(static_cast<int>(wParam), reinterpret_cast<void *>(lParam)));
case SCI_GETSTYLEBITSNEEDED:
return 8;
@@ -1023,7 +1023,8 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return DocumentLexState()->PropertyType(reinterpret_cast<const char *>(wParam));
case SCI_DESCRIBEPROPERTY:
- return StringResult(lParam, DocumentLexState()->DescribeProperty(reinterpret_cast<const char *>(wParam)));
+ return StringResult(lParam,
+ DocumentLexState()->DescribeProperty(reinterpret_cast<const char *>(wParam)));
case SCI_DESCRIBEKEYWORDSETS:
return StringResult(lParam, DocumentLexState()->DescribeWordListSets());
@@ -1032,26 +1033,27 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return DocumentLexState()->LineEndTypesSupported();
case SCI_ALLOCATESUBSTYLES:
- return DocumentLexState()->AllocateSubStyles(wParam, lParam);
+ return DocumentLexState()->AllocateSubStyles(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_GETSUBSTYLESSTART:
- return DocumentLexState()->SubStylesStart(wParam);
+ return DocumentLexState()->SubStylesStart(static_cast<int>(wParam));
case SCI_GETSUBSTYLESLENGTH:
- return DocumentLexState()->SubStylesLength(wParam);
+ return DocumentLexState()->SubStylesLength(static_cast<int>(wParam));
case SCI_GETSTYLEFROMSUBSTYLE:
- return DocumentLexState()->StyleFromSubStyle(wParam);
+ return DocumentLexState()->StyleFromSubStyle(static_cast<int>(wParam));
case SCI_GETPRIMARYSTYLEFROMSTYLE:
- return DocumentLexState()->PrimaryStyleFromStyle(wParam);
+ return DocumentLexState()->PrimaryStyleFromStyle(static_cast<int>(wParam));
case SCI_FREESUBSTYLES:
DocumentLexState()->FreeSubStyles();
break;
case SCI_SETIDENTIFIERS:
- DocumentLexState()->SetIdentifiers(wParam, reinterpret_cast<const char *>(lParam));
+ DocumentLexState()->SetIdentifiers(static_cast<int>(wParam),
+ reinterpret_cast<const char *>(lParam));
break;
case SCI_DISTANCETOSECONDARYSTYLES:
diff --git a/scintilla/src/UniConversion.cxx b/scintilla/src/UniConversion.cxx index f261d12..4421d1a 100644 --- a/scintilla/src/UniConversion.cxx +++ b/scintilla/src/UniConversion.cxx @@ -17,7 +17,6 @@ using namespace Scintilla; namespace Scintilla {
#endif
-enum { SURROGATE_LEAD_FIRST = 0xD800 };
enum { SURROGATE_TRAIL_FIRST = 0xDC00 };
enum { SURROGATE_TRAIL_LAST = 0xDFFF };
enum { SUPPLEMENTAL_PLANE_FIRST = 0x10000 };
@@ -43,7 +42,7 @@ unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) { }
void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
- int k = 0;
+ unsigned int k = 0;
for (unsigned int i = 0; i < tlen && uptr[i];) {
unsigned int uch = uptr[i];
if (uch < 0x80) {
@@ -67,7 +66,8 @@ void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned }
i++;
}
- putf[len] = '\0';
+ if (k < len)
+ putf[k] = '\0';
}
unsigned int UTF8CharLength(unsigned char ch) {
@@ -145,7 +145,7 @@ unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf, unsigned int i=0;
while ((i<len) && (ui<tlen)) {
unsigned char ch = us[i++];
- wchar_t value = 0;
+ unsigned int value = 0;
if (ch < 0x80) {
value = ch;
} else if (((len-i) >= 1) && (ch < 0x80 + 0x40 + 0x20)) {
diff --git a/scintilla/src/UniConversion.h b/scintilla/src/UniConversion.h index 23dcc17..e2e3887 100644 --- a/scintilla/src/UniConversion.h +++ b/scintilla/src/UniConversion.h @@ -55,6 +55,12 @@ inline bool UTF8IsNEL(const unsigned char *us) { return (us[0] == 0xc2) && (us[1] == 0x85);
}
+enum { SURROGATE_LEAD_FIRST = 0xD800 };
+enum { SURROGATE_LEAD_LAST = 0xDBFF };
+inline unsigned int UTF16CharLength(wchar_t uch) {
+ return ((uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_LEAD_LAST)) ? 2 : 1;
+}
+
#ifdef SCI_NAMESPACE
}
#endif
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index 8a62a90..d815614 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -101,8 +101,14 @@ ViewStyle::ViewStyle(const ViewStyle &source) { markers[mrk] = source.markers[mrk];
}
CalcLargestMarkerHeight();
+ indicatorsDynamic = 0;
+ indicatorsSetFore = 0;
for (int ind=0; ind<=INDIC_MAX; ind++) {
indicators[ind] = source.indicators[ind];
+ if (indicators[ind].IsDynamic())
+ indicatorsDynamic++;
+ if (indicators[ind].OverridesTextFore())
+ indicatorsSetFore++;
}
selColours = source.selColours;
@@ -197,6 +203,8 @@ void ViewStyle::Init(size_t stylesSize_) { indicators[2] = Indicator(INDIC_PLAIN, ColourDesired(0xff, 0, 0));
technology = SC_TECHNOLOGY_DEFAULT;
+ indicatorsDynamic = 0;
+ indicatorsSetFore = 0;
lineHeight = 1;
lineOverlap = 0;
maxAscent = 1;
@@ -318,6 +326,14 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) { FontRealised *fr = Find(styles[k]);
styles[k].Copy(fr->font, *fr);
}
+ indicatorsDynamic = 0;
+ indicatorsSetFore = 0;
+ for (int ind = 0; ind <= INDIC_MAX; ind++) {
+ if (indicators[ind].IsDynamic())
+ indicatorsDynamic++;
+ if (indicators[ind].OverridesTextFore())
+ indicatorsSetFore++;
+ }
maxAscent = 1;
maxDescent = 1;
FindMaxAscentDescent();
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h index 7b83546..df0e322 100644 --- a/scintilla/src/ViewStyle.h +++ b/scintilla/src/ViewStyle.h @@ -83,6 +83,8 @@ public: LineMarker markers[MARKER_MAX + 1];
int largestMarkerHeight;
Indicator indicators[INDIC_MAX + 1];
+ unsigned int indicatorsDynamic;
+ unsigned int indicatorsSetFore;
int technology;
int lineHeight;
int lineOverlap;
diff --git a/scintilla/version.txt b/scintilla/version.txt index 8f3487f..a32b072 100644 --- a/scintilla/version.txt +++ b/scintilla/version.txt @@ -1 +1 @@ -353
+354
diff --git a/scintilla/win32/HanjaDic.cxx b/scintilla/win32/HanjaDic.cxx new file mode 100644 index 0000000..94fc10b --- /dev/null +++ b/scintilla/win32/HanjaDic.cxx @@ -0,0 +1,122 @@ +// Scintilla source code edit control +/** @file HanjaDic.cxx + ** Korean Hanja Dictionary + ** Convert between Korean Hanja and Hangul by COM interface. + **/ +// Copyright 2015 by Neil Hodgson <neilh@scintilla.org> +// The License.txt file describes the conditions under which this software may be distributed. + +#include <windows.h> + +#include "UniConversion.h" +#include "HanjaDic.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +namespace HanjaDict { + +interface IRadical; +interface IHanja; +interface IStrokes; + +typedef enum { HANJA_UNKNOWN = 0, HANJA_K0 = 1, HANJA_K1 = 2, HANJA_OTHER = 3 } HANJA_TYPE; + +interface IHanjaDic : IUnknown { + STDMETHOD(OpenMainDic)(); + STDMETHOD(CloseMainDic)(); + STDMETHOD(GetHanjaWords)(BSTR bstrHangul, SAFEARRAY* ppsaHanja, VARIANT_BOOL* pfFound); + STDMETHOD(GetHanjaChars)(unsigned short wchHangul, BSTR* pbstrHanjaChars, VARIANT_BOOL* pfFound); + STDMETHOD(HanjaToHangul)(BSTR bstrHanja, BSTR* pbstrHangul); + STDMETHOD(GetHanjaType)(unsigned short wchHanja, HANJA_TYPE* pHanjaType); + STDMETHOD(GetHanjaSense)(unsigned short wchHanja, BSTR* pbstrSense); + STDMETHOD(GetRadicalID)(short SeqNumOfRadical, short* pRadicalID, unsigned short* pwchRadical); + STDMETHOD(GetRadical)(short nRadicalID, IRadical** ppIRadical); + STDMETHOD(RadicalIDToHanja)(short nRadicalID, unsigned short* pwchRadical); + STDMETHOD(GetHanja)(unsigned short wchHanja, IHanja** ppIHanja); + STDMETHOD(GetStrokes)(short nStrokes, IStrokes** ppIStrokes); + STDMETHOD(OpenDefaultCustomDic)(); + STDMETHOD(OpenCustomDic)(BSTR bstrPath, long* plUdr); + STDMETHOD(CloseDefaultCustomDic)(); + STDMETHOD(CloseCustomDic)(long lUdr); + STDMETHOD(CloseAllCustomDics)(); + STDMETHOD(GetDefaultCustomHanjaWords)(BSTR bstrHangul, SAFEARRAY** ppsaHanja, VARIANT_BOOL* pfFound); + STDMETHOD(GetCustomHanjaWords)(long lUdr, BSTR bstrHangul, SAFEARRAY** ppsaHanja, VARIANT_BOOL* pfFound); + STDMETHOD(PutDefaultCustomHanjaWord)(BSTR bstrHangul, BSTR bstrHanja); + STDMETHOD(PutCustomHanjaWord)(long lUdr, BSTR bstrHangul, BSTR bstrHanja); + STDMETHOD(MaxNumOfRadicals)(short* pVal); + STDMETHOD(MaxNumOfStrokes)(short* pVal); + STDMETHOD(DefaultCustomDic)(long* pVal); + STDMETHOD(DefaultCustomDic)(long pVal); + STDMETHOD(MaxHanjaType)(HANJA_TYPE* pHanjaType); + STDMETHOD(MaxHanjaType)(HANJA_TYPE pHanjaType); +}; + +extern "C" const GUID __declspec(selectany) IID_IHanjaDic = +{ 0xad75f3ac, 0x18cd, 0x48c6, { 0xa2, 0x7d, 0xf1, 0xe9, 0xa7, 0xdc, 0xe4, 0x32 } }; + +class HanjaDic { +private: + HRESULT hr; + CLSID CLSID_HanjaDic; + +public: + IHanjaDic *HJinterface; + + HanjaDic() : HJinterface(NULL) { + hr = CLSIDFromProgID(OLESTR("mshjdic.hanjadic"), &CLSID_HanjaDic); + if (SUCCEEDED(hr)) { + hr = CoCreateInstance(CLSID_HanjaDic, NULL, + CLSCTX_INPROC_SERVER, IID_IHanjaDic, + (LPVOID *)& HJinterface); + if (SUCCEEDED(hr)) { + hr = HJinterface->OpenMainDic(); + } + } + } + + ~HanjaDic() { + if (SUCCEEDED(hr)) { + hr = HJinterface->CloseMainDic(); + HJinterface->Release(); + } + } + + bool HJdictAvailable() { + return SUCCEEDED(hr); + } + + bool IsHanja(int hanja) { + HANJA_TYPE hanjaType; + hr = HJinterface->GetHanjaType(static_cast<unsigned short>(hanja), &hanjaType); + if (SUCCEEDED(hr)) { + return (hanjaType > 0); + } + return false; + } +}; + +int GetHangulOfHanja(int hanjaChar) { + // Convert hanja character to hangul one. + int hangulChar = -1; // If fails, return -1. + HanjaDic dict; + if (!dict.HJdictAvailable() || !dict.IsHanja(hanjaChar)) { + return hangulChar; + } + wchar_t convHnja[UTF8MaxBytes] = {0}; + convHnja[0] = static_cast<wchar_t>(hanjaChar); + + BSTR bstrHangul = SysAllocString(NULL); + BSTR bstrHanja = SysAllocString(convHnja); + HRESULT hr = dict.HJinterface->HanjaToHangul(bstrHanja, &bstrHangul); + if (SUCCEEDED(hr)) { + wchar_t wHangul = static_cast<wchar_t *>(bstrHangul)[0]; + hangulChar = static_cast<int>(wHangul); + } + SysFreeString(bstrHangul); + SysFreeString(bstrHanja); + return hangulChar; +} + +} diff --git a/scintilla/win32/HanjaDic.h b/scintilla/win32/HanjaDic.h new file mode 100644 index 0000000..5ba61f6 --- /dev/null +++ b/scintilla/win32/HanjaDic.h @@ -0,0 +1,26 @@ +// Scintilla source code edit control +/** @file HanjaDic.h + ** Korean Hanja Dictionary + ** Convert between Korean Hanja and Hangul by COM interface. + **/ +// Copyright 2015 by Neil Hodgson <neilh@scintilla.org> +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef HANJADIC_H +#define HANJADIC_H + +#ifdef SCI_NAMESPACE +namespace Scintilla { +#endif + +namespace HanjaDict { + +int GetHangulOfHanja(int character); + +} + +#ifdef SCI_NAMESPACE +} +#endif + +#endif diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index 211b8d4..69e6407 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -84,6 +84,7 @@ #endif
#include "PlatWin.h"
+#include "HanjaDic.h"
#ifndef SPI_GETWHEELSCROLLLINES
#define SPI_GETWHEELSCROLLLINES 104
@@ -251,6 +252,11 @@ class ScintillaWin : void MoveImeCarets(int offset);
void DrawImeIndicator(int indicator, int len);
void SetCandidateWindowPos();
+ void BytesToUniChar(const char *bytes, const int bytesLen, wchar_t *character, int &charsLen);
+ void UniCharToBytes(const wchar_t *character, const int charsLen, char *bytes, int &bytesLen);
+ void RangeToHangul(int uniStrLen);
+ void EscapeHanja();
+ void ToggleHanja();
UINT CodePageOfDocument();
virtual bool ValidCodePage(int codePage) const;
@@ -802,6 +808,127 @@ void ScintillaWin::SetCandidateWindowPos() { }
}
+void ScintillaWin::BytesToUniChar(const char *bytes, const int bytesLen, wchar_t *characters, int &charsLen) {
+ // Return results over characters and charsLen.
+ if (IsUnicodeMode()) {
+ charsLen = ::MultiByteToWideChar(SC_CP_UTF8, 0, bytes, bytesLen, NULL, 0);
+ ::MultiByteToWideChar(SC_CP_UTF8, 0, bytes, bytesLen, characters, charsLen);
+ } else {
+ charsLen = ::MultiByteToWideChar(CodePageOfDocument(), 0, bytes, bytesLen, NULL, 0);
+ ::MultiByteToWideChar(CodePageOfDocument(), 0, bytes, bytesLen, characters, charsLen);
+ }
+}
+
+void ScintillaWin::UniCharToBytes(const wchar_t *characters, const int charsLen, char *bytes, int &bytesLen) {
+ // Return results over bytes and bytesLen.
+ if (IsUnicodeMode()) {
+ bytesLen = UTF8Length(characters, charsLen);
+ UTF8FromUTF16(characters, charsLen, bytes, bytesLen);
+ bytes[bytesLen] = '\0';
+ } else {
+ bytesLen = ::WideCharToMultiByte(CodePageOfDocument(), 0,
+ characters, charsLen, bytes, bytesLen, 0, 0);
+ bytes[bytesLen] = '\0';
+ }
+}
+
+void ScintillaWin::RangeToHangul(int uniStrLen) {
+ // Convert every hanja to hangul from current position to the length uniStrLen.
+ // Even if not coverted, the caret should advance by 1 character.
+ pdoc->BeginUndoAction();
+ for (int i=0; i<uniStrLen; i++) {
+ unsigned int const safeLength = UTF8MaxBytes+1;
+
+ int currentPos = CurrentPosition();
+ int oneCharLen = pdoc->LenChar(currentPos);
+
+ if (oneCharLen > 1) {
+ wchar_t uniChar[safeLength] = { 0 };
+ int uniCharLen = 1;
+ char oneChar[safeLength] = "\0\0\0\0";
+ pdoc->GetCharRange(oneChar, currentPos, oneCharLen);
+
+ BytesToUniChar(oneChar, oneCharLen, uniChar, uniCharLen);
+
+ int hangul = HanjaDict::GetHangulOfHanja(uniChar[0]);
+ if (hangul > 0) {
+ uniChar[0] = static_cast<wchar_t>(hangul);
+
+ UniCharToBytes(uniChar, uniCharLen, oneChar, oneCharLen);
+
+ pdoc->DelChar(currentPos);
+ InsertPaste(oneChar, oneCharLen);
+ } else {
+ MoveImeCarets(oneCharLen);
+ }
+ } else {
+ MoveImeCarets(oneCharLen);
+ }
+ }
+ pdoc->EndUndoAction();
+}
+
+void ScintillaWin::EscapeHanja() {
+ // The candidate box pops up to user to select a hanja.
+ // It comes into WM_IME_COMPOSITION with GCS_RESULTSTR.
+ // The existing hangul or hanja is replaced with it.
+ if (sel.Count() > 1) {
+ return; // Do not allow multi carets.
+ }
+ int currentPos = CurrentPosition();
+ int oneCharLen = pdoc->LenChar(currentPos);
+
+ if (oneCharLen < 2) {
+ return; // No need to handle SBCS.
+ }
+
+ // ImmEscapeW() may overwrite uniChar[] with a null terminated string.
+ // So enlarge it enough to Maximum 4 as in UTF-8.
+ unsigned int const safeLength = UTF8MaxBytes+1;
+ wchar_t uniChar[safeLength] = {0};
+ int uniCharLen = 1;
+ char oneChar[safeLength] = "\0\0\0\0";
+
+ pdoc->GetCharRange(oneChar, currentPos, oneCharLen);
+
+ BytesToUniChar(oneChar, oneCharLen, uniChar, uniCharLen);
+
+ // Set the candidate box position since IME may show it.
+ SetCandidateWindowPos();
+
+ // IME_ESC_HANJA_MODE appears to receive the first character only.
+ HIMC hIMC=ImmGetContext(MainHWND());
+ if (hIMC) {
+ if (ImmEscapeW(GetKeyboardLayout(0), hIMC, IME_ESC_HANJA_MODE, &uniChar)) {
+ SetCandidateWindowPos(); // Force it again for sure.
+ SetSelection (currentPos, currentPos + oneCharLen);
+ }
+ ::ImmReleaseContext(MainHWND(), hIMC);
+ }
+}
+
+void ScintillaWin::ToggleHanja() {
+ // If selection, convert every hanja to hangul within the main range.
+ // If no selection, commit to IME.
+ if (sel.Count() > 1) {
+ return; // Do not allow multi carets.
+ }
+
+ int selStart = sel.RangeMain().Start().Position();
+ int documentStrLen = sel.RangeMain().Length();
+ int selEnd = selStart + documentStrLen;
+ int uniStrLen = pdoc->CountCharacters(selStart, selEnd);
+
+ // Convert one by one from the start of main range.
+ SetSelection(selStart, selStart);
+
+ if (uniStrLen > 0) {
+ RangeToHangul(uniStrLen);
+ } else {
+ EscapeHanja();
+ }
+}
+
sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
// Copy & paste by johnsonj with a lot of helps of Neil.
// Great thanks for my foreruners, jiniya and BLUEnLIVE.
@@ -852,22 +979,20 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { bool tmpRecordingMacro = recordingMacro;
recordingMacro = false;
- for (unsigned int i = 0; i < wcsLen; i++) {
- wchar_t uniChar[1] = { 0 };
+ for (size_t i = 0; i < wcsLen; ) {
+ const size_t ucWidth = UTF16CharLength(wcs[i]);
+ const std::wstring uniChar(wcs+i, ucWidth);
char oneChar[UTF8MaxBytes + 1] = "\0\0\0\0"; // Maximum 4 bytes in utf8
unsigned int oneCharLen = 0;
- uniChar[0] = wcs[i];
-
if (IsUnicodeMode()) {
- oneCharLen = UTF8Length(uniChar, 1);
- UTF8FromUTF16(uniChar, 1, oneChar, oneCharLen);
- oneChar[oneCharLen] = '\0';
+ oneCharLen = UTF8Length(uniChar.c_str(), static_cast<unsigned int>(uniChar.length()));
+ UTF8FromUTF16(uniChar.c_str(), static_cast<unsigned int>(uniChar.length()), oneChar, oneCharLen);
} else {
oneCharLen = ::WideCharToMultiByte(InputCodePage(), 0,
- uniChar, 1, oneChar, sizeof(oneChar)-1, 0, 0);
- oneChar[oneCharLen] = '\0';
+ uniChar.c_str(), static_cast<unsigned int>(uniChar.length()), oneChar, sizeof(oneChar)-1, 0, 0);
}
+ oneChar[oneCharLen] = '\0';
// Display a character.
AddCharUTF(oneChar, oneCharLen);
@@ -891,6 +1016,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { break;
}
DrawImeIndicator(indicator, oneCharLen);
+ i += ucWidth;
}
recordingMacro = tmpRecordingMacro;
@@ -905,23 +1031,22 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { (hIMC, GCS_RESULTSTR, wcs, maxLenInputIME);
unsigned int wcsLen = bytes / 2;
- for (unsigned int i = 0; i < wcsLen; i++) {
- wchar_t uniChar[1] = { 0 };
+ for (size_t i = 0; i < wcsLen;) {
+ const size_t ucWidth = UTF16CharLength(wcs[i]);
+ const std::wstring uniChar(wcs+i, ucWidth);
char oneChar[UTF8MaxBytes+1] = "\0\0\0\0"; // Maximum 4 bytes in UTF-8.
unsigned int oneCharLen = 0;
- uniChar[0] = wcs[i];
-
if (IsUnicodeMode()) {
- oneCharLen = UTF8Length(uniChar, 1);
- UTF8FromUTF16(uniChar, 1, oneChar, oneCharLen);
- oneChar[oneCharLen] = '\0';
+ oneCharLen = UTF8Length(uniChar.c_str(), static_cast<unsigned int>(uniChar.length()));
+ UTF8FromUTF16(uniChar.c_str(), static_cast<unsigned int>(uniChar.length()), oneChar, oneCharLen);
} else {
oneCharLen = ::WideCharToMultiByte(InputCodePage(), 0,
- uniChar, 1, oneChar, sizeof(oneChar)-1, 0, 0);
- oneChar[oneCharLen] = '\0';
+ uniChar.c_str(), static_cast<unsigned int>(uniChar.length()), oneChar, sizeof(oneChar)-1, 0, 0);
}
+ oneChar[oneCharLen] = '\0';
AddCharUTF(oneChar, oneCharLen);
+ i += ucWidth;
}
}
SetCandidateWindowPos();
@@ -1327,8 +1452,12 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam break;
}
- case WM_IME_KEYDOWN:
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_IME_KEYDOWN: {
+ if (wParam == VK_HANJA) {
+ ToggleHanja();
+ }
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ }
case WM_KEYUP:
//Platform::DebugPrintf("S keyup %d %x %x\n",iMessage, wParam, lParam);
@@ -2093,7 +2222,6 @@ void ScintillaWin::Paste() { unsigned int mlen = UTF8Length(&uptr[0], ulen);
std::vector<char> putf(mlen+1);
- // CP_UTF8 not available on Windows 95, so use UTF8FromUTF16()
UTF8FromUTF16(&uptr[0], ulen, &putf[0], mlen);
InsertPasteShape(&putf[0], mlen, pasteShape);
|