diff options
61 files changed, 1965 insertions, 1492 deletions
diff --git a/build/makefile.deps.mak b/build/makefile.deps.mak index 3a08dda..16db646 100644 --- a/build/makefile.deps.mak +++ b/build/makefile.deps.mak @@ -297,7 +297,6 @@ $(SCI_SRC_OBJDIR)\ScintillaBase.obj: \ $(SCI_INC)\Scintilla.h \
$(SCI_LIB)\PropSetSimple.h \
$(SCI_SRC)\ContractionState.h \
- $(SCI_SRC)\SVector.h \
$(SCI_SRC)\SplitVector.h \
$(SCI_SRC)\Partitioning.h \
$(SCI_SRC)\RunStyles.h \
@@ -368,7 +367,6 @@ $(SCI_WIN_OBJDIR)\ScintillaWin.obj: \ $(SCI_INC)\ILexer.h \
$(SCI_INC)\Scintilla.h \
$(SCI_SRC)\ContractionState.h \
- $(SCI_SRC)\SVector.h \
$(SCI_SRC)\SplitVector.h \
$(SCI_SRC)\Partitioning.h \
$(SCI_SRC)\RunStyles.h \
diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index 73a651b..eeca2ea 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -235,7 +235,6 @@ <ClInclude Include="src\Selection.h" /> <ClInclude Include="src\SplitVector.h" /> <ClInclude Include="src\Style.h" /> - <ClInclude Include="src\SVector.h" /> <ClInclude Include="src\UniConversion.h" /> <ClInclude Include="src\ViewStyle.h" /> <ClInclude Include="src\XPM.h" /> diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters index 07a6863..8b57396 100644 --- a/scintilla/Scintilla.vcxproj.filters +++ b/scintilla/Scintilla.vcxproj.filters @@ -317,9 +317,6 @@ <ClInclude Include="src\Style.h"> <Filter>src</Filter> </ClInclude> - <ClInclude Include="src\SVector.h"> - <Filter>src</Filter> - </ClInclude> <ClInclude Include="src\UniConversion.h"> <Filter>src</Filter> </ClInclude> diff --git a/scintilla/Scintilla_VS2010.vcxproj b/scintilla/Scintilla_VS2010.vcxproj index 3833405..ae42593 100644 --- a/scintilla/Scintilla_VS2010.vcxproj +++ b/scintilla/Scintilla_VS2010.vcxproj @@ -230,7 +230,6 @@ <ClInclude Include="src\Selection.h" /> <ClInclude Include="src\SplitVector.h" /> <ClInclude Include="src\Style.h" /> - <ClInclude Include="src\SVector.h" /> <ClInclude Include="src\UniConversion.h" /> <ClInclude Include="src\ViewStyle.h" /> <ClInclude Include="src\XPM.h" /> diff --git a/scintilla/Scintilla_VS2010.vcxproj.filters b/scintilla/Scintilla_VS2010.vcxproj.filters index 07a6863..8b57396 100644 --- a/scintilla/Scintilla_VS2010.vcxproj.filters +++ b/scintilla/Scintilla_VS2010.vcxproj.filters @@ -317,9 +317,6 @@ <ClInclude Include="src\Style.h"> <Filter>src</Filter> </ClInclude> - <ClInclude Include="src\SVector.h"> - <Filter>src</Filter> - </ClInclude> <ClInclude Include="src\UniConversion.h"> <Filter>src</Filter> </ClInclude> diff --git a/scintilla/Scintilla_icl13.vcxproj b/scintilla/Scintilla_icl13.vcxproj index 2668912..5c1fe21 100644 --- a/scintilla/Scintilla_icl13.vcxproj +++ b/scintilla/Scintilla_icl13.vcxproj @@ -255,7 +255,6 @@ <ClInclude Include="src\Selection.h" /> <ClInclude Include="src\SplitVector.h" /> <ClInclude Include="src\Style.h" /> - <ClInclude Include="src\SVector.h" /> <ClInclude Include="src\UniConversion.h" /> <ClInclude Include="src\ViewStyle.h" /> <ClInclude Include="src\XPM.h" /> diff --git a/scintilla/Scintilla_icl13.vcxproj.filters b/scintilla/Scintilla_icl13.vcxproj.filters index 07a6863..8b57396 100644 --- a/scintilla/Scintilla_icl13.vcxproj.filters +++ b/scintilla/Scintilla_icl13.vcxproj.filters @@ -317,9 +317,6 @@ <ClInclude Include="src\Style.h"> <Filter>src</Filter> </ClInclude> - <ClInclude Include="src\SVector.h"> - <Filter>src</Filter> - </ClInclude> <ClInclude Include="src\UniConversion.h"> <Filter>src</Filter> </ClInclude> diff --git a/scintilla/cppcheck.suppress b/scintilla/cppcheck.suppress new file mode 100644 index 0000000..de777f8 --- /dev/null +++ b/scintilla/cppcheck.suppress @@ -0,0 +1,45 @@ +// File to suppress cppcheck warnings for files that will not be fixed. +// Does not suppress warnings where an additional occurrence of the warning may be of interest. +// Does not suppress false positives from cppcheck. + +// Coding style is to use assignments in constructor when there are many +// members to initialize or the initialization is complex or has comments. +useInitializationList + +// Suppress most lexer warnings since the lexers are maintained by others +variableScope:scintilla/lexers/LexA68k.cxx +useInitializationList:scintilla/lexers/LexAsm.cxx +useInitializationList:scintilla/lexers/LexBasic.cxx +noCopyConstructor:scintilla/lexers/LexBash.cxx +variableScope:scintilla/lexers/LexBash.cxx +variableScope:scintilla/lexers/LexCmake.cxx +variableScope:scintilla/lexers/LexCoffeeScript.cxx +variableScope:scintilla/lexers/LexCSS.cxx +useInitializationList:scintilla/lexers/LexD.cxx +redundantCondition:scintilla/lexers/LexECL.cxx +variableScope:scintilla/lexers/LexErlang.cxx +variableScope:scintilla/lexers/LexFortran.cxx +variableScope:scintilla/lexers/LexGui4Cli.cxx +variableScope:scintilla/lexers/LexInno.cxx +variableScope:scintilla/lexers/LexLaTeX.cxx +variableScope:scintilla/lexers/LexMarkdown.cxx +variableScope:scintilla/lexers/LexMetapost.cxx +variableScope:scintilla/lexers/LexModula.cxx +variableScope:scintilla/lexers/LexNimrod.cxx +variableScope:scintilla/lexers/LexNsis.cxx +variableScope:scintilla/lexers/LexOpal.cxx +variableScope:scintilla/lexers/LexOthers.cxx +variableScope:scintilla/lexers/LexPB.cxx +variableScope:scintilla/lexers/LexPS.cxx +uninitMemberVar:scintilla/lexers/LexPerl.cxx +variableScope:scintilla/lexers/LexRuby.cxx +uninitMemberVar:scintilla/lexers/LexRuby.cxx +variableScope:scintilla/lexers/LexSpecman.cxx +unreadVariable:scintilla/lexers/LexSpice.cxx +invalidscanf:scintilla/lexers/LexTCMD.cxx +variableScope:scintilla/lexers/LexTeX.cxx +variableScope:scintilla/lexers/LexTxt2tags.cxx +variableScope:scintilla/lexers/LexVHDL.cxx + +// Suppress C-style pointer casting for Qt code as won't be changing +cstyleCast:scintilla/qt/ScintillaEdit/ScintillaDocument.cpp diff --git a/scintilla/doc/ScintillaDoc.html b/scintilla/doc/ScintillaDoc.html index d9b2d16..1c95c86 100644 --- a/scintilla/doc/ScintillaDoc.html +++ b/scintilla/doc/ScintillaDoc.html @@ -82,7 +82,7 @@ <h1>Scintilla Documentation</h1>
- <p>Last edited 18/January/2013 NH</p>
+ <p>Last edited 5/May/2013 NH</p>
<p>There is <a class="jump" href="Design.html">an overview of the internal design of
Scintilla</a>.<br />
@@ -323,7 +323,7 @@ <td>o <a class="toc" href="#ProvisionalMessages"><span class="provisional">Provisional messages</span></a></td>
<td>o <a class="toc" href="#DeprecatedMessages">Deprecated messages</a></td>
-
+
</tr>
<tr>
@@ -560,7 +560,7 @@ <code>SCI_RELEASEALLEXTENDEDSTYLES</code> releases any extended styles allocated by the container.
<code>SCI_ALLOCATEEXTENDEDSTYLES</code> allocates a range of style numbers after the byte style values and returns
the number of the first allocated style.
- Ranges for margin and annotation styles should be allocated before calling
+ Ranges for margin and annotation styles should be allocated before calling
<a class="message" href="#SCI_MARGINSETSTYLEOFFSET">SCI_MARGINSETSTYLEOFFSET</a> or
<a class="message" href="#SCI_ANNOTATIONSETSTYLEOFFSET">SCI_ANNOTATIONSETSTYLEOFFSET</a>.</p>
@@ -2207,7 +2207,7 @@ struct Sci_TextToFind { <p>Scintilla can handle the major line end conventions <span class="provisional">and, depending on settings and
the current lexer also support additional Unicode line ends</span>.</p>
-
+
<p>Scintilla can interpret any of the Macintosh (\r), Unix (\n) and Windows (\r\n)
line ends.
When the user presses the Enter key, one of these line
@@ -2559,7 +2559,7 @@ struct Sci_TextToFind { <p>The weight or boldness of a font can be set with <code>SCI_STYLESETBOLD</code>
or <code>SCI_STYLESETWEIGHT</code>. The weight is a number between 1 and 999 with 1 being very light
and 999 very heavy. While any value can be used, fonts often only support between 2 and 4 weights with three weights
- being common enough to have symbolic names:
+ being common enough to have symbolic names:
<code>SC_WEIGHT_NORMAL</code> (400),
<code>SC_WEIGHT_SEMIBOLD</code> (600), and
<code>SC_WEIGHT_BOLD</code> (700).
@@ -2999,10 +2999,10 @@ struct Sci_TextToFind { <p>
<b id="SCI_SETMARGINOPTIONS">SCI_SETMARGINOPTIONS(int marginOptions)</b><br />
<b id="SCI_GETMARGINOPTIONS">SCI_GETMARGINOPTIONS</b><br />
- Define margin options by enabling appropriate bit flags. At the moment, only one flag is available
- <code>SC_MARGINOPTION_SUBLINESELECT</code>=1, which controls how wrapped lines are selected when clicking
- on margin in front of them. If <code>SC_MARGINOPTION_SUBLINESELECT</code> is set only sub line of wrapped
- line is selected, otherwise whole wrapped line is selected. Margin options are set to
+ Define margin options by enabling appropriate bit flags. At the moment, only one flag is available
+ <code>SC_MARGINOPTION_SUBLINESELECT</code>=1, which controls how wrapped lines are selected when clicking
+ on margin in front of them. If <code>SC_MARGINOPTION_SUBLINESELECT</code> is set only sub line of wrapped
+ line is selected, otherwise whole wrapped line is selected. Margin options are set to
<code>SC_MARGINOPTION_NONE</code>=0 by default.
</p>
@@ -3224,7 +3224,7 @@ struct Sci_TextToFind { <p><b id="SCI_GETWORDCHARS">SCI_GETWORDCHARS(<unused>, char *characters)</b><br />
This fills the characters parameter with all the characters included in words.
- The characters parameter must be large enough to hold all of the characters.
+ The characters parameter must be large enough to hold all of the characters.
If the characters parameter is 0 then the length that should be allocated
to store the entire set is returned.</p>
@@ -3637,7 +3637,7 @@ struct Sci_TextToFind { <p><b id="SCI_MARKERDEFINEPIXMAP">SCI_MARKERDEFINEPIXMAP(int markerNumber, const char
*xpm)</b><br />
- Markers can be set to pixmaps with this message. The
+ Markers can be set to pixmaps with this message. The
<a class="jump" href="#XPM">XPM format</a> is used for the pixmap.
Pixmaps use the <code>SC_MARK_PIXMAP</code> marker symbol. </p>
@@ -3646,9 +3646,9 @@ struct Sci_TextToFind { <b id="SCI_RGBAIMAGESETHEIGHT">SCI_RGBAIMAGESETHEIGHT(int height)</b><br />
<b id="SCI_RGBAIMAGESETSCALE">SCI_RGBAIMAGESETSCALE(int scalePercent)</b><br />
<b id="SCI_MARKERDEFINERGBAIMAGE">SCI_MARKERDEFINERGBAIMAGE(int markerNumber, const char *pixels)</b><br />
- Markers can be set to translucent pixmaps with this message. The
+ Markers can be set to translucent pixmaps with this message. The
<a class="jump" href="#RGBA">RGBA format</a> is used for the pixmap.
- The width and height must previously been set with the <code>SCI_RGBAIMAGESETWIDTH</code> and
+ The width and height must previously been set with the <code>SCI_RGBAIMAGESETWIDTH</code> and
<code>SCI_RGBAIMAGESETHEIGHT</code> messages.</p>
<p>A scale factor in percent may be set with <code>SCI_RGBAIMAGESETSCALE</code>. This is useful on OS X with
a retina display where each display unit is 2 pixels: use a factor of 200 so that each image pixel is dsplayed using a screen pixel.
@@ -3925,6 +3925,16 @@ struct Sci_TextToFind { Apperance will not be as good as <code>INDIC_SQUIGGLE</code> on OS X in HiDPI mode.</td>
</tr>
+ <tr>
+ <td align="left"><code>INDIC_COMPOSITIONTHICK</code></td>
+
+ <td align="center">14</td>
+
+ <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>
+ </tr>
+
</tbody>
</table>
@@ -4017,7 +4027,7 @@ struct Sci_TextToFind { <p><b id="SCI_FINDINDICATORSHOW">SCI_FINDINDICATORSHOW(int start, int end)</b><br />
<b id="SCI_FINDINDICATORFLASH">SCI_FINDINDICATORFLASH(int start, int end)</b><br />
These two messages show and animate the find indicator. The indicator remains visible with
- <code>SCI_FINDINDICATORSHOW</code> and fades out after showing for half a second with
+ <code>SCI_FINDINDICATORSHOW</code> and fades out after showing for half a second with
<code>SCI_FINDINDICATORFLASH</code>.
<code>SCI_FINDINDICATORSHOW</code> behaves similarly to the OS X TextEdit and Safari applications
and is best suited to editing documentation where the search target is often a word.
@@ -4260,10 +4270,10 @@ struct Sci_TextToFind { Autocompletion list items may display an image as well as text. Each image is first registered with an integer
type. Then this integer is included in the text of the list separated by a '?' from the text. For example,
"fclose?2 fopen" displays image 2 before the string "fclose" and no image before "fopen".
- The images are in either the <a class="jump" href="#XPM">XPM format</a> (<code>SCI_REGISTERIMAGE</code>) or
+ The images are in either the <a class="jump" href="#XPM">XPM format</a> (<code>SCI_REGISTERIMAGE</code>) or
<a class="jump" href="#RGBA">RGBA format</a> (<code>SCI_REGISTERRGBAIMAGE</code>).
For <code>SCI_REGISTERRGBAIMAGE</code> the width and height must previously been set with
- the <a class="message" href="#SCI_RGBAIMAGESETWIDTH"><code>SCI_RGBAIMAGESETWIDTH</code></a> and
+ the <a class="message" href="#SCI_RGBAIMAGESETWIDTH"><code>SCI_RGBAIMAGESETWIDTH</code></a> and
<a class="message" href="#SCI_RGBAIMAGESETHEIGHT"><code>SCI_RGBAIMAGESETHEIGHT</code></a> messages.
The set of registered images can be cleared with <code>SCI_CLEARREGISTEREDIMAGES</code> and the '?' separator changed
with <code>SCI_AUTOCSETTYPESEPARATOR</code>.
@@ -4423,7 +4433,7 @@ struct Sci_TextToFind { <p><b id="SCI_CALLTIPSETPOSITION">SCI_CALLTIPSETPOSITION(bool above)</b><br />
By default the calltip is displayed below the text, setting above to <code>true</code>
(1) will display it above the text.</p>
-
+
<h2 id="KeyboardCommands">Keyboard commands</h2>
@@ -4738,7 +4748,7 @@ struct Sci_TextToFind { <p>The modifiers are a combination of zero or more of <code>SCMOD_ALT</code>,
<code>SCMOD_CTRL</code>, <code>SCMOD_SHIFT</code>, and <code>SCMOD_META</code>.
- On OS X, the Command key is mapped to <code>SCMOD_CTRL</code> and the Control key to
+ On OS X, the Command key is mapped to <code>SCMOD_CTRL</code> and the Control key to
<code>SCMOD_META</code>.
If you are building a table, you might
want to use <code>SCMOD_NORM</code>, which has the value 0, to mean no modifiers.</p>
@@ -4841,7 +4851,7 @@ struct Sci_RangeToFormat { The Surface IDs are not really used for measurement (<code>bDraw=0</code>) but can be set
to a bitmap context (created with <code>CGBitmapContextCreate</code>) to avoid runtime warnings.</p>
- <p>On GTK+, the surface IDs to use can be found from the printing context with
+ <p>On GTK+, the surface IDs to use can be found from the printing context with
<code>gtk_print_context_get_cairo_context(context)</code>.</p>
<code>chrg.cpMin</code> and <code>chrg.cpMax</code> define the start position and maximum
@@ -5014,7 +5024,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <p><code>SCI_GETRANGEPOINTER</code> provides direct access to just the
range requested. The gap is not moved unless it is within the requested range so this call
- can be faster than <code>SCI_GETCHARACTERPOINTER</code>.
+ can be faster than <code>SCI_GETCHARACTERPOINTER</code>.
This can be used by application code that is able to act on blocks of text or ranges of lines.</p>
<p><code>SCI_GETGAPPOSITION</code> returns the current gap position.
@@ -5165,6 +5175,8 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <a class="message" href="#SCI_GETALLLINESVISIBLE">SCI_GETALLLINESVISIBLE</a><br />
<a class="message" href="#SCI_SETFOLDLEVEL">SCI_SETFOLDLEVEL(int line, int level)</a><br />
<a class="message" href="#SCI_GETFOLDLEVEL">SCI_GETFOLDLEVEL(int line)</a><br />
+ <a class="message" href="#SCI_SETAUTOMATICFOLD">SCI_SETAUTOMATICFOLD(int automaticFold)</a><br />
+ <a class="message" href="#SCI_GETAUTOMATICFOLD">SCI_GETAUTOMATICFOLD</a><br />
<a class="message" href="#SCI_SETFOLDFLAGS">SCI_SETFOLDFLAGS(int flags)</a><br />
<a class="message" href="#SCI_GETLASTCHILD">SCI_GETLASTCHILD(int line, int level)</a><br />
<a class="message" href="#SCI_GETFOLDPARENT">SCI_GETFOLDPARENT(int line)</a><br />
@@ -5173,6 +5185,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <a class="message" href="#SCI_GETFOLDEXPANDED">SCI_GETFOLDEXPANDED(int line)</a><br />
<a class="message" href="#SCI_CONTRACTEDFOLDNEXT">SCI_CONTRACTEDFOLDNEXT(int lineStart)</a><br />
<a class="message" href="#SCI_TOGGLEFOLD">SCI_TOGGLEFOLD(int line)</a><br />
+ <a class="message" href="#SCI_FOLDLINE">SCI_FOLDLINE(int line, int action)</a><br />
+ <a class="message" href="#SCI_FOLDCHILDREN">SCI_FOLDCHILDREN(int line, int action)</a><br />
+ <a class="message" href="#SCI_FOLDALL">SCI_FOLDALL(int action)</a><br />
+ <a class="message" href="#SCI_EXPANDCHILDREN">SCI_EXPANDCHILDREN(int line, int level)</a><br />
<a class="message" href="#SCI_ENSUREVISIBLE">SCI_ENSUREVISIBLE(int line)</a><br />
<a class="message" href="#SCI_ENSUREVISIBLEENFORCEPOLICY">SCI_ENSUREVISIBLEENFORCEPOLICY(int
line)</a><br />
@@ -5330,6 +5346,102 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ until you had finished. See <code>SciTEBase::FoldAll()</code> and
<code>SciTEBase::Expand()</code> for examples of the use of these messages.</p>
+ <p><b id="SCI_FOLDLINE">SCI_FOLDLINE(int line, int action)</b><br />
+ <b id="SCI_FOLDCHILDREN">SCI_FOLDCHILDREN(int line, int action)</b><br />
+ <b id="SCI_FOLDALL">SCI_FOLDALL(int action)</b><br />
+ These messages provide a higher-level approach to folding instead of setting expanded flags and showing
+ or hiding individual lines.</p>
+ <p>An individual fold can be contracted/expanded/toggled with <code>SCI_FOLDLINE</code>.
+ To affect all child folds as well call <code>SCI_FOLDCHILDREN</code>.</p>
+ <p>To affect the entire document call <code>SCI_FOLDALL</code>. With <code>SC_FOLDACTION_TOGGLE</code>
+ the first fold header in the document is examined to decide whether to expand or contract.
+ </p>
+ <table cellpadding="1" cellspacing="2" border="0" summary="Fold flags">
+ <tbody>
+ <tr>
+ <th align="left">Symbol</th>
+ <th align="left">Value</th>
+ <th align="left">Effect</th>
+ </tr>
+ </tbody>
+
+ <tbody valign="top">
+ <tr>
+ <td align="left">SC_FOLDACTION_CONTRACT</td>
+ <td align="left">0</td>
+ <td align="left">Contract.</td>
+ </tr>
+
+ <tr>
+ <td align="left">SC_FOLDACTION_EXPAND</td>
+ <td align="left">1</td>
+ <td align="left">Expand.</td>
+ </tr>
+
+ <tr>
+ <td align="left">SC_FOLDACTION_TOGGLE</td>
+ <td align="left">2</td>
+ <td align="left">Toggle between contracted and expanded.</td>
+ </tr>
+
+ </tbody>
+ </table>
+ <p></p>
+
+ <p><b id="SCI_EXPANDCHILDREN">SCI_EXPANDCHILDREN(int line, int level)</b><br />
+ This is used to respond to a change to a line causing its fold level or whether it is a header to change,
+ perhaps when adding or removing a '{'.</p>
+ <p>By the time the container has received the notification that the line has changed,
+ the fold level has already been set, so the container has to use the previous level in this call
+ so that any range hidden underneath this line can be shown.
+ </p>
+
+ <p><b id="SCI_SETAUTOMATICFOLD">SCI_SETAUTOMATICFOLD(int automaticFold)</b><br />
+ <b id="SCI_GETAUTOMATICFOLD">SCI_GETAUTOMATICFOLD</b><br />
+ Instead of implementing all the logic for handling folding in the container, Scintilla can provide behaviour
+ that is adequate for many applications. The <code>automaticFold</code> argument is a bit set defining
+ which of the 3 pieces of folding implementation should be enabled. Most applications should be able to use the
+ <code>SC_AUTOMATICFOLD_SHOW</code> and <code>SC_AUTOMATICFOLD_CHANGE</code>
+ flags unless they wish to implement quite different behavious such as defining their own fold structure.
+ <code>SC_AUTOMATICFOLD_CLICK</code> is more likely to be set off when an application would
+ like to add or change click behaviour such as showing method headers only when Shift+Alt is used in
+ conjunction with a click.
+ </p>
+ <table cellpadding="1" cellspacing="2" border="0" summary="Fold flags">
+ <tbody>
+ <tr>
+ <th align="left">Symbol</th>
+ <th align="left">Value</th>
+ <th align="left">Effect</th>
+ </tr>
+ </tbody>
+
+ <tbody valign="top">
+ <tr>
+ <td align="left">SC_AUTOMATICFOLD_SHOW</td>
+ <td align="left">1</td>
+ <td align="left">Automatically show lines as needed.
+ This avoids sending the <code>SCN_NEEDSHOWN</code> notification.</td>
+ </tr>
+
+ <tr>
+ <td align="left">SC_AUTOMATICFOLD_CLICK</td>
+ <td align="left">2</td>
+ <td align="left">Handle clicks in fold margin automatically.
+ This avoids sending the <code>SCN_MARGINCLICK</code> notification for folding margins.</td>
+ </tr>
+
+ <tr>
+ <td align="left">SC_AUTOMATICFOLD_CHANGE</td>
+ <td align="left">4</td>
+ <td align="left">Show lines as needed when fold structure is changed.
+ The <code>SCN_MODIFIED</code> notification is still sent unless it is disabled by the
+ container.</td>
+ </tr>
+
+ </tbody>
+ </table>
+
<p><b id="SCI_CONTRACTEDFOLDNEXT">SCI_CONTRACTEDFOLDNEXT(int lineStart)</b><br />
Search efficiently for lines that are contracted fold headers.
This is useful when saving the user's folding when switching documents or saving folding with a file.
@@ -6219,7 +6331,7 @@ To allow lexers to determine the end position of a line and thus more easily sup <span class="S10">};</span><br />
</div>
-<p>The <code>ILexer</code>, <code>ILexerWithSubStyles</code>, <code>IDocument</code>, and
+<p>The <code>ILexer</code>, <code>ILexerWithSubStyles</code>, <code>IDocument</code>, and
<code>IDocumentWithLineEnd</code> interfaces may be
expanded in the future with extended versions (<code>ILexer2</code>...).
The <code>Version</code> method indicates which interface is
@@ -6324,11 +6436,11 @@ struct SCNotification { <p><b id="SCI_SETIDENTIFIER">SCI_SETIDENTIFIER(int identifier)</b><br />
<b id="SCI_GETIDENTIFIER">SCI_GETIDENTIFIER</b><br />
- These two messages set and get the identifier of the Scintilla instance which is included in notifications as the
- <code>idFrom</code> field.
+ These two messages set and get the identifier of the Scintilla instance which is included in notifications as the
+ <code>idFrom</code> field.
When an application creates multiple Scintilla widgets, this allows the source of each notification to be found.
- On Windows, this value is initialised in the <code>CreateWindow</code> call and stored as the
- <code>GWLP_ID</code> attribute of the window.
+ On Windows, this value is initialised in the <code>CreateWindow</code> call and stored as the
+ <code>GWLP_ID</code> attribute of the window.
The value should be small, preferrably less than 16 bits,
rather than a pointer as some of the functions will only transmit 16 or 32 bits.
</p>
@@ -7053,17 +7165,17 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next <p><b id="SCN_AUTOCCHARDELETED">SCN_AUTOCCHARDELETED</b><br />
The user deleted a character while autocompletion list was active.
There is no other information in SCNotification.</p>
-
+
<h2 id="Images">Images</h2>
-
+
<p>Two formats are supported for images used in margin markers and autocompletion lists, RGBA and XPM.</p>
<h3 id="RGBA">RGBA</h3>
-
+
<p>The RGBA format allows translucency with an <a class="jump" href="#alpha">alpha</a>
value for each pixel. It is simpler than
<code>XPM</code> and more capable.</p>
-
+
<p>The data is a sequence of 4 byte pixel values starting with the pixels for the top line, with the
leftmost pixel first, then continuing with the pixels for subsequent lines. There is no gap between
lines for alignment reasons.</p>
@@ -7072,22 +7184,22 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next The colour bytes are not premultiplied by the alpha value. That is, a fully red pixel that is
25% opaque will be [FF, 00, 00, 3F]</p>
- <p>Since the RGBA pixel data does not include any size information the
- width and height must previously been set with the
- <a class="message" href="#SCI_RGBAIMAGESETWIDTH"><code>SCI_RGBAIMAGESETWIDTH</code></a> and
+ <p>Since the RGBA pixel data does not include any size information the
+ width and height must previously been set with the
+ <a class="message" href="#SCI_RGBAIMAGESETWIDTH"><code>SCI_RGBAIMAGESETWIDTH</code></a> and
<a class="message" href="#SCI_RGBAIMAGESETHEIGHT"><code>SCI_RGBAIMAGESETHEIGHT</code></a> messages.</p>
-
+
<p>GUI platforms often include functions for reading image file formats like PNG into memory
in the RGBA form or a similar form.
If there is no suitable platform support, the <a href="http://lodev.org/lodepng/">LodePNG and picoPNG</a> libraries are small libraries
for loading and decoding PNG files available under a BSD-style license.</p>
-
+
<p>RGBA format is supported on Windows, GTK+ and OS X Cocoa.</p>
<h3 id="XPM">XPM</h3>
-
- <p>The XPM format is
- <a class="jump" href="http://en.wikipedia.org/wiki/X_PixMap">described here</a>.
+
+ <p>The XPM format is
+ <a class="jump" href="http://en.wikipedia.org/wiki/X_PixMap">described here</a>.
Scintilla is only able to handle XPM pixmaps that use one character per pixel with no named colours.
There may be a completely transparent colour named "None".</p>
<p>There are two forms of data structure used for XPM images, the first "lines form" format is well suited
@@ -7237,11 +7349,10 @@ EM_SETTARGETDEVICE <h2 id="BuildingScintilla">Building Scintilla</h2>
<p>To build Scintilla or SciTE, see the README file present in both the Scintilla and SciTE
- directories. For Windows, GCC 3.2, Borland C++ or Microsoft Visual Studio .NET can be used
- for building. There is a make file for building Scintilla but not SciTE with Visual C++ 6 at
- scintilla/win32/scintilla_vc6.mak. For GTK+, GCC 3.1 should be used. GTK+ 1.2x and 2.0x are
+ directories. For Windows, GCC 4.7 or Microsoft Visual C++ 2010 can be used
+ for building. For GTK+, GCC 4.1 or newer should be used. GTK+ 2.8+ and 3.x are
supported. The version of GTK+ installed should be detected automatically.
- When both GTK+ 1 and GTK+ 2 are present, building for GTK+ 1.x requires defining GTK1
+ When both GTK+ 2 and GTK+ 3 are present, building for GTK+ 3.x requires defining GTK3
on the command line.</p>
<h3>Static linking</h3>
diff --git a/scintilla/doc/ScintillaDownload.html b/scintilla/doc/ScintillaDownload.html index 846ba81..027393f 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/scintilla330.zip?download">
+ <font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla331.zip?download">
Windows</a>
- <a href="http://prdownloads.sourceforge.net/scintilla/scintilla330.tgz?download">
+ <a href="http://prdownloads.sourceforge.net/scintilla/scintilla331.tgz?download">
GTK+/Linux</a>
</font>
</td>
@@ -41,7 +41,7 @@ containing very few restrictions.
</p>
<h3>
- Release 3.3.0
+ Release 3.3.1
</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/scintilla330.zip?download">zip format</a> (1250K) commonly used on Windows</li>
- <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla330.tgz?download">tgz format</a> (1100K) commonly used on Linux and compatible operating systems</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla331.zip?download">zip format</a> (1250K) commonly used on Windows</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla331.tgz?download">tgz format</a> (1100K) 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 becfb5a..d759529 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -422,6 +422,7 @@ <td>John Donoghue</td>
</tr><tr>
<td>kudah</td>
+ <td>Igor Shaula</td>
</tr>
</table>
<p>
@@ -434,10 +435,103 @@ </li>
</ul>
<h3>
- 3.3.1 placeholder
+ <a href="http://prdownloads.sourceforge.net/scintilla/scite332.zip?download">Release 3.3.2</a>
</h3>
<ul>
<li>
+ Released 11 December 2013.
+ </li>
+ <li>
+ Basic implementations of common folding methods added to Scintilla to make it
+ easier for containers to implement folding.
+ </li>
+ <li>
+ Add indicator INDIC_COMPOSITIONTHICK, a thick low underline, to mimic an
+ appearance used for Asian language input composition.
+ </li>
+ <li>
+ On Cocoa, implement font quality setting.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/988/">Feature #988.</a>
+ </li>
+ <li>
+ On Cocoa, implement automatic enabling of commands and added clear command.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/987/">Feature #987.</a>
+ </li>
+ <li>
+ Haskell folder improved.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1459/">Bug #1459 </a>.
+ </li>
+ <li>
+ LaTeX lexer bug fixed for Unicode character following '\'.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1468/">Bug #1468 </a>.
+ </li>
+ <li>
+ PowerShell lexer recognises here strings and doccomment keywords.
+ #region folding added.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/985/">Feature #985.</a>
+ </li>
+ <li>
+ Fix multi-typing when two carets are located in virtual space on one line so that spaces
+ are preserved.
+ </li>
+ <li>
+ Fixes to input composition on Cocoa and implementation of accented character input through
+ press and hold. Set selection correctly so that changes to pieces of composition text are easier to perform.
+ Restore undo collection after a sequence of composition actions.
+ Composition popups appear near input.
+ </li>
+ <li>
+ Fix lexer problem where no line end was seen at end of document.
+ </li>
+ <li>
+ Fix crash on Cocoa when view deallocated.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1466/">Bug #1466</a>.
+ </li>
+ <li>
+ Fix Qt window positioning to not assume the top right of a monitor is at 0, 0.
+ </li>
+ <li>
+ Fix Qt to not track mouse when widget is hidden.
+ </li>
+ <li>
+ Qt now supports Qt 5.0.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1448/">Bug #1448</a>.
+ </li>
+ <li>
+ Fix drawing on Windows with Direct2D when returning from lock screen.
+ The render target had to be recreated and an area would be black since the drawing was not retried.
+ </li>
+ <li>
+ Fix display of DBCS documents on Windows Direct2D/DirectWrite with default character set.
+ </li>
+ <li>
+ For SciTE on Windows, fixed most-recently-used menu when files opened through check.if.already.opened.
+ </li>
+ <li>
+ In SciTE, do not call OnSave twice when files saved asynchronously.
+ </li>
+ <li>
+ Scintilla no longer builds with Visual C++ 2005 or Visual C++ 6.0.
+ </li>
+ </ul>
+ <h3>
+ <a href="http://prdownloads.sourceforge.net/scintilla/scite331.zip?download">Release 3.3.1</a>
+ </h3>
+ <ul>
+ <li>
+ Released 11 April 2013.
+ </li>
+ <li>
+ Autocompletion lists can now appear in priority order or be sorted by Scintilla.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/981/">Feature #981.</a>
+ </li>
+ <li>
+ Most lexers now lex an extra NUL byte at the end of the
+ document which makes it more likely they will classify keywords at document end correctly.
+ <a href="http://sourceforge.net/p/scintilla/bugs/574/">Bug #574</a>,
+ <a href="http://sourceforge.net/p/scintilla/bugs/588/">Bug #588.</a>
+ </li>
+ <li>
Haskell lexer improved in several ways.
<a href="http://sourceforge.net/p/scintilla/bugs/1459/">Bug #1459.</a>
</li>
@@ -446,8 +540,29 @@ <a href="http://sourceforge.net/p/scintilla/bugs/1414/">Bug #1414.</a>
</li>
<li>
+ Ruby lexer crash fixed with keyword at start of document.
+ </li>
+ <li>
The PLAT_NCURSES platform now called PLAT_CURSES as may work on other implementations.
</li>
+ <li>
+ Bug on Cocoa fixed where input composition with multiple selection or virtual space selection
+ could make undo stop working.
+ </li>
+ <li>
+ Direct2D/DirectWrite mode on Windows now displays documents in non-Latin1 8-bit encodings correctly.
+ </li>
+ <li>
+ Character positioning corrected in Direct2D/DirectWrite mode on Windows to avoid text moving and cutting off
+ lower parts of characters.
+ </li>
+ <li>
+ Position of calltip and autocompletion lists fixed on Cocoa.
+ </li>
+ <li>
+ While regular expression search in DBCS text is still not working, matching partial characters is now avoided
+ by moving end of match to end of character.
+ </li>
</ul>
<h3>
<a href="http://prdownloads.sourceforge.net/scintilla/scite330.zip?download">Release 3.3.0</a>
@@ -1058,7 +1173,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=352439&aid=3510979&group_id=2439">Feature #3510979.</a>
</li>
<li>
- Fixed single quoted strings in bash lexer.
+ Fixed single quoted strings in bash lexer.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3512208&group_id=2439">Bug #3512208.</a>
</li>
<li>
@@ -1086,7 +1201,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3514882&group_id=2439">Bug #3514882.</a>
</li>
<li>
- Fix printing crash when using Direct2D to display on-screen.
+ Fix printing crash when using Direct2D to display on-screen.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3513946&group_id=2439">Bug #3513946.</a>
</li>
<li>
@@ -1094,22 +1209,22 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3514885&group_id=2439">Bug #3514885.</a>
</li>
<li>
- Fixed the Move Selected Lines command when last line does not end with a line end character.
+ Fixed the Move Selected Lines command when last line does not end with a line end character.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3511023&group_id=2439">Bug #3511023.</a>
</li>
<li>
- Fix word wrap indentation printing to use printer settings instead of screen settings.
+ Fix word wrap indentation printing to use printer settings instead of screen settings.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3512961&group_id=2439">Bug #3512961.</a>
</li>
<li>
- Fix SciTE bug where executing an empty command prevented executing further commands
+ Fix SciTE bug where executing an empty command prevented executing further commands
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3512976&group_id=2439">Bug #3512976.</a>
</li>
<li>
Fix SciTE bugs with focus in user strips and made strips more robust with invalid definitions.
</li>
<li>
- Suppress SciTE regular expression option when searching with find next selection.
+ Suppress SciTE regular expression option when searching with find next selection.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3510985&group_id=2439">Bug #3510985.</a>
</li>
<li>
@@ -1121,7 +1236,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3501321&group_id=2439">Bug #3501321.</a>
</li>
<li>
- Fix column finding method so that tab is counted correctly.
+ Fix column finding method so that tab is counted correctly.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3483713&group_id=2439">Bug #3483713.</a>
</li>
</ul>
@@ -1146,7 +1261,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=352439&aid=3488209&group_id=2439">Feature #3488209.</a>
</li>
<li>
- CPP lexer fixes styling after document comment keywords.
+ CPP lexer fixes styling after document comment keywords.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3495445&group_id=2439">Bug #3495445.</a>
</li>
<li>
@@ -1162,7 +1277,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3495836&group_id=2439">Bug #3495836.</a>
</li>
<li>
- SciTE xml.auto.close.tags no longer closes with PHP code similar to <a $this->
+ SciTE xml.auto.close.tags no longer closes with PHP code similar to <a $this->
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3488067&group_id=2439">Bug #3488067.</a>
</li>
<li>
@@ -1170,11 +1285,11 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3487440&group_id=2439">Bug #3487440.</a>
</li>
<li>
- Crash fixed for SCI_MOVESELECTEDLINESDOWN with empty vertical selection.
+ Crash fixed for SCI_MOVESELECTEDLINESDOWN with empty vertical selection.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3496403&group_id=2439">Bug #3496403.</a>
</li>
<li>
- Differences between buffered and unbuffered mode on Direct2D eliminated.
+ Differences between buffered and unbuffered mode on Direct2D eliminated.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3495791&group_id=2439">Bug #3495791.</a>
</li>
<li>
@@ -1218,7 +1333,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3488481&group_id=2439">Bug #3488481.</a>
</li>
<li>
- SciTE on Windows Find in Files sets focus to dialog when already created; allows opening dialog when a job is running.
+ SciTE on Windows Find in Files sets focus to dialog when already created; allows opening dialog when a job is running.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3480635&group_id=2439">Bug #3480635.</a>
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3486657&group_id=2439">Bug #3486657.</a>
</li>
@@ -1243,7 +1358,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3484179&group_id=2439">Bug #3484179.</a>
</li>
<li>
- Selected line ends are highlighted more consistently.
+ Selected line ends are highlighted more consistently.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3484330&group_id=2439">Bug #3484330.</a>
</li>
<li>
@@ -1251,7 +1366,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3482777&group_id=2439">Bug #3482777.</a>
</li>
<li>
- Fix failure messages from empty commands in SciTE.
+ Fix failure messages from empty commands in SciTE.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3480645&group_id=2439">Bug #3480645.</a>
</li>
<li>
@@ -1271,7 +1386,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=352439&aid=3486654&group_id=2439">Feature #3486654.</a>
</li>
<li>
- SciTE allows optional use of character escapes in calltips.
+ SciTE allows optional use of character escapes in calltips.
<a href="https://sourceforge.net/tracker/?func=detail&atid=352439&aid=3495239&group_id=2439">Feature #3495239.</a>
</li>
<li>
@@ -1530,7 +1645,7 @@ On Windows Vista or newer, drawing may be performed with Direct2D and DirectWrite instead of GDI.
</li>
<li>
- Cairo is now used for all drawing on GTK+. GDK drawing was removed.
+ Cairo is now used for all drawing on GTK+. GDK drawing was removed.
</li>
<li>
Paletted display support removed.
@@ -1602,7 +1717,7 @@ </li>
<li>
The set of properties files imported by SciTE can be controlled with the properties imports.include and imports.exclude.
- The import statement has been extended to allow "import *".
+ The import statement has been extended to allow "import *".
The properties files for some languages are no longer automatically loaded by default. The properties files affected are
avenue, baan, escript, lot, metapost, and mmixal.
</li>
@@ -1721,7 +1836,7 @@ <a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3324563&group_id=2439">Bug #3324563.</a>
</li>
<li>
- Python lexer has lexer.python.keywords2.no.sub.identifiers option to avoid highlighting second set of
+ Python lexer has lexer.python.keywords2.no.sub.identifiers option to avoid highlighting second set of
keywords following '.'.
<a href="https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3325333&group_id=2439">Bug #3325333.</a>
</li>
diff --git a/scintilla/doc/index.html b/scintilla/doc/index.html index 00ea4c1..cc42f73 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="20130330" />
+ <meta name="Date.Modified" content="20130411" />
<style type="text/css">
#versionlist {
margin: 0;
@@ -55,8 +55,8 @@ GTK+</font>
</td>
<td width="40%" align="right">
- <font color="#FFCC99" size="3"> Release version 3.3.0<br />
- Site last modified March 30 2013</font>
+ <font color="#FFCC99" size="3"> Release version 3.3.1<br />
+ Site last modified April 11 2013</font>
</td>
<td width="20%">
@@ -71,7 +71,9 @@ </tr>
</table>
<ul id="versionlist">
- <li>Version 3.3.0 implements overlay scrollers and kinetic scrolling on Cocoa.
+ <li>Version 3.3.1 fixes bugs on Cocoa.</li>
+ <li>Version 3.3.0 should not be used on Cocoa since it contains bugs fixed in 3.3.1.
+ It implements overlay scrollers and kinetic scrolling on Cocoa.
Performance improved on GTK+ and Cocoa by performing more work in
high-priority idle tasks.</li>
<li>Version 3.2.5 SCI_ALLOCATEEXTENDEDSTYLES introduced so that different uses
diff --git a/scintilla/include/SciLexer.h b/scintilla/include/SciLexer.h index 1027a0a..5d57cfa 100644 --- a/scintilla/include/SciLexer.h +++ b/scintilla/include/SciLexer.h @@ -1023,6 +1023,8 @@ #define SCE_HA_COMMENTBLOCK3 16
#define SCE_HA_PRAGMA 17
#define SCE_HA_PREPROCESSOR 18
+#define SCE_HA_STRINGEOL 19
+#define SCE_HA_RESERVED_OPERATOR 20
#define SCE_T3_DEFAULT 0
#define SCE_T3_X_DEFAULT 1
#define SCE_T3_PREPROCESSOR 2
@@ -1327,6 +1329,9 @@ #define SCE_POWERSHELL_FUNCTION 11
#define SCE_POWERSHELL_USER1 12
#define SCE_POWERSHELL_COMMENTSTREAM 13
+#define SCE_POWERSHELL_HERE_STRING 14
+#define SCE_POWERSHELL_HERE_CHARACTER 15
+#define SCE_POWERSHELL_COMMENTDOCKEYWORD 16
#define SCE_MYSQL_DEFAULT 0
#define SCE_MYSQL_COMMENT 1
#define SCE_MYSQL_COMMENTLINE 2
diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index a204219..15092bb 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -264,6 +264,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_SQUIGGLELOW 11
#define INDIC_DOTBOX 12
#define INDIC_SQUIGGLEPIXMAP 13
+#define INDIC_COMPOSITIONTHICK 14
#define INDIC_MAX 31
#define INDIC_CONTAINER 8
#define INDIC0_MASK 0x20
@@ -440,7 +441,19 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETFOLDEXPANDED 2229
#define SCI_GETFOLDEXPANDED 2230
#define SCI_TOGGLEFOLD 2231
+#define SC_FOLDACTION_CONTRACT 0
+#define SC_FOLDACTION_EXPAND 1
+#define SC_FOLDACTION_TOGGLE 2
+#define SCI_FOLDLINE 2237
+#define SCI_FOLDCHILDREN 2238
+#define SCI_EXPANDCHILDREN 2239
+#define SCI_FOLDALL 2662
#define SCI_ENSUREVISIBLE 2232
+#define SC_AUTOMATICFOLD_SHOW 0x0001
+#define SC_AUTOMATICFOLD_CLICK 0x0002
+#define SC_AUTOMATICFOLD_CHANGE 0x0004
+#define SCI_SETAUTOMATICFOLD 2663
+#define SCI_GETAUTOMATICFOLD 2664
#define SC_FOLDFLAG_LINEBEFORE_EXPANDED 0x0002
#define SC_FOLDFLAG_LINEBEFORE_CONTRACTED 0x0004
#define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index 89c09d1..36bf72d 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -581,6 +581,7 @@ val INDIC_DOTS=10 val INDIC_SQUIGGLELOW=11
val INDIC_DOTBOX=12
val INDIC_SQUIGGLEPIXMAP=13
+val INDIC_COMPOSITIONTHICK=14
val INDIC_MAX=31
val INDIC_CONTAINER=8
val INDIC0_MASK=0x20
@@ -1109,9 +1110,37 @@ get bool GetFoldExpanded=2230(int line,) # Switch a header line between expanded and contracted.
fun void ToggleFold=2231(int line,)
+enu FoldAction=SC_FOLDACTION
+val SC_FOLDACTION_CONTRACT=0
+val SC_FOLDACTION_EXPAND=1
+val SC_FOLDACTION_TOGGLE=2
+
+# Expand or contract a fold header.
+fun void FoldLine=2237(int line, int action)
+
+# Expand or contract a fold header and its children.
+fun void FoldChildren=2238(int line, int action)
+
+# Expand a fold header and all children. Use the level argument instead of the line's current level.
+fun void ExpandChildren=2239(int line, int level)
+
+# Expand or contract all fold headers.
+fun void FoldAll=2662(int action,)
+
# Ensure a particular line is visible by expanding any header line hiding it.
fun void EnsureVisible=2232(int line,)
+enu AutomaticFold=SC_AUTOMATICFOLD_
+val SC_AUTOMATICFOLD_SHOW=0x0001
+val SC_AUTOMATICFOLD_CLICK=0x0002
+val SC_AUTOMATICFOLD_CHANGE=0x0004
+
+# Set automatic folding behaviours.
+set void SetAutomaticFold=2663(int automaticFold,)
+
+# Get automatic folding behaviours.
+get int GetAutomaticFold=2664(,)
+
enu FoldFlag=SC_FOLDFLAG_
val SC_FOLDFLAG_LINEBEFORE_EXPANDED=0x0002
val SC_FOLDFLAG_LINEBEFORE_CONTRACTED=0x0004
@@ -3586,6 +3615,8 @@ val SCE_HA_COMMENTBLOCK2=15 val SCE_HA_COMMENTBLOCK3=16
val SCE_HA_PRAGMA=17
val SCE_HA_PREPROCESSOR=18
+val SCE_HA_STRINGEOL=19
+val SCE_HA_RESERVED_OPERATOR=20
# Lexical states of SCLEX_TADS3
lex TADS3=SCLEX_TADS3 SCE_T3_
val SCE_T3_DEFAULT=0
@@ -3926,6 +3957,9 @@ val SCE_POWERSHELL_ALIAS=10 val SCE_POWERSHELL_FUNCTION=11
val SCE_POWERSHELL_USER1=12
val SCE_POWERSHELL_COMMENTSTREAM=13
+val SCE_POWERSHELL_HERE_STRING=14
+val SCE_POWERSHELL_HERE_CHARACTER=15
+val SCE_POWERSHELL_COMMENTDOCKEYWORD=16
# Lexical state for SCLEX_MYSQL
lex MySQL=SCLEX_MYSQL SCE_MYSQL_
val SCE_MYSQL_DEFAULT=0
diff --git a/scintilla/lexers/LexAVS.cxx b/scintilla/lexers/LexAVS.cxx index e8ac4d6..f9f21dc 100644 --- a/scintilla/lexers/LexAVS.cxx +++ b/scintilla/lexers/LexAVS.cxx @@ -83,7 +83,7 @@ static void ColouriseAvsDoc( styler.SetLineState(currentLine, 0);
}
}
-
+
// Determine if the current state should terminate.
if (sc.state == SCE_AVS_OPERATOR) {
sc.SetState(SCE_AVS_DEFAULT);
diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx index 2c00003..c367761 100644 --- a/scintilla/lexers/LexCPP.cxx +++ b/scintilla/lexers/LexCPP.cxx @@ -455,9 +455,9 @@ int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) { if (n == 4) {
// Rebuild preprocessorDefinitions
preprocessorDefinitionsStart.clear();
- for (int nDefinition = 0; nDefinition < ppDefinitions.len; nDefinition++) {
- char *cpDefinition = ppDefinitions.words[nDefinition];
- char *cpEquals = strchr(cpDefinition, '=');
+ for (int nDefinition = 0; nDefinition < ppDefinitions.Length(); nDefinition++) {
+ const char *cpDefinition = ppDefinitions.WordAt(nDefinition);
+ const char *cpEquals = strchr(cpDefinition, '=');
if (cpEquals) {
std::string name(cpDefinition, cpEquals - cpDefinition);
std::string val(cpEquals+1);
diff --git a/scintilla/lexers/LexHaskell.cxx b/scintilla/lexers/LexHaskell.cxx index 7c2a968..4f47494 100644 --- a/scintilla/lexers/LexHaskell.cxx +++ b/scintilla/lexers/LexHaskell.cxx @@ -4,21 +4,20 @@ * A haskell lexer for the scintilla code control.
* Some stuff "lended" from LexPython.cxx and LexCPP.cxx.
* External lexer stuff inspired from the caml external lexer.
+ * Folder copied from Python's.
*
* Written by Tobias Engvall - tumm at dtek dot chalmers dot se
*
* Several bug fixes by Krasimir Angelov - kr.angelov at gmail.com
*
- * Improvements by kudah - kudahkukarek at gmail.com
+ * Improved by kudah <kudahkukarek@gmail.com>
*
* TODO:
- * * Implement a folder :)
- * * Nice Character-lexing (stuff inside '\''), LexPython has
- * this.
- *
+ * * A proper lexical folder to fold group declarations, comments, pragmas,
+ * #ifdefs, explicit layout, lists, tuples, quasi-quotes, splces, etc, etc,
+ * etc.
*
*****************************************************************/
-
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -26,6 +25,9 @@ #include <assert.h>
#include <ctype.h>
+#include <string>
+#include <map>
+
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
@@ -37,20 +39,12 @@ #include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
+#include "OptionSet.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
-#ifdef BUILD_AS_EXTERNAL_LEXER
-
-#include "ExternalLexer.h"
-#include "WindowAccessor.h"
-
-#define BUILD_EXTERNAL_LEXER 0
-
-#endif
-
#define HA_MODE_DEFAULT 0
#define HA_MODE_IMPORT1 1
#define HA_MODE_IMPORT2 2
@@ -58,143 +52,481 @@ using namespace Scintilla; #define HA_MODE_MODULE 4
#define HA_MODE_FFI 5
#define HA_MODE_TYPE 6
+#define HA_MODE_PRAGMA 7
+
+#define INDENT_OFFSET 1
+
+static int u_iswalpha(int);
+static int u_iswalnum(int);
+static int u_iswupper(int);
+static int u_IsHaskellSymbol(int);
+
+// #define HASKELL_UNICODE
-static inline bool IsAWordStart(const int ch) {
- return (IsLowerCase(ch) || IsUpperCase(ch) || ch == '_');
+#ifndef HASKELL_UNICODE
+
+// Stubs
+
+static int u_iswalpha(int) {
+ return 0;
+}
+
+static int u_iswalnum(int) {
+ return 0;
+}
+
+static int u_iswupper(int) {
+ return 0;
+}
+
+static int u_IsHaskellSymbol(int) {
+ return 0;
+}
+
+#endif
+
+static inline bool IsHaskellLetter(const int ch) {
+ if (IsASCII(ch)) {
+ return (ch >= 'a' && ch <= 'z')
+ || (ch >= 'A' && ch <= 'Z');
+ } else {
+ return u_iswalpha(ch) != 0;
+ }
+}
+
+static inline bool IsHaskellAlphaNumeric(const int ch) {
+ if (IsASCII(ch)) {
+ return IsAlphaNumeric(ch);
+ } else {
+ return u_iswalnum(ch) != 0;
+ }
}
-static inline bool IsAWordChar(const int ch, const bool magicHash) {
- return ( IsAlphaNumeric(ch)
+static inline bool IsHaskellUpperCase(const int ch) {
+ if (IsASCII(ch)) {
+ return ch >= 'A' && ch <= 'Z';
+ } else {
+ return u_iswupper(ch) != 0;
+ }
+}
+
+static inline bool IsAnHaskellOperatorChar(const int ch) {
+ if (IsASCII(ch)) {
+ return
+ ( ch == '!' || ch == '#' || ch == '$' || ch == '%'
+ || ch == '&' || ch == '*' || ch == '+' || ch == '-'
+ || ch == '.' || ch == '/' || ch == ':' || ch == '<'
+ || ch == '=' || ch == '>' || ch == '?' || ch == '@'
+ || ch == '^' || ch == '|' || ch == '~' || ch == '\\');
+ } else {
+ return u_IsHaskellSymbol(ch) != 0;
+ }
+}
+
+static inline bool IsAHaskellWordStart(const int ch) {
+ return IsHaskellLetter(ch) || ch == '_';
+}
+
+static inline bool IsAHaskellWordChar(const int ch) {
+ return ( IsHaskellAlphaNumeric(ch)
|| ch == '_'
- || ch == '\''
- || (magicHash && ch == '#'));
+ || ch == '\'');
+}
+
+static inline bool IsCommentBlockStyle(int style) {
+ return (style >= SCE_HA_COMMENTBLOCK && style <= SCE_HA_COMMENTBLOCK3);
}
-static inline bool IsAnOperatorChar(const int ch) {
- return
- ( ch == '!' || ch == '#' || ch == '$' || ch == '%'
- || ch == '&' || ch == '*' || ch == '+' || ch == '-'
- || ch == '.' || ch == '/' || ch == ':' || ch == '<'
- || ch == '=' || ch == '>' || ch == '?' || ch == '@'
- || ch == '\\' || ch == '^' || ch == '|' || ch == '~');
+static inline bool IsCommentStyle(int style) {
+ return (style >= SCE_HA_COMMENTLINE && style <= SCE_HA_COMMENTBLOCK3);
+}
+
+inline int StyleFromNestLevel(const unsigned int nestLevel) {
+ return SCE_HA_COMMENTBLOCK + (nestLevel % 3);
+ }
+
+struct OptionsHaskell {
+ bool magicHash;
+ bool allowQuotes;
+ bool implicitParams;
+ bool highlightSafe;
+ bool stylingWithinPreprocessor;
+ bool fold;
+ bool foldComment;
+ bool foldCompact;
+ bool foldImports;
+ bool foldIndentedImports;
+ OptionsHaskell() {
+ magicHash = true; // Widespread use, enabled by default.
+ allowQuotes = true; // Widespread use, enabled by default.
+ implicitParams = false; // Fell out of favor, seldom used, disabled.
+ highlightSafe = true; // Moderately used, doesn't hurt to enable.
+ stylingWithinPreprocessor = false;
+ fold = false;
+ foldComment = false;
+ foldCompact = false;
+ foldImports = false;
+ foldIndentedImports = true;
+ }
+};
+
+static const char * const haskellWordListDesc[] = {
+ "Keywords",
+ "FFI",
+ 0
+};
+
+struct OptionSetHaskell : public OptionSet<OptionsHaskell> {
+ OptionSetHaskell() {
+ DefineProperty("lexer.haskell.allow.hash", &OptionsHaskell::magicHash,
+ "Set to 0 to disallow the '#' character at the end of identifiers and "
+ "literals with the haskell lexer "
+ "(GHC -XMagicHash extension)");
+
+ DefineProperty("lexer.haskell.allow.quotes", &OptionsHaskell::allowQuotes,
+ "Set to 0 to disable highlighting of Template Haskell name quotations "
+ "and promoted constructors "
+ "(GHC -XTemplateHaskell and -XDataKinds extensions)");
+
+ DefineProperty("lexer.haskell.allow.questionmark", &OptionsHaskell::implicitParams,
+ "Set to 1 to allow the '?' character at the start of identifiers "
+ "with the haskell lexer "
+ "(GHC & Hugs -XImplicitParams extension)");
+
+ DefineProperty("lexer.haskell.import.safe", &OptionsHaskell::highlightSafe,
+ "Set to 0 to disallow \"safe\" keyword in imports "
+ "(GHC -XSafe, -XTrustworthy, -XUnsafe extensions)");
+
+ DefineProperty("styling.within.preprocessor", &OptionsHaskell::stylingWithinPreprocessor,
+ "For Haskell code, determines whether all preprocessor code is styled in the "
+ "preprocessor style (0, the default) or only from the initial # to the end "
+ "of the command word(1)."
+ );
+
+ DefineProperty("fold", &OptionsHaskell::fold);
+
+ DefineProperty("fold.comment", &OptionsHaskell::foldComment);
+
+ DefineProperty("fold.compact", &OptionsHaskell::foldCompact);
+
+ DefineProperty("fold.haskell.imports", &OptionsHaskell::foldImports,
+ "Set to 1 to enable folding of import declarations");
+
+ DefineProperty("fold.haskell.imports.indented", &OptionsHaskell::foldIndentedImports,
+ "Set this property to 0 to disable folding imports not starting at "
+ "column 0 when fold.haskell.imports=1");
+
+ DefineWordListSets(haskellWordListDesc);
+ }
+};
+
+class LexerHaskell : public ILexer {
+ int firstImportLine;
+ WordList keywords;
+ WordList ffi;
+ WordList reserved_operators;
+ OptionsHaskell options;
+ OptionSetHaskell osHaskell;
+
+ enum HashCount {
+ oneHash
+ ,twoHashes
+ ,unlimitedHashes
+ };
+
+ inline void skipMagicHash(StyleContext &sc, const HashCount hashes) {
+ if (options.magicHash && sc.ch == '#') {
+ sc.Forward();
+ if (hashes == twoHashes && sc.ch == '#') {
+ sc.Forward();
+ } else if (hashes == unlimitedHashes) {
+ while (sc.ch == '#') {
+ sc.Forward();
+ }
+ }
+ }
+ }
+
+ bool LineContainsImport(const int line, Accessor &styler) {
+ if (options.foldImports) {
+ int currentPos = styler.LineStart(line);
+ int style = styler.StyleAt(currentPos);
+
+ if (options.foldIndentedImports) {
+ int eol_pos = styler.LineStart(line + 1) - 1;
+
+ while (currentPos < eol_pos) {
+ int ch = styler[currentPos];
+ style = styler.StyleAt(currentPos);
+
+ if (ch == ' ' || ch == '\t'
+ || IsCommentBlockStyle(style)) {
+ currentPos++;
+ } else {
+ break;
+ }
+ }
+ }
+
+ return (style == SCE_HA_KEYWORD
+ && styler.Match(currentPos, "import"));
+ } else {
+ return false;
+ }
+ }
+public:
+ LexerHaskell() : firstImportLine(-1) {}
+ virtual ~LexerHaskell() {}
+
+ void SCI_METHOD Release() {
+ delete this;
+ }
+
+ int SCI_METHOD Version() const {
+ return lvOriginal;
+ }
+
+ const char * SCI_METHOD PropertyNames() {
+ return osHaskell.PropertyNames();
+ }
+
+ int SCI_METHOD PropertyType(const char *name) {
+ return osHaskell.PropertyType(name);
+ }
+
+ const char * SCI_METHOD DescribeProperty(const char *name) {
+ return osHaskell.DescribeProperty(name);
+ }
+
+ int SCI_METHOD PropertySet(const char *key, const char *val);
+
+ const char * SCI_METHOD DescribeWordListSets() {
+ return osHaskell.DescribeWordListSets();
+ }
+
+ int SCI_METHOD WordListSet(int n, const char *wl);
+
+ void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
+
+ void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
+
+ void * SCI_METHOD PrivateCall(int, void *) {
+ return 0;
+ }
+
+ static ILexer *LexerFactoryHaskell() {
+ return new LexerHaskell();
+ }
+};
+
+int SCI_METHOD LexerHaskell::PropertySet(const char *key, const char *val) {
+ if (osHaskell.PropertySet(&options, key, val)) {
+ return 0;
+ }
+ return -1;
}
-static void ColorizeHaskellDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+int SCI_METHOD LexerHaskell::WordListSet(int n, const char *wl) {
+ WordList *wordListN = 0;
+ switch (n) {
+ case 0:
+ wordListN = &keywords;
+ break;
+ case 1:
+ wordListN = &ffi;
+ break;
+ case 2:
+ wordListN = &reserved_operators;
+ break;
+ }
+ int firstModification = -1;
+ if (wordListN) {
+ WordList wlNew;
+ wlNew.Set(wl);
+ if (*wordListN != wlNew) {
+ wordListN->Set(wl);
+ firstModification = 0;
+ }
+ }
+ return firstModification;
+}
- WordList &keywords = *keywordlists[0];
- WordList &ffi = *keywordlists[1];
+void SCI_METHOD LexerHaskell::Lex(unsigned int startPos, int length, int initStyle
+ ,IDocument *pAccess) {
+ LexAccessor styler(pAccess);
- // property lexer.haskell.allow.hash
- // Set to 1 to allow the # character in identifiers with the haskell lexer.
- // (GHC -XMagicHash extension)
- const bool magicHash = styler.GetPropertyInt("lexer.haskell.allow.hash") != 0;
- const bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
+ // Do not leak onto next line
+ if (initStyle == SCE_HA_STRINGEOL)
+ initStyle = SCE_HA_DEFAULT;
StyleContext sc(startPos, length, initStyle, styler);
int lineCurrent = styler.GetLine(startPos);
- int state = lineCurrent ? styler.GetLineState(lineCurrent-1)
- : HA_MODE_DEFAULT;
- int mode = state & 0xF;
- int xmode = state >> 4; // obscure parameter. Means different things in different modes.
+
+ int state = lineCurrent ? styler.GetLineState(lineCurrent-1) : 0;
+ int mode = state & 0x7;
+ int nestLevel = state >> 3;
+
+ int base = 10;
+ bool dot = false;
+
+ bool inDashes = false;
+
+ assert(!(IsCommentBlockStyle(initStyle) && nestLevel <= 0));
while (sc.More()) {
// Check for state end
+ // For line numbering (and by extension, nested comments) to work,
+ // states should always forward one character at a time.
+ // states should match on line ends using OnLineEnd function.
+ // If a state sometimes does _not_ forward a character, it should check
+ // first if it's not on a line end and forward otherwise.
+ // If a state forwards more than one character, it should check every time
+ // that it is not a line end and cease forwarding otherwise.
+ if (sc.atLineEnd) {
+ // Remember the line state for future incremental lexing
+ styler.SetLineState(lineCurrent, (nestLevel << 3) | mode);
+ lineCurrent++;
+ }
+
+ if (sc.atLineStart && (sc.state == SCE_HA_STRING || sc.state == SCE_HA_CHARACTER)) {
+ // Prevent SCE_HA_STRINGEOL from leaking back to previous line
+ sc.SetState(sc.state);
+ }
+
+ // Handle line continuation generically.
+ if (sc.ch == '\\' &&
+ ( sc.state == SCE_HA_STRING
+ || sc.state == SCE_HA_PREPROCESSOR)) {
+ if (sc.chNext == '\n' || sc.chNext == '\r') {
+ sc.Forward();
+
+ // Remember the line state for future incremental lexing
+ styler.SetLineState(lineCurrent, (nestLevel << 3) | mode);
+ lineCurrent++;
+
+ if (sc.ch == '\r' && sc.chNext == '\n') {
+ sc.Forward();
+ }
+ sc.Forward();
+ continue;
+ }
+ }
+
// Operator
if (sc.state == SCE_HA_OPERATOR) {
int style = SCE_HA_OPERATOR;
if (sc.ch == ':' &&
// except "::"
- !(sc.chNext == ':' && !IsAnOperatorChar(sc.GetRelative(2)))) {
+ !(sc.chNext == ':' && !IsAnHaskellOperatorChar(sc.GetRelative(2)))) {
style = SCE_HA_CAPITAL;
}
- while(IsAnOperatorChar(sc.ch))
+ while (IsAnHaskellOperatorChar(sc.ch))
sc.Forward();
- styler.ColourTo(sc.currentPos - 1, style);
- sc.ChangeState(SCE_HA_DEFAULT);
+ char s[100];
+ sc.GetCurrent(s, sizeof(s));
+
+ if (reserved_operators.InList(s))
+ style = SCE_HA_RESERVED_OPERATOR;
+
+ sc.ChangeState(style);
+ sc.SetState(SCE_HA_DEFAULT);
}
// String
else if (sc.state == SCE_HA_STRING) {
- if (sc.ch == '\"') {
+ if (sc.atLineEnd) {
+ sc.ChangeState(SCE_HA_STRINGEOL);
+ sc.ForwardSetState(SCE_HA_DEFAULT);
+ } else if (sc.ch == '\"') {
sc.Forward();
+ skipMagicHash(sc, oneHash);
sc.SetState(SCE_HA_DEFAULT);
} else if (sc.ch == '\\') {
sc.Forward(2);
- } else if (sc.atLineEnd) {
- sc.SetState(SCE_HA_DEFAULT);
} else {
sc.Forward();
}
}
// Char
else if (sc.state == SCE_HA_CHARACTER) {
- if (sc.ch == '\'') {
+ if (sc.atLineEnd) {
+ sc.ChangeState(SCE_HA_STRINGEOL);
+ sc.ForwardSetState(SCE_HA_DEFAULT);
+ } else if (sc.ch == '\'') {
sc.Forward();
+ skipMagicHash(sc, oneHash);
sc.SetState(SCE_HA_DEFAULT);
} else if (sc.ch == '\\') {
sc.Forward(2);
- } else if (sc.atLineEnd) {
- sc.SetState(SCE_HA_DEFAULT);
} else {
sc.Forward();
}
}
// Number
else if (sc.state == SCE_HA_NUMBER) {
- if (IsADigit(sc.ch, xmode) ||
- (sc.ch=='.' && IsADigit(sc.chNext, xmode))) {
+ if (IsADigit(sc.ch, base)) {
sc.Forward();
- } else if ((xmode == 10) &&
+ } else if (sc.ch=='.' && dot && IsADigit(sc.chNext, base)) {
+ sc.Forward(2);
+ dot = false;
+ } else if ((base == 10) &&
(sc.ch == 'e' || sc.ch == 'E') &&
(IsADigit(sc.chNext) || sc.chNext == '+' || sc.chNext == '-')) {
sc.Forward();
if (sc.ch == '+' || sc.ch == '-')
sc.Forward();
} else {
+ skipMagicHash(sc, twoHashes);
sc.SetState(SCE_HA_DEFAULT);
}
}
// Keyword or Identifier
else if (sc.state == SCE_HA_IDENTIFIER) {
+ int style = IsHaskellUpperCase(sc.ch) ? SCE_HA_CAPITAL : SCE_HA_IDENTIFIER;
+
+ assert(IsAHaskellWordStart(sc.ch));
+
+ sc.Forward();
+
while (sc.More()) {
- if (IsAWordChar(sc.ch, magicHash)) {
+ if (IsAHaskellWordChar(sc.ch)) {
sc.Forward();
- } else if (xmode == SCE_HA_CAPITAL && sc.ch=='.') {
- if (isupper(sc.chNext)) {
- xmode = SCE_HA_CAPITAL;
+ } else if (sc.ch == '.' && style == SCE_HA_CAPITAL) {
+ if (IsHaskellUpperCase(sc.chNext)) {
sc.Forward();
- } else if (IsAWordStart(sc.chNext)) {
- xmode = SCE_HA_IDENTIFIER;
+ style = SCE_HA_CAPITAL;
+ } else if (IsAHaskellWordStart(sc.chNext)) {
sc.Forward();
- } else if (IsAnOperatorChar(sc.chNext)) {
- xmode = SCE_HA_OPERATOR;
+ style = SCE_HA_IDENTIFIER;
+ } else if (IsAnHaskellOperatorChar(sc.chNext)) {
sc.Forward();
+ style = sc.ch == ':' ? SCE_HA_CAPITAL : SCE_HA_OPERATOR;
+ while (IsAnHaskellOperatorChar(sc.ch))
+ sc.Forward();
+ break;
} else {
break;
}
- } else if (xmode == SCE_HA_OPERATOR && IsAnOperatorChar(sc.ch)) {
- sc.Forward();
} else {
break;
}
}
+ skipMagicHash(sc, unlimitedHashes);
+
char s[100];
sc.GetCurrent(s, sizeof(s));
- int style = xmode;
-
int new_mode = HA_MODE_DEFAULT;
if (keywords.InList(s)) {
style = SCE_HA_KEYWORD;
- } else if (isupper(s[0])) {
- if (mode >= HA_MODE_IMPORT1 && mode <= HA_MODE_IMPORT3) {
+ } else if (style == SCE_HA_CAPITAL) {
+ if (mode == HA_MODE_IMPORT1 || mode == HA_MODE_IMPORT3) {
style = SCE_HA_MODULE;
new_mode = HA_MODE_IMPORT2;
} else if (mode == HA_MODE_MODULE) {
@@ -204,6 +536,11 @@ static void ColorizeHaskellDoc(unsigned int startPos, int length, int initStyle, strcmp(s,"qualified") == 0) {
style = SCE_HA_KEYWORD;
new_mode = HA_MODE_IMPORT1;
+ } else if (options.highlightSafe &&
+ mode == HA_MODE_IMPORT1 &&
+ strcmp(s,"safe") == 0) {
+ style = SCE_HA_KEYWORD;
+ new_mode = HA_MODE_IMPORT1;
} else if (mode == HA_MODE_IMPORT2) {
if (strcmp(s,"as") == 0) {
style = SCE_HA_KEYWORD;
@@ -223,7 +560,8 @@ static void ColorizeHaskellDoc(unsigned int startPos, int length, int initStyle, }
}
- styler.ColourTo(sc.currentPos - 1, style);
+ sc.ChangeState(style);
+ sc.SetState(SCE_HA_DEFAULT);
if (strcmp(s,"import") == 0 && mode != HA_MODE_FFI)
new_mode = HA_MODE_IMPORT1;
@@ -235,87 +573,95 @@ static void ColorizeHaskellDoc(unsigned int startPos, int length, int initStyle, || strcmp(s,"data") == 0)
new_mode = HA_MODE_TYPE;
- xmode = 0;
- sc.ChangeState(SCE_HA_DEFAULT);
mode = new_mode;
}
// Comments
// Oneliner
else if (sc.state == SCE_HA_COMMENTLINE) {
- if (xmode == 1 && sc.ch != '-') {
- xmode = 0;
- if (IsAnOperatorChar(sc.ch))
+ if (sc.atLineEnd) {
+ sc.SetState(mode == HA_MODE_PRAGMA ? SCE_HA_PRAGMA : SCE_HA_DEFAULT);
+ sc.Forward(); // prevent double counting a line
+ } else if (inDashes && sc.ch != '-' && mode != HA_MODE_PRAGMA) {
+ inDashes = false;
+ if (IsAnHaskellOperatorChar(sc.ch))
sc.ChangeState(SCE_HA_OPERATOR);
- } else if (sc.atLineEnd) {
- sc.SetState(SCE_HA_DEFAULT);
} else {
sc.Forward();
}
}
// Nested
- else if (sc.state == SCE_HA_COMMENTBLOCK) {
+ else if (IsCommentBlockStyle(sc.state)) {
if (sc.Match('{','-')) {
+ sc.SetState(StyleFromNestLevel(nestLevel));
sc.Forward(2);
- xmode++;
- }
- else if (sc.Match('-','}')) {
+ nestLevel++;
+ } else if (sc.Match('-','}')) {
sc.Forward(2);
- xmode--;
- if (xmode == 0) {
- sc.SetState(SCE_HA_DEFAULT);
- }
+ nestLevel--;
+ assert(nestLevel >= 0);
+ sc.SetState(
+ nestLevel <= 0
+ ? (mode == HA_MODE_PRAGMA ? SCE_HA_PRAGMA : SCE_HA_DEFAULT)
+ : StyleFromNestLevel(nestLevel - 1));
} else {
- if (sc.atLineEnd) {
- // Remember the line state for future incremental lexing
- styler.SetLineState(lineCurrent, (xmode << 4) | mode);
- lineCurrent++;
- }
sc.Forward();
}
}
// Pragma
else if (sc.state == SCE_HA_PRAGMA) {
if (sc.Match("#-}")) {
+ mode = HA_MODE_DEFAULT;
sc.Forward(3);
sc.SetState(SCE_HA_DEFAULT);
+ } else if (sc.Match('-','-')) {
+ sc.SetState(SCE_HA_COMMENTLINE);
+ sc.Forward(2);
+ inDashes = false;
+ } else if (sc.Match('{','-')) {
+ sc.SetState(StyleFromNestLevel(nestLevel));
+ sc.Forward(2);
+ nestLevel = 1;
} else {
sc.Forward();
}
}
// Preprocessor
else if (sc.state == SCE_HA_PREPROCESSOR) {
- if (stylingWithinPreprocessor && !IsAWordStart(sc.ch)) {
+ if (sc.atLineEnd) {
sc.SetState(SCE_HA_DEFAULT);
- } else if (sc.ch == '\\' && !stylingWithinPreprocessor) {
- sc.Forward(2);
- } else if (sc.atLineEnd) {
+ sc.Forward(); // prevent double counting a line
+ } else if (options.stylingWithinPreprocessor && !IsHaskellLetter(sc.ch)) {
sc.SetState(SCE_HA_DEFAULT);
} else {
sc.Forward();
}
}
- // New state?
- if (sc.state == SCE_HA_DEFAULT) {
+ // New state?
+ else if (sc.state == SCE_HA_DEFAULT) {
// Digit
if (IsADigit(sc.ch)) {
sc.SetState(SCE_HA_NUMBER);
if (sc.ch == '0' && (sc.chNext == 'X' || sc.chNext == 'x')) {
- // Match anything starting with "0x" or "0X", too
- sc.Forward(2);
- xmode = 16;
+ // Match anything starting with "0x" or "0X", too
+ sc.Forward(2);
+ base = 16;
+ dot = false;
} else if (sc.ch == '0' && (sc.chNext == 'O' || sc.chNext == 'o')) {
- // Match anything starting with "0x" or "0X", too
- sc.Forward(2);
- xmode = 8;
+ // Match anything starting with "0o" or "0O", too
+ sc.Forward(2);
+ base = 8;
+ dot = false;
} else {
- sc.Forward();
- xmode = 10;
+ sc.Forward();
+ base = 10;
+ dot = true;
}
mode = HA_MODE_DEFAULT;
}
// Pragma
else if (sc.Match("{-#")) {
+ mode = HA_MODE_PRAGMA;
sc.SetState(SCE_HA_PRAGMA);
sc.Forward(3);
}
@@ -323,23 +669,54 @@ static void ColorizeHaskellDoc(unsigned int startPos, int length, int initStyle, else if (sc.Match('-','-')) {
sc.SetState(SCE_HA_COMMENTLINE);
sc.Forward(2);
- xmode = 1;
+ inDashes = true;
}
// Comment block
else if (sc.Match('{','-')) {
- sc.SetState(SCE_HA_COMMENTBLOCK);
+ sc.SetState(StyleFromNestLevel(nestLevel));
sc.Forward(2);
- xmode = 1;
+ nestLevel = 1;
}
// String
- else if (sc.Match('\"')) {
+ else if (sc.ch == '\"') {
sc.SetState(SCE_HA_STRING);
sc.Forward();
}
- // Character
- else if (sc.Match('\'')) {
+ // Character or quoted name
+ else if (sc.ch == '\'') {
sc.SetState(SCE_HA_CHARACTER);
sc.Forward();
+
+ if (options.allowQuotes) {
+ // Quoted type ''T
+ if (sc.ch=='\'' && IsAHaskellWordStart(sc.chNext)) {
+ sc.Forward();
+ sc.ChangeState(SCE_HA_IDENTIFIER);
+ } else if (sc.chNext != '\'') {
+ // Quoted value or promoted constructor 'N
+ if (IsAHaskellWordStart(sc.ch)) {
+ sc.ChangeState(SCE_HA_IDENTIFIER);
+ // Promoted constructor operator ':~>
+ } else if (sc.ch == ':') {
+ sc.ChangeState(SCE_HA_OPERATOR);
+ // Promoted list or tuple '[T]
+ } else if (sc.ch == '[' || sc.ch== '(') {
+ styler.ColourTo(sc.currentPos - 1, SCE_HA_OPERATOR);
+ sc.ChangeState(SCE_HA_DEFAULT);
+ }
+ }
+ }
+ }
+ // Operator starting with '?' or an implicit parameter
+ else if (sc.ch == '?') {
+ sc.SetState(SCE_HA_OPERATOR);
+
+ if ( options.implicitParams
+ && IsAHaskellWordStart(sc.chNext)
+ && !IsHaskellUpperCase(sc.chNext)) {
+ sc.Forward();
+ sc.ChangeState(SCE_HA_IDENTIFIER);
+ }
}
// Preprocessor
else if (sc.atLineStart && sc.ch == '#') {
@@ -348,7 +725,7 @@ static void ColorizeHaskellDoc(unsigned int startPos, int length, int initStyle, sc.Forward();
}
// Operator
- else if (IsAnOperatorChar(sc.ch)) {
+ else if (IsAnHaskellOperatorChar(sc.ch)) {
mode = HA_MODE_DEFAULT;
sc.SetState(SCE_HA_OPERATOR);
}
@@ -358,78 +735,230 @@ static void ColorizeHaskellDoc(unsigned int startPos, int length, int initStyle, || sc.ch == '[' || sc.ch == ']'
|| sc.ch == '{' || sc.ch == '}') {
sc.SetState(SCE_HA_OPERATOR);
- sc.Forward();
- sc.SetState(SCE_HA_DEFAULT);
+ sc.ForwardSetState(SCE_HA_DEFAULT);
}
// Keyword or Identifier
- else if (IsAWordStart(sc.ch)) {
- xmode = isupper(sc.ch) ? SCE_HA_CAPITAL : SCE_HA_IDENTIFIER;
+ else if (IsAHaskellWordStart(sc.ch)) {
sc.SetState(SCE_HA_IDENTIFIER);
- sc.Forward();
+ // Something we don't care about
} else {
- if (sc.atLineEnd) {
- // Remember the line state for future incremental lexing
- styler.SetLineState(lineCurrent, (xmode << 4) | mode);
- lineCurrent++;
- }
sc.Forward();
}
}
+ // This branch should never be reached.
+ else {
+ assert(false);
+ sc.Forward();
+ }
}
+ styler.SetLineState(lineCurrent, (nestLevel << 3) | mode);
sc.Complete();
}
-// External stuff - used for dynamic-loading, not implemented in wxStyledTextCtrl yet.
-// Inspired by the caml external lexer - Credits to Robert Roessler - http://www.rftp.com
-#ifdef BUILD_EXTERNAL_LEXER
-static const char* LexerName = "haskell";
-
-void EXT_LEXER_DECL Lex(unsigned int lexer, unsigned int startPos, int length, int initStyle,
- char *words[], WindowID window, char *props)
-{
- PropSetSimple ps;
- ps.SetMultiple(props);
- WindowAccessor wa(window, ps);
-
- int nWL = 0;
- for (; words[nWL]; nWL++) ;
- WordList** wl = new WordList* [nWL + 1];
- int i = 0;
- for (; i<nWL; i++)
- {
- wl[i] = new WordList();
- wl[i]->Set(words[i]);
+// Mangled version of lexlib/Accessor.cxx IndentAmount.
+// Modified to treat comment blocks as whitespace
+// plus special case for commentline/preprocessor.
+static int HaskellIndentAmount(Accessor &styler, int line) {
+
+ // Determines the indentation level of the current line
+ // Comment blocks are treated as whitespace
+
+ int pos = styler.LineStart(line);
+ int eol_pos = styler.LineStart(line + 1) - 1;
+
+ char ch = styler[pos];
+ int style = styler.StyleAt(pos);
+
+ int indent = 0;
+ bool inPrevPrefix = line > 0;
+
+ int posPrev = inPrevPrefix ? styler.LineStart(line-1) : 0;
+
+ while ((ch == ' ' || ch == '\t' || IsCommentBlockStyle(style)) && (pos < eol_pos)) {
+ if (inPrevPrefix) {
+ char chPrev = styler[posPrev++];
+ if (chPrev != ' ' && chPrev != '\t') {
+ inPrevPrefix = false;
+ }
+ }
+ if (ch == '\t') {
+ indent = (indent / 8 + 1) * 8;
+ } else { // Space or comment block
+ indent++;
+ }
+ pos++;
+ ch = styler[pos];
+ style = styler.StyleAt(pos);
}
- wl[i] = 0;
- ColorizeHaskellDoc(startPos, length, initStyle, wl, wa);
- wa.Flush();
- for (i=nWL-1;i>=0;i--)
- delete wl[i];
- delete [] wl;
+ indent += SC_FOLDLEVELBASE;
+ // if completely empty line or the start of a comment or preprocessor...
+ if ( styler.LineStart(line) == styler.Length()
+ || ch == ' '
+ || ch == '\t'
+ || ch == '\n'
+ || ch == '\r'
+ || IsCommentStyle(style)
+ || style == SCE_HA_PREPROCESSOR)
+ return indent | SC_FOLDLEVELWHITEFLAG;
+ else
+ return indent;
}
-void EXT_LEXER_DECL Fold (unsigned int lexer, unsigned int startPos, int length, int initStyle,
- char *words[], WindowID window, char *props)
-{
-
+static inline int IndentAmountWithOffset(Accessor &styler, int line) {
+ int indent = HaskellIndentAmount(styler, line);
+ int indentLevel = indent & SC_FOLDLEVELNUMBERMASK;
+ return indentLevel == (SC_FOLDLEVELBASE & SC_FOLDLEVELNUMBERMASK)
+ ? indent
+ : (indentLevel + INDENT_OFFSET) | (indent & ~SC_FOLDLEVELNUMBERMASK);
}
-int EXT_LEXER_DECL GetLexerCount()
-{
- return 1;
+static inline int RemoveIndentOffset(int indentLevel) {
+ return indentLevel == (SC_FOLDLEVELBASE & SC_FOLDLEVELNUMBERMASK)
+ ? indentLevel
+ : indentLevel - INDENT_OFFSET;
}
-void EXT_LEXER_DECL GetLexerName(unsigned int Index, char *name, int buflength)
-{
- if (buflength > 0) {
- buflength--;
- int n = strlen(LexerName);
- if (n > buflength)
- n = buflength;
- memcpy(name, LexerName, n), name[n] = '\0';
+void SCI_METHOD LexerHaskell::Fold(unsigned int startPos, int length, int // initStyle
+ ,IDocument *pAccess) {
+ if (!options.fold)
+ return;
+
+ Accessor styler(pAccess, NULL);
+
+ const int maxPos = startPos + length;
+ const int maxLines =
+ maxPos == styler.Length()
+ ? styler.GetLine(maxPos)
+ : styler.GetLine(maxPos - 1); // Requested last line
+ const int docLines = styler.GetLine(styler.Length()); // Available last line
+
+ // Backtrack to previous non-blank line so we can determine indent level
+ // for any white space lines
+ // and so we can fix any preceding fold level (which is why we go back
+ // at least one line in all cases)
+ int lineCurrent = styler.GetLine(startPos);
+ bool importHere = LineContainsImport(lineCurrent, styler);
+ int indentCurrent = IndentAmountWithOffset(styler, lineCurrent);
+
+ while (lineCurrent > 0) {
+ lineCurrent--;
+ importHere = LineContainsImport(lineCurrent, styler);
+ indentCurrent = IndentAmountWithOffset(styler, lineCurrent);
+ if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG))
+ break;
+ }
+
+ int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
+
+ if (lineCurrent <= firstImportLine) {
+ firstImportLine = -1; // readjust first import position
+ }
+
+ if (importHere) {
+ if (firstImportLine == -1) {
+ firstImportLine = lineCurrent;
+ }
+ indentCurrentLevel = RemoveIndentOffset(indentCurrentLevel);
+ if (firstImportLine != lineCurrent) {
+ indentCurrentLevel++;
+ }
+ }
+
+ indentCurrent = indentCurrentLevel | (indentCurrent & ~SC_FOLDLEVELNUMBERMASK);
+
+ // Process all characters to end of requested range
+ //that hangs over the end of the range. Cap processing in all cases
+ // to end of document.
+ while (lineCurrent <= docLines && lineCurrent <= maxLines) {
+
+ // Gather info
+ int lineNext = lineCurrent + 1;
+ importHere = false;
+ int indentNext = indentCurrent;
+
+ if (lineNext <= docLines) {
+ // Information about next line is only available if not at end of document
+ importHere = LineContainsImport(lineNext, styler);
+ indentNext = IndentAmountWithOffset(styler, lineNext);
+ }
+ if (indentNext & SC_FOLDLEVELWHITEFLAG)
+ indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel;
+
+ // Skip past any blank lines for next indent level info; we skip also
+ // comments (all comments, not just those starting in column 0)
+ // which effectively folds them into surrounding code rather
+ // than screwing up folding.
+
+ while (lineNext < docLines && (indentNext & SC_FOLDLEVELWHITEFLAG)) {
+ lineNext++;
+ importHere = LineContainsImport(lineNext, styler);
+ indentNext = IndentAmountWithOffset(styler, lineNext);
+ }
+
+ int indentNextLevel = indentNext & SC_FOLDLEVELNUMBERMASK;
+
+ if (importHere) {
+ if (firstImportLine == -1) {
+ firstImportLine = lineNext;
+ }
+ indentNextLevel = RemoveIndentOffset(indentNextLevel);
+ if (firstImportLine != lineNext) {
+ indentNextLevel++;
+ }
+ }
+
+ indentNext = indentNextLevel | (indentNext & ~SC_FOLDLEVELNUMBERMASK);
+
+ const int levelBeforeComments = Maximum(indentCurrentLevel,indentNextLevel);
+
+ // Now set all the indent levels on the lines we skipped
+ // Do this from end to start. Once we encounter one line
+ // which is indented more than the line after the end of
+ // the comment-block, use the level of the block before
+
+ int skipLine = lineNext;
+ int skipLevel = indentNextLevel;
+
+ while (--skipLine > lineCurrent) {
+ int skipLineIndent = IndentAmountWithOffset(styler, skipLine);
+
+ if (options.foldCompact) {
+ if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > indentNextLevel) {
+ skipLevel = levelBeforeComments;
+ }
+
+ int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG;
+
+ styler.SetLevel(skipLine, skipLevel | whiteFlag);
+ } else {
+ if ( (skipLineIndent & SC_FOLDLEVELNUMBERMASK) > indentNextLevel
+ && !(skipLineIndent & SC_FOLDLEVELWHITEFLAG)) {
+ skipLevel = levelBeforeComments;
+ }
+
+ styler.SetLevel(skipLine, skipLevel);
+ }
+ }
+
+ int lev = indentCurrent;
+
+ if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
+ if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ }
+
+ // Set fold level for this line and move to next line
+ styler.SetLevel(lineCurrent, options.foldCompact ? lev : lev & ~SC_FOLDLEVELWHITEFLAG);
+
+ indentCurrent = indentNext;
+ indentCurrentLevel = indentNextLevel;
+ lineCurrent = lineNext;
}
+
+ // NOTE: Cannot set level of last line here because indentCurrent doesn't have
+ // header flag set; the loop above is crafted to take care of this case!
+ //styler.SetLevel(lineCurrent, indentCurrent);
}
-#endif
-LexerModule lmHaskell(SCLEX_HASKELL, ColorizeHaskellDoc, "haskell");
+LexerModule lmHaskell(SCLEX_HASKELL, LexerHaskell::LexerFactoryHaskell, "haskell", haskellWordListDesc);
diff --git a/scintilla/lexers/LexLaTeX.cxx b/scintilla/lexers/LexLaTeX.cxx index 6f9612d..f3b1405 100644 --- a/scintilla/lexers/LexLaTeX.cxx +++ b/scintilla/lexers/LexLaTeX.cxx @@ -224,7 +224,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle chNext = styler.SafeGetCharAt(i + 1); } else if (chNext == '\r' || chNext == '\n') { styler.ColourTo(i, SCE_L_ERROR); - } else { + } else if (isascii(chNext)) { styler.ColourTo(i + 1, SCE_L_SHORTCMD); if (chNext == '(') { mode = 1; @@ -340,7 +340,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle chNext = styler.SafeGetCharAt(i + 1); } else if (chNext == '\r' || chNext == '\n') { styler.ColourTo(i, SCE_L_ERROR); - } else { + } else if (isascii(chNext)) { if (chNext == ')') { mode = 0; state = SCE_L_DEFAULT; @@ -382,7 +382,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle chNext = styler.SafeGetCharAt(i + 1); } else if (chNext == '\r' || chNext == '\n') { styler.ColourTo(i, SCE_L_ERROR); - } else { + } else if (isascii(chNext)) { if (chNext == ']') { mode = 0; state = SCE_L_DEFAULT; diff --git a/scintilla/lexers/LexModula.cxx b/scintilla/lexers/LexModula.cxx index f07f568..5f0e4e0 100644 --- a/scintilla/lexers/LexModula.cxx +++ b/scintilla/lexers/LexModula.cxx @@ -63,16 +63,16 @@ static inline unsigned IsOperator( StyleContext & sc, WordList & op ) { s[0] = sc.ch;
s[1] = sc.chNext;
s[2] = 0;
- for( i = 0; i < op.len; i++ ) {
- if( ( strlen( op.words[i] ) == 2 ) &&
- ( s[0] == op.words[i][0] && s[1] == op.words[i][1] ) ) {
+ for( i = 0; i < op.Length(); i++ ) {
+ if( ( strlen( op.WordAt(i) ) == 2 ) &&
+ ( s[0] == op.WordAt(i)[0] && s[1] == op.WordAt(i)[1] ) ) {
return 2;
}
}
s[1] = 0;
- for( i = 0; i < op.len; i++ ) {
- if( ( strlen( op.words[i] ) == 1 ) &&
- ( s[0] == op.words[i][0] ) ) {
+ for( i = 0; i < op.Length(); i++ ) {
+ if( ( strlen( op.WordAt(i) ) == 1 ) &&
+ ( s[0] == op.WordAt(i)[0] ) ) {
return 1;
}
}
diff --git a/scintilla/lexers/LexOthers.cxx b/scintilla/lexers/LexOthers.cxx index b0ccb54..b887c53 100644 --- a/scintilla/lexers/LexOthers.cxx +++ b/scintilla/lexers/LexOthers.cxx @@ -1047,10 +1047,10 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin }
} else if (state == stCtagsStart) {
if ((lineBuffer[i - 1] == '\t') &&
- ((ch == '/' && lineBuffer[i + 1] == '^') || Is0To9(ch))) {
+ ((ch == '/' && chNext == '^') || Is0To9(ch))) {
state = stCtags;
break;
- } else if ((ch == '/') && (lineBuffer[i + 1] == '^')) {
+ } else if ((ch == '/') && (chNext == '^')) {
state = stCtagsStartString;
}
} else if ((state == stCtagsStartString) && ((lineBuffer[i] == '$') && (lineBuffer[i + 1] == '/'))) {
diff --git a/scintilla/lexers/LexPowerShell.cxx b/scintilla/lexers/LexPowerShell.cxx index b33301a..5d6711d 100644 --- a/scintilla/lexers/LexPowerShell.cxx +++ b/scintilla/lexers/LexPowerShell.cxx @@ -40,6 +40,7 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt WordList &keywords3 = *keywordlists[2];
WordList &keywords4 = *keywordlists[3];
WordList &keywords5 = *keywordlists[4];
+ WordList &keywords6 = *keywordlists[5];
styler.StartAt(startPos);
@@ -52,9 +53,26 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt sc.SetState(SCE_POWERSHELL_DEFAULT);
}
} else if (sc.state == SCE_POWERSHELL_COMMENTSTREAM) {
+ if(sc.atLineStart) {
+ while(IsASpaceOrTab(sc.ch)) {
+ sc.Forward();
+ }
+ if (sc.ch == '.' && IsAWordChar(sc.chNext)) {
+ sc.SetState(SCE_POWERSHELL_COMMENTDOCKEYWORD);
+ }
+ }
if (sc.ch == '>' && sc.chPrev == '#') {
sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
}
+ } else if (sc.state == SCE_POWERSHELL_COMMENTDOCKEYWORD) {
+ if(!IsAWordChar(sc.ch)) {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (!keywords6.InList(s + 1)) {
+ sc.ChangeState(SCE_POWERSHELL_COMMENTSTREAM);
+ }
+ sc.SetState(SCE_POWERSHELL_COMMENTSTREAM);
+ }
} else if (sc.state == SCE_POWERSHELL_STRING) {
// This is a doubles quotes string
if (sc.ch == '\"') {
@@ -65,6 +83,18 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt if (sc.ch == '\'') {
sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
}
+ } else if (sc.state == SCE_POWERSHELL_HERE_STRING) {
+ // This is a doubles quotes here-string
+ if (sc.atLineStart && sc.ch == '\"' && sc.chNext == '@') {
+ sc.Forward(2);
+ sc.SetState(SCE_POWERSHELL_DEFAULT);
+ }
+ } else if (sc.state == SCE_POWERSHELL_HERE_CHARACTER) {
+ // This is a single quote here-string
+ if (sc.atLineStart && sc.ch == '\'' && sc.chNext == '@') {
+ sc.Forward(2);
+ sc.SetState(SCE_POWERSHELL_DEFAULT);
+ }
} else if (sc.state == SCE_POWERSHELL_NUMBER) {
if (!IsADigit(sc.ch)) {
sc.SetState(SCE_POWERSHELL_DEFAULT);
@@ -107,6 +137,10 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt sc.SetState(SCE_POWERSHELL_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_POWERSHELL_CHARACTER);
+ } else if (sc.ch == '@' && sc.chNext == '\"') {
+ sc.SetState(SCE_POWERSHELL_HERE_STRING);
+ } else if (sc.ch == '@' && sc.chNext == '\'') {
+ sc.SetState(SCE_POWERSHELL_HERE_CHARACTER);
} else if (sc.ch == '$') {
sc.SetState(SCE_POWERSHELL_VARIABLE);
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
@@ -159,11 +193,23 @@ static void FoldPowerShellDoc(unsigned int startPos, int length, int initStyle, levelNext--;
}
} else if (foldComment && style == SCE_POWERSHELL_COMMENTSTREAM) {
- if (stylePrev != SCE_POWERSHELL_COMMENTSTREAM) {
+ if (stylePrev != SCE_POWERSHELL_COMMENTSTREAM && stylePrev != SCE_POWERSHELL_COMMENTDOCKEYWORD) {
levelNext++;
- } else if (styleNext != SCE_POWERSHELL_COMMENTSTREAM) {
+ } else if (styleNext != SCE_POWERSHELL_COMMENTSTREAM && styleNext != SCE_POWERSHELL_COMMENTDOCKEYWORD) {
levelNext--;
}
+ } else if (foldComment && style == SCE_POWERSHELL_COMMENT) {
+ if (ch == '#') {
+ unsigned int j = i + 1;
+ while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
+ j++;
+ }
+ if (styler.Match(j, "region")) {
+ levelNext++;
+ } else if (styler.Match(j, "endregion")) {
+ levelNext--;
+ }
+ }
}
if (!IsASpace(ch))
visibleChars++;
@@ -194,6 +240,7 @@ static const char * const powershellWordLists[] = { "Aliases",
"Functions",
"User1",
+ "DocComment",
0
};
diff --git a/scintilla/lexlib/LexerModule.cxx b/scintilla/lexlib/LexerModule.cxx index 853039f..349a925 100644 --- a/scintilla/lexlib/LexerModule.cxx +++ b/scintilla/lexlib/LexerModule.cxx @@ -75,7 +75,7 @@ int LexerModule::GetNumWordLists() const { const char *LexerModule::GetWordListDescription(int index) const {
assert(index < GetNumWordLists());
- if (index >= GetNumWordLists()) {
+ if (!wordListDescriptions || (index >= GetNumWordLists())) {
return "";
} else {
return wordListDescriptions[index];
diff --git a/scintilla/lexlib/PropSetSimple.cxx b/scintilla/lexlib/PropSetSimple.cxx index f3eff19..ef341b8 100644 --- a/scintilla/lexlib/PropSetSimple.cxx +++ b/scintilla/lexlib/PropSetSimple.cxx @@ -141,30 +141,21 @@ static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, i return maxExpands;
}
-char *PropSetSimple::Expanded(const char *key) const {
+int PropSetSimple::GetExpanded(const char *key, char *result) const {
std::string val = Get(key);
ExpandAllInPlace(*this, val, 100, VarChain(key));
- char *ret = new char [val.size() + 1];
- strcpy(ret, val.c_str());
- return ret;
-}
-
-int PropSetSimple::GetExpanded(const char *key, char *result) const {
- char *val = Expanded(key);
- const int n = static_cast<int>(strlen(val));
+ const int n = static_cast<int>(val.size());
if (result) {
- strcpy(result, val);
+ strcpy(result, val.c_str());
}
- delete []val;
return n; // Not including NUL
}
int PropSetSimple::GetInt(const char *key, int defaultValue) const {
- char *val = Expanded(key);
- if (val) {
- int retVal = val[0] ? atoi(val) : defaultValue;
- delete []val;
- return retVal;
+ std::string val = Get(key);
+ ExpandAllInPlace(*this, val, 100, VarChain(key));
+ if (!val.empty()) {
+ return atoi(val.c_str());
}
return defaultValue;
}
diff --git a/scintilla/lexlib/PropSetSimple.h b/scintilla/lexlib/PropSetSimple.h index ca91b63..de94f7f 100644 --- a/scintilla/lexlib/PropSetSimple.h +++ b/scintilla/lexlib/PropSetSimple.h @@ -21,7 +21,6 @@ public: void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
void SetMultiple(const char *);
const char *Get(const char *key) const;
- char *Expanded(const char *key) const;
int GetExpanded(const char *key, char *result) const;
int GetInt(const char *key, int defaultValue=0) const;
};
diff --git a/scintilla/lexlib/StyleContext.h b/scintilla/lexlib/StyleContext.h index c3194ae..1799793 100644 --- a/scintilla/lexlib/StyleContext.h +++ b/scintilla/lexlib/StyleContext.h @@ -76,7 +76,7 @@ class StyleContext { // End of line?
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win)
// or on LF alone (Unix). Avoid triggering two times on Dos/Win.
- if (lineStartNext < styler.Length())
+ if (currentLine < lineDocEnd)
atLineEnd = static_cast<int>(pos) >= (lineStartNext-1);
else // Last line
atLineEnd = static_cast<int>(pos) >= lineStartNext;
@@ -85,6 +85,7 @@ class StyleContext { public:
unsigned int currentPos;
int currentLine;
+ int lineDocEnd;
int lineStartNext;
bool atLineStart;
bool atLineEnd;
@@ -112,6 +113,7 @@ public: lengthDocument = static_cast<unsigned int>(styler.Length());
if (endPos == lengthDocument)
endPos++;
+ lineDocEnd = styler.GetLine(lengthDocument);
atLineStart = static_cast<unsigned int>(styler.LineStart(currentLine)) == startPos;
unsigned int pos = currentPos;
ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos, 0));
diff --git a/scintilla/lexlib/WordList.cxx b/scintilla/lexlib/WordList.cxx index 1d6cf56..62b0a14 100644 --- a/scintilla/lexlib/WordList.cxx +++ b/scintilla/lexlib/WordList.cxx @@ -45,29 +45,37 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa prev = curr;
}
char **keywords = new char *[words + 1];
- if (keywords) {
- words = 0;
- prev = '\0';
- size_t slen = strlen(wordlist);
- for (size_t k = 0; k < slen; k++) {
- if (!wordSeparator[static_cast<unsigned char>(wordlist[k])]) {
- if (!prev) {
- keywords[words] = &wordlist[k];
- words++;
- }
- } else {
- wordlist[k] = '\0';
+ words = 0;
+ prev = '\0';
+ size_t slen = strlen(wordlist);
+ for (size_t k = 0; k < slen; k++) {
+ if (!wordSeparator[static_cast<unsigned char>(wordlist[k])]) {
+ if (!prev) {
+ keywords[words] = &wordlist[k];
+ words++;
}
- prev = wordlist[k];
+ } else {
+ wordlist[k] = '\0';
}
- keywords[words] = &wordlist[slen];
- *len = words;
- } else {
- *len = 0;
+ prev = wordlist[k];
}
+ keywords[words] = &wordlist[slen];
+ *len = words;
return keywords;
}
+WordList::WordList(bool onlyLineEnds_) :
+ words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_) {
+}
+
+WordList::~WordList() {
+ Clear();
+}
+
+WordList::operator bool() const {
+ return len ? true : false;
+}
+
bool WordList::operator!=(const WordList &other) const {
if (len != other.len)
return true;
@@ -78,6 +86,10 @@ bool WordList::operator!=(const WordList &other) const { return false;
}
+int WordList::Length() const {
+ return len;
+}
+
void WordList::Clear() {
if (words) {
delete []list;
@@ -217,3 +229,8 @@ bool WordList::InListAbbreviated(const char *s, const char marker) const { }
return false;
}
+
+const char *WordList::WordAt(int n) const {
+ return words[n];
+}
+
diff --git a/scintilla/lexlib/WordList.h b/scintilla/lexlib/WordList.h index 4ce0246..964d1fd 100644 --- a/scintilla/lexlib/WordList.h +++ b/scintilla/lexlib/WordList.h @@ -15,23 +15,23 @@ namespace Scintilla { /**
*/
class WordList {
-public:
// Each word contains at least one character - a empty word acts as sentinel at the end.
char **words;
char *list;
int len;
bool onlyLineEnds; ///< Delimited by any white space or only line ends
int starts[256];
- WordList(bool onlyLineEnds_ = false) :
- words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_)
- {}
- ~WordList() { Clear(); }
- operator bool() const { return len ? true : false; }
+public:
+ WordList(bool onlyLineEnds_ = false);
+ ~WordList();
+ operator bool() const;
bool operator!=(const WordList &other) const;
+ int Length() const;
void Clear();
void Set(const char *s);
bool InList(const char *s) const;
bool InListAbbreviated(const char *s, const char marker) const;
+ const char *WordAt(int n) const;
};
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/CallTip.cxx b/scintilla/src/CallTip.cxx index d574a6d..d285a83 100644 --- a/scintilla/src/CallTip.cxx +++ b/scintilla/src/CallTip.cxx @@ -7,12 +7,14 @@ #include <stdlib.h>
#include <string.h>
+#include <stdio.h>
+
+#include <string>
#include "Platform.h"
#include "Scintilla.h"
#include "CallTip.h"
-#include <stdio.h>
#ifdef SCI_NAMESPACE
using namespace Scintilla;
@@ -22,7 +24,6 @@ CallTip::CallTip() { wCallTip = 0;
inCallTipMode = false;
posStartCallTip = 0;
- val = 0;
rectUp = PRectangle(0,0,0,0);
rectDown = PRectangle(0,0,0,0);
lineHeight = 1;
@@ -56,8 +57,6 @@ CallTip::CallTip() { CallTip::~CallTip() {
font.Release();
wCallTip.Destroy();
- delete []val;
- val = 0;
}
// Although this test includes 0, we should never see a \0 character.
@@ -176,17 +175,17 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { // Draw the definition in three parts: before highlight, highlighted, after highlight
int ytext = rcClient.top + ascent + 1;
rcClient.bottom = ytext + surfaceWindow->Descent(font) + 1;
- char *chunkVal = val;
+ const char *chunkVal = val.c_str();
bool moreChunks = true;
int maxWidth = 0;
while (moreChunks) {
- char *chunkEnd = strchr(chunkVal, '\n');
+ const char *chunkEnd = strchr(chunkVal, '\n');
if (chunkEnd == NULL) {
chunkEnd = chunkVal + strlen(chunkVal);
moreChunks = false;
}
- int chunkOffset = chunkVal - val;
+ int chunkOffset = chunkVal - val.c_str();
int chunkLength = chunkEnd - chunkVal;
int chunkEndOffset = chunkOffset + chunkLength;
int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset);
@@ -215,7 +214,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { }
void CallTip::PaintCT(Surface *surfaceWindow) {
- if (!val)
+ if (val.empty())
return;
PRectangle rcClientPos = wCallTip.GetClientPosition();
PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left,
@@ -253,10 +252,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char * int codePage_, int characterSet,
int technology, Window &wParent) {
clickPlace = 0;
- delete []val;
- val = 0;
- val = new char[strlen(defn) + 1];
- strcpy(val, defn);
+ val = defn;
codePage = codePage_;
Surface *surfaceMeasure = Surface::Allocate(technology);
if (!surfaceMeasure)
@@ -275,7 +271,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char * // Only support \n here - simply means container must avoid \r!
int numLines = 1;
const char *newline;
- const char *look = val;
+ const char *look = val.c_str();
rectUp = PRectangle(0,0,0,0);
rectDown = PRectangle(0,0,0,0);
offsetMain = insetX; // changed to right edge of any arrows
diff --git a/scintilla/src/CallTip.h b/scintilla/src/CallTip.h index 85b837f..fca69d1 100644 --- a/scintilla/src/CallTip.h +++ b/scintilla/src/CallTip.h @@ -17,7 +17,7 @@ namespace Scintilla { class CallTip {
int startHighlight; // character offset to start and...
int endHighlight; // ...end of highlighted text
- char *val;
+ std::string val;
Font font;
PRectangle rectUp; // rectangle of last up angle in the tip
PRectangle rectDown; // rectangle of last down arrow in the tip
diff --git a/scintilla/src/CellBuffer.cxx b/scintilla/src/CellBuffer.cxx index 7c1b42c..95e2a80 100644 --- a/scintilla/src/CellBuffer.cxx +++ b/scintilla/src/CellBuffer.cxx @@ -10,6 +10,8 @@ #include <stdlib.h>
#include <stdarg.h>
+#include <algorithm>
+
#include "Platform.h"
#include "Scintilla.h"
@@ -81,11 +83,15 @@ Action::~Action() { Destroy();
}
-void Action::Create(actionType at_, int position_, char *data_, int lenData_, bool mayCoalesce_) {
+void Action::Create(actionType at_, int position_, const char *data_, int lenData_, bool mayCoalesce_) {
delete []data;
+ data = NULL;
position = position_;
at = at_;
- data = data_;
+ if (lenData_) {
+ data = new char[lenData_];
+ memcpy(data, data_, lenData_);
+ }
lenData = lenData_;
mayCoalesce = mayCoalesce_;
}
@@ -162,7 +168,7 @@ void UndoHistory::EnsureUndoRoom() { }
}
-void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData,
+void UndoHistory::AppendAction(actionType at, int position, const char *data, int lengthData,
bool &startSequence, bool mayCoalesce) {
EnsureUndoRoom();
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
@@ -393,11 +399,7 @@ const char *CellBuffer::InsertString(int position, const char *s, int insertLeng if (collectingUndo) {
// Save into the undo/redo stack, but only the characters - not the formatting
// This takes up about half load time
- data = new char[insertLength];
- for (int i = 0; i < insertLength; i++) {
- data[i] = s[i];
- }
- uh.AppendAction(insertAction, position, data, insertLength, startSequence);
+ uh.AppendAction(insertAction, position, s, insertLength, startSequence);
}
BasicInsertString(position, s, insertLength);
@@ -439,10 +441,8 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startS if (!readOnly) {
if (collectingUndo) {
// Save into the undo/redo stack, but only the characters - not the formatting
- data = new char[deleteLength];
- for (int i = 0; i < deleteLength; i++) {
- data[i] = substance.ValueAt(position + i);
- }
+ // The gap would be moved to position anyway for the deletion so this doesn't cost extra
+ const char *data = substance.RangePointer(position, deleteLength);
uh.AppendAction(removeAction, position, data, deleteLength, startSequence);
}
diff --git a/scintilla/src/CellBuffer.h b/scintilla/src/CellBuffer.h index 86b94cb..394b89a 100644 --- a/scintilla/src/CellBuffer.h +++ b/scintilla/src/CellBuffer.h @@ -80,7 +80,7 @@ public: Action();
~Action();
- void Create(actionType at_, int position_=0, char *data_=0, int lenData_=0, bool mayCoalesce_=true);
+ void Create(actionType at_, int position_=0, const char *data_=0, int lenData_=0, bool mayCoalesce_=true);
void Destroy();
void Grab(Action *source);
};
@@ -105,7 +105,7 @@ public: UndoHistory();
~UndoHistory();
- void AppendAction(actionType at, int position, char *data, int length, bool &startSequence, bool mayCoalesce=true);
+ void AppendAction(actionType at, int position, const char *data, int length, bool &startSequence, bool mayCoalesce=true);
void BeginUndoAction();
void EndUndoAction();
diff --git a/scintilla/src/ContractionState.cxx b/scintilla/src/ContractionState.cxx index 938e16f..ac8939e 100644 --- a/scintilla/src/ContractionState.cxx +++ b/scintilla/src/ContractionState.cxx @@ -7,6 +7,8 @@ #include <string.h>
+#include <algorithm>
+
#include "Platform.h"
#include "SplitVector.h"
diff --git a/scintilla/src/Decoration.cxx b/scintilla/src/Decoration.cxx index 4ed0b46..1ad03e4 100644 --- a/scintilla/src/Decoration.cxx +++ b/scintilla/src/Decoration.cxx @@ -9,6 +9,8 @@ #include <stdlib.h>
#include <stdarg.h>
+#include <algorithm>
+
#include "Platform.h"
#include "Scintilla.h"
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index 38b931c..33a7c79 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -13,6 +13,7 @@ #include <string>
#include <vector>
+#include <algorithm>
#include "Platform.h"
@@ -102,8 +103,6 @@ Document::Document() { useTabs = true;
tabIndents = true;
backspaceUnindents = false;
- watchers = 0;
- lenWatchers = 0;
matchesValid = false;
regex = 0;
@@ -122,16 +121,13 @@ Document::Document() { }
Document::~Document() {
- for (int i = 0; i < lenWatchers; i++) {
- watchers[i].watcher->NotifyDeleted(this, watchers[i].userData);
+ for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) {
+ it->watcher->NotifyDeleted(this, it->userData);
}
- delete []watchers;
for (int j=0; j<ldSize; j++) {
delete perLineData[j];
perLineData[j] = 0;
}
- watchers = 0;
- lenWatchers = 0;
delete regex;
regex = 0;
delete pli;
@@ -309,9 +305,9 @@ int SCI_METHOD Document::LineEnd(int line) const { }
void SCI_METHOD Document::SetErrorStatus(int status) {
- // Tell the watchers the lexer has changed.
- for (int i = 0; i < lenWatchers; i++) {
- watchers[i].watcher->NotifyErrorOccurred(this, watchers[i].userData, status);
+ // Tell the watchers an error has occurred.
+ for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) {
+ it->watcher->NotifyErrorOccurred(this, it->userData, status);
}
}
@@ -420,7 +416,7 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in int lookLine = line;
int lookLineLevel = level;
int lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
- while ((lookLine > 0) && ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) ||
+ while ((lookLine > 0) && ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) ||
((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum >= (GetLevel(lookLine + 1) & SC_FOLDLEVELNUMBERMASK))))) {
lookLineLevel = GetLevel(--lookLine);
lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
@@ -453,8 +449,8 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in }
}
if (firstChangeableLineBefore == -1) {
- for (lookLine = line - 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
- lookLine >= beginFoldBlock;
+ for (lookLine = line - 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
+ lookLine >= beginFoldBlock;
lookLineLevel = GetLevel(--lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK) {
if ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) || (lookLineLevelNum > (level & SC_FOLDLEVELNUMBERMASK))) {
firstChangeableLineBefore = lookLine;
@@ -466,8 +462,8 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in firstChangeableLineBefore = beginFoldBlock - 1;
int firstChangeableLineAfter = -1;
- for (lookLine = line + 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
- lookLine <= endFoldBlock;
+ for (lookLine = line + 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK;
+ lookLine <= endFoldBlock;
lookLineLevel = GetLevel(++lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK) {
if ((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum < (GetLevel(lookLine + 1) & SC_FOLDLEVELNUMBERMASK))) {
firstChangeableLineAfter = lookLine;
@@ -715,7 +711,7 @@ bool SCI_METHOD Document::IsDBCSLeadByte(char ch) const { // Shift_jis
return ((uch >= 0x81) && (uch <= 0x9F)) ||
((uch >= 0xE0) && (uch <= 0xFC));
- // Lead bytes F0 to FC may be a Microsoft addition.
+ // Lead bytes F0 to FC may be a Microsoft addition.
case 936:
// GBK
return (uch >= 0x81) && (uch <= 0xFE);
@@ -892,7 +888,7 @@ void * SCI_METHOD Document::ConvertToDocument() { int Document::Undo() {
int newPos = -1;
CheckReadOnly();
- if (enteredModification == 0) {
+ if ((enteredModification == 0) && (cb.IsCollectingUndo())) {
enteredModification++;
if (!cb.IsReadOnly()) {
bool startSavePoint = cb.IsSavePoint();
@@ -977,7 +973,7 @@ int Document::Undo() { int Document::Redo() {
int newPos = -1;
CheckReadOnly();
- if (enteredModification == 0) {
+ if ((enteredModification == 0) && (cb.IsCollectingUndo())) {
enteredModification++;
if (!cb.IsReadOnly()) {
bool startSavePoint = cb.IsSavePoint();
@@ -1050,11 +1046,6 @@ bool Document::InsertCString(int position, const char *s) { return InsertString(position, s, static_cast<int>(s ? strlen(s) : 0));
}
-void Document::ChangeChar(int pos, char ch) {
- DeleteChars(pos, 1);
- InsertChar(pos, ch);
-}
-
void Document::DelChar(int pos) {
DeleteChars(pos, LenChar(pos));
}
@@ -1212,32 +1203,25 @@ void Document::Indent(bool forwards, int lineBottom, int lineTop) { // Convert line endings for a piece of text to a particular mode.
// Stop at len or when a NUL is found.
-// Caller must delete the returned pointer.
-char *Document::TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolModeWanted) {
- char *dest = new char[2 * len + 1];
- const char *sptr = s;
- char *dptr = dest;
- for (size_t i = 0; (i < len) && (*sptr != '\0'); i++) {
- if (*sptr == '\n' || *sptr == '\r') {
+std::string Document::TransformLineEnds(const char *s, size_t len, int eolModeWanted) {
+ std::string dest;
+ for (size_t i = 0; (i < len) && (s[i]); i++) {
+ if (s[i] == '\n' || s[i] == '\r') {
if (eolModeWanted == SC_EOL_CR) {
- *dptr++ = '\r';
+ dest.push_back('\r');
} else if (eolModeWanted == SC_EOL_LF) {
- *dptr++ = '\n';
+ dest.push_back('\n');
} else { // eolModeWanted == SC_EOL_CRLF
- *dptr++ = '\r';
- *dptr++ = '\n';
+ dest.push_back('\r');
+ dest.push_back('\n');
}
- if ((*sptr == '\r') && (i+1 < len) && (*(sptr+1) == '\n')) {
+ if ((s[i] == '\r') && (i+1 < len) && (s[i+1] == '\n')) {
i++;
- sptr++;
}
- sptr++;
} else {
- *dptr++ = *sptr++;
+ dest.push_back(s[i]);
}
}
- *dptr++ = '\0';
- *pLenOut = (dptr - dest) - 1;
return dest;
}
@@ -1667,25 +1651,6 @@ int Document::LinesTotal() const { return cb.Lines();
}
-void Document::ChangeCase(Range r, bool makeUpperCase) {
- for (int pos = r.start; pos < r.end;) {
- int len = LenChar(pos);
- if (len == 1) {
- char ch = CharAt(pos);
- if (makeUpperCase) {
- if (IsLowerCase(ch)) {
- ChangeChar(pos, static_cast<char>(MakeUpperCase(ch)));
- }
- } else {
- if (IsUpperCase(ch)) {
- ChangeChar(pos, static_cast<char>(MakeLowerCase(ch)));
- }
- }
- }
- pos += len;
- }
-}
-
void Document::SetDefaultCharClasses(bool includeWordClass) {
charClass.SetDefaultCharClasses(includeWordClass);
}
@@ -1763,8 +1728,9 @@ void Document::EnsureStyledTo(int pos) { pli->Colourise(endStyledTo, pos);
} else {
// Ask the watchers to style, and stop as soon as one responds.
- for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++) {
- watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
+ for (std::vector<WatcherWithUserData>::iterator it = watchers.begin();
+ (pos > GetEndStyled()) && (it != watchers.end()); ++it) {
+ it->watcher->NotifyStyleNeeded(this, it->userData, pos);
}
}
}
@@ -1772,8 +1738,8 @@ void Document::EnsureStyledTo(int pos) { void Document::LexerChanged() {
// Tell the watchers the lexer has changed.
- for (int i = 0; i < lenWatchers; i++) {
- watchers[i].watcher->NotifyLexerChanged(this, watchers[i].userData);
+ for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) {
+ it->watcher->NotifyLexerChanged(this, it->userData);
}
}
@@ -1821,10 +1787,6 @@ void Document::MarginSetStyles(int line, const unsigned char *styles) { NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line));
}
-int Document::MarginLength(int line) const {
- return static_cast<LineAnnotation *>(perLineData[ldMargin])->Length(line);
-}
-
void Document::MarginClearAll() {
int maxEditorLine = LinesTotal();
for (int l=0; l<maxEditorLine; l++)
@@ -1833,10 +1795,6 @@ void Document::MarginClearAll() { static_cast<LineAnnotation *>(perLineData[ldMargin])->ClearAll();
}
-bool Document::AnnotationAny() const {
- return static_cast<LineAnnotation *>(perLineData[ldAnnotation])->AnySet();
-}
-
StyledText Document::AnnotationStyledText(int line) {
LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldAnnotation]);
return StyledText(pla->Length(line), pla->Text(line),
@@ -1866,10 +1824,6 @@ void Document::AnnotationSetStyles(int line, const unsigned char *styles) { }
}
-int Document::AnnotationLength(int line) const {
- return static_cast<LineAnnotation *>(perLineData[ldAnnotation])->Length(line);
-}
-
int Document::AnnotationLines(int line) const {
return static_cast<LineAnnotation *>(perLineData[ldAnnotation])->Lines(line);
}
@@ -1895,54 +1849,34 @@ void SCI_METHOD Document::DecorationFillRange(int position, int value, int fillL }
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
- for (int i = 0; i < lenWatchers; i++) {
- if ((watchers[i].watcher == watcher) &&
- (watchers[i].userData == userData))
- return false;
- }
- WatcherWithUserData *pwNew = new WatcherWithUserData[lenWatchers + 1];
- for (int j = 0; j < lenWatchers; j++)
- pwNew[j] = watchers[j];
- pwNew[lenWatchers].watcher = watcher;
- pwNew[lenWatchers].userData = userData;
- delete []watchers;
- watchers = pwNew;
- lenWatchers++;
+ WatcherWithUserData wwud(watcher, userData);
+ std::vector<WatcherWithUserData>::iterator it =
+ std::find(watchers.begin(), watchers.end(), wwud);
+ if (it != watchers.end())
+ return false;
+ watchers.push_back(wwud);
return true;
}
bool Document::RemoveWatcher(DocWatcher *watcher, void *userData) {
- for (int i = 0; i < lenWatchers; i++) {
- if ((watchers[i].watcher == watcher) &&
- (watchers[i].userData == userData)) {
- if (lenWatchers == 1) {
- delete []watchers;
- watchers = 0;
- lenWatchers = 0;
- } else {
- WatcherWithUserData *pwNew = new WatcherWithUserData[lenWatchers];
- for (int j = 0; j < lenWatchers - 1; j++) {
- pwNew[j] = (j < i) ? watchers[j] : watchers[j + 1];
- }
- delete []watchers;
- watchers = pwNew;
- lenWatchers--;
- }
- return true;
- }
+ std::vector<WatcherWithUserData>::iterator it =
+ std::find(watchers.begin(), watchers.end(), WatcherWithUserData(watcher, userData));
+ if (it != watchers.end()) {
+ watchers.erase(it);
+ return true;
}
return false;
}
void Document::NotifyModifyAttempt() {
- for (int i = 0; i < lenWatchers; i++) {
- watchers[i].watcher->NotifyModifyAttempt(this, watchers[i].userData);
+ for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) {
+ it->watcher->NotifyModifyAttempt(this, it->userData);
}
}
void Document::NotifySavePoint(bool atSavePoint) {
- for (int i = 0; i < lenWatchers; i++) {
- watchers[i].watcher->NotifySavePoint(this, watchers[i].userData, atSavePoint);
+ for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) {
+ it->watcher->NotifySavePoint(this, it->userData, atSavePoint);
}
}
@@ -1952,8 +1886,8 @@ void Document::NotifyModified(DocModification mh) { } else if (mh.modificationType & SC_MOD_DELETETEXT) {
decorations.DeleteRange(mh.position, mh.length);
}
- for (int i = 0; i < lenWatchers; i++) {
- watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData);
+ for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) {
+ it->watcher->NotifyModified(this, mh, it->userData);
}
}
@@ -2127,10 +2061,9 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { */
class BuiltinRegex : public RegexSearchBase {
public:
- BuiltinRegex(CharClassify *charClassTable) : search(charClassTable), substituted(NULL) {}
+ BuiltinRegex(CharClassify *charClassTable) : search(charClassTable) {}
virtual ~BuiltinRegex() {
- delete substituted;
}
virtual long FindText(Document *doc, int minPos, int maxPos, const char *s,
@@ -2141,7 +2074,7 @@ public: private:
RESearch search;
- char *substituted;
+ std::string substituted;
};
// Define a way for the Regular Expression code to access the document
@@ -2236,6 +2169,8 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s int success = search.Execute(di, startOfLine, endOfLine);
if (success) {
pos = search.bopat[0];
+ // Ensure only whole characters selected
+ search.eopat[0] = doc->MovePositionOutsideChar(search.eopat[0], 1, false);
lenRet = search.eopat[0] - search.bopat[0];
// There can be only one start of a line, so no need to look for last match in line
if ((increment == -1) && (s[0] != '^')) {
@@ -2261,86 +2196,55 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s }
const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, int *length) {
- delete []substituted;
- substituted = 0;
+ substituted.clear();
DocumentIndexer di(doc, doc->Length());
- if (!search.GrabMatches(di))
- return 0;
- unsigned int lenResult = 0;
- for (int i = 0; i < *length; i++) {
- if (text[i] == '\\') {
- if (text[i + 1] >= '0' && text[i + 1] <= '9') {
- unsigned int patNum = text[i + 1] - '0';
- lenResult += search.eopat[patNum] - search.bopat[patNum];
- i++;
- } else {
- switch (text[i + 1]) {
- case 'a':
- case 'b':
- case 'f':
- case 'n':
- case 'r':
- case 't':
- case 'v':
- case '\\':
- i++;
- }
- lenResult++;
- }
- } else {
- lenResult++;
- }
- }
- substituted = new char[lenResult + 1];
- char *o = substituted;
+ search.GrabMatches(di);
for (int j = 0; j < *length; j++) {
if (text[j] == '\\') {
if (text[j + 1] >= '0' && text[j + 1] <= '9') {
unsigned int patNum = text[j + 1] - '0';
unsigned int len = search.eopat[patNum] - search.bopat[patNum];
- if (search.pat[patNum]) // Will be null if try for a match that did not occur
- memcpy(o, search.pat[patNum], len);
- o += len;
+ if (!search.pat[patNum].empty()) // Will be null if try for a match that did not occur
+ substituted.append(search.pat[patNum].c_str(), len);
j++;
} else {
j++;
switch (text[j]) {
case 'a':
- *o++ = '\a';
+ substituted.push_back('\a');
break;
case 'b':
- *o++ = '\b';
+ substituted.push_back('\b');
break;
case 'f':
- *o++ = '\f';
+ substituted.push_back('\f');
break;
case 'n':
- *o++ = '\n';
+ substituted.push_back('\n');
break;
case 'r':
- *o++ = '\r';
+ substituted.push_back('\r');
break;
case 't':
- *o++ = '\t';
+ substituted.push_back('\t');
break;
case 'v':
- *o++ = '\v';
+ substituted.push_back('\v');
break;
case '\\':
- *o++ = '\\';
+ substituted.push_back('\\');
break;
default:
- *o++ = '\\';
+ substituted.push_back('\\');
j--;
}
}
} else {
- *o++ = text[j];
+ substituted.push_back(text[j]);
}
}
- *o = '\0';
- *length = lenResult;
- return substituted;
+ *length = static_cast<int>(substituted.length());
+ return substituted.c_str();
}
#ifndef SCI_OWNREGEX
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h index 1c6a02a..00cd1e6 100644 --- a/scintilla/src/Document.h +++ b/scintilla/src/Document.h @@ -198,17 +198,17 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader { public:
/** Used to pair watcher pointer with user data. */
- class WatcherWithUserData {
- public:
+ struct WatcherWithUserData {
DocWatcher *watcher;
void *userData;
- WatcherWithUserData() {
- watcher = 0;
- userData = 0;
+ WatcherWithUserData(DocWatcher *watcher_=0, void *userData_=0) :
+ watcher(watcher_), userData(userData_) {
+ }
+ bool operator==(const WatcherWithUserData &other) {
+ return (watcher == other.watcher) && (userData == other.userData);
}
};
- enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
private:
int refCount;
CellBuffer cb;
@@ -221,8 +221,7 @@ private: int enteredStyling;
int enteredReadOnlyCount;
- WatcherWithUserData *watchers;
- int lenWatchers;
+ std::vector<WatcherWithUserData> watchers;
// ldSize is not real data - it is for dimensions and loops
enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize };
@@ -316,14 +315,13 @@ public: int CountCharacters(int startPos, int endPos);
int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop);
- static char *TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolModeWanted);
+ static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);
void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
bool IsReadOnly() { return cb.IsReadOnly(); }
bool InsertChar(int pos, char ch);
bool InsertCString(int position, const char *s);
- void ChangeChar(int pos, char ch);
void DelChar(int pos);
void DelCharBack(int pos);
@@ -371,8 +369,6 @@ public: const char *SubstituteByPosition(const char *text, int *length);
int LinesTotal() const;
- void ChangeCase(Range r, bool makeUpperCase);
-
void SetDefaultCharClasses(bool includeWordClass);
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
int GetCharsOfClass(CharClassify::cc charClass, unsigned char *buffer);
@@ -399,22 +395,17 @@ public: void MarginSetStyle(int line, int style);
void MarginSetStyles(int line, const unsigned char *styles);
void MarginSetText(int line, const char *text);
- int MarginLength(int line) const;
void MarginClearAll();
- bool AnnotationAny() const;
StyledText AnnotationStyledText(int line);
void AnnotationSetText(int line, const char *text);
void AnnotationSetStyle(int line, int style);
void AnnotationSetStyles(int line, const unsigned char *styles);
- int AnnotationLength(int line) const;
int AnnotationLines(int line) const;
void AnnotationClearAll();
bool AddWatcher(DocWatcher *watcher, void *userData);
bool RemoveWatcher(DocWatcher *watcher, void *userData);
- const WatcherWithUserData *GetWatchers() const { return watchers; }
- int GetLenWatchers() const { return lenWatchers; }
CharClassify::cc WordCharClass(unsigned char ch);
bool IsWordPartSeparator(char ch);
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index ff05228..2f5cb46 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -106,7 +106,7 @@ Editor::Editor() { stylesValid = false;
technology = SC_TECHNOLOGY_DEFAULT;
scaleRGBAImage = 100;
-
+
printMagnification = 0;
printColourMode = SC_PRINT_NORMAL;
printWrapState = eWrapWord;
@@ -149,7 +149,7 @@ Editor::Editor() { caretYPolicy = CARET_EVEN;
caretYSlop = 0;
-
+
visiblePolicy = 0;
visibleSlop = 0;
@@ -208,6 +208,7 @@ Editor::Editor() { recordingMacro = false;
foldFlags = 0;
+ foldAutomatic = 0;
wrapState = eWrapNone;
wrapWidth = LineLayout::wrapWidthInfinite;
@@ -1246,6 +1247,9 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange rang const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1);
XYScrollPosition newXY(xOffset, topLine);
+ if (rcClient.Empty()) {
+ return newXY;
+ }
// Vertical positioning
if ((options & xysVertical) && (pt.y < rcClient.top || ptBottomCaret.y >= rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) {
@@ -1764,7 +1768,7 @@ static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset, size_t endSegment = start;
while ((endSegment+1 < len) && (static_cast<size_t>(styles[endSegment+1]) == style))
endSegment++;
- width += surface->WidthText(vs.styles[style+styleOffset].font, text + start,
+ width += surface->WidthText(vs.styles[style+styleOffset].font, text + start,
static_cast<int>(endSegment - start + 1));
start = endSegment + 1;
}
@@ -2286,7 +2290,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou if (vstyle.styles[ll->styles[charInLine]].visible) {
if (isControl) {
if (ll->chars[charInLine] == '\t') {
- ll->positions[charInLine + 1] =
+ ll->positions[charInLine + 1] =
((static_cast<int>((startsegx + 2) / tabWidth) + 1) * tabWidth) - startsegx;
} else if (controlCharSymbol < 32) {
if (ctrlCharWidth[ll->chars[charInLine]] == 0) {
@@ -3850,7 +3854,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { vsPrint.braceBadLightIndicatorSet = false;
// Set colours for printing according to users settings
- for (size_t sty = 0; sty < vsPrint.stylesSize; sty++) {
+ for (size_t sty = 0; sty < vsPrint.styles.size(); sty++) {
if (printColourMode == SC_PRINT_INVERTLIGHT) {
vsPrint.styles[sty].fore = InvertedLight(vsPrint.styles[sty].fore);
vsPrint.styles[sty].back = InvertedLight(vsPrint.styles[sty].back);
@@ -4443,7 +4447,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) { void Editor::NotifyFocus(bool) {}
void Editor::SetCtrlID(int identifier) {
- ctrlID = identifier;
+ ctrlID = identifier;
}
void Editor::NotifyStyleToNeeded(int endStyleNeeded) {
@@ -4563,11 +4567,32 @@ bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { x += vs.ms[margin].width;
}
if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) {
+ int position = pdoc->LineStart(LineFromLocation(pt));
+ if ((vs.ms[marginClicked].mask & SC_MASK_FOLDERS) && (foldAutomatic & SC_AUTOMATICFOLD_CLICK)) {
+ int lineClick = pdoc->LineFromPosition(position);
+ if (shift && ctrl) {
+ FoldAll(SC_FOLDACTION_TOGGLE);
+ } else {
+ int levelClick = pdoc->GetLevel(lineClick);
+ if (levelClick & SC_FOLDLEVELHEADERFLAG) {
+ if (shift) {
+ // Ensure all children visible
+ FoldExpand(lineClick, SC_FOLDACTION_EXPAND, levelClick);
+ } else if (ctrl) {
+ FoldExpand(lineClick, SC_FOLDACTION_TOGGLE, levelClick);
+ } else {
+ // Toggle this line
+ FoldLine(lineClick, SC_FOLDACTION_TOGGLE);
+ }
+ }
+ }
+ return true;
+ }
SCNotification scn = {0};
scn.nmhdr.code = SCN_MARGINCLICK;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
(alt ? SCI_ALT : 0);
- scn.position = pdoc->LineStart(LineFromLocation(pt));
+ scn.position = position;
scn.margin = marginClicked;
NotifyParent(scn);
return true;
@@ -4706,11 +4731,11 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { insertingNewLine = true;
}
if (insertingNewLine && (mh.position != pdoc->LineStart(lineOfPos)))
- NotifyNeedShown(mh.position, pdoc->LineStart(lineOfPos+1) - mh.position);
+ NeedShown(mh.position, pdoc->LineStart(lineOfPos+1) - mh.position);
else
- NotifyNeedShown(mh.position, 0);
+ NeedShown(mh.position, 0);
} else if (mh.modificationType & SC_MOD_BEFOREDELETE) {
- NotifyNeedShown(mh.position, mh.length);
+ NeedShown(mh.position, mh.length);
}
}
if (mh.linesAdded != 0) {
@@ -4767,6 +4792,9 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { }
}
}
+ if ((mh.modificationType & SC_MOD_CHANGEFOLD) && (foldAutomatic & SC_AUTOMATICFOLD_CHANGE)) {
+ FoldChanged(mh.line, mh.foldLevelNow, mh.foldLevelPrev);
+ }
// NOW pay the piper WRT "deferred" visual updates
if (IsLastStep(mh)) {
@@ -4989,10 +5017,9 @@ void Editor::ChangeCaseOfSelection(int caseMapping) { SelectionRange current = sel.Range(r);
SelectionRange currentNoVS = current;
currentNoVS.ClearVirtualSpace();
- char *text = CopyRange(currentNoVS.Start().Position(), currentNoVS.End().Position());
size_t rangeBytes = currentNoVS.Length();
if (rangeBytes > 0) {
- std::string sText(text, rangeBytes);
+ std::string sText = RangeText(currentNoVS.Start().Position(), currentNoVS.End().Position());
std::string sMapped = CaseMapString(sText, caseMapping);
@@ -5015,7 +5042,6 @@ void Editor::ChangeCaseOfSelection(int caseMapping) { sel.Range(r) = current;
}
}
- delete []text;
}
}
@@ -5027,17 +5053,15 @@ void Editor::LineTranspose() { int endPrev = pdoc->LineEnd(line - 1);
int start = pdoc->LineStart(line);
int end = pdoc->LineEnd(line);
- char *line1 = CopyRange(startPrev, endPrev);
+ std::string line1 = RangeText(startPrev, endPrev);
int len1 = endPrev - startPrev;
- char *line2 = CopyRange(start, end);
+ std::string line2 = RangeText(start, end);
int len2 = end - start;
pdoc->DeleteChars(start, len2);
pdoc->DeleteChars(startPrev, len1);
- pdoc->InsertString(startPrev, line2, len2);
- pdoc->InsertString(start - len1 + len2, line1, len1);
+ pdoc->InsertString(startPrev, line2.c_str(), len2);
+ pdoc->InsertString(start - len1 + len2, line1.c_str(), len1);
MovePositionTo(SelectionPosition(start - len1 + len2));
- delete []line1;
- delete []line2;
}
}
@@ -5060,11 +5084,10 @@ void Editor::Duplicate(bool forLine) { start = SelectionPosition(pdoc->LineStart(line));
end = SelectionPosition(pdoc->LineEnd(line));
}
- char *text = CopyRange(start.Position(), end.Position());
+ std::string text = RangeText(start.Position(), end.Position());
if (forLine)
pdoc->InsertString(end.Position(), eol, eolLen);
- pdoc->InsertString(end.Position() + eolLen, text, SelectionRange(end, start).Length());
- delete []text;
+ pdoc->InsertString(end.Position() + eolLen, text.c_str(), SelectionRange(end, start).Length());
}
if (sel.Count() && sel.IsRectangular()) {
SelectionPosition last = sel.Last();
@@ -5992,19 +6015,6 @@ static bool Close(Point pt1, Point pt2) { return true;
}
-char *Editor::CopyRange(int start, int end) {
- char *text = 0;
- if (start < end) {
- int len = end - start;
- text = new char[len + 1];
- for (int i = 0; i < len; i++) {
- text[i] = pdoc->CharAt(start + i);
- }
- text[len] = '\0';
- }
- return text;
-}
-
std::string Editor::RangeText(int start, int end) const {
if (start < end) {
int len = end - start;
@@ -6024,21 +6034,13 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { int start = pdoc->LineStart(currentLine);
int end = pdoc->LineEnd(currentLine);
- char *text = CopyRange(start, end);
- size_t textLen = text ? strlen(text) : 0;
- // include room for \r\n\0
- textLen += 3;
- char *textWithEndl = new char[textLen];
- textWithEndl[0] = '\0';
- if (text)
- strcat(textWithEndl, text);
+ std::string text = RangeText(start, end);
if (pdoc->eolMode != SC_EOL_LF)
- strcat(textWithEndl, "\r");
+ text.append("\r");
if (pdoc->eolMode != SC_EOL_CR)
- strcat(textWithEndl, "\n");
- ss->Set(textWithEndl, static_cast<int>(strlen(textWithEndl) + 1),
+ text.append("\n");
+ ss->Copy(text.c_str(), static_cast<int>(text.length() + 1),
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, true);
- delete []text;
}
} else {
int delimiterLength = 0;
@@ -6050,7 +6052,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { }
}
size_t size = sel.Length() + delimiterLength * sel.Count();
- char *text = new char[size + 1];
+ std::string text(size+1, '\0');
int j = 0;
std::vector<SelectionRange> rangesInOrder = sel.RangesCopy();
if (sel.selType == Selection::selRectangle)
@@ -6072,7 +6074,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { }
}
text[size] = '\0';
- ss->Set(text, static_cast<int>(size + 1), pdoc->dbcsCodePage,
+ ss->Copy(&text[0], static_cast<int>(size + 1), pdoc->dbcsCodePage,
vs.styles[STYLE_DEFAULT].characterSet, sel.IsRectangular(), sel.selType == Selection::selLines);
}
}
@@ -6081,7 +6083,8 @@ void Editor::CopyRangeToClipboard(int start, int end) { start = pdoc->ClampPositionIntoDocument(start);
end = pdoc->ClampPositionIntoDocument(end);
SelectionText selectedText;
- selectedText.Set(CopyRange(start, end), end - start + 1,
+ std::string text = RangeText(start, end);
+ selectedText.Copy(text.c_str(), end - start + 1,
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
CopyToClipboard(selectedText);
}
@@ -6366,7 +6369,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b if (inSelMargin) {
// Inside margin selection type should be either selSubLine or selWholeLine.
if (selectionType == selSubLine) {
- // If it is selSubLine, we're inside a *double* click and word wrap is enabled,
+ // If it is selSubLine, we're inside a *double* click and word wrap is enabled,
// so we switch to selWholeLine in order to select whole line.
selectionType = selWholeLine;
} else if (selectionType != selSubLine && selectionType != selWholeLine) {
@@ -6378,7 +6381,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b selectionType = selWord;
doubleClick = true;
} else if (selectionType == selWord) {
- // Since we ended up here, we're inside a *triple* click, which should always select
+ // Since we ended up here, we're inside a *triple* click, which should always select
// whole line irregardless of word wrap being enabled or not.
selectionType = selWholeLine;
} else {
@@ -6443,7 +6446,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b lineAnchorPos = sel.MainAnchor() - 1;
else
lineAnchorPos = sel.MainAnchor();
- // Reset selection type if there is an empty selection.
+ // Reset selection type if there is an empty selection.
// This ensures that we don't end up stuck in previous selection mode, which is no longer valid.
// Otherwise, if there's a non empty selection, reset selection type only if it differs from selSubLine and selWholeLine.
// This ensures that we continue selecting in the same selection mode.
@@ -6979,34 +6982,42 @@ void Editor::SetAnnotationVisible(int visible) { /**
* Recursively expand a fold, making lines visible except where they have an unexpanded parent.
*/
-void Editor::Expand(int &line, bool doExpand) {
+int Editor::ExpandLine(int line) {
int lineMaxSubord = pdoc->GetLastChild(line);
line++;
while (line <= lineMaxSubord) {
- if (doExpand)
- cs.SetVisible(line, line, true);
+ cs.SetVisible(line, line, true);
int level = pdoc->GetLevel(line);
if (level & SC_FOLDLEVELHEADERFLAG) {
- if (doExpand && cs.GetExpanded(line)) {
- Expand(line, true);
+ if (cs.GetExpanded(line)) {
+ line = ExpandLine(line);
} else {
- Expand(line, false);
+ line = pdoc->GetLastChild(line);
}
- } else {
- line++;
}
+ line++;
+ }
+ return lineMaxSubord;
+}
+
+void Editor::SetFoldExpanded(int lineDoc, bool expanded) {
+ if (cs.SetExpanded(lineDoc, expanded)) {
+ RedrawSelMargin();
}
}
-void Editor::ToggleContraction(int line) {
+void Editor::FoldLine(int line, int action) {
if (line >= 0) {
- if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) {
- line = pdoc->GetFoldParent(line);
- if (line < 0)
- return;
+ if (action == SC_FOLDACTION_TOGGLE) {
+ if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) {
+ line = pdoc->GetFoldParent(line);
+ if (line < 0)
+ return;
+ }
+ action = (cs.GetExpanded(line)) ? SC_FOLDACTION_CONTRACT : SC_FOLDACTION_EXPAND;
}
- if (cs.GetExpanded(line)) {
+ if (action == SC_FOLDACTION_CONTRACT) {
int lineMaxSubord = pdoc->GetLastChild(line);
if (lineMaxSubord > line) {
cs.SetExpanded(line, 0);
@@ -7017,9 +7028,6 @@ void Editor::ToggleContraction(int line) { // This does not re-expand the fold
EnsureCaretVisible();
}
-
- SetScrollBars();
- Redraw();
}
} else {
@@ -7028,11 +7036,35 @@ void Editor::ToggleContraction(int line) { GoToLine(line);
}
cs.SetExpanded(line, 1);
- Expand(line, true);
- SetScrollBars();
- Redraw();
+ ExpandLine(line);
+ }
+
+ SetScrollBars();
+ Redraw();
+ }
+}
+
+void Editor::FoldExpand(int line, int action, int level) {
+ bool expanding = action == SC_FOLDACTION_EXPAND;
+ if (action == SC_FOLDACTION_TOGGLE) {
+ expanding = !cs.GetExpanded(line);
+ }
+ SetFoldExpanded(line, expanding);
+ if (expanding && (cs.HiddenLines() == 0))
+ // Nothing to do
+ return;
+ int lineMaxSubord = pdoc->GetLastChild(line, level & SC_FOLDLEVELNUMBERMASK);
+ line++;
+ cs.SetVisible(line, lineMaxSubord, expanding);
+ while (line <= lineMaxSubord) {
+ int levelLine = pdoc->GetLevel(line);
+ if (levelLine & SC_FOLDLEVELHEADERFLAG) {
+ SetFoldExpanded(line, expanding);
}
+ line++;
}
+ SetScrollBars();
+ Redraw();
}
int Editor::ContractedFoldNext(int lineStart) {
@@ -7058,7 +7090,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { WrapLines(true, -1);
if (!cs.GetVisible(lineDoc)) {
- // Back up to find a non-blank line
+ // Back up to find a non-blank line
int lookLine = lineDoc;
int lookLineLevel = pdoc->GetLevel(lookLine);
while ((lookLine > 0) && (lookLineLevel & SC_FOLDLEVELWHITEFLAG)) {
@@ -7066,7 +7098,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { }
int lineParent = pdoc->GetFoldParent(lookLine);
if (lineParent < 0) {
- // Backed up to a top level line, so try to find parent of initial line
+ // Backed up to a top level line, so try to find parent of initial line
lineParent = pdoc->GetFoldParent(lineDoc);
}
if (lineParent >= 0) {
@@ -7074,7 +7106,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { EnsureLineVisible(lineParent, enforcePolicy);
if (!cs.GetExpanded(lineParent)) {
cs.SetExpanded(lineParent, 1);
- Expand(lineParent, true);
+ ExpandLine(lineParent);
}
}
SetScrollBars();
@@ -7103,6 +7135,89 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { }
}
+void Editor::FoldAll(int action) {
+ pdoc->EnsureStyledTo(pdoc->Length());
+ int maxLine = pdoc->LinesTotal();
+ bool expanding = action == SC_FOLDACTION_EXPAND;
+ if (action == SC_FOLDACTION_TOGGLE) {
+ // Discover current state
+ for (int lineSeek = 0; lineSeek < maxLine; lineSeek++) {
+ if (pdoc->GetLevel(lineSeek) & SC_FOLDLEVELHEADERFLAG) {
+ expanding = !cs.GetExpanded(lineSeek);
+ break;
+ }
+ }
+ }
+ if (expanding) {
+ cs.SetVisible(0, maxLine, true);
+ for (int line = 0; line < maxLine; line++) {
+ int levelLine = pdoc->GetLevel(line);
+ if (levelLine & SC_FOLDLEVELHEADERFLAG) {
+ SetFoldExpanded(line, true);
+ }
+ }
+ } else {
+ for (int line = 0; line < maxLine; line++) {
+ int level = pdoc->GetLevel(line);
+ if ((level & SC_FOLDLEVELHEADERFLAG) &&
+ (SC_FOLDLEVELBASE == (level & SC_FOLDLEVELNUMBERMASK))) {
+ SetFoldExpanded(line, false);
+ int lineMaxSubord = pdoc->GetLastChild(line, -1);
+ if (lineMaxSubord > line) {
+ cs.SetVisible(line + 1, lineMaxSubord, false);
+ }
+ }
+ }
+ }
+ SetScrollBars();
+ Redraw();
+}
+
+void Editor::FoldChanged(int line, int levelNow, int levelPrev) {
+ if (levelNow & SC_FOLDLEVELHEADERFLAG) {
+ if (!(levelPrev & SC_FOLDLEVELHEADERFLAG)) {
+ // Adding a fold point.
+ if (cs.SetExpanded(line, true)) {
+ RedrawSelMargin();
+ }
+ FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
+ }
+ } else if (levelPrev & SC_FOLDLEVELHEADERFLAG) {
+ if (!cs.GetExpanded(line)) {
+ // Removing the fold from one that has been contracted so should expand
+ // otherwise lines are left invisible with no way to make them visible
+ if (cs.SetExpanded(line, true)) {
+ RedrawSelMargin();
+ }
+ FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
+ }
+ }
+ if (!(levelNow & SC_FOLDLEVELWHITEFLAG) &&
+ ((levelPrev & SC_FOLDLEVELNUMBERMASK) > (levelNow & SC_FOLDLEVELNUMBERMASK))) {
+ if (cs.HiddenLines()) {
+ // See if should still be hidden
+ int parentLine = pdoc->GetFoldParent(line);
+ if ((parentLine < 0) || (cs.GetExpanded(parentLine) && cs.GetVisible(parentLine))) {
+ cs.SetVisible(line, line, true);
+ SetScrollBars();
+ Redraw();
+ }
+ }
+ }
+}
+
+void Editor::NeedShown(int pos, int len) {
+ if (foldAutomatic & SC_AUTOMATICFOLD_SHOW) {
+ int lineStart = pdoc->LineFromPosition(pos);
+ int lineEnd = pdoc->LineFromPosition(pos+len);
+ for (int line = lineStart; line <= lineEnd; line++) {
+ EnsureLineVisible(line, false);
+ }
+ } else {
+ NotifyNeedShown(pos, len);
+ }
+}
+
int Editor::GetTag(char *tagValue, int tagNumber) {
const char *text = 0;
int length = 0;
@@ -7165,18 +7280,17 @@ int Editor::WrapCount(int line) { void Editor::AddStyledText(char *buffer, int appendLength) {
// The buffer consists of alternating character bytes and style bytes
int textLength = appendLength / 2;
- char *text = new char[textLength];
+ std::string text(textLength, '\0');
int i;
for (i = 0; i < textLength; i++) {
text[i] = buffer[i*2];
}
- pdoc->InsertString(CurrentPosition(), text, textLength);
+ pdoc->InsertString(CurrentPosition(), text.c_str(), textLength);
for (i = 0; i < textLength; i++) {
text[i] = buffer[i*2+1];
}
pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff));
- pdoc->SetStyles(textLength, text);
- delete []text;
+ pdoc->SetStyles(textLength, text.c_str());
SetEmptySelection(sel.MainCaret() + textLength);
}
@@ -7924,10 +8038,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETLINEENDTYPESALLOWED:
return pdoc->GetLineEndTypesAllowed();
-
+
case SCI_GETLINEENDTYPESACTIVE:
return pdoc->GetLineEndTypesActive();
-
+
case SCI_STARTSTYLING:
pdoc->StartStyling(wParam, static_cast<char>(lParam));
break;
@@ -8140,7 +8254,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break;
case SCI_TEXTWIDTH:
- PLATFORM_ASSERT(wParam < vs.stylesSize);
+ PLATFORM_ASSERT(wParam < vs.styles.size());
PLATFORM_ASSERT(lParam);
return TextWidth(wParam, CharPtrFromSPtr(lParam));
@@ -8309,7 +8423,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_MARKERGET:
return pdoc->GetMark(wParam);
- case SCI_MARKERNEXT:
+ case SCI_MARKERNEXT:
return pdoc->MarkerNext(wParam, lParam);
case SCI_MARKERPREVIOUS: {
@@ -8550,21 +8664,42 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return cs.HiddenLines() ? 0 : 1;
case SCI_SETFOLDEXPANDED:
- if (cs.SetExpanded(wParam, lParam != 0)) {
- RedrawSelMargin();
- }
+ SetFoldExpanded(wParam, lParam != 0);
break;
case SCI_GETFOLDEXPANDED:
return cs.GetExpanded(wParam);
+ case SCI_SETAUTOMATICFOLD:
+ foldAutomatic = wParam;
+ break;
+
+ case SCI_GETAUTOMATICFOLD:
+ return foldAutomatic;
+
case SCI_SETFOLDFLAGS:
foldFlags = wParam;
Redraw();
break;
case SCI_TOGGLEFOLD:
- ToggleContraction(wParam);
+ FoldLine(wParam, SC_FOLDACTION_TOGGLE);
+ break;
+
+ case SCI_FOLDLINE:
+ FoldLine(wParam, lParam);
+ break;
+
+ case SCI_FOLDCHILDREN:
+ FoldExpand(wParam, lParam, pdoc->GetLevel(wParam));
+ break;
+
+ case SCI_FOLDALL:
+ FoldAll(wParam);
+ break;
+
+ case SCI_EXPANDCHILDREN:
+ FoldExpand(wParam, SC_FOLDACTION_EXPAND, lParam);
break;
case SCI_CONTRACTEDFOLDNEXT:
@@ -8578,7 +8713,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { EnsureLineVisible(wParam, true);
break;
- case SCI_SCROLLRANGE:
+ case SCI_SCROLLRANGE:
ScrollRange(SelectionRange(lParam, wParam));
break;
@@ -8951,9 +9086,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CREATEDOCUMENT: {
Document *doc = new Document();
- if (doc) {
- doc->AddRef();
- }
+ doc->AddRef();
return reinterpret_cast<sptr_t>(doc);
}
@@ -8967,11 +9100,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CREATELOADER: {
Document *doc = new Document();
- if (doc) {
- doc->AddRef();
- doc->Allocate(wParam);
- doc->SetUndoCollection(false);
- }
+ doc->AddRef();
+ doc->Allocate(wParam);
+ doc->SetUndoCollection(false);
return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc));
}
@@ -9516,18 +9647,18 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CHANGELEXERSTATE:
pdoc->ChangeLexerState(wParam, lParam);
break;
-
+
case SCI_SETIDENTIFIER:
SetCtrlID(wParam);
break;
-
+
case SCI_GETIDENTIFIER:
return GetCtrlID();
case SCI_SETTECHNOLOGY:
// No action by default
break;
-
+
case SCI_GETTECHNOLOGY:
return technology;
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index a6f0355..a31ac03 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -91,20 +91,13 @@ public: Free();
}
void Free() {
- Set(0, 0, 0, 0, false, false);
- }
- void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
delete []s;
- s = s_;
- if (s)
- len = len_;
- else
- len = 0;
- codePage = codePage_;
- characterSet = characterSet_;
- rectangular = rectangular_;
- lineCopy = lineCopy_;
- FixSelectionForClipboard();
+ s = 0;
+ len = 0;
+ rectangular = false;
+ lineCopy = false;
+ codePage = 0;
+ characterSet = 0;
}
void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
delete []s;
@@ -274,6 +267,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool recordingMacro;
int foldFlags;
+ int foldAutomatic;
ContractionState cs;
// Hotspot support
@@ -522,7 +516,6 @@ protected: // ScintillaBase subclass needs access to much of Editor void GoToLine(int lineNo);
virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
- char *CopyRange(int start, int end);
std::string RangeText(int start, int end) const;
void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
void CopyRangeToClipboard(int start, int end);
@@ -565,14 +558,20 @@ protected: // ScintillaBase subclass needs access to much of Editor void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
void SetAnnotationHeights(int start, int end);
- void SetDocPointer(Document *document);
+ virtual void SetDocPointer(Document *document);
void SetAnnotationVisible(int visible);
- void Expand(int &line, bool doExpand);
- void ToggleContraction(int line);
+ int ExpandLine(int line);
+ void SetFoldExpanded(int lineDoc, bool expanded);
+ void FoldLine(int line, int action);
+ void FoldExpand(int line, int action, int level);
int ContractedFoldNext(int lineStart);
void EnsureLineVisible(int lineDoc, bool enforcePolicy);
+ void FoldChanged(int line, int levelNow, int levelPrev);
+ void NeedShown(int pos, int len);
+ void FoldAll(int action);
+
int GetTag(char *tagValue, int tagNumber);
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
diff --git a/scintilla/src/Indicator.cxx b/scintilla/src/Indicator.cxx index 20e7f6e..0127320 100644 --- a/scintilla/src/Indicator.cxx +++ b/scintilla/src/Indicator.cxx @@ -152,6 +152,9 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r surface->FillRectangle(rcDot, fore);
x += 2;
}
+ } else if (style == INDIC_COMPOSITIONTHICK) {
+ PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom);
+ surface->FillRectangle(rcComposition, fore);
} else { // Either INDIC_PLAIN or unknown
surface->MoveTo(rc.left, ymid);
surface->LineTo(rc.right, ymid);
diff --git a/scintilla/src/KeyMap.cxx b/scintilla/src/KeyMap.cxx index a659a77..74e7a2d 100644 --- a/scintilla/src/KeyMap.cxx +++ b/scintilla/src/KeyMap.cxx @@ -5,6 +5,10 @@ // Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#include <stdlib.h>
+
+#include <vector>
+
#include "Platform.h"
#include "Scintilla.h"
@@ -15,7 +19,7 @@ using namespace Scintilla;
#endif
-KeyMap::KeyMap() : kmap(0), len(0), alloc(0) {
+KeyMap::KeyMap() {
for (int i = 0; MapDefault[i].key; i++) {
AssignCmdKey(MapDefault[i].key,
MapDefault[i].modifiers,
@@ -28,37 +32,25 @@ KeyMap::~KeyMap() { }
void KeyMap::Clear() {
- delete []kmap;
- kmap = 0;
- len = 0;
- alloc = 0;
+ kmap.clear();
}
void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) {
- if ((len+1) >= alloc) {
- KeyToCommand *ktcNew = new KeyToCommand[alloc + 5];
- if (!ktcNew)
- return;
- for (int k = 0; k < len; k++)
- ktcNew[k] = kmap[k];
- alloc += 5;
- delete []kmap;
- kmap = ktcNew;
- }
- for (int keyIndex = 0; keyIndex < len; keyIndex++) {
+ for (size_t keyIndex = 0; keyIndex < kmap.size(); keyIndex++) {
if ((key == kmap[keyIndex].key) && (modifiers == kmap[keyIndex].modifiers)) {
kmap[keyIndex].msg = msg;
return;
}
}
- kmap[len].key = key;
- kmap[len].modifiers = modifiers;
- kmap[len].msg = msg;
- len++;
+ KeyToCommand ktc;
+ ktc.key = key;
+ ktc.modifiers = modifiers;
+ ktc.msg = msg;
+ kmap.push_back(ktc);
}
unsigned int KeyMap::Find(int key, int modifiers) {
- for (int i = 0; i < len; i++) {
+ for (size_t i = 0; i < kmap.size(); i++) {
if ((key == kmap[i].key) && (modifiers == kmap[i].modifiers)) {
return kmap[i].msg;
}
diff --git a/scintilla/src/KeyMap.h b/scintilla/src/KeyMap.h index 6584b29..2b7ebe6 100644 --- a/scintilla/src/KeyMap.h +++ b/scintilla/src/KeyMap.h @@ -32,9 +32,7 @@ public: /**
*/
class KeyMap {
- KeyToCommand *kmap;
- int len;
- int alloc;
+ std::vector<KeyToCommand> kmap;
static const KeyToCommand MapDefault[];
public:
diff --git a/scintilla/src/PerLine.cxx b/scintilla/src/PerLine.cxx index 0d8c1c6..1154022 100644 --- a/scintilla/src/PerLine.cxx +++ b/scintilla/src/PerLine.cxx @@ -7,6 +7,8 @@ #include <string.h>
+#include <algorithm>
+
#include "Platform.h"
#include "Scintilla.h"
@@ -43,17 +45,6 @@ int MarkerHandleSet::Length() const { return c;
}
-int MarkerHandleSet::NumberFromHandle(int handle) const {
- MarkerHandleNumber *mhn = root;
- while (mhn) {
- if (mhn->handle == handle) {
- return mhn->number;
- }
- mhn = mhn->next;
- }
- return - 1;
-}
-
int MarkerHandleSet::MarkValue() const {
unsigned int m = 0;
MarkerHandleNumber *mhn = root;
@@ -77,8 +68,6 @@ bool MarkerHandleSet::Contains(int handle) const { bool MarkerHandleSet::InsertHandle(int handle, int markerNum) {
MarkerHandleNumber *mhn = new MarkerHandleNumber;
- if (!mhn)
- return false;
mhn->handle = handle;
mhn->number = markerNum;
mhn->next = root;
@@ -209,8 +198,6 @@ int LineMarkers::AddMark(int line, int markerNum, int lines) { if (!markers[line]) {
// Need new structure to hold marker handle
markers[line] = new MarkerHandleSet();
- if (!markers[line])
- return -1;
}
markers[line]->InsertHandle(handleCurrent, markerNum);
@@ -389,10 +376,6 @@ void LineAnnotation::RemoveLine(int line) { }
}
-bool LineAnnotation::AnySet() const {
- return annotations.Length() > 0;
-}
-
bool LineAnnotation::MultipleStyles(int line) const {
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
return reinterpret_cast<AnnotationHeader *>(annotations[line])->style == IndividualStyles;
diff --git a/scintilla/src/PerLine.h b/scintilla/src/PerLine.h index ad85eb1..c314612 100644 --- a/scintilla/src/PerLine.h +++ b/scintilla/src/PerLine.h @@ -32,7 +32,6 @@ public: MarkerHandleSet();
~MarkerHandleSet();
int Length() const;
- int NumberFromHandle(int handle) const;
int MarkValue() const; ///< Bit set of marker numbers.
bool Contains(int handle) const;
bool InsertHandle(int handle, int markerNum);
@@ -101,7 +100,6 @@ public: virtual void InsertLine(int line);
virtual void RemoveLine(int line);
- bool AnySet() const;
bool MultipleStyles(int line) const;
int Style(int line);
const char *Text(int line) const;
diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx index b6f8144..387ed54 100644 --- a/scintilla/src/PositionCache.cxx +++ b/scintilla/src/PositionCache.cxx @@ -207,7 +207,7 @@ int LineLayout::EndLineStyle() const { }
LineLayoutCache::LineLayoutCache() :
- level(0), length(0), size(0), cache(0),
+ level(0),
allInvalidated(false), styleClock(-1), useCount(0) {
Allocate(0);
}
@@ -216,24 +216,15 @@ LineLayoutCache::~LineLayoutCache() { Deallocate();
}
-void LineLayoutCache::Allocate(int length_) {
- PLATFORM_ASSERT(cache == NULL);
+void LineLayoutCache::Allocate(size_t length_) {
+ PLATFORM_ASSERT(cache.empty());
allInvalidated = false;
- length = length_;
- size = length;
- if (size > 1) {
- size = (size / 16 + 1) * 16;
- }
- if (size > 0) {
- cache = new LineLayout * [size];
- }
- for (int i = 0; i < size; i++)
- cache[i] = 0;
+ cache.resize(length_);
}
void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
PLATFORM_ASSERT(useCount == 0);
- int lengthForLevel = 0;
+ size_t lengthForLevel = 0;
if (level == llcCaret) {
lengthForLevel = 1;
} else if (level == llcPage) {
@@ -241,35 +232,31 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { } else if (level == llcDocument) {
lengthForLevel = linesInDoc;
}
- if (lengthForLevel > size) {
+ if (lengthForLevel > cache.size()) {
Deallocate();
Allocate(lengthForLevel);
} else {
- if (lengthForLevel < length) {
- for (int i = lengthForLevel; i < length; i++) {
+ if (lengthForLevel < cache.size()) {
+ for (size_t i = lengthForLevel; i < cache.size(); i++) {
delete cache[i];
cache[i] = 0;
}
}
- length = lengthForLevel;
+ cache.resize(lengthForLevel);
}
- PLATFORM_ASSERT(length == lengthForLevel);
- PLATFORM_ASSERT(cache != NULL || length == 0);
+ PLATFORM_ASSERT(cache.size() == lengthForLevel);
}
void LineLayoutCache::Deallocate() {
PLATFORM_ASSERT(useCount == 0);
- for (int i = 0; i < length; i++)
+ for (size_t i = 0; i < cache.size(); i++)
delete cache[i];
- delete []cache;
- cache = 0;
- length = 0;
- size = 0;
+ cache.clear();
}
void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
- if (cache && !allInvalidated) {
- for (int i = 0; i < length; i++) {
+ if (!cache.empty() && !allInvalidated) {
+ for (size_t i = 0; i < cache.size(); i++) {
if (cache[i]) {
cache[i]->Invalidate(validity_);
}
@@ -303,15 +290,15 @@ LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChar } else if (level == llcPage) {
if (lineNumber == lineCaret) {
pos = 0;
- } else if (length > 1) {
- pos = 1 + (lineNumber % (length - 1));
+ } else if (cache.size() > 1) {
+ pos = 1 + (lineNumber % (cache.size() - 1));
}
} else if (level == llcDocument) {
pos = lineNumber;
}
if (pos >= 0) {
PLATFORM_ASSERT(useCount == 0);
- if (cache && (pos < length)) {
+ if (!cache.empty() && (pos < static_cast<int>(cache.size()))) {
if (cache[pos]) {
if ((cache[pos]->lineNumber != lineNumber) ||
(cache[pos]->maxLineLength < maxChars)) {
@@ -322,12 +309,10 @@ LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChar if (!cache[pos]) {
cache[pos] = new LineLayout(maxChars);
}
- if (cache[pos]) {
- cache[pos]->lineNumber = lineNumber;
- cache[pos]->inCache = true;
- ret = cache[pos];
- useCount++;
- }
+ cache[pos]->lineNumber = lineNumber;
+ cache[pos]->inCache = true;
+ ret = cache[pos];
+ useCount++;
}
}
@@ -351,33 +336,18 @@ void LineLayoutCache::Dispose(LineLayout *ll) { }
void BreakFinder::Insert(int val) {
- // Expand if needed
- if (saeLen >= saeSize) {
- saeSize *= 2;
- int *selAndEdgeNew = new int[saeSize];
- for (unsigned int j = 0; j<saeLen; j++) {
- selAndEdgeNew[j] = selAndEdge[j];
- }
- delete []selAndEdge;
- selAndEdge = selAndEdgeNew;
- }
-
if (val >= nextBreak) {
- for (unsigned int j = 0; j<saeLen; j++) {
- if (val == selAndEdge[j]) {
+ for (std::vector<int>::iterator it = selAndEdge.begin(); it != selAndEdge.end(); ++it) {
+ if (val == *it) {
return;
}
- if (val < selAndEdge[j]) {
- for (unsigned int k = saeLen; k>j; k--) {
- selAndEdge[k] = selAndEdge[k-1];
- }
- saeLen++;
- selAndEdge[j] = val;
+ if (val <*it) {
+ selAndEdge.insert(it, 1, val);
return;
}
}
// Not less than any so append
- selAndEdge[saeLen++] = val;
+ selAndEdge.push_back(val);
}
}
@@ -399,17 +369,11 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL lineEnd(lineEnd_),
posLineStart(posLineStart_),
nextBreak(lineStart_),
- saeSize(0),
- saeLen(0),
saeCurrentPos(0),
saeNext(0),
subBreak(-1),
pdoc(pdoc_) {
- saeSize = 8;
- selAndEdge = new int[saeSize];
- for (unsigned int j=0; j < saeSize; j++) {
- selAndEdge[j] = 0;
- }
+ selAndEdge.resize(1);
// Search for first visible break
// First find the first visible character
@@ -447,11 +411,10 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL Insert(pos);
}
}
- saeNext = (saeLen > 0) ? selAndEdge[0] : -1;
+ saeNext = (!selAndEdge.empty()) ? selAndEdge[0] : -1;
}
BreakFinder::~BreakFinder() {
- delete []selAndEdge;
}
int BreakFinder::First() const {
@@ -467,7 +430,7 @@ int BreakFinder::Next() { IsControlCharacter(ll->chars[nextBreak]) || IsControlCharacter(ll->chars[nextBreak + 1])) {
if (nextBreak == saeNext) {
saeCurrentPos++;
- saeNext = (saeLen > saeCurrentPos) ? selAndEdge[saeCurrentPos] : -1;
+ saeNext = (saeCurrentPos < selAndEdge.size()) ? selAndEdge[saeCurrentPos] : -1;
}
nextBreak++;
if ((nextBreak - prev) < lengthStartSubdivision) {
@@ -509,7 +472,7 @@ void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_, len = len_;
clock = clock_;
if (s_ && positions_) {
- positions = new XYPOSITION[len + (len + 1) / 2];
+ positions = new XYPOSITION[len + (len / 4) + 1];
for (unsigned int i=0; i<len; i++) {
positions[i] = static_cast<XYPOSITION>(positions_[i]);
}
@@ -566,20 +529,18 @@ void PositionCacheEntry::ResetClock() { }
PositionCache::PositionCache() {
- size = 0x400;
clock = 1;
- pces = new PositionCacheEntry[size];
+ pces.resize(0x400);
allClear = true;
}
PositionCache::~PositionCache() {
Clear();
- delete []pces;
}
void PositionCache::Clear() {
if (!allClear) {
- for (size_t i=0; i<size; i++) {
+ for (size_t i=0; i<pces.size(); i++) {
pces[i].Clear();
}
}
@@ -589,9 +550,7 @@ void PositionCache::Clear() { void PositionCache::SetSize(size_t size_) {
Clear();
- delete []pces;
- size = size_;
- pces = new PositionCacheEntry[size];
+ pces.resize(size_);
}
void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
@@ -599,17 +558,17 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned allClear = false;
int probe = -1;
- if ((size > 0) && (len < 30)) {
+ if ((!pces.empty()) && (len < 30)) {
// Only store short strings in the cache so it doesn't churn with
// long comments with only a single comment.
// Two way associative: try two probe positions.
int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
- probe = static_cast<int>(hashValue % size);
+ probe = static_cast<int>(hashValue % pces.size());
if (pces[probe].Retrieve(styleNumber, s, len, positions)) {
return;
}
- int probe2 = static_cast<int>((hashValue * 37) % size);
+ int probe2 = static_cast<int>((hashValue * 37) % pces.size());
if (pces[probe2].Retrieve(styleNumber, s, len, positions)) {
return;
}
@@ -639,7 +598,7 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned if (clock > 60000) {
// Since there are only 16 bits for the clock, wrap it round and
// reset all cache entries so none get stuck with a high clock.
- for (size_t i=0; i<size; i++) {
+ for (size_t i=0; i<pces.size(); i++) {
pces[i].ResetClock();
}
clock = 2;
diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h index 1b909fd..50913f4 100644 --- a/scintilla/src/PositionCache.h +++ b/scintilla/src/PositionCache.h @@ -73,13 +73,11 @@ public: */
class LineLayoutCache {
int level;
- int length;
- int size;
- LineLayout **cache;
+ std::vector<LineLayout *>cache;
bool allInvalidated;
int styleClock;
int useCount;
- void Allocate(int length_);
+ void Allocate(size_t length_);
void AllocateForLevel(int linesOnScreen, int linesInDoc);
public:
LineLayoutCache();
@@ -122,9 +120,7 @@ class BreakFinder { int lineEnd;
int posLineStart;
int nextBreak;
- int *selAndEdge;
- unsigned int saeSize;
- unsigned int saeLen;
+ std::vector<int> selAndEdge;
unsigned int saeCurrentPos;
int saeNext;
int subBreak;
@@ -146,8 +142,7 @@ public: };
class PositionCache {
- PositionCacheEntry *pces;
- size_t size;
+ std::vector<PositionCacheEntry> pces;
unsigned int clock;
bool allClear;
// Private so PositionCache objects can not be copied
@@ -157,7 +152,7 @@ public: ~PositionCache();
void Clear();
void SetSize(size_t size_);
- size_t GetSize() const { return size; }
+ size_t GetSize() const { return pces.size(); }
void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc);
};
diff --git a/scintilla/src/RESearch.cxx b/scintilla/src/RESearch.cxx index d3da8fb..be8166b 100644 --- a/scintilla/src/RESearch.cxx +++ b/scintilla/src/RESearch.cxx @@ -43,10 +43,6 @@ *
* int RESearch::Execute(characterIndexer &ci, int lp, int endp)
*
- * RESearch::Substitute: substitute the matched portions in a new string.
- *
- * int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst)
- *
* re_fail: failure routine for RESearch::Execute. (no longer used)
*
* void re_fail(char *msg, char op)
@@ -206,6 +202,8 @@ #include <stdlib.h>
+#include <string>
+
#include "CharClassify.h"
#include "RESearch.h"
@@ -269,36 +267,29 @@ void RESearch::Init() { sta = NOP; /* status of lastpat */
bol = 0;
for (int i = 0; i < MAXTAG; i++)
- pat[i] = 0;
+ pat[i].clear();
for (int j = 0; j < BITBLK; j++)
bittab[j] = 0;
}
void RESearch::Clear() {
for (int i = 0; i < MAXTAG; i++) {
- delete []pat[i];
- pat[i] = 0;
+ pat[i].clear();
bopat[i] = NOTFOUND;
eopat[i] = NOTFOUND;
}
}
-bool RESearch::GrabMatches(CharacterIndexer &ci) {
- bool success = true;
+void RESearch::GrabMatches(CharacterIndexer &ci) {
for (unsigned int i = 0; i < MAXTAG; i++) {
if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) {
unsigned int len = eopat[i] - bopat[i];
- pat[i] = new char[len + 1];
- if (pat[i]) {
- for (unsigned int j = 0; j < len; j++)
- pat[i][j] = ci.CharAt(bopat[i] + j);
- pat[i][len] = '\0';
- } else {
- success = false;
- }
+ pat[i] = std::string(len+1, '\0');
+ for (unsigned int j = 0; j < len; j++)
+ pat[i][j] = ci.CharAt(bopat[i] + j);
+ pat[i][len] = '\0';
}
}
- return success;
}
void RESearch::ChSet(unsigned char c) {
@@ -967,52 +958,4 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) { return lp;
}
-/*
- * RESearch::Substitute:
- * substitute the matched portions of the src in dst.
- *
- * & substitute the entire matched pattern.
- *
- * \digit substitute a subpattern, with the given tag number.
- * Tags are numbered from 1 to 9. If the particular
- * tagged subpattern does not exist, null is substituted.
- */
-int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst) {
- unsigned char c;
- int pin;
- int bp;
- int ep;
-
- if (!*src || !bopat[0])
- return 0;
-
- while ((c = *src++) != 0) {
- switch (c) {
-
- case '&':
- pin = 0;
- break;
-
- case '\\':
- c = *src++;
- if (c >= '0' && c <= '9') {
- pin = c - '0';
- break;
- }
-
- default:
- *dst++ = c;
- continue;
- }
-
- if ((bp = bopat[pin]) != 0 && (ep = eopat[pin]) != 0) {
- while (ci.CharAt(bp) && bp < ep)
- *dst++ = ci.CharAt(bp++);
- if (bp < ep)
- return 0;
- }
- }
- *dst = '\0';
- return 1;
-}
diff --git a/scintilla/src/RESearch.h b/scintilla/src/RESearch.h index e2f8d50..bf31b24 100644 --- a/scintilla/src/RESearch.h +++ b/scintilla/src/RESearch.h @@ -33,10 +33,9 @@ class RESearch { public:
RESearch(CharClassify *charClassTable);
~RESearch();
- bool GrabMatches(CharacterIndexer &ci);
+ void GrabMatches(CharacterIndexer &ci);
const char *Compile(const char *pattern, int length, bool caseSensitive, bool posix);
int Execute(CharacterIndexer &ci, int lp, int endp);
- int Substitute(CharacterIndexer &ci, char *src, char *dst);
enum { MAXTAG=10 };
enum { MAXNFA=2048 };
@@ -44,7 +43,7 @@ public: int bopat[MAXTAG];
int eopat[MAXTAG];
- char *pat[MAXTAG];
+ std::string pat[MAXTAG];
private:
void Init();
diff --git a/scintilla/src/RunStyles.cxx b/scintilla/src/RunStyles.cxx index 29ce08f..c8698a2 100644 --- a/scintilla/src/RunStyles.cxx +++ b/scintilla/src/RunStyles.cxx @@ -9,6 +9,8 @@ #include <stdlib.h>
#include <stdarg.h>
+#include <stdexcept>
+
#include "Platform.h"
#include "Scintilla.h"
@@ -113,7 +115,13 @@ int RunStyles::EndRun(int position) { }
bool RunStyles::FillRange(int &position, int value, int &fillLength) {
+ if (fillLength <= 0) {
+ return false;
+ }
int end = position + fillLength;
+ if (end > Length()) {
+ return false;
+ }
int runEnd = RunFromPosition(end);
if (styles->ValueAt(runEnd) == value) {
// End already has value so trim range.
@@ -249,3 +257,31 @@ int RunStyles::Find(int value, int start) const { }
return -1;
}
+
+void RunStyles::Check() {
+ if (Length() < 0) {
+ throw std::runtime_error("RunStyles: Length can not be negative.");
+ }
+ if (starts->Partitions() < 1) {
+ throw std::runtime_error("RunStyles: Must always have 1 or more partitions.");
+ }
+ if (starts->Partitions() != styles->Length()-1) {
+ throw std::runtime_error("RunStyles: Partitions and styles different lengths.");
+ }
+ int start=0;
+ while (start < Length()) {
+ int end = EndRun(start);
+ if (start >= end) {
+ throw std::runtime_error("RunStyles: Partition is 0 length.");
+ }
+ start = end;
+ }
+ if (styles->ValueAt(styles->Length()-1) != 0) {
+ throw std::runtime_error("RunStyles: Unused style at end changed.");
+ }
+ for (int j=1; j<styles->Length()-1; j++) {
+ if (styles->ValueAt(j) == styles->ValueAt(j-1)) {
+ throw std::runtime_error("RunStyles: Style of a partition same as previous.");
+ }
+ }
+}
diff --git a/scintilla/src/RunStyles.h b/scintilla/src/RunStyles.h index 25f9752..0191d9a 100644 --- a/scintilla/src/RunStyles.h +++ b/scintilla/src/RunStyles.h @@ -43,6 +43,8 @@ public: bool AllSame() const;
bool AllSameAs(int value) const;
int Find(int value, int start) const;
+
+ void Check();
};
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/SVector.h b/scintilla/src/SVector.h deleted file mode 100644 index 7d1a8a8..0000000 --- a/scintilla/src/SVector.h +++ /dev/null @@ -1,123 +0,0 @@ -// Scintilla source code edit control
-/** @file SVector.h
- ** A simple expandable vector.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@hare.net.au>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef SVECTOR_H
-#define SVECTOR_H
-
-#ifdef SCI_NAMESPACE
-namespace Scintilla {
-#endif
-
-/**
- * A simple expandable integer vector.
- * Storage not allocated for elements until an element is used.
- * This makes it very lightweight unless used so is a good match for optional features.
- */
-class SVector {
- enum { allocSize = 4000 };
-
- int *v; ///< The vector
- unsigned int size; ///< Number of elements allocated
- unsigned int len; ///< Number of elements used in vector
-
- /** Internally allocate more elements than the user wants
- * to avoid thrashing the memory allocator. */
- void SizeTo(int newSize) {
- if (newSize < allocSize)
- newSize += allocSize;
- else
- newSize = (newSize * 3) / 2;
- int *newv = new int[newSize];
- size = newSize;
- unsigned int i=0;
- for (; i<len; i++) {
- newv[i] = v[i];
- }
- for (; i<size; i++) {
- newv[i] = 0;
- }
- delete []v;
- v = newv;
- }
-
-public:
- SVector() {
- v = 0;
- len = 0;
- size = 0;
- }
- ~SVector() {
- Free();
- }
- /// Constructor from another vector.
- SVector(const SVector &other) {
- v = 0;
- len = 0;
- size = 0;
- if (other.Length() > 0) {
- SizeTo(other.Length());
- for (int i=0; i<other.Length(); i++)
- v[i] = other.v[i];
- len = other.Length();
- }
- }
- /// Copy constructor.
- SVector &operator=(const SVector &other) {
- if (this != &other) {
- delete []v;
- v = 0;
- len = 0;
- size = 0;
- if (other.Length() > 0) {
- SizeTo(other.Length());
- for (int i=0; i<other.Length(); i++)
- v[i] = other.v[i];
- len = other.Length();
- }
- }
- return *this;
- }
- /** @brief Accessor.
- * Allows to access values from the list, and grows it if accessing
- * outside the current bounds. The returned value in this case is 0. */
- int &operator[](unsigned int i) {
- if (i >= len) {
- if (i >= size) {
- SizeTo(i);
- }
- len = i+1;
- }
- return v[i];
- }
- /// Reset vector.
- void Free() {
- delete []v;
- v = 0;
- size = 0;
- len = 0;
- }
- /** @brief Grow vector size.
- * Doesn't allow a vector to be shrinked. */
- void SetLength(unsigned int newLength) {
- if (newLength > len) {
- if (newLength >= size) {
- SizeTo(newLength);
- }
- }
- len = newLength;
- }
- /// Get the current length (number of used elements) of the vector.
- int Length() const {
- return len;
- }
-};
-
-#ifdef SCI_NAMESPACE
-}
-#endif
-
-#endif
diff --git a/scintilla/src/Selection.cxx b/scintilla/src/Selection.cxx index 7192a2a..a708a53 100644 --- a/scintilla/src/Selection.cxx +++ b/scintilla/src/Selection.cxx @@ -20,14 +20,18 @@ using namespace Scintilla; #endif
void SelectionPosition::MoveForInsertDelete(bool insertion, int startChange, int length) {
- if (position == startChange) {
- virtualSpace = 0;
- }
if (insertion) {
- if (position > startChange) {
+ if (position == startChange) {
+ int virtualLengthRemove = std::min(length, virtualSpace);
+ virtualSpace -= virtualLengthRemove;
+ position += virtualLengthRemove;
+ } else if (position > startChange) {
position += length;
}
} else {
+ if (position == startChange) {
+ virtualSpace = 0;
+ }
if (position > startChange) {
int endDeletion = startChange + length;
if (position > endDeletion) {
diff --git a/scintilla/src/SplitVector.h b/scintilla/src/SplitVector.h index c64358e..5b8876c 100644 --- a/scintilla/src/SplitVector.h +++ b/scintilla/src/SplitVector.h @@ -174,8 +174,7 @@ public: }
RoomFor(insertLength);
GapTo(position);
- for (int i = 0; i < insertLength; i++)
- body[part1Length + i] = v;
+ std::fill(&body[part1Length], &body[part1Length + insertLength], v);
lengthBody += insertLength;
part1Length += insertLength;
gapLength -= insertLength;
diff --git a/scintilla/src/Style.cxx b/scintilla/src/Style.cxx index 9587d14..e12bdd1 100644 --- a/scintilla/src/Style.cxx +++ b/scintilla/src/Style.cxx @@ -21,7 +21,7 @@ FontAlias::FontAlias() { FontAlias::~FontAlias() {
SetID(0);
- // ~Font will not release the actual font resource sine it is now 0
+ // ~Font will not release the actual font resource since it is now 0
}
void FontAlias::MakeAlias(Font &fontOrigin) {
@@ -32,12 +32,29 @@ void FontAlias::ClearFont() { SetID(0);
}
-bool FontSpecification::EqualTo(const FontSpecification &other) const {
- return weight == other.weight &&
+bool FontSpecification::operator==(const FontSpecification &other) const {
+ return fontName == other.fontName &&
+ weight == other.weight &&
italic == other.italic &&
size == other.size &&
characterSet == other.characterSet &&
- fontName == other.fontName;
+ extraFontFlag == other.extraFontFlag;
+}
+
+bool FontSpecification::operator<(const FontSpecification &other) const {
+ if (fontName != other.fontName)
+ return fontName < other.fontName;
+ if (weight != other.weight)
+ return weight < other.weight;
+ if (italic != other.italic)
+ return italic == false;
+ if (size != other.size)
+ return size < other.size;
+ if (characterSet != other.characterSet)
+ return characterSet < other.characterSet;
+ if (extraFontFlag != other.extraFontFlag)
+ return extraFontFlag < other.extraFontFlag;
+ return false;
}
FontMeasurements::FontMeasurements() {
@@ -68,6 +85,7 @@ Style::Style(const Style &source) : FontSpecification(), FontMeasurements() { weight = source.weight;
italic = source.italic;
size = source.size;
+ fontName = source.fontName;
eolFilled = source.eolFilled;
underline = source.underline;
caseForce = source.caseForce;
@@ -91,6 +109,7 @@ Style &Style::operator=(const Style &source) { weight = source.weight;
italic = source.italic;
size = source.size;
+ fontName = source.fontName;
eolFilled = source.eolFilled;
underline = source.underline;
caseForce = source.caseForce;
diff --git a/scintilla/src/Style.h b/scintilla/src/Style.h index 5b7d3f3..5f520e7 100644 --- a/scintilla/src/Style.h +++ b/scintilla/src/Style.h @@ -27,7 +27,8 @@ struct FontSpecification { characterSet(0),
extraFontFlag(0) {
}
- bool EqualTo(const FontSpecification &other) const;
+ bool operator==(const FontSpecification &other) const;
+ bool operator<(const FontSpecification &other) const;
};
// Just like Font but only has a copy of the FontID so should not delete it
@@ -77,7 +78,7 @@ public: const char *fontName_, int characterSet_,
int weight_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_,
- bool visible_, bool changeable_, bool hotspot_);
+ bool visible_, bool changeable_, bool hotspot_);
void ClearTo(const Style &source);
void Copy(Font &font_, const FontMeasurements &fm_);
bool IsProtected() const { return !(changeable && visible);}
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index e1eafcc..7661821 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -33,100 +33,52 @@ MarginStyle::MarginStyle() : // A list of the fontnames - avoids wasting space in each style
FontNames::FontNames() {
- size = 8;
- names = new char *[size];
- max = 0;
}
FontNames::~FontNames() {
Clear();
- delete []names;
- names = 0;
}
void FontNames::Clear() {
- for (int i=0; i<max; i++) {
- delete []names[i];
- }
- max = 0;
+ names.clear();
}
const char *FontNames::Save(const char *name) {
if (!name)
return 0;
- for (int i=0; i<max; i++) {
- if (strcmp(names[i], name) == 0) {
- return names[i];
- }
- }
- if (max >= size) {
- // Grow array
- int sizeNew = size * 2;
- char **namesNew = new char *[sizeNew];
- for (int j=0; j<max; j++) {
- namesNew[j] = names[j];
+
+ for (std::vector<char *>::const_iterator it=names.begin(); it != names.end(); ++it) {
+ if (strcmp(*it, name) == 0) {
+ return *it;
}
- delete []names;
- names = namesNew;
- size = sizeNew;
}
- names[max] = new char[strlen(name) + 1];
- strcpy(names[max], name);
- max++;
- return names[max-1];
+ char *nameSave = new char[strlen(name) + 1];
+ strcpy(nameSave, name);
+ names.push_back(nameSave);
+ return nameSave;
}
-FontRealised::FontRealised(const FontSpecification &fs) {
- frNext = NULL;
- (FontSpecification &)(*this) = fs;
+FontRealised::FontRealised() {
}
FontRealised::~FontRealised() {
font.Release();
- delete frNext;
- frNext = 0;
}
-void FontRealised::Realise(Surface &surface, int zoomLevel, int technology) {
- PLATFORM_ASSERT(fontName);
- sizeZoomed = size + zoomLevel * SC_FONT_SIZE_MULTIPLIER;
+void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs) {
+ PLATFORM_ASSERT(fs.fontName);
+ sizeZoomed = fs.size + zoomLevel * SC_FONT_SIZE_MULTIPLIER;
if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1
sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
float deviceHeight = surface.DeviceHeightFont(sizeZoomed);
- FontParameters fp(fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, weight, italic, extraFontFlag, technology, characterSet);
+ FontParameters fp(fs.fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, fs.weight, fs.italic, fs.extraFontFlag, technology, fs.characterSet);
font.Create(fp);
ascent = surface.Ascent(font);
descent = surface.Descent(font);
aveCharWidth = surface.AverageCharWidth(font);
spaceWidth = surface.WidthChar(font, ' ');
- if (frNext) {
- frNext->Realise(surface, zoomLevel, technology);
- }
-}
-
-FontRealised *FontRealised::Find(const FontSpecification &fs) {
- if (!fs.fontName)
- return this;
- FontRealised *fr = this;
- while (fr) {
- if (fr->EqualTo(fs))
- return fr;
- fr = fr->frNext;
- }
- return 0;
-}
-
-void FontRealised::FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent) {
- FontRealised *fr = this;
- while (fr) {
- if (maxAscent < fr->ascent)
- maxAscent = fr->ascent;
- if (maxDescent < fr->descent)
- maxDescent = fr->descent;
- fr = fr->frNext;
- }
}
ViewStyle::ViewStyle() {
@@ -134,9 +86,8 @@ ViewStyle::ViewStyle() { }
ViewStyle::ViewStyle(const ViewStyle &source) {
- frFirst = NULL;
- Init(source.stylesSize);
- for (unsigned int sty=0; sty<source.stylesSize; sty++) {
+ Init(source.styles.size());
+ for (unsigned int sty=0; sty<source.styles.size(); sty++) {
styles[sty] = source.styles[sty];
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
@@ -218,16 +169,14 @@ ViewStyle::ViewStyle(const ViewStyle &source) { }
ViewStyle::~ViewStyle() {
- delete []styles;
- styles = NULL;
- delete frFirst;
- frFirst = NULL;
+ styles.clear();
+ for (FontMap::iterator it = fonts.begin(); it != fonts.end(); ++it) {
+ delete it->second;
+ }
+ fonts.clear();
}
void ViewStyle::Init(size_t stylesSize_) {
- frFirst = NULL;
- stylesSize = 0;
- styles = NULL;
AllocStyles(stylesSize_);
nextExtendedStyle = 256;
fontNames.Clear();
@@ -334,52 +283,42 @@ void ViewStyle::Init(size_t stylesSize_) { braceBadLightIndicator = 0;
}
-void ViewStyle::CreateFont(const FontSpecification &fs) {
- if (fs.fontName) {
- for (FontRealised *cur=frFirst; cur; cur=cur->frNext) {
- if (cur->EqualTo(fs))
- return;
- if (!cur->frNext) {
- cur->frNext = new FontRealised(fs);
- return;
- }
- }
- frFirst = new FontRealised(fs);
+void ViewStyle::Refresh(Surface &surface) {
+ for (FontMap::iterator it = fonts.begin(); it != fonts.end(); ++it) {
+ delete it->second;
}
-}
+ fonts.clear();
-void ViewStyle::Refresh(Surface &surface) {
- delete frFirst;
- frFirst = NULL;
selbar = Platform::Chrome();
selbarlight = Platform::ChromeHighlight();
- for (unsigned int i=0; i<stylesSize; i++) {
+ for (unsigned int i=0; i<styles.size(); i++) {
styles[i].extraFontFlag = extraFontFlag;
}
CreateFont(styles[STYLE_DEFAULT]);
- for (unsigned int j=0; j<stylesSize; j++) {
+ for (unsigned int j=0; j<styles.size(); j++) {
CreateFont(styles[j]);
}
- assert(frFirst);
- frFirst->Realise(surface, zoomLevel, technology);
+ for (FontMap::iterator it = fonts.begin(); it != fonts.end(); ++it) {
+ it->second->Realise(surface, zoomLevel, technology, it->first);
+ }
- for (unsigned int k=0; k<stylesSize; k++) {
- FontRealised *fr = frFirst->Find(styles[k]);
+ for (unsigned int k=0; k<styles.size(); k++) {
+ FontRealised *fr = Find(styles[k]);
styles[k].Copy(fr->font, *fr);
}
maxAscent = 1;
maxDescent = 1;
- frFirst->FindMaxAscentDescent(maxAscent, maxDescent);
+ FindMaxAscentDescent(maxAscent, maxDescent);
maxAscent += extraAscent;
maxDescent += extraDescent;
lineHeight = maxAscent + maxDescent;
someStylesProtected = false;
someStylesForceCase = false;
- for (unsigned int l=0; l<stylesSize; l++) {
+ for (unsigned int l=0; l<styles.size(); l++) {
if (styles[l].IsProtected()) {
someStylesProtected = true;
}
@@ -401,25 +340,6 @@ void ViewStyle::Refresh(Surface &surface) { textStart = marginInside ? fixedColumnWidth : leftMarginWidth;
}
-void ViewStyle::AllocStyles(size_t sizeNew) {
- Style *stylesNew = new Style[sizeNew];
- size_t i=0;
- for (; i<stylesSize; i++) {
- stylesNew[i] = styles[i];
- stylesNew[i].fontName = styles[i].fontName;
- }
- if (stylesSize > STYLE_DEFAULT) {
- for (; i<sizeNew; i++) {
- if (i != STYLE_DEFAULT) {
- stylesNew[i].ClearTo(styles[STYLE_DEFAULT]);
- }
- }
- }
- delete []styles;
- styles = stylesNew;
- stylesSize = sizeNew;
-}
-
void ViewStyle::ReleaseAllExtendedStyles() {
nextExtendedStyle = 256;
}
@@ -431,11 +351,8 @@ int ViewStyle::AllocateExtendedStyles(int numberStyles) { }
void ViewStyle::EnsureStyle(size_t index) {
- if (index >= stylesSize) {
- size_t sizeNew = stylesSize * 2;
- while (sizeNew <= index)
- sizeNew *= 2;
- AllocStyles(sizeNew);
+ if (index >= styles.size()) {
+ AllocStyles(index+1);
}
}
@@ -449,7 +366,7 @@ void ViewStyle::ResetDefaultStyle() { void ViewStyle::ClearStyles() {
// Reset all styles to be like the default style
- for (unsigned int i=0; i<stylesSize; i++) {
+ for (unsigned int i=0; i<styles.size(); i++) {
if (i != STYLE_DEFAULT) {
styles[i].ClearTo(styles[STYLE_DEFAULT]);
}
@@ -470,7 +387,7 @@ bool ViewStyle::ProtectionActive() const { }
bool ViewStyle::ValidStyle(size_t styleIndex) const {
- return styleIndex < stylesSize;
+ return styleIndex < styles.size();
}
void ViewStyle::CalcLargestMarkerHeight() {
@@ -488,3 +405,44 @@ void ViewStyle::CalcLargestMarkerHeight() { }
}
}
+
+void ViewStyle::AllocStyles(size_t sizeNew) {
+ size_t i=styles.size();
+ styles.resize(sizeNew);
+ if (styles.size() > STYLE_DEFAULT) {
+ for (; i<sizeNew; i++) {
+ if (i != STYLE_DEFAULT) {
+ styles[i].ClearTo(styles[STYLE_DEFAULT]);
+ }
+ }
+ }
+}
+
+void ViewStyle::CreateFont(const FontSpecification &fs) {
+ if (fs.fontName) {
+ FontMap::iterator it = fonts.find(fs);
+ if (it == fonts.end()) {
+ fonts[fs] = new FontRealised();
+ }
+ }
+}
+
+FontRealised *ViewStyle::Find(const FontSpecification &fs) {
+ if (!fs.fontName) // Invalid specification so return arbitrary object
+ return fonts.begin()->second;
+ FontMap::iterator it = fonts.find(fs);
+ if (it != fonts.end()) {
+ // Should always reach here since map was just set for all styles
+ return it->second;
+ }
+ return 0;
+}
+
+void ViewStyle::FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent) {
+ for (FontMap::const_iterator it = fonts.begin(); it != fonts.end(); ++it) {
+ if (maxAscent < it->second->ascent)
+ maxAscent = it->second->ascent;
+ if (maxDescent < it->second->descent)
+ maxDescent = it->second->descent;
+ }
+}
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h index 1830ae8..2288a64 100644 --- a/scintilla/src/ViewStyle.h +++ b/scintilla/src/ViewStyle.h @@ -28,9 +28,7 @@ public: */
class FontNames {
private:
- char **names;
- int size;
- int max;
+ std::vector<char *> names;
// Private so FontNames objects can not be copied
FontNames(const FontNames &);
@@ -41,32 +39,30 @@ public: const char *Save(const char *name);
};
-class FontRealised : public FontSpecification, public FontMeasurements {
+class FontRealised : public FontMeasurements {
// Private so FontRealised objects can not be copied
FontRealised(const FontRealised &);
FontRealised &operator=(const FontRealised &);
public:
Font font;
- FontRealised *frNext;
- FontRealised(const FontSpecification &fs);
+ FontRealised();
virtual ~FontRealised();
- void Realise(Surface &surface, int zoomLevel, int technology);
- FontRealised *Find(const FontSpecification &fs);
- void FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent);
+ void Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs);
};
enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
+typedef std::map<FontSpecification, FontRealised *> FontMap;
+
/**
*/
class ViewStyle {
-public:
FontNames fontNames;
- FontRealised *frFirst;
- size_t stylesSize;
- Style *styles;
+ FontMap fonts;
+public:
+ std::vector<Style> styles;
size_t nextExtendedStyle;
LineMarker markers[MARKER_MAX + 1];
int largestMarkerHeight;
@@ -143,9 +139,7 @@ public: ViewStyle(const ViewStyle &source);
~ViewStyle();
void Init(size_t stylesSize_=64);
- void CreateFont(const FontSpecification &fs);
void Refresh(Surface &surface);
- void AllocStyles(size_t sizeNew);
void ReleaseAllExtendedStyles();
int AllocateExtendedStyles(int numberStyles);
void EnsureStyle(size_t index);
@@ -155,6 +149,13 @@ public: bool ProtectionActive() const;
bool ValidStyle(size_t styleIndex) const;
void CalcLargestMarkerHeight();
+private:
+ void AllocStyles(size_t sizeNew);
+ void CreateFont(const FontSpecification &fs);
+ FontRealised *Find(const FontSpecification &fs);
+ void FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent);
+ // Private so can only be copied through copy constructor which ensures font names initialised correctly
+ ViewStyle &operator=(const ViewStyle &);
};
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/XPM.cxx b/scintilla/src/XPM.cxx index 02b2f32..59fa2c2 100644 --- a/scintilla/src/XPM.cxx +++ b/scintilla/src/XPM.cxx @@ -41,12 +41,8 @@ static size_t MeasureLength(const char *s) { return i;
}
-ColourDesired XPM::ColourDesiredFromCode(int ch) const {
- return *colourCodeTable[ch];
-}
-
ColourDesired XPM::ColourFromCode(int ch) const {
- return *colourCodeTable[ch];
+ return colourCodeTable[ch];
}
void XPM::FillRun(Surface *surface, int code, int startX, int y, int x) {
@@ -56,13 +52,11 @@ void XPM::FillRun(Surface *surface, int code, int startX, int y, int x) { }
}
-XPM::XPM(const char *textForm) :
- data(0), codes(0), colours(0), lines(0) {
+XPM::XPM(const char *textForm) {
Init(textForm);
}
-XPM::XPM(const char *const *linesForm) :
- data(0), codes(0), colours(0), lines(0) {
+XPM::XPM(const char *const *linesForm) {
Init(linesForm);
}
@@ -76,10 +70,9 @@ void XPM::Init(const char *textForm) { // if memcmp implemented strangely. Must be 4 bytes at least at destination.
if ((0 == memcmp(textForm, "/* X", 4)) && (0 == memcmp(textForm, "/* XPM */", 9))) {
// Build the lines form out of the text form
- const char **linesForm = LinesFormFromTextForm(textForm);
- if (linesForm != 0) {
- Init(linesForm);
- delete []linesForm;
+ std::vector<const char *> linesForm = LinesFormFromTextForm(textForm);
+ if (!linesForm.empty()) {
+ Init(&linesForm[0]);
}
} else {
// It is really in line form
@@ -92,18 +85,17 @@ void XPM::Init(const char *const *linesForm) { height = 1;
width = 1;
nColours = 1;
- data = NULL;
+ pixels.clear();
codeTransparent = ' ';
- codes = NULL;
- colours = NULL;
- lines = NULL;
if (!linesForm)
return;
+ std::fill(colourCodeTable, colourCodeTable+256, 0);
const char *line0 = linesForm[0];
width = atoi(line0);
line0 = NextField(line0);
height = atoi(line0);
+ pixels.resize(width*height);
line0 = NextField(line0);
nColours = atoi(line0);
line0 = NextField(line0);
@@ -111,56 +103,33 @@ void XPM::Init(const char *const *linesForm) { // Only one char per pixel is supported
return;
}
- codes = new char[nColours];
- colours = new ColourDesired[nColours];
-
- int strings = 1+height+nColours;
- lines = new char *[strings];
- size_t allocation = 0;
- for (int i=0; i<strings; i++) {
- allocation += MeasureLength(linesForm[i]) + 1;
- }
- data = new char[allocation];
- char *nextBit = data;
- for (int j=0; j<strings; j++) {
- lines[j] = nextBit;
- size_t len = MeasureLength(linesForm[j]);
- memcpy(nextBit, linesForm[j], len);
- nextBit += len;
- *nextBit++ = '\0';
- }
-
- for (int code=0; code<256; code++) {
- colourCodeTable[code] = 0;
- }
for (int c=0; c<nColours; c++) {
const char *colourDef = linesForm[c+1];
- codes[c] = colourDef[0];
+ int code = static_cast<unsigned char>(colourDef[0]);
colourDef += 4;
+ ColourDesired colour(0xff, 0xff, 0xff);
if (*colourDef == '#') {
- colours[c].Set(colourDef);
+ colour.Set(colourDef);
} else {
- colours[c] = ColourDesired(0xff, 0xff, 0xff);
- codeTransparent = codes[c];
+ codeTransparent = code;
}
- colourCodeTable[static_cast<unsigned char>(codes[c])] = &(colours[c]);
+ colourCodeTable[code] = colour;
+ }
+
+ for (int y=0; y<height; y++) {
+ const char *lform = linesForm[y+nColours+1];
+ size_t len = MeasureLength(lform);
+ for (size_t x = 0; x<len; x++)
+ pixels[y * width + x] = static_cast<unsigned char>(lform[x]);
}
}
void XPM::Clear() {
- delete []data;
- data = 0;
- delete []codes;
- codes = 0;
- delete []colours;
- colours = 0;
- delete []lines;
- lines = 0;
}
void XPM::Draw(Surface *surface, PRectangle &rc) {
- if (!data || !codes || !colours || !lines) {
+ if (pixels.empty()) {
return;
}
// Centre the pixmap
@@ -170,7 +139,7 @@ void XPM::Draw(Surface *surface, PRectangle &rc) { int prevCode = 0;
int xStartRun = 0;
for (int x=0; x<width; x++) {
- int code = lines[y+nColours+1][x];
+ int code = pixels[y * width + x];
if (code != prevCode) {
FillRun(surface, prevCode, startX + xStartRun, startY + y, startX + x);
xStartRun = x;
@@ -182,23 +151,23 @@ void XPM::Draw(Surface *surface, PRectangle &rc) { }
void XPM::PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const {
- if (!data || !codes || !colours || !lines || (x<0) || (x >= width) || (y<0) || (y >= height)) {
+ if (pixels.empty() || (x<0) || (x >= width) || (y<0) || (y >= height)) {
colour = 0;
transparent = true;
return;
}
- int code = lines[y+nColours+1][x];
+ int code = pixels[y * width + x];
transparent = code == codeTransparent;
if (transparent) {
colour = 0;
} else {
- colour = ColourDesiredFromCode(code).AsLong();
+ colour = ColourFromCode(code).AsLong();
}
}
-const char **XPM::LinesFormFromTextForm(const char *textForm) {
+std::vector<const char *> XPM::LinesFormFromTextForm(const char *textForm) {
// Build the lines form out of the text form
- const char **linesForm = 0;
+ std::vector<const char *> linesForm;
int countQuotes = 0;
int strings=1;
int j=0;
@@ -214,111 +183,23 @@ const char **XPM::LinesFormFromTextForm(const char *textForm) { line0 = NextField(line0);
// Add 1 line for each colour
strings += atoi(line0);
- linesForm = new const char *[strings];
- if (linesForm == 0) {
- break; // Memory error!
- }
}
if (countQuotes / 2 >= strings) {
break; // Bad height or number of colors!
}
if ((countQuotes & 1) == 0) {
- linesForm[countQuotes / 2] = textForm + j + 1;
+ linesForm.push_back(textForm + j + 1);
}
countQuotes++;
}
}
if (textForm[j] == '\0' || countQuotes / 2 > strings) {
// Malformed XPM! Height + number of colors too high or too low
- delete []linesForm;
- linesForm = 0;
+ linesForm.clear();
}
return linesForm;
}
-// In future, may want to minimize search time by sorting and using a binary search.
-
-XPMSet::XPMSet() : set(0), len(0), maximum(0), height(-1), width(-1) {
-}
-
-XPMSet::~XPMSet() {
- Clear();
-}
-
-void XPMSet::Clear() {
- for (int i = 0; i < len; i++) {
- delete set[i];
- }
- delete []set;
- set = 0;
- len = 0;
- maximum = 0;
- height = -1;
- width = -1;
-}
-
-void XPMSet::Add(int ident, const char *textForm) {
- // Invalidate cached dimensions
- height = -1;
- width = -1;
-
- // Replace if this id already present
- for (int i = 0; i < len; i++) {
- if (set[i]->GetId() == ident) {
- set[i]->Init(textForm);
- return;
- }
- }
-
- // Not present, so add to end
- XPM *pxpm = new XPM(textForm);
- if (pxpm) {
- pxpm->SetId(ident);
- if (len == maximum) {
- maximum += 64;
- XPM **setNew = new XPM *[maximum];
- for (int i = 0; i < len; i++) {
- setNew[i] = set[i];
- }
- delete []set;
- set = setNew;
- }
- set[len] = pxpm;
- len++;
- }
-}
-
-XPM *XPMSet::Get(int ident) {
- for (int i = 0; i < len; i++) {
- if (set[i]->GetId() == ident) {
- return set[i];
- }
- }
- return 0;
-}
-
-int XPMSet::GetHeight() {
- if (height < 0) {
- for (int i = 0; i < len; i++) {
- if (height < set[i]->GetHeight()) {
- height = set[i]->GetHeight();
- }
- }
- }
- return (height > 0) ? height : 0;
-}
-
-int XPMSet::GetWidth() {
- if (width < 0) {
- for (int i = 0; i < len; i++) {
- if (width < set[i]->GetWidth()) {
- width = set[i]->GetWidth();
- }
- }
- }
- return (width > 0) ? width : 0;
-}
-
RGBAImage::RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_) :
height(height_), width(width_), scale(scale_) {
if (pixels_) {
diff --git a/scintilla/src/XPM.h b/scintilla/src/XPM.h index 9ecb1d5..ddac02e 100644 --- a/scintilla/src/XPM.h +++ b/scintilla/src/XPM.h @@ -1,6 +1,6 @@ // Scintilla source code edit control
/** @file XPM.h
- ** Define a class that holds data in the X Pixmap (XPM) format.
+ ** Define a classes to hold image data in the X Pixmap (XPM) and RGBA formats.
**/
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
@@ -16,19 +16,14 @@ namespace Scintilla { * Hold a pixmap in XPM format.
*/
class XPM {
- int pid; // Assigned by container
int height;
int width;
int nColours;
- char *data;
+ std::vector<unsigned char> pixels;
+ ColourDesired colourCodeTable[256];
char codeTransparent;
- char *codes;
- ColourDesired *colours;
- ColourDesired ColourDesiredFromCode(int ch) const;
ColourDesired ColourFromCode(int ch) const;
void FillRun(Surface *surface, int code, int startX, int y, int x);
- char **lines;
- ColourDesired *colourCodeTable[256];
public:
XPM(const char *textForm);
XPM(const char *const *linesForm);
@@ -38,41 +33,15 @@ public: void Clear();
/// Decompose image into runs and use FillRectangle for each run
void Draw(Surface *surface, PRectangle &rc);
- char **InLinesForm() { return lines; }
- void SetId(int pid_) { pid = pid_; }
- int GetId() const { return pid; }
int GetHeight() const { return height; }
int GetWidth() const { return width; }
void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const;
- static const char **LinesFormFromTextForm(const char *textForm);
+private:
+ static std::vector<const char *>LinesFormFromTextForm(const char *textForm);
};
/**
- * A collection of pixmaps indexed by integer id.
- */
-class XPMSet {
- XPM **set; ///< The stored XPMs.
- int len; ///< Current number of XPMs.
- int maximum; ///< Current maximum number of XPMs, increased by steps if reached.
- int height; ///< Memorize largest height of the set.
- int width; ///< Memorize largest width of the set.
-public:
- XPMSet();
- ~XPMSet();
- /// Remove all XPMs.
- void Clear();
- /// Add a XPM.
- void Add(int ident, const char *textForm);
- /// Get XPM by id.
- XPM *Get(int ident);
- /// Give the largest height of the set.
- int GetHeight();
- /// Give the largest width of the set.
- int GetWidth();
-};
-
-/**
- * An translucent image stoed as a sequence of RGBA bytes.
+ * A translucent image stored as a sequence of RGBA bytes.
*/
class RGBAImage {
// Private so RGBAImage objects can not be copied
diff --git a/scintilla/version.txt b/scintilla/version.txt index 7f72ddf..1665c53 100644 --- a/scintilla/version.txt +++ b/scintilla/version.txt @@ -1 +1 @@ -330
+331
diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx index 0fb0951..027f299 100644 --- a/scintilla/win32/PlatWin.cxx +++ b/scintilla/win32/PlatWin.cxx @@ -369,6 +369,7 @@ FontCached::FontCached(const FontParameters &fp) : }
}
pTextLayout->Release();
+ pTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_UNIFORM, lineMetrics[0].height, lineMetrics[0].baseline);
}
fid = reinterpret_cast<void *>(new FormatAndMetrics(pTextFormat, fp.extraFontFlag, fp.characterSet, yAscent, yDescent, yInternalLeading));
}
@@ -406,11 +407,9 @@ FontID FontCached::FindOrCreate(const FontParameters &fp) { }
if (ret == 0) {
FontCached *fc = new FontCached(fp);
- if (fc) {
- fc->next = first;
- first = fc;
- ret = fc->fid;
- }
+ fc->next = first;
+ first = fc;
+ ret = fc->fid;
}
::LeaveCriticalSection(&crPlatformLock);
return ret;
@@ -859,7 +858,7 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig DIB_RGB_COLORS, reinterpret_cast<void **>(&image), NULL, 0);
if (hbmMem) {
HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem);
-
+
for (int y=height-1; y>=0; y--) {
for (int x=0; x<width; x++) {
unsigned char *pixel = image + (y*width+x) * 4;
@@ -871,7 +870,7 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig pixel[3] = static_cast<unsigned char>(*pixelsImage++);
}
}
-
+
BLENDFUNCTION merge = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
AlphaBlendFn(reinterpret_cast<HDC>(hdc), rc.left, rc.top, rc.Width(), rc.Height(), hMemDC, 0, 0, width, height, merge);
@@ -1338,7 +1337,7 @@ void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) { pBrush->SetColor(col);
} else {
HRESULT hr = pRenderTarget->CreateSolidColorBrush(col, &pBrush);
- if (!SUCCEEDED(hr) && pBrush) {
+ if (!SUCCEEDED(hr) && pBrush) {
pBrush->Release();
pBrush = 0;
}
@@ -1406,11 +1405,11 @@ void SurfaceD2D::LineTo(int x_, int y_) { pRenderTarget->FillRectangle(&rectangle1, pBrush);
} else if ((abs(xDiff) == abs(yDiff))) {
// 45 degree slope
- pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5, y + 0.5),
+ pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5, y + 0.5),
D2D1::Point2F(x_ + 0.5 - xDelta, y_ + 0.5 - yDelta), pBrush);
} else {
// Line has a different slope so difficult to avoid last pixel
- pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5, y + 0.5),
+ pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5, y + 0.5),
D2D1::Point2F(x_ + 0.5, y_ + 0.5), pBrush);
}
x = x_;
@@ -1491,15 +1490,15 @@ void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) { void SurfaceD2D::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) {
if (pRenderTarget) {
- D2D1_ROUNDED_RECT roundedRectFill = D2D1::RoundedRect(
+ D2D1_ROUNDED_RECT roundedRectFill = {
D2D1::RectF(rc.left+1.0, rc.top+1.0, rc.right-1.0, rc.bottom-1.0),
- 8, 8);
+ 8, 8};
D2DPenColour(back);
pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush);
- D2D1_ROUNDED_RECT roundedRect = D2D1::RoundedRect(
+ D2D1_ROUNDED_RECT roundedRect = {
D2D1::RectF(rc.left + 0.5, rc.top+0.5, rc.right - 0.5, rc.bottom-0.5),
- 8, 8);
+ 8, 8};
D2DPenColour(fore);
pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush);
}
@@ -1518,15 +1517,16 @@ void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil D2DPenColour(outline, alphaOutline);
pRenderTarget->DrawRectangle(rectOutline, pBrush);
} else {
- D2D1_ROUNDED_RECT roundedRectFill = D2D1::RoundedRect(
+ const float cornerSizeF = static_cast<float>(cornerSize);
+ D2D1_ROUNDED_RECT roundedRectFill = {
D2D1::RectF(RoundFloat(rc.left) + 1.0, rc.top + 1.0, RoundFloat(rc.right) - 1.0, rc.bottom - 1.0),
- cornerSize, cornerSize);
+ cornerSizeF, cornerSizeF};
D2DPenColour(fill, alphaFill);
pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush);
- D2D1_ROUNDED_RECT roundedRect = D2D1::RoundedRect(
+ D2D1_ROUNDED_RECT roundedRect = {
D2D1::RectF(RoundFloat(rc.left) + 0.5, rc.top + 0.5, RoundFloat(rc.right) - 0.5, rc.bottom - 0.5),
- cornerSize, cornerSize);
+ cornerSizeF, cornerSizeF};
D2DPenColour(outline, alphaOutline);
pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush);
}
@@ -1557,7 +1557,7 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig ID2D1Bitmap *bitmap = 0;
D2D1_SIZE_U size = D2D1::SizeU(width, height);
- D2D1_BITMAP_PROPERTIES props = {{DXGI_FORMAT_B8G8R8A8_UNORM,
+ D2D1_BITMAP_PROPERTIES props = {{DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_PREMULTIPLIED}, 72.0, 72.0};
HRESULT hr = pRenderTarget->CreateBitmap(size, &image[0],
width * 4, &props, &bitmap);
@@ -1572,9 +1572,9 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig void SurfaceD2D::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {
if (pRenderTarget) {
FLOAT radius = rc.Width() / 2.0f - 1.0f;
- D2D1_ELLIPSE ellipse = D2D1::Ellipse(
+ D2D1_ELLIPSE ellipse = {
D2D1::Point2F((rc.left + rc.right) / 2.0f, (rc.top + rc.bottom) / 2.0f),
- radius,radius);
+ radius,radius};
PenColour(back);
pRenderTarget->FillEllipse(ellipse, pBrush);
@@ -1593,7 +1593,7 @@ void SurfaceD2D::Copy(PRectangle rc, Point from, Surface &surfaceSource) { if (SUCCEEDED(hr)) {
D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom};
D2D1_RECT_F rcSource = {from.x, from.y, from.x + rc.Width(), from.y + rc.Height()};
- pRenderTarget->DrawBitmap(pBitmap, rcDestination, 1.0f,
+ pRenderTarget->DrawBitmap(pBitmap, rcDestination, 1.0f,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, rcSource);
pRenderTarget->Flush();
pBitmap->Release();
@@ -1610,8 +1610,8 @@ void SurfaceD2D::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, co D2D1_RECT_F rcClip = {rc.left, rc.top, rc.right, rc.bottom};
pRenderTarget->PushAxisAlignedClip(rcClip, D2D1_ANTIALIAS_MODE_ALIASED);
}
-
- // Explicitly creating a text layout appears a little faster
+
+ // Explicitly creating a text layout appears a little faster
IDWriteTextLayout *pTextLayout;
HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat,
rc.Width(), rc.Height(), &pTextLayout);
@@ -1810,7 +1810,7 @@ XYPOSITION SurfaceD2D::AverageCharWidth(Font &font_) { // Create a layout
IDWriteTextLayout *pTextLayout = 0;
const WCHAR wszAllAlpha[] = L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- HRESULT hr = pIDWriteFactory->CreateTextLayout(wszAllAlpha, static_cast<UINT32>(wcslen(wszAllAlpha)),
+ HRESULT hr = pIDWriteFactory->CreateTextLayout(wszAllAlpha, static_cast<UINT32>(wcslen(wszAllAlpha)),
pTextFormat, 1000.0, 1000.0, &pTextLayout);
if (SUCCEEDED(hr)) {
DWRITE_TEXT_METRICS textMetrics;
@@ -1906,7 +1906,7 @@ void Window::SetPositionRelative(PRectangle rc, Window w) { // If hMonitor is NULL, that's just the main screen anyways.
//::GetMonitorInfo(hMonitor, &mi);
RECT rcWork = RectFromMonitor(hMonitor);
-
+
if (rcWork.left < rcWork.right) {
// Now clamp our desired rectangle to fit inside the work area
// This way, the menu will fit wholly on one screen. An improvement even
@@ -2061,45 +2061,24 @@ struct ListItemData { int pixId;
};
-#define _ROUND2(n,pow2) \
- ( ( (n) + (pow2) - 1) & ~((pow2) - 1) )
-
class LineToItem {
- char *words;
- int wordsCount;
- int wordsSize;
+ std::vector<char> words;
- ListItemData *data;
- int len;
- int count;
-
-private:
- void FreeWords() {
- delete []words;
- words = NULL;
- wordsCount = 0;
- wordsSize = 0;
- }
- char *AllocWord(const char *word);
+ std::vector<ListItemData> data;
public:
- LineToItem() : words(NULL), wordsCount(0), wordsSize(0), data(NULL), len(0), count(0) {
+ LineToItem() {
}
~LineToItem() {
Clear();
}
void Clear() {
- FreeWords();
- delete []data;
- data = NULL;
- len = 0;
- count = 0;
+ words.clear();
+ data.clear();
}
- ListItemData *Append(const char *text, int value);
-
ListItemData Get(int index) const {
- if (index >= 0 && index < count) {
+ if (index >= 0 && index < static_cast<int>(data.size())) {
return data[index];
} else {
ListItemData missing = {"", -1};
@@ -2107,56 +2086,20 @@ public: }
}
int Count() const {
- return count;
+ return static_cast<int>(data.size());
}
- ListItemData *AllocItem();
+ void AllocItem(const char *text, int pixId) {
+ ListItemData lid = { text, pixId };
+ data.push_back(lid);
+ }
- void SetWords(char *s) {
- words = s; // N.B. will be deleted on destruction
+ char *SetWords(const char *s) {
+ words = std::vector<char>(s, s+strlen(s)+1);
+ return &words[0];
}
};
-char *LineToItem::AllocWord(const char *text) {
- int chars = static_cast<int>(strlen(text) + 1);
- int newCount = wordsCount + chars;
- if (newCount > wordsSize) {
- wordsSize = _ROUND2(newCount * 2, 8192);
- char *wordsNew = new char[wordsSize];
- memcpy(wordsNew, words, wordsCount);
- int offset = wordsNew - words;
- for (int i=0; i<count; i++)
- data[i].text += offset;
- delete []words;
- words = wordsNew;
- }
- char *s = &words[wordsCount];
- wordsCount = newCount;
- strncpy(s, text, chars);
- return s;
-}
-
-ListItemData *LineToItem::AllocItem() {
- if (count >= len) {
- int lenNew = _ROUND2((count+1) * 2, 1024);
- ListItemData *dataNew = new ListItemData[lenNew];
- memcpy(dataNew, data, count * sizeof(ListItemData));
- delete []data;
- data = dataNew;
- len = lenNew;
- }
- ListItemData *item = &data[count];
- count++;
- return item;
-}
-
-ListItemData *LineToItem::Append(const char *text, int imageIndex) {
- ListItemData *item = AllocItem();
- item->text = AllocWord(text);
- item->pixId = imageIndex;
- return item;
-}
-
const TCHAR ListBoxX_ClassName[] = TEXT("ListBoxX");
ListBox::ListBox() {
@@ -2189,7 +2132,7 @@ class ListBoxX : public ListBox { int wheelDelta; // mouse wheel residue
HWND GetHWND() const;
- void AppendListItem(const char *startword, const char *numword);
+ void AppendListItem(const char *text, const char *numword);
void AdjustWindowRect(PRectangle *rc) const;
int ItemHeight() const;
int MinClientWidth() const;
@@ -2364,16 +2307,9 @@ void ListBoxX::Clear() { lti.Clear();
}
-void ListBoxX::Append(char *s, int type) {
- int index = ::SendMessage(lb, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(s));
- if (index < 0)
- return;
- ListItemData *newItem = lti.Append(s, type);
- unsigned int len = static_cast<unsigned int>(strlen(s));
- if (maxItemCharacters < len) {
- maxItemCharacters = len;
- widestItem = newItem->text;
- }
+void ListBoxX::Append(char *, int) {
+ // This method is no longer called in Scintilla
+ PLATFORM_ASSERT(false);
}
int ListBoxX::Length() {
@@ -2506,24 +2442,21 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { }
}
-void ListBoxX::AppendListItem(const char *startword, const char *numword) {
- ListItemData *item = lti.AllocItem();
- item->text = startword;
+void ListBoxX::AppendListItem(const char *text, const char *numword) {
+ int pixId = -1;
if (numword) {
- int pixId = 0;
+ pixId = 0;
char ch;
while ((ch = *++numword) != '\0') {
pixId = 10 * pixId + (ch - '0');
}
- item->pixId = pixId;
- } else {
- item->pixId = -1;
}
- unsigned int len = static_cast<unsigned int>(strlen(item->text));
+ lti.AllocItem(text, pixId);
+ unsigned int len = static_cast<unsigned int>(strlen(text));
if (maxItemCharacters < len) {
maxItemCharacters = len;
- widestItem = item->text;
+ widestItem = text;
}
}
@@ -2533,9 +2466,7 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) { SetRedraw(false);
Clear();
size_t size = strlen(list);
- char *words = new char[size+1];
- lti.SetWords(words);
- memcpy(words, list, size+1);
+ char *words = lti.SetWords(list);
char *startword = words;
char *numword = NULL;
for (size_t i=0; i < size; i++) {
diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index 76b387b..24c5364 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -425,10 +425,21 @@ void ScintillaWin::EnsureRenderTarget() { // Create a Direct2D render target.
#if 1
- pD2DFactory->CreateHwndRenderTarget(
- D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(), 96.0, 96.0),
- D2D1::HwndRenderTargetProperties(hw, size),
- &pRenderTarget);
+ D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp;
+ dhrtp.hwnd = hw;
+ dhrtp.pixelSize = size;
+ dhrtp.presentOptions = D2D1_PRESENT_OPTIONS_NONE;
+
+ D2D1_RENDER_TARGET_PROPERTIES drtp;
+ drtp.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
+ drtp.pixelFormat.format = DXGI_FORMAT_UNKNOWN;
+ drtp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_UNKNOWN;
+ drtp.dpiX = 96.0;
+ drtp.dpiY = 96.0;
+ drtp.usage = D2D1_RENDER_TARGET_USAGE_NONE;
+ drtp.minLevel = D2D1_FEATURE_LEVEL_DEFAULT;
+
+ pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pRenderTarget);
#else
pD2DFactory->CreateHwndRenderTarget(
D2D1::RenderTargetProperties(
@@ -569,29 +580,30 @@ LRESULT ScintillaWin::WndPaint(uptr_t wParam) { pps = &ps;
::BeginPaint(MainHWND(), pps);
}
+ rcPaint = PRectangle(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom);
+ PRectangle rcClient = GetClientRectangle();
+ paintingAllText = rcPaint.Contains(rcClient);
if (technology == SC_TECHNOLOGY_DEFAULT) {
AutoSurface surfaceWindow(pps->hdc, this);
if (surfaceWindow) {
- rcPaint = PRectangle(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom);
- PRectangle rcClient = GetClientRectangle();
- paintingAllText = rcPaint.Contains(rcClient);
Paint(surfaceWindow, rcPaint);
surfaceWindow->Release();
}
} else {
#if defined(USE_D2D)
- EnsureRenderTarget();
- AutoSurface surfaceWindow(pRenderTarget, this);
- if (surfaceWindow) {
- pRenderTarget->BeginDraw();
- rcPaint = PRectangle(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom);
- PRectangle rcClient = GetClientRectangle();
- paintingAllText = rcPaint.Contains(rcClient);
- Paint(surfaceWindow, rcPaint);
- surfaceWindow->Release();
- HRESULT hr = pRenderTarget->EndDraw();
- if (hr == D2DERR_RECREATE_TARGET) {
- DropRenderTarget();
+ for (int attempt=0;attempt<2;attempt++) {
+ EnsureRenderTarget();
+ AutoSurface surfaceWindow(pRenderTarget, this);
+ if (surfaceWindow) {
+ pRenderTarget->BeginDraw();
+ Paint(surfaceWindow, rcPaint);
+ surfaceWindow->Release();
+ HRESULT hr = pRenderTarget->EndDraw();
+ if (hr == D2DERR_RECREATE_TARGET) {
+ DropRenderTarget();
+ } else {
+ break;
+ }
}
}
#endif
@@ -694,7 +706,7 @@ UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) { }
switch (characterSet) {
case SC_CHARSET_ANSI: return 1252;
- case SC_CHARSET_DEFAULT: return 0;
+ case SC_CHARSET_DEFAULT: return documentCodePage;
case SC_CHARSET_BALTIC: return 1257;
case SC_CHARSET_CHINESEBIG5: return 950;
case SC_CHARSET_EASTEUROPE: return 1250;
@@ -780,7 +792,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam ::SendMessage(hWnd, iMessage, wParam, lParam);
break;
}
-
+
// Don't handle datazoom.
// (A good idea for datazoom would be to "fold" or "unfold" details.
// i.e. if datazoomed out only class structures are visible, when datazooming in the control
@@ -1167,7 +1179,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case SCI_GETKEYSUNICODE:
return keysAlwaysUnicode;
-
+
case SCI_SETTECHNOLOGY:
if ((wParam == SC_TECHNOLOGY_DEFAULT) || (wParam == SC_TECHNOLOGY_DIRECTWRITE)) {
if (technology != static_cast<int>(wParam)) {
@@ -1721,11 +1733,12 @@ void ScintillaWin::InsertPasteText(const char *text, int len, SelectionPosition if (isRectangular) {
PasteRectangular(selStart, text, len);
} else {
- char *convertedText = 0;
+ std::string convertedText;
if (convertPastes) {
// Convert line endings of the paste into our local line-endings mode
- convertedText = Document::TransformLineEnds(&len, text, len, pdoc->eolMode);
- text = convertedText;
+ convertedText = Document::TransformLineEnds(text, len, pdoc->eolMode);
+ len = static_cast<int>(convertedText.length());
+ text = convertedText.c_str();
}
if (isLine) {
int insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()));
@@ -1742,7 +1755,6 @@ void ScintillaWin::InsertPasteText(const char *text, int len, SelectionPosition } else {
InsertPaste(selStart, text, len);
}
- delete []convertedText;
}
}
@@ -1763,26 +1775,25 @@ void ScintillaWin::Paste() { wchar_t *uptr = static_cast<wchar_t *>(memUSelection.ptr);
if (uptr) {
unsigned int len;
- char *putf;
+ std::vector<char> putf;
// Default Scintilla behaviour in Unicode mode
if (IsUnicodeMode()) {
unsigned int bytes = memUSelection.Size();
len = UTF8Length(uptr, bytes / 2);
- putf = new char[len + 1];
- UTF8FromUTF16(uptr, bytes / 2, putf, len);
+ putf.resize(len + 1);
+ UTF8FromUTF16(uptr, bytes / 2, &putf[0], len);
} else {
// CF_UNICODETEXT available, but not in Unicode mode
// Convert from Unicode to current Scintilla code page
UINT cpDest = CodePageOfDocument();
len = ::WideCharToMultiByte(cpDest, 0, uptr, -1,
NULL, 0, NULL, NULL) - 1; // subtract 0 terminator
- putf = new char[len + 1];
+ putf.resize(len + 1);
::WideCharToMultiByte(cpDest, 0, uptr, -1,
- putf, len + 1, NULL, NULL);
+ &putf[0], len + 1, NULL, NULL);
}
- InsertPasteText(putf, len, selStart, isRectangular, isLine);
- delete []putf;
+ InsertPasteText(&putf[0], len, selStart, isRectangular, isLine);
}
memUSelection.Unlock();
} else {
@@ -1800,24 +1811,17 @@ void ScintillaWin::Paste() { // In Unicode mode, convert clipboard text to UTF-8
if (IsUnicodeMode()) {
- wchar_t *uptr = new wchar_t[len+1];
+ std::vector<wchar_t> uptr(len+1);
unsigned int ulen = ::MultiByteToWideChar(CP_ACP, 0,
- ptr, len, uptr, len+1);
+ ptr, len, &uptr[0], len+1);
- unsigned int mlen = UTF8Length(uptr, ulen);
- char *putf = new char[mlen + 1];
- if (putf) {
+ 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, ulen, putf, mlen);
- }
-
- delete []uptr;
+ UTF8FromUTF16(&uptr[0], ulen, &putf[0], mlen);
- if (putf) {
- InsertPasteText(putf, mlen, selStart, isRectangular, isLine);
- delete []putf;
- }
+ InsertPasteText(&putf[0], mlen, selStart, isRectangular, isLine);
} else {
InsertPasteText(ptr, len, selStart, isRectangular, isLine);
}
@@ -2556,21 +2560,20 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, STGMEDIUM medium = {0, {0}, 0};
- char *data = 0;
- bool dataAllocated = false;
+ std::vector<char> data; // Includes terminating NUL
FORMATETC fmtu = {CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
HRESULT hr = pIDataSource->GetData(&fmtu, &medium);
if (SUCCEEDED(hr) && medium.hGlobal) {
- wchar_t *udata = static_cast<wchar_t *>(::GlobalLock(medium.hGlobal));
+ GlobalMemory memUDrop(medium.hGlobal);
+ wchar_t *udata = static_cast<wchar_t *>(memUDrop.ptr);
if (udata) {
if (IsUnicodeMode()) {
- int tlen = ::GlobalSize(medium.hGlobal);
+ int tlen = memUDrop.Size();
// Convert UTF-16 to UTF-8
int dataLen = UTF8Length(udata, tlen/2);
- data = new char[dataLen+1];
- UTF8FromUTF16(udata, tlen/2, data, dataLen);
- dataAllocated = true;
+ data.resize(dataLen+1);
+ UTF8FromUTF16(udata, tlen/2, &data[0], dataLen);
} else {
// Convert UTF-16 to ANSI
//
@@ -2580,34 +2583,31 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, UINT cpDest = CodePageOfDocument();
int tlen = ::WideCharToMultiByte(cpDest, 0, udata, -1,
NULL, 0, NULL, NULL) - 1; // subtract 0 terminator
- data = new char[tlen + 1];
- memset(data, 0, (tlen+1));
+ data.resize(tlen + 1);
::WideCharToMultiByte(cpDest, 0, udata, -1,
- data, tlen + 1, NULL, NULL);
- dataAllocated = true;
+ &data[0], tlen + 1, NULL, NULL);
}
}
- }
-
- if (!data) {
+ memUDrop.Unlock();
+ } else {
FORMATETC fmte = {CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
hr = pIDataSource->GetData(&fmte, &medium);
if (SUCCEEDED(hr) && medium.hGlobal) {
- data = static_cast<char *>(::GlobalLock(medium.hGlobal));
+ GlobalMemory memDrop(medium.hGlobal);
+ const char *cdata = static_cast<char *>(memDrop.ptr);
+ if (cdata)
+ data.assign(cdata, cdata+strlen(cdata)+1);
+ memDrop.Unlock();
}
}
- if (data && convertPastes) {
+ if (!data.empty() && convertPastes) {
// Convert line endings of the drop into our local line-endings mode
- int len = static_cast<int>(strlen(data));
- char *convertedText = Document::TransformLineEnds(&len, data, len, pdoc->eolMode);
- if (dataAllocated)
- delete []data;
- data = convertedText;
- dataAllocated = true;
+ std::string convertedText = Document::TransformLineEnds(&data[0], data.size() - 1, pdoc->eolMode);
+ data.assign(convertedText.c_str(), convertedText.c_str()+convertedText.length()+1);
}
- if (!data) {
+ if (data.empty()) {
//Platform::DebugPrintf("Bad data format: 0x%x\n", hres);
return hr;
}
@@ -2619,9 +2619,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, ::ScreenToClient(MainHWND(), &rpt);
SelectionPosition movePos = SPositionFromLocation(Point(rpt.x, rpt.y), false, false, UserVirtualSpace());
- DropAt(movePos, data, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK);
-
- ::GlobalUnlock(medium.hGlobal);
+ DropAt(movePos, &data[0], *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK);
// Free data
if (medium.pUnkForRelease != NULL)
@@ -2629,9 +2627,6 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, else
::GlobalFree(medium.hGlobal);
- if (dataAllocated)
- delete []data;
-
return S_OK;
} catch (...) {
errorStatus = SC_STATUS_FAILURE;
@@ -2762,11 +2757,9 @@ BOOL ScintillaWin::CreateSystemCaret() { sysCaretHeight = vs.lineHeight;
int bitmapSize = (((sysCaretWidth + 15) & ~15) >> 3) *
sysCaretHeight;
- char *bits = new char[bitmapSize];
- memset(bits, 0, bitmapSize);
+ std::vector<char> bits(bitmapSize);
sysCaretBitmap = ::CreateBitmap(sysCaretWidth, sysCaretHeight, 1,
- 1, reinterpret_cast<BYTE *>(bits));
- delete []bits;
+ 1, reinterpret_cast<BYTE *>(&bits[0]));
BOOL retval = ::CreateCaret(
MainHWND(), sysCaretBitmap,
sysCaretWidth, sysCaretHeight);
@@ -2818,10 +2811,21 @@ sptr_t PASCAL ScintillaWin::CTWndProc( surfaceWindow->Init(ps.hdc, hWnd);
} else {
#if defined(USE_D2D)
- pD2DFactory->CreateHwndRenderTarget(
- D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(), 96.0, 96.0),
- D2D1::HwndRenderTargetProperties(hWnd, D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top)),
- &pCTRenderTarget);
+ D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp;
+ dhrtp.hwnd = hWnd;
+ dhrtp.pixelSize = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top);
+ dhrtp.presentOptions = D2D1_PRESENT_OPTIONS_NONE;
+
+ D2D1_RENDER_TARGET_PROPERTIES drtp;
+ drtp.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
+ drtp.pixelFormat.format = DXGI_FORMAT_UNKNOWN;
+ drtp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_UNKNOWN;
+ drtp.dpiX = 96.0;
+ drtp.dpiY = 96.0;
+ drtp.usage = D2D1_RENDER_TARGET_USAGE_NONE;
+ drtp.minLevel = D2D1_FEATURE_LEVEL_DEFAULT;
+
+ pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pCTRenderTarget);
surfaceWindow->Init(pCTRenderTarget, hWnd);
pCTRenderTarget->BeginDraw();
#endif
|