summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2014-05-22 09:41:44 +0300
committerXhmikosR <xhmikosr@users.sourceforge.net>2014-05-22 10:22:24 +0300
commitf2a80f864fe05792b1f234aa3716f2cb89b3474e (patch)
tree4b604cc8f6c2ebbfbeb4546ff0cbece41170956a
parent12ee3c17590032a0e93654fb6fbdeb0972b4e113 (diff)
downloadnotepad2-mod-f2a80f864fe05792b1f234aa3716f2cb89b3474e.zip
notepad2-mod-f2a80f864fe05792b1f234aa3716f2cb89b3474e.tar.gz
notepad2-mod-f2a80f864fe05792b1f234aa3716f2cb89b3474e.tar.bz2
Update Scintilla to 3.4.2.
-rw-r--r--scintilla/cppcheck.suppress1
-rw-r--r--scintilla/doc/ScintillaDoc.html75
-rw-r--r--scintilla/doc/ScintillaDownload.html10
-rw-r--r--scintilla/doc/ScintillaHistory.html84
-rw-r--r--scintilla/doc/index.html10
-rw-r--r--scintilla/include/Platform.h24
-rw-r--r--scintilla/include/SciLexer.h13
-rw-r--r--scintilla/include/Scintilla.h5
-rw-r--r--scintilla/include/Scintilla.iface22
-rw-r--r--scintilla/lexers/LexCPP.cxx490
-rw-r--r--scintilla/lexers/LexCoffeeScript.cxx2
-rw-r--r--scintilla/lexers/LexDMIS.cxx355
-rw-r--r--scintilla/lexers/LexFortran.cxx2
-rw-r--r--scintilla/lexers/LexHTML.cxx8
-rw-r--r--scintilla/lexers/LexLua.cxx2
-rw-r--r--scintilla/lexers/LexPerl.cxx6
-rw-r--r--scintilla/lexers/LexRuby.cxx2
-rw-r--r--scintilla/lexlib/LexerModule.h2
-rw-r--r--scintilla/lexlib/PropSetSimple.cxx5
-rw-r--r--scintilla/scripts/ScintillaData.py11
-rw-r--r--scintilla/src/AutoComplete.h2
-rw-r--r--scintilla/src/CallTip.cxx63
-rw-r--r--scintilla/src/Catalogue.cxx1
-rw-r--r--scintilla/src/CharClassify.cxx5
-rw-r--r--scintilla/src/ContractionState.cxx4
-rw-r--r--scintilla/src/ContractionState.h1
-rw-r--r--scintilla/src/Document.cxx113
-rw-r--r--scintilla/src/Document.h20
-rw-r--r--scintilla/src/Editor.cxx1129
-rw-r--r--scintilla/src/Editor.h11
-rw-r--r--scintilla/src/Indicator.cxx72
-rw-r--r--scintilla/src/LineMarker.cxx168
-rw-r--r--scintilla/src/PositionCache.cxx19
-rw-r--r--scintilla/src/PositionCache.h2
-rw-r--r--scintilla/src/RESearch.cxx9
-rw-r--r--scintilla/src/ScintillaBase.cxx59
-rw-r--r--scintilla/src/Selection.cxx8
-rw-r--r--scintilla/src/Selection.h1
-rw-r--r--scintilla/src/ViewStyle.cxx8
-rw-r--r--scintilla/src/ViewStyle.h2
-rw-r--r--scintilla/src/XPM.cxx8
-rw-r--r--scintilla/version.txt2
-rw-r--r--scintilla/win32/PlatWin.cxx246
-rw-r--r--scintilla/win32/ScintillaWin.cxx220
44 files changed, 2140 insertions, 1162 deletions
diff --git a/scintilla/cppcheck.suppress b/scintilla/cppcheck.suppress
index 212afad..63aa750 100644
--- a/scintilla/cppcheck.suppress
+++ b/scintilla/cppcheck.suppress
@@ -25,6 +25,7 @@ variableScope:scintilla/lexers/LexNsis.cxx
variableScope:scintilla/lexers/LexOpal.cxx
variableScope:scintilla/lexers/LexOthers.cxx
variableScope:scintilla/lexers/LexPB.cxx
+noCopyConstructor:scintilla/lexers/LexPerl.cxx
variableScope:scintilla/lexers/LexPS.cxx
variableScope:scintilla/lexers/LexRuby.cxx
uninitMemberVar:scintilla/lexers/LexRuby.cxx
diff --git a/scintilla/doc/ScintillaDoc.html b/scintilla/doc/ScintillaDoc.html
index 081c460..5350e85 100644
--- a/scintilla/doc/ScintillaDoc.html
+++ b/scintilla/doc/ScintillaDoc.html
@@ -82,7 +82,7 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 22 January 2014 NH</p>
+ <p>Last edited 1 May 2014 NH</p>
<p>There is <a class="jump" href="Design.html">an overview of the internal design of
Scintilla</a>.<br />
@@ -100,6 +100,8 @@
How to implement a lexer in the container</a>.<br />
<a class="jump" href="http://sphere.sourceforge.net/flik/docs/scintilla-folding.html">
How to implement folding</a>.<br />
+ <a class="jump" href="https://bitbucket.org/StarFire/scintilla-doc/downloads/Scintilla-var'aq-Tutorial.pdf">
+ Beginner's Guide to lexing and folding</a>.<br />
The <a class="jump" href="SciCoding.html">coding style</a> used in Scintilla and SciTE is
worth following if you want to contribute code to Scintilla but is not compulsory.</p>
@@ -411,6 +413,7 @@
<a class="message" href="#SCI_ADDSTYLEDTEXT">SCI_ADDSTYLEDTEXT(int length, cell *s)</a><br />
<a class="message" href="#SCI_APPENDTEXT">SCI_APPENDTEXT(int length, const char *s)</a><br />
<a class="message" href="#SCI_INSERTTEXT">SCI_INSERTTEXT(int pos, const char *text)</a><br />
+ <a class="message" href="#SCI_CHANGEINSERTION">SCI_CHANGEINSERTION(int length, const char *text)</a><br />
<a class="message" href="#SCI_CLEARALL">SCI_CLEARALL</a><br />
<a class="message" href="#SCI_DELETERANGE">SCI_DELETERANGE(int pos, int deleteLength)</a><br />
<a class="message" href="#SCI_CLEARDOCUMENTSTYLE">SCI_CLEARDOCUMENTSTYLE</a><br />
@@ -544,6 +547,10 @@
the current position if <code>pos</code> is -1. If the current position is after the insertion point
then it is moved along with its surrounding text but no scrolling is performed.</p>
+ <p><b id="SCI_CHANGEINSERTION">SCI_CHANGEINSERTION(int length, const char *text)</b><br />
+ This may only be called from a <a class="message" href="#SC_MOD_INSERTCHECK">SC_MOD_INSERTCHECK</a>
+ notification handler and will change the text being inserted to that provided.</p>
+
<p><b id="SCI_CLEARALL">SCI_CLEARALL</b><br />
Unless the document is read-only, this deletes all the text.</p>
@@ -976,7 +983,7 @@ struct Sci_TextToFind {
If this property is set then when text is pasted any line ends are converted to match the document's
end of line mode as set with
<a class="message" href="#SCI_SETEOLMODE">SCI_SETEOLMODE</a>.
- Currently only changeable on Windows. On GTK+ pasted text is always converted.</p>
+ Defaults to true.</p>
<h2 id="ErrorHandling">Error handling</h2>
@@ -2208,7 +2215,7 @@ struct Sci_TextToFind {
baseline (its 'descent').
Space may be added to the maximum ascent (<code>SCI_SETEXTRAASCENT</code>) and the
maximum descent (<code>SCI_SETEXTRADESCENT</code>) to allow for more space between lines.
- This may done to make the text easier to read or to accomodate underlines or highlights.
+ This may done to make the text easier to read or to accommodate underlines or highlights.
</p>
<h2 id="Cursor">Cursor</h2>
@@ -5414,6 +5421,14 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<td align="left">display hexadecimal fold levels in line margin to aid debugging of
folding. The appearance of this feature may change in the future.</td>
</tr>
+
+ <tr>
+ <td align="left">SC_FOLDFLAG_LINESTATE</td>
+ <td align="left">128</td>
+
+ <td align="left">display hexadecimal line state in line margin to aid debugging of lexing and folding.
+ May not be used at the same time as <code>SC_FOLDFLAG_LEVELNUMBERS</code>.</td>
+ </tr>
</tbody>
</table>
@@ -6789,7 +6804,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MOD_INSERTTEXT</code></td>
- <td align="center">0x01</td>
+ <td align="right">0x01</td>
<td>Text has been inserted into the document.</td>
@@ -6799,7 +6814,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MOD_DELETETEXT</code></td>
- <td align="center">0x02</td>
+ <td align="right">0x02</td>
<td>Text has been removed from the document.</td>
@@ -6809,7 +6824,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MOD_CHANGESTYLE</code></td>
- <td align="center">0x04</td>
+ <td align="right">0x04</td>
<td>A style change has occurred.</td>
@@ -6819,7 +6834,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MOD_CHANGEFOLD</code></td>
- <td align="center">0x08</td>
+ <td align="right">0x08</td>
<td>A folding change has occurred.</td>
@@ -6829,7 +6844,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_PERFORMED_USER</code></td>
- <td align="center">0x10</td>
+ <td align="right">0x10</td>
<td>Information: the operation was done by the user.</td>
@@ -6839,7 +6854,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_PERFORMED_UNDO</code></td>
- <td align="center">0x20</td>
+ <td align="right">0x20</td>
<td>Information: this was the result of an Undo.</td>
@@ -6849,7 +6864,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_PERFORMED_REDO</code></td>
- <td align="center">0x40</td>
+ <td align="right">0x40</td>
<td>Information: this was the result of a Redo.</td>
@@ -6859,7 +6874,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MULTISTEPUNDOREDO</code></td>
- <td align="center">0x80</td>
+ <td align="right">0x80</td>
<td>This is part of a multi-step Undo or Redo transaction.</td>
@@ -6869,7 +6884,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_LASTSTEPINUNDOREDO</code></td>
- <td align="center">0x100</td>
+ <td align="right">0x100</td>
<td>This is the final step in an Undo or Redo transaction.</td>
@@ -6879,7 +6894,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MOD_CHANGEMARKER</code></td>
- <td align="center">0x200</td>
+ <td align="right">0x200</td>
<td>One or more markers has changed in a line.</td>
@@ -6889,7 +6904,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MOD_BEFOREINSERT</code></td>
- <td align="center">0x400</td>
+ <td align="right">0x400</td>
<td>Text is about to be inserted into the document.</td>
@@ -6899,7 +6914,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MOD_BEFOREDELETE</code></td>
- <td align="center">0x800</td>
+ <td align="right">0x800</td>
<td>Text is about to be deleted from the document.</td>
@@ -6909,7 +6924,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MOD_CHANGEINDICATOR</code></td>
- <td align="center">0x4000</td>
+ <td align="right">0x4000</td>
<td>An indicator has been added or removed from a range of text.</td>
@@ -6919,7 +6934,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code id="SC_MOD_CHANGELINESTATE">SC_MOD_CHANGELINESTATE</code></td>
- <td align="center">0x8000</td>
+ <td align="right">0x8000</td>
<td>A line state has changed because <a class="message" href="#SCI_SETLINESTATE">SCI_SETLINESTATE</a>
was called.</td>
@@ -6930,7 +6945,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code id="SC_MOD_LEXERSTATE">SC_MOD_LEXERSTATE</code></td>
- <td align="center">0x80000</td>
+ <td align="right">0x80000</td>
<td>The internal state of a lexer has changed over a range.</td>
@@ -6940,7 +6955,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code id="SC_MOD_CHANGEMARGIN">SC_MOD_CHANGEMARGIN</code></td>
- <td align="center">0x10000</td>
+ <td align="right">0x10000</td>
<td>A text margin has changed.</td>
@@ -6950,7 +6965,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code id="SC_MOD_CHANGEANNOTATION">SC_MOD_CHANGEANNOTATION</code></td>
- <td align="center">0x20000</td>
+ <td align="right">0x20000</td>
<td>An annotation has changed.</td>
@@ -6958,9 +6973,21 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
</tr>
<tr>
+ <td align="left"><code id="SC_MOD_INSERTCHECK">SC_MOD_INSERTCHECK</code></td>
+
+ <td align="right">0x100000</td>
+
+ <td>Text is about to be inserted. The handler may change the text being inserted by calling
+ <a class="message" href="#SCI_CHANGEINSERTION">SCI_CHANGEINSERTION</a>.
+ No other modifications may be made in this handler.</td>
+
+ <td><code>position, length, text</code></td>
+ </tr>
+
+ <tr>
<td align="left"><code>SC_MULTILINEUNDOREDO</code></td>
- <td align="center">0x1000</td>
+ <td align="right">0x1000</td>
<td>This is part of an Undo or Redo with multi-line changes.</td>
@@ -6970,7 +6997,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_STARTACTION</code></td>
- <td align="center">0x2000</td>
+ <td align="right">0x2000</td>
<td>This is set on a SC_PERFORMED_USER action when it is the
first or only step in an undo transaction. This can be used to integrate the Scintilla
@@ -6985,7 +7012,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code id="SC_MOD_CONTAINER">SC_MOD_CONTAINER</code></td>
- <td align="center">0x40000</td>
+ <td align="right">0x40000</td>
<td>This is set on for actions that the container stored into the undo stack with
<a class="message" href="#SCI_ADDUNDOACTION"><code>SCI_ADDUNDOACTION</code></a>.
@@ -6997,7 +7024,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
<tr>
<td align="left"><code>SC_MODEVENTMASKALL</code></td>
- <td align="center">0x7FFFF</td>
+ <td align="right">0x1FFFFF</td>
<td>This is a mask for all valid flags. This is the default mask state set by <a
class="message" href="#SCI_SETMODEVENTMASK"><code>SCI_SETMODEVENTMASK</code></a>.</td>
diff --git a/scintilla/doc/ScintillaDownload.html b/scintilla/doc/ScintillaDownload.html
index 3f9e820..4143bd4 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/scintilla341.zip?download">
+ <font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla342.zip?download">
Windows</a>&nbsp;&nbsp;
- <a href="http://prdownloads.sourceforge.net/scintilla/scintilla341.tgz?download">
+ <a href="http://prdownloads.sourceforge.net/scintilla/scintilla342.tgz?download">
GTK+/Linux</a>&nbsp;&nbsp;
</font>
</td>
@@ -41,7 +41,7 @@
containing very few restrictions.
</p>
<h3>
- Release 3.4.1
+ Release 3.4.2
</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/scintilla341.zip?download">zip format</a> (1450K) commonly used on Windows</li>
- <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla341.tgz?download">tgz format</a> (1300K) commonly used on Linux and compatible operating systems</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla342.zip?download">zip format</a> (1450K) commonly used on Windows</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla342.tgz?download">tgz format</a> (1300K) commonly used on Linux and compatible operating systems</li>
</ul>
Instructions for building on both Windows and Linux are included in the readme file.
<h4>
diff --git a/scintilla/doc/ScintillaHistory.html b/scintilla/doc/ScintillaHistory.html
index a5eca67..50d69ea 100644
--- a/scintilla/doc/ScintillaHistory.html
+++ b/scintilla/doc/ScintillaHistory.html
@@ -447,6 +447,7 @@
<td>Mike M</td>
</tr><tr>
<td>nkmathew</td>
+ <td>Andreas Tscharner</td>
</tr>
</table>
<p>
@@ -459,6 +460,89 @@
</li>
</ul>
<h3>
+ <a href="http://prdownloads.sourceforge.net/scintilla/scite342.zip?download">Release 3.4.2</a>
+ </h3>
+ <ul>
+ <li>
+ Released 22 May 2014.
+ </li>
+ <li>
+ Insertions can be filtered or modified by calling SCI_CHANGEINSERTION inside a handler for
+ SC_MOD_INSERTCHECK.
+ </li>
+ <li>
+ DMIS lexer added. DMIS is a language for coordinate measuring machines.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1049/">Feature #1049.</a>
+ </li>
+ <li>
+ Line state may be displayed in the line number margin to aid in debugging lexing and folding with
+ SC_FOLDFLAG_LINESTATE (128).
+ </li>
+ <li>
+ C++ lexer understands more preprocessor statements. #if defined SYMBOL is understood.
+ Some macros with arguments can be understood and these may be predefined in keyword set 4
+ (keywords5 for SciTE)
+ with syntax similar to CHECKVERSION(x)=(x&lt;3).
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1051/">Feature #1051.</a>
+ </li>
+ <li>
+ C++ lexer can highlight task marker keywords in comments as SCE_C_TASKMARKER.
+ </li>
+ <li>
+ C++ lexer can optionally highlight escape sequences in strings as SCE_C_ESCAPESEQUENCE.
+ </li>
+ <li>
+ C++ lexer supports Go back quoted raw string literals with lexer.cpp.backquoted.strings option.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1047/">Feature #1047.</a>
+ </li>
+ <li>
+ SciTE performs word and search match highlighting as an idle task to improve interactivity
+ and allow use of these features on large files.
+ </li>
+ <li>
+ Bug fixed on Cocoa where previous caret lines were visible.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1593/">Bug #1593</a>.
+ </li>
+ <li>
+ Bug fixed where caret remained invisible when period set to 0.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1592/">Bug #1592</a>.
+ </li>
+ <li>
+ Fixed display flashing when scrolling with GTK+ 3.10.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1567/">Bug #1567</a>.
+ </li>
+ <li>
+ Fixed calls and constants deprecated in GTK+ 3.10.
+ </li>
+ <li>
+ Fixed bug on Windows where WM_GETTEXT did not provide data in UTF-16 for Unicode window.
+ <a href="http://sourceforge.net/p/scintilla/bugs/685/">Bug #685</a>.
+ </li>
+ <li>
+ For SciTE, protect access to variables used by threads with a mutex to prevent data races.
+ </li>
+ <li>
+ For SciTE on GTK+ fix thread object leaks.
+ Display the version of GTK+ compiled against in the about box.
+ </li>
+ <li>
+ For SciTE on GTK+ 3.10, fix the size of the tab bar's content and use
+ freedesktop.org standard icon names where possible.
+ </li>
+ <li>
+ For SciTE on Windows, fix bug where invoking help resubmitted the
+ running program.
+ <a href="http://sourceforge.net/p/scintilla/bugs/272/">Bug #272</a>.
+ </li>
+ <li>
+ SciTE's highlight current word feature no longer matches the selection when it contains space.
+ </li>
+ <li>
+ For building SciTE in Visual C++, the win\SciTE.vcxproj project file should be used.
+ The boundscheck directory and its project and solution files have been removed.
+ </li>
+ </ul>
+ <h3>
<a href="http://prdownloads.sourceforge.net/scintilla/scite341.zip?download">Release 3.4.1</a>
</h3>
<ul>
diff --git a/scintilla/doc/index.html b/scintilla/doc/index.html
index 9115851..c319e5a 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="20140401" />
+ <meta name="Date.Modified" content="20140522" />
<style type="text/css">
#versionlist {
margin: 0;
@@ -55,8 +55,8 @@
GTK+, and OS X</font>
</td>
<td width="40%" align="right">
- <font color="#FFCC99" size="3"> Release version 3.4.1<br />
- Site last modified April 1 2014</font>
+ <font color="#FFCC99" size="3"> Release version 3.4.2<br />
+ Site last modified May 22 2014</font>
</td>
<td width="20%">
&nbsp;
@@ -71,11 +71,9 @@
</tr>
</table>
<ul id="versionlist">
+ <li>Version 3.4.2 allows the application to filter input from typing, paste, drag &amp; drop and similar.</li>
<li>Version 3.4.1 fixes a regression in 3.4.0 that stopped the caret moving when lines were wrapped.</li>
<li>Version 3.4.0 finalises the Unicode line ends and substyles features provisionally added in 3.2.5.</li>
- <li>Version 3.3.9 fixes a bug in 3.3.8 that caused external lexers to fail.</li>
- <li>Version 3.3.8 improves drawing quality and enhances lexers.</li>
- <li>Version 3.3.7 uses responsive scrolling on OS X 10.9, enhances lexers, and fixes bugs.</li>
</ul>
<ul id="menu">
<li id="remote1"><a href="http://www.scintilla.org/SciTEImage.html">Screenshot</a></li>
diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h
index df7728d..83fc9ed 100644
--- a/scintilla/include/Platform.h
+++ b/scintilla/include/Platform.h
@@ -77,7 +77,9 @@ namespace Scintilla {
typedef float XYPOSITION;
typedef double XYACCUMULATOR;
-//#define XYPOSITION int
+inline int RoundXYPosition(XYPOSITION xyPos) {
+ return int(xyPos + 0.5);
+}
// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
@@ -92,7 +94,7 @@ typedef void *IdlerID;
/**
* A geometric point class.
- * Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably.
+ * Point is similar to the Win32 POINT and GTK+ GdkPoint types.
*/
class Point {
public:
@@ -102,6 +104,10 @@ public:
explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) {
}
+ static Point FromInts(int x_, int y_) {
+ return Point(static_cast<XYPOSITION>(x_), static_cast<XYPOSITION>(y_));
+ }
+
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
static Point FromLong(long lpoint);
@@ -109,7 +115,7 @@ public:
/**
* A geometric rectangle class.
- * PRectangle is exactly the same as the Win32 RECT so can be used interchangeably.
+ * PRectangle is similar to the Win32 RECT.
* PRectangles contain their top and left sides, but not their right and bottom sides.
*/
class PRectangle {
@@ -119,10 +125,15 @@ public:
XYPOSITION right;
XYPOSITION bottom;
- PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
+ explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
left(left_), top(top_), right(right_), bottom(bottom_) {
}
+ static PRectangle FromInts(int left_, int top_, int right_, int bottom_) {
+ return PRectangle(static_cast<XYPOSITION>(left_), static_cast<XYPOSITION>(top_),
+ static_cast<XYPOSITION>(right_), static_cast<XYPOSITION>(bottom_));
+ }
+
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
bool operator==(PRectangle &rc) const {
@@ -516,11 +527,6 @@ public:
}
#endif
-// Shut up annoying Visual C++ warnings:
-#ifdef _MSC_VER
-#pragma warning(disable: 4244 4309 4514 4710)
-#endif
-
#if defined(__GNUC__) && defined(SCINTILLA_QT)
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
diff --git a/scintilla/include/SciLexer.h b/scintilla/include/SciLexer.h
index 67b40d4..e347b20 100644
--- a/scintilla/include/SciLexer.h
+++ b/scintilla/include/SciLexer.h
@@ -126,6 +126,7 @@
#define SCLEX_RUST 111
#define SCLEX_DMAP 112
#define SCLEX_AS 113
+#define SCLEX_DMIS 114
#define SCLEX_AHK 200
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
@@ -170,6 +171,8 @@
#define SCE_C_PREPROCESSORCOMMENT 23
#define SCE_C_PREPROCESSORCOMMENTDOC 24
#define SCE_C_USERLITERAL 25
+#define SCE_C_TASKMARKER 26
+#define SCE_C_ESCAPESEQUENCE 27
#define SCE_D_DEFAULT 0
#define SCE_D_COMMENT 1
#define SCE_D_COMMENTLINE 2
@@ -1722,6 +1725,16 @@
#define SCE_DMAP_WORD 8
#define SCE_DMAP_WORD2 9
#define SCE_DMAP_WORD3 10
+#define SCE_DMIS_DEFAULT 0
+#define SCE_DMIS_COMMENT 1
+#define SCE_DMIS_STRING 2
+#define SCE_DMIS_NUMBER 3
+#define SCE_DMIS_KEYWORD 4
+#define SCE_DMIS_MAJORWORD 5
+#define SCE_DMIS_MINORWORD 6
+#define SCE_DMIS_UNSUPPORTED_MAJOR 7
+#define SCE_DMIS_UNSUPPORTED_MINOR 8
+#define SCE_DMIS_LABEL 9
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif
diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h
index 0f653cd..0b80263 100644
--- a/scintilla/include/Scintilla.h
+++ b/scintilla/include/Scintilla.h
@@ -50,6 +50,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_ADDTEXT 2001
#define SCI_ADDSTYLEDTEXT 2002
#define SCI_INSERTTEXT 2003
+#define SCI_CHANGEINSERTION 2672
#define SCI_CLEARALL 2004
#define SCI_DELETERANGE 2645
#define SCI_CLEARDOCUMENTSTYLE 2005
@@ -461,6 +462,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008
#define SC_FOLDFLAG_LINEAFTER_CONTRACTED 0x0010
#define SC_FOLDFLAG_LEVELNUMBERS 0x0040
+#define SC_FOLDFLAG_LINESTATE 0x0080
#define SCI_SETFOLDFLAGS 2233
#define SCI_ENSUREVISIBLEENFORCEPOLICY 2234
#define SCI_SETTABINDENTS 2260
@@ -945,7 +947,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_MOD_CHANGEANNOTATION 0x20000
#define SC_MOD_CONTAINER 0x40000
#define SC_MOD_LEXERSTATE 0x80000
-#define SC_MODEVENTMASKALL 0xFFFFF
+#define SC_MOD_INSERTCHECK 0x100000
+#define SC_MODEVENTMASKALL 0x1FFFFF
#define SC_UPDATE_CONTENT 0x1
#define SC_UPDATE_SELECTION 0x2
#define SC_UPDATE_V_SCROLL 0x4
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface
index fe6d99f..fd8ad44 100644
--- a/scintilla/include/Scintilla.iface
+++ b/scintilla/include/Scintilla.iface
@@ -98,6 +98,9 @@ fun void AddStyledText=2002(int length, cells c)
# Insert string at a position.
fun void InsertText=2003(position pos, string text)
+# Change the text that is being inserted in response to SC_MOD_INSERTCHECK
+fun void ChangeInsertion=2672(int length, string text)
+
# Delete all text in the document.
fun void ClearAll=2004(,)
@@ -1151,6 +1154,7 @@ val SC_FOLDFLAG_LINEBEFORE_CONTRACTED=0x0004
val SC_FOLDFLAG_LINEAFTER_EXPANDED=0x0008
val SC_FOLDFLAG_LINEAFTER_CONTRACTED=0x0010
val SC_FOLDFLAG_LEVELNUMBERS=0x0040
+val SC_FOLDFLAG_LINESTATE=0x0080
# Set some style options for folding.
set void SetFoldFlags=2233(int flags,)
@@ -2494,7 +2498,8 @@ val SC_MOD_CHANGEMARGIN=0x10000
val SC_MOD_CHANGEANNOTATION=0x20000
val SC_MOD_CONTAINER=0x40000
val SC_MOD_LEXERSTATE=0x80000
-val SC_MODEVENTMASKALL=0xFFFFF
+val SC_MOD_INSERTCHECK=0x100000
+val SC_MODEVENTMASKALL=0x1FFFFF
enu Update=SC_UPDATE_
val SC_UPDATE_CONTENT=0x1
@@ -2659,6 +2664,7 @@ val SCLEX_KVIRC=110
val SCLEX_RUST=111
val SCLEX_DMAP=112
val SCLEX_AS=113
+val SCLEX_DMIS=114
## notepad2 custom code for the AHK lexer - start
val SCLEX_AHK=200
## notepad2 custom code for the AHK lexer - end
@@ -2714,6 +2720,8 @@ val SCE_C_HASHQUOTEDSTRING=22
val SCE_C_PREPROCESSORCOMMENT=23
val SCE_C_PREPROCESSORCOMMENTDOC=24
val SCE_C_USERLITERAL=25
+val SCE_C_TASKMARKER=26
+val SCE_C_ESCAPESEQUENCE=27
# Lexical states for SCLEX_D
lex D=SCLEX_D SCE_D_
val SCE_D_DEFAULT=0
@@ -4466,6 +4474,18 @@ val SCE_DMAP_IDENTIFIER=7
val SCE_DMAP_WORD=8
val SCE_DMAP_WORD2=9
val SCE_DMAP_WORD3=10
+# Lexical states for SCLEX_DMIS
+lex DMIS=SCLEX_DMIS SCE_DMIS_
+val SCE_DMIS_DEFAULT=0
+val SCE_DMIS_COMMENT=1
+val SCE_DMIS_STRING=2
+val SCE_DMIS_NUMBER=3
+val SCE_DMIS_KEYWORD=4
+val SCE_DMIS_MAJORWORD=5
+val SCE_DMIS_MINORWORD=6
+val SCE_DMIS_UNSUPPORTED_MAJOR=7
+val SCE_DMIS_UNSUPPORTED_MINOR=8
+val SCE_DMIS_LABEL=9
# Events
diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx
index 76a47e0..7fe6809 100644
--- a/scintilla/lexers/LexCPP.cxx
+++ b/scintilla/lexers/LexCPP.cxx
@@ -36,7 +36,10 @@
using namespace Scintilla;
#endif
-static bool IsSpaceEquiv(int state) {
+namespace {
+ // Use an unnamed namespace to protect the functions and classes from name conflicts
+
+bool IsSpaceEquiv(int state) {
return (state <= SCE_C_COMMENTDOC) ||
// including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE
(state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) ||
@@ -50,7 +53,7 @@ static bool IsSpaceEquiv(int state) {
// a = b+++/ptn/...
// Putting a space between the '++' post-inc operator and the '+' binary op
// fixes this, and is highly recommended for readability anyway.
-static bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
+bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
int pos = (int) sc.currentPos;
while (--pos > 0) {
char ch = styler[pos];
@@ -61,7 +64,7 @@ static bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
return false;
}
-static bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
+bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
// Don't look at styles, so no need to flush.
int pos = (int) sc.currentPos;
int currentLine = styler.GetLine(pos);
@@ -83,7 +86,120 @@ static bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
return !*s;
}
-static std::string GetRestOfLine(LexAccessor &styler, int start, bool allowSpace) {
+bool IsSpaceOrTab(int ch) {
+ return ch == ' ' || ch == '\t';
+}
+
+bool OnlySpaceOrTab(const std::string &s) {
+ for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
+ if (!IsSpaceOrTab(*it))
+ return false;
+ }
+ return true;
+}
+
+std::vector<std::string> StringSplit(const std::string &text, int separator) {
+ std::vector<std::string> vs(text.empty() ? 0 : 1);
+ for (std::string::const_iterator it = text.begin(); it != text.end(); ++it) {
+ if (*it == separator) {
+ vs.push_back(std::string());
+ } else {
+ vs.back() += *it;
+ }
+ }
+ return vs;
+}
+
+struct BracketPair {
+ std::vector<std::string>::iterator itBracket;
+ std::vector<std::string>::iterator itEndBracket;
+};
+
+BracketPair FindBracketPair(std::vector<std::string> &tokens) {
+ BracketPair bp;
+ std::vector<std::string>::iterator itTok = std::find(tokens.begin(), tokens.end(), "(");
+ bp.itBracket = tokens.end();
+ bp.itEndBracket = tokens.end();
+ if (itTok != tokens.end()) {
+ bp.itBracket = itTok;
+ size_t nest = 0;
+ while (itTok != tokens.end()) {
+ if (*itTok == "(") {
+ nest++;
+ } else if (*itTok == ")") {
+ nest--;
+ if (nest == 0) {
+ bp.itEndBracket = itTok;
+ return bp;
+ }
+ }
+ ++itTok;
+ }
+ }
+ bp.itBracket = tokens.end();
+ return bp;
+}
+
+void highlightTaskMarker(StyleContext &sc, LexAccessor &styler,
+ int activity, WordList &markerList, bool caseSensitive){
+ if ((isoperator(sc.chPrev) || IsASpace(sc.chPrev)) && markerList.Length()) {
+ const int lengthMarker = 50;
+ char marker[lengthMarker+1];
+ int currPos = (int) sc.currentPos;
+ int i = 0;
+ while (i < lengthMarker) {
+ char ch = styler.SafeGetCharAt(currPos + i);
+ if (IsASpace(ch) || isoperator(ch)) {
+ break;
+ }
+ if (caseSensitive)
+ marker[i] = ch;
+ else
+ marker[i] = static_cast<char>(tolower(ch));
+ i++;
+ }
+ marker[i] = '\0';
+ if (markerList.InList(marker)) {
+ sc.SetState(SCE_C_TASKMARKER|activity);
+ }
+ }
+}
+
+struct EscapeSequence {
+ int digitsLeft;
+ CharacterSet setHexDigits;
+ CharacterSet setOctDigits;
+ CharacterSet setNoneNumeric;
+ CharacterSet *escapeSetValid;
+ EscapeSequence() {
+ digitsLeft = 0;
+ escapeSetValid = 0;
+ setHexDigits = CharacterSet(CharacterSet::setDigits, "ABCDEFabcdef");
+ setOctDigits = CharacterSet(CharacterSet::setNone, "01234567");
+ }
+ void resetEscapeState(int nextChar) {
+ digitsLeft = 0;
+ escapeSetValid = &setNoneNumeric;
+ if (nextChar == 'U') {
+ digitsLeft = 9;
+ escapeSetValid = &setHexDigits;
+ } else if (nextChar == 'u') {
+ digitsLeft = 5;
+ escapeSetValid = &setHexDigits;
+ } else if (nextChar == 'x') {
+ digitsLeft = 5;
+ escapeSetValid = &setHexDigits;
+ } else if (setOctDigits.Contains(nextChar)) {
+ digitsLeft = 3;
+ escapeSetValid = &setOctDigits;
+ }
+ }
+ bool atEscapeEnd(int currChar) const {
+ return (digitsLeft <= 0) || !escapeSetValid->Contains(currChar);
+ }
+};
+
+std::string GetRestOfLine(LexAccessor &styler, int start, bool allowSpace) {
std::string restOfLine;
int i =0;
char ch = styler.SafeGetCharAt(start, '\n');
@@ -100,40 +216,21 @@ static std::string GetRestOfLine(LexAccessor &styler, int start, bool allowSpace
return restOfLine;
}
-static bool IsStreamCommentStyle(int style) {
+bool IsStreamCommentStyle(int style) {
return style == SCE_C_COMMENT ||
style == SCE_C_COMMENTDOC ||
style == SCE_C_COMMENTDOCKEYWORD ||
style == SCE_C_COMMENTDOCKEYWORDERROR;
}
-static std::vector<std::string> Tokenize(const std::string &s) {
- // Break into space separated tokens
- std::string word;
- std::vector<std::string> tokens;
- for (const char *cp = s.c_str(); *cp; cp++) {
- if ((*cp == ' ') || (*cp == '\t')) {
- if (!word.empty()) {
- tokens.push_back(word);
- word = "";
- }
- } else {
- word += *cp;
- }
- }
- if (!word.empty()) {
- tokens.push_back(word);
- }
- return tokens;
-}
-
struct PPDefinition {
int line;
std::string key;
std::string value;
bool isUndef;
- PPDefinition(int line_, const std::string &key_, const std::string &value_, bool isUndef_ = false) :
- line(line_), key(key_), value(value_), isUndef(isUndef_) {
+ std::string arguments;
+ PPDefinition(int line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, std::string arguments_="") :
+ line(line_), key(key_), value(value_), isUndef(isUndef_), arguments(arguments_) {
}
};
@@ -211,6 +308,8 @@ struct OptionsCPP {
bool updatePreprocessor;
bool triplequotedStrings;
bool hashquotedStrings;
+ bool backQuotedStrings;
+ bool escapeSequence;
bool fold;
bool foldSyntaxBased;
bool foldComment;
@@ -229,6 +328,8 @@ struct OptionsCPP {
updatePreprocessor = true;
triplequotedStrings = false;
hashquotedStrings = false;
+ backQuotedStrings = false;
+ escapeSequence = false;
fold = false;
foldSyntaxBased = true;
foldComment = false;
@@ -243,12 +344,13 @@ struct OptionsCPP {
}
};
-static const char *const cppWordLists[] = {
+const char *const cppWordLists[] = {
"Primary keywords and identifiers",
"Secondary keywords and identifiers",
"Documentation comment keywords",
"Global classes and typedefs",
"Preprocessor definitions",
+ "Task marker and error marker keywords",
0,
};
@@ -274,6 +376,12 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
DefineProperty("lexer.cpp.hashquoted.strings", &OptionsCPP::hashquotedStrings,
"Set to 1 to enable highlighting of hash-quoted strings.");
+ DefineProperty("lexer.cpp.backquoted.strings", &OptionsCPP::backQuotedStrings,
+ "Set to 1 to enable highlighting of back-quoted raw strings .");
+
+ DefineProperty("lexer.cpp.escape.sequence", &OptionsCPP::escapeSequence,
+ "Set to 1 to enable highlighting of escape sequences in strings");
+
DefineProperty("fold", &OptionsCPP::fold);
DefineProperty("fold.cpp.syntax.based", &OptionsCPP::foldSyntaxBased,
@@ -312,7 +420,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
}
};
-static const char styleSubable[] = {SCE_C_IDENTIFIER, SCE_C_COMMENTDOCKEYWORD, 0};
+const char styleSubable[] = {SCE_C_IDENTIFIER, SCE_C_COMMENTDOCKEYWORD, 0};
+
+}
class LexerCPP : public ILexerWithSubStyles {
bool caseSensitive;
@@ -321,6 +431,7 @@ class LexerCPP : public ILexerWithSubStyles {
CharacterSet setArithmethicOp;
CharacterSet setRelOp;
CharacterSet setLogicalOp;
+ CharacterSet setWordStart;
PPStates vlls;
std::vector<PPDefinition> ppDefineHistory;
WordList keywords;
@@ -328,9 +439,26 @@ class LexerCPP : public ILexerWithSubStyles {
WordList keywords3;
WordList keywords4;
WordList ppDefinitions;
- std::map<std::string, std::string> preprocessorDefinitionsStart;
+ WordList markerList;
+ struct SymbolValue {
+ std::string value;
+ std::string arguments;
+ SymbolValue(const std::string &value_="", const std::string &arguments_="") : value(value_), arguments(arguments_) {
+ }
+ SymbolValue &operator = (const std::string &value_) {
+ value = value_;
+ arguments.clear();
+ return *this;
+ }
+ bool IsMacro() const {
+ return !arguments.empty();
+ }
+ };
+ typedef std::map<std::string, SymbolValue> SymbolTable;
+ SymbolTable preprocessorDefinitionsStart;
OptionsCPP options;
OptionSetCPP osCPP;
+ EscapeSequence escapeSeq;
SparseState<std::string> rawStringTerminators;
enum { activeFlag = 0x40 };
enum { ssIdentifier, ssDocKeyword };
@@ -417,8 +545,9 @@ public:
static int MaskActive(int style) {
return style & ~activeFlag;
}
- void EvaluateTokens(std::vector<std::string> &tokens);
- bool EvaluateExpression(const std::string &expr, const std::map<std::string, std::string> &preprocessorDefinitions);
+ void EvaluateTokens(std::vector<std::string> &tokens, const SymbolTable &preprocessorDefinitions);
+ std::vector<std::string> Tokenize(const std::string &expr) const;
+ bool EvaluateExpression(const std::string &expr, const SymbolTable &preprocessorDefinitions);
};
int SCI_METHOD LexerCPP::PropertySet(const char *key, const char *val) {
@@ -452,6 +581,9 @@ int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) {
case 4:
wordListN = &ppDefinitions;
break;
+ case 5:
+ wordListN = &markerList;
+ break;
}
int firstModification = -1;
if (wordListN) {
@@ -469,7 +601,16 @@ int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) {
if (cpEquals) {
std::string name(cpDefinition, cpEquals - cpDefinition);
std::string val(cpEquals+1);
- preprocessorDefinitionsStart[name] = val;
+ size_t bracket = name.find('(');
+ size_t bracketEnd = name.find(')');
+ if ((bracket != std::string::npos) && (bracketEnd != std::string::npos)) {
+ // Macro
+ std::string args = name.substr(bracket + 1, bracketEnd - bracket - 1);
+ name = name.substr(0, bracket);
+ preprocessorDefinitionsStart[name] = SymbolValue(val, args);
+ } else {
+ preprocessorDefinitionsStart[name] = val;
+ }
} else {
std::string name(cpDefinition);
std::string val("1");
@@ -499,7 +640,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]");
- CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
+ setWordStart = CharacterSet(CharacterSet::setAlpha, "_", 0x80, true);
CharacterSet setInvalidRawFirst(CharacterSet::setNone, " )\\\t\v\f\n");
@@ -511,6 +652,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
int visibleChars = 0;
bool lastWordWasUUID = false;
int styleBeforeDCKeyword = SCE_C_DEFAULT;
+ int styleBeforeTaskMarker = SCE_C_DEFAULT;
bool continuationLine = false;
bool isIncludePreprocessor = false;
bool isStringInPreprocessor = false;
@@ -540,7 +682,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
}
}
- StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(0xff));
+ StyleContext sc(startPos, length, initStyle, styler, static_cast<unsigned char>(0xff));
LinePPState preproc = vlls.ForLine(lineCurrent);
bool definitionsChanged = false;
@@ -556,12 +698,12 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
definitionsChanged = true;
}
- std::map<std::string, std::string> preprocessorDefinitions = preprocessorDefinitionsStart;
+ SymbolTable preprocessorDefinitions = preprocessorDefinitionsStart;
for (std::vector<PPDefinition>::iterator itDef = ppDefineHistory.begin(); itDef != ppDefineHistory.end(); ++itDef) {
if (itDef->isUndef)
preprocessorDefinitions.erase(itDef->key);
else
- preprocessorDefinitions[itDef->key] = itDef->value;
+ preprocessorDefinitions[itDef->key] = SymbolValue(itDef->value, itDef->arguments);
}
std::string rawStringTerminator = rawStringTerminators.ValueAt(lineCurrent-1);
@@ -581,13 +723,13 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
// Inside inactive preprocessor declaration, state will be reset anyway at the end of this block.
if ((sc.state == SCE_C_STRING) || (sc.state == SCE_C_CHARACTER)) {
// Prevent SCE_C_STRINGEOL from leaking back to previous line which
- // ends with a line continuation by locking in the state upto this position.
+ // ends with a line continuation by locking in the state up to this position.
sc.SetState(sc.state);
}
if ((MaskActive(sc.state) == SCE_C_PREPROCESSOR) && (!continuationLine)) {
sc.SetState(SCE_C_DEFAULT|activitySet);
}
- // Reset states to begining of colourise so no surprises
+ // Reset states to beginning of colourise so no surprises
// if different sets of lines lexed.
visibleChars = 0;
lastWordWasUUID = false;
@@ -725,6 +867,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT|activitySet);
+ } else {
+ styleBeforeTaskMarker = SCE_C_COMMENT;
+ highlightTaskMarker(sc, styler, activitySet, markerList, caseSensitive);
}
break;
case SCE_C_COMMENTDOC:
@@ -742,6 +887,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
case SCE_C_COMMENTLINE:
if (sc.atLineStart && !continuationLine) {
sc.SetState(SCE_C_DEFAULT|activitySet);
+ } else {
+ styleBeforeTaskMarker = SCE_C_COMMENTLINE;
+ highlightTaskMarker(sc, styler, activitySet, markerList, caseSensitive);
}
break;
case SCE_C_COMMENTLINEDOC:
@@ -794,9 +942,11 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
isIncludePreprocessor = false;
}
} else if (sc.ch == '\\') {
- if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
- sc.Forward();
+ if (options.escapeSequence) {
+ sc.SetState(SCE_C_ESCAPESEQUENCE|activitySet);
+ escapeSeq.resetEscapeState(sc.chNext);
}
+ sc.Forward(); // Skip all characters after the backslash
} else if (sc.ch == '\"') {
if (sc.chNext == '_') {
sc.ChangeState(SCE_C_USERLITERAL|activitySet);
@@ -805,6 +955,24 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
}
}
break;
+ case SCE_C_ESCAPESEQUENCE:
+ escapeSeq.digitsLeft--;
+ if (!escapeSeq.atEscapeEnd(sc.ch)) {
+ break;
+ }
+ if (sc.ch == '"') {
+ sc.SetState(SCE_C_STRING|activitySet);
+ sc.ForwardSetState(SCE_C_DEFAULT|activitySet);
+ } else if (sc.ch == '\\') {
+ escapeSeq.resetEscapeState(sc.chNext);
+ sc.Forward();
+ } else {
+ sc.SetState(SCE_C_STRING|activitySet);
+ if (sc.atLineEnd) {
+ sc.ChangeState(SCE_C_STRINGEOL|activitySet);
+ }
+ }
+ break;
case SCE_C_HASHQUOTEDSTRING:
if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
@@ -880,6 +1048,12 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
if (sc.atLineEnd || sc.ch == ')') {
sc.SetState(SCE_C_DEFAULT|activitySet);
}
+ break;
+ case SCE_C_TASKMARKER:
+ if (isoperator(sc.ch) || IsASpace(sc.ch)) {
+ sc.SetState(styleBeforeTaskMarker|activitySet);
+ styleBeforeTaskMarker = SCE_C_DEFAULT;
+ }
}
if (sc.atLineEnd && !atLineEndBeforeSwitch) {
@@ -900,6 +1074,10 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
} else if (options.hashquotedStrings && sc.Match('#', '\"')) {
sc.SetState(SCE_C_HASHQUOTEDSTRING|activitySet);
sc.Forward();
+ } else if (options.backQuotedStrings && sc.Match('`')) {
+ sc.SetState(SCE_C_STRINGRAW|activitySet);
+ rawStringTerminator = "`";
+ sc.Forward();
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
if (lastWordWasUUID) {
sc.SetState(SCE_C_UUID|activitySet);
@@ -1018,19 +1196,35 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
} else if (sc.Match("define")) {
if (options.updatePreprocessor && !preproc.IsInactive()) {
std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 6, true);
- if (restOfLine.find(")") == std::string::npos) { // Don't handle macros with arguments
- std::vector<std::string> tokens = Tokenize(restOfLine);
- std::string key;
- std::string value("1");
- if (tokens.size() >= 1) {
- key = tokens[0];
- if (tokens.size() >= 2) {
- value = tokens[1];
- }
- preprocessorDefinitions[key] = value;
- ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value));
- definitionsChanged = true;
- }
+ size_t startName = 0;
+ while ((startName < restOfLine.length()) && IsSpaceOrTab(restOfLine[startName]))
+ startName++;
+ size_t endName = startName;
+ while ((endName < restOfLine.length()) && setWord.Contains(static_cast<unsigned char>(restOfLine[endName])))
+ endName++;
+ std::string key = restOfLine.substr(startName, endName-startName);
+ if (restOfLine[endName] == '(') {
+ // Macro
+ size_t endArgs = endName;
+ while ((endArgs < restOfLine.length()) && (restOfLine[endArgs] != ')'))
+ endArgs++;
+ std::string args = restOfLine.substr(endName + 1, endArgs - endName - 1);
+ size_t startValue = endArgs+1;
+ while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue]))
+ startValue++;
+ std::string value = restOfLine.substr(startValue);
+ preprocessorDefinitions[key] = SymbolValue(value, args);
+ ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value, false, args));
+ definitionsChanged = true;
+ } else {
+ // Value
+ size_t startValue = endName;
+ while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue]))
+ startValue++;
+ std::string value = restOfLine.substr(startValue);
+ preprocessorDefinitions[key] = value;
+ ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value));
+ definitionsChanged = true;
}
}
} else if (sc.Match("undef")) {
@@ -1180,19 +1374,36 @@ void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle,
}
}
-void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens) {
+void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens, const SymbolTable &preprocessorDefinitions) {
- // Evaluate defined() statements to either 0 or 1
- for (size_t i=0; (i+2)<tokens.size();) {
- if ((tokens[i] == "defined") && (tokens[i+1] == "(")) {
+ // Remove whitespace tokens
+ tokens.erase(std::remove_if(tokens.begin(), tokens.end(), OnlySpaceOrTab), tokens.end());
+
+ // Evaluate defined statements to either 0 or 1
+ for (size_t i=0; (i+1)<tokens.size();) {
+ if (tokens[i] == "defined") {
const char *val = "0";
- if (tokens[i+2] == ")") {
- // defined()
- tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 3);
- } else if (((i+3)<tokens.size()) && (tokens[i+3] == ")")) {
- // defined(<int>)
- tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 4);
- val = "1";
+ if (tokens[i+1] == "(") {
+ if (((i + 2)<tokens.size()) && (tokens[i + 2] == ")")) {
+ // defined()
+ tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 3);
+ } else if (((i+3)<tokens.size()) && (tokens[i+3] == ")")) {
+ // defined(<identifier>)
+ SymbolTable::const_iterator it = preprocessorDefinitions.find(tokens[i+2]);
+ if (it != preprocessorDefinitions.end()) {
+ val = "1";
+ }
+ tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 4);
+ } else {
+ // Spurious '(' so erase as more likely to result in false
+ tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 2);
+ }
+ } else {
+ // defined <identifier>
+ SymbolTable::const_iterator it = preprocessorDefinitions.find(tokens[i+1]);
+ if (it != preprocessorDefinitions.end()) {
+ val = "1";
+ }
}
tokens[i] = val;
} else {
@@ -1200,21 +1411,82 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens) {
}
}
+ // Evaluate identifiers
+ const size_t maxIterations = 100;
+ size_t iterations = 0; // Limit number of iterations in case there is a recursive macro.
+ for (size_t i = 0; (i<tokens.size()) && (iterations < maxIterations);) {
+ iterations++;
+ if (setWordStart.Contains(static_cast<unsigned char>(tokens[i][0]))) {
+ SymbolTable::const_iterator it = preprocessorDefinitions.find(tokens[i]);
+ if (it != preprocessorDefinitions.end()) {
+ // Tokenize value
+ std::vector<std::string> macroTokens = Tokenize(it->second.value);
+ if (it->second.IsMacro()) {
+ if ((i + 1 < tokens.size()) && (tokens.at(i + 1) == "(")) {
+ // Create map of argument name to value
+ std::vector<std::string> argumentNames = StringSplit(it->second.arguments, ',');
+ std::map<std::string, std::string> arguments;
+ size_t arg = 0;
+ size_t tok = i+2;
+ while ((tok < tokens.size()) && (arg < argumentNames.size()) && (tokens.at(tok) != ")")) {
+ if (tokens.at(tok) != ",") {
+ arguments[argumentNames.at(arg)] = tokens.at(tok);
+ arg++;
+ }
+ tok++;
+ }
+
+ // Remove invocation
+ tokens.erase(tokens.begin() + i, tokens.begin() + tok + 1);
+
+ // Substitute values into macro
+ macroTokens.erase(std::remove_if(macroTokens.begin(), macroTokens.end(), OnlySpaceOrTab), macroTokens.end());
+
+ for (size_t iMacro = 0; iMacro < macroTokens.size();) {
+ if (setWordStart.Contains(static_cast<unsigned char>(macroTokens[iMacro][0]))) {
+ std::map<std::string, std::string>::const_iterator itFind = arguments.find(macroTokens[iMacro]);
+ if (itFind != arguments.end()) {
+ // TODO: Possible that value will be expression so should insert tokenized form
+ macroTokens[iMacro] = itFind->second;
+ }
+ }
+ iMacro++;
+ }
+
+ // Insert results back into tokens
+ tokens.insert(tokens.begin() + i, macroTokens.begin(), macroTokens.end());
+
+ } else {
+ i++;
+ }
+ } else {
+ // Remove invocation
+ tokens.erase(tokens.begin() + i);
+ // Insert results back into tokens
+ tokens.insert(tokens.begin() + i, macroTokens.begin(), macroTokens.end());
+ }
+ } else {
+ // Identifier not found
+ tokens.erase(tokens.begin() + i);
+ }
+ } else {
+ i++;
+ }
+ }
+
// Find bracketed subexpressions and recurse on them
- std::vector<std::string>::iterator itBracket = std::find(tokens.begin(), tokens.end(), "(");
- std::vector<std::string>::iterator itEndBracket = std::find(tokens.begin(), tokens.end(), ")");
- while ((itBracket != tokens.end()) && (itEndBracket != tokens.end()) && (itEndBracket > itBracket)) {
- std::vector<std::string> inBracket(itBracket + 1, itEndBracket);
- EvaluateTokens(inBracket);
+ BracketPair bracketPair = FindBracketPair(tokens);
+ while (bracketPair.itBracket != tokens.end()) {
+ std::vector<std::string> inBracket(bracketPair.itBracket + 1, bracketPair.itEndBracket);
+ EvaluateTokens(inBracket, preprocessorDefinitions);
// The insertion is done before the removal because there were failures with the opposite approach
- tokens.insert(itBracket, inBracket.begin(), inBracket.end());
- itBracket = std::find(tokens.begin(), tokens.end(), "(");
- itEndBracket = std::find(tokens.begin(), tokens.end(), ")");
- tokens.erase(itBracket, itEndBracket + 1);
+ tokens.insert(bracketPair.itBracket, inBracket.begin(), inBracket.end());
- itBracket = std::find(tokens.begin(), tokens.end(), "(");
- itEndBracket = std::find(tokens.begin(), tokens.end(), ")");
+ bracketPair = FindBracketPair(tokens);
+ tokens.erase(bracketPair.itBracket, bracketPair.itEndBracket + 1);
+
+ bracketPair = FindBracketPair(tokens);
}
// Evaluate logical negations
@@ -1283,45 +1555,51 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens) {
}
}
-bool LexerCPP::EvaluateExpression(const std::string &expr, const std::map<std::string, std::string> &preprocessorDefinitions) {
- // Break into tokens, replacing with definitions
- std::string word;
+std::vector<std::string> LexerCPP::Tokenize(const std::string &expr) const {
+ // Break into tokens
std::vector<std::string> tokens;
const char *cp = expr.c_str();
- for (;;) {
+ while (*cp) {
+ std::string word;
if (setWord.Contains(static_cast<unsigned char>(*cp))) {
- word += *cp;
- } else {
- std::map<std::string, std::string>::const_iterator it = preprocessorDefinitions.find(word);
- if (it != preprocessorDefinitions.end()) {
- tokens.push_back(it->second);
- } else if (!word.empty() && ((word[0] >= '0' && word[0] <= '9') || (word == "defined"))) {
- tokens.push_back(word);
+ // Identifiers and numbers
+ while (setWord.Contains(static_cast<unsigned char>(*cp))) {
+ word += *cp;
+ cp++;
}
- word = "";
- if (!*cp) {
- break;
+ } else if (IsSpaceOrTab(*cp)) {
+ while (IsSpaceOrTab(*cp)) {
+ word += *cp;
+ cp++;
}
- if ((*cp != ' ') && (*cp != '\t')) {
- std::string op(cp, 1);
- if (setRelOp.Contains(static_cast<unsigned char>(*cp))) {
- if (setRelOp.Contains(static_cast<unsigned char>(cp[1]))) {
- op += cp[1];
- cp++;
- }
- } else if (setLogicalOp.Contains(static_cast<unsigned char>(*cp))) {
- if (setLogicalOp.Contains(static_cast<unsigned char>(cp[1]))) {
- op += cp[1];
- cp++;
- }
- }
- tokens.push_back(op);
+ } else if (setRelOp.Contains(static_cast<unsigned char>(*cp))) {
+ word += *cp;
+ cp++;
+ if (setRelOp.Contains(static_cast<unsigned char>(*cp))) {
+ word += *cp;
+ cp++;
+ }
+ } else if (setLogicalOp.Contains(static_cast<unsigned char>(*cp))) {
+ word += *cp;
+ cp++;
+ if (setLogicalOp.Contains(static_cast<unsigned char>(*cp))) {
+ word += *cp;
+ cp++;
}
+ } else {
+ // Should handle strings, characters, and comments here
+ word += *cp;
+ cp++;
}
- cp++;
+ tokens.push_back(word);
}
+ return tokens;
+}
+
+bool LexerCPP::EvaluateExpression(const std::string &expr, const SymbolTable &preprocessorDefinitions) {
+ std::vector<std::string> tokens = Tokenize(expr);
- EvaluateTokens(tokens);
+ EvaluateTokens(tokens, preprocessorDefinitions);
// "0" or "" -> false else true
bool isFalse = tokens.empty() ||
diff --git a/scintilla/lexers/LexCoffeeScript.cxx b/scintilla/lexers/LexCoffeeScript.cxx
index ceaaf7f..20ecf7d 100644
--- a/scintilla/lexers/LexCoffeeScript.cxx
+++ b/scintilla/lexers/LexCoffeeScript.cxx
@@ -158,7 +158,7 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
- // Reset states to begining of colourise so no surprises
+ // Reset states to beginning of colourise so no surprises
// if different sets of lines lexed.
visibleChars = 0;
lastWordWasUUID = false;
diff --git a/scintilla/lexers/LexDMIS.cxx b/scintilla/lexers/LexDMIS.cxx
new file mode 100644
index 0000000..7f23ba9
--- /dev/null
+++ b/scintilla/lexers/LexDMIS.cxx
@@ -0,0 +1,355 @@
+// Scintilla source code edit control
+/** @file LexDMIS.cxx
+ ** Lexer for DMIS.
+ **/
+// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 2013-2014 by Andreas Tscharner <andy@vis.ethz.ch>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+
+#include <cstdlib>
+#include <cassert>
+#include <cstring>
+#include <cctype>
+
+#include "ILexer.h"
+#include "SciLexer.h"
+#include "Scintilla.h"
+
+#include "LexerModule.h"
+#include "LexAccessor.h"
+#include "StyleContext.h"
+#include "CharacterSet.h"
+#include "WordList.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+
+static const char *const DMISWordListDesc[] = {
+ "DMIS Major Words",
+ "DMIS Minor Words",
+ "Unsupported DMIS Major Words",
+ "Unsupported DMIS Minor Words",
+ "Keywords for code folding start",
+ "Corresponding keywords for code folding end",
+ 0
+};
+
+
+class LexerDMIS : public ILexer
+{
+ private:
+ char *m_wordListSets;
+ WordList m_majorWords;
+ WordList m_minorWords;
+ WordList m_unsupportedMajor;
+ WordList m_unsupportedMinor;
+ WordList m_codeFoldingStart;
+ WordList m_codeFoldingEnd;
+
+ char * SCI_METHOD UpperCase(char *item);
+ void SCI_METHOD InitWordListSets(void);
+
+ public:
+ LexerDMIS(void);
+ virtual ~LexerDMIS(void);
+
+ int SCI_METHOD Version() const {
+ return lvOriginal;
+ }
+
+ void SCI_METHOD Release() {
+ delete this;
+ }
+
+ const char * SCI_METHOD PropertyNames() {
+ return NULL;
+ }
+
+ int SCI_METHOD PropertyType(const char *) {
+ return -1;
+ }
+
+ const char * SCI_METHOD DescribeProperty(const char *) {
+ return NULL;
+ }
+
+ int SCI_METHOD PropertySet(const char *, const char *) {
+ return -1;
+ }
+
+ int SCI_METHOD WordListSet(int n, const char *wl);
+
+ void * SCI_METHOD PrivateCall(int, void *) {
+ return NULL;
+ }
+
+ static ILexer *LexerFactoryDMIS() {
+ return new LexerDMIS;
+ }
+
+ const char * SCI_METHOD DescribeWordListSets();
+ void SCI_METHOD Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess);
+ void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess);
+};
+
+
+char * SCI_METHOD LexerDMIS::UpperCase(char *item)
+{
+ char *itemStart;
+
+
+ itemStart = item;
+ while (item && *item) {
+ *item = toupper(*item);
+ item++;
+ };
+ return itemStart;
+}
+
+void SCI_METHOD LexerDMIS::InitWordListSets(void)
+{
+ size_t totalLen = 0;
+
+
+ for (int i=0; DMISWordListDesc[i]; i++) {
+ totalLen += strlen(DMISWordListDesc[i]);
+ totalLen++;
+ };
+
+ totalLen++;
+ this->m_wordListSets = new char[totalLen];
+ memset(this->m_wordListSets, 0, totalLen);
+
+ for (int i=0; DMISWordListDesc[i]; i++) {
+ strcat(this->m_wordListSets, DMISWordListDesc[i]);
+ strcat(this->m_wordListSets, "\n");
+ };
+}
+
+
+LexerDMIS::LexerDMIS(void) {
+ this->InitWordListSets();
+
+ this->m_majorWords.Clear();
+ this->m_minorWords.Clear();
+ this->m_unsupportedMajor.Clear();
+ this->m_unsupportedMinor.Clear();
+ this->m_codeFoldingStart.Clear();
+ this->m_codeFoldingEnd.Clear();
+}
+
+LexerDMIS::~LexerDMIS(void) {
+ delete[] this->m_wordListSets;
+}
+
+int SCI_METHOD LexerDMIS::WordListSet(int n, const char *wl)
+{
+ switch (n) {
+ case 0:
+ this->m_majorWords.Clear();
+ this->m_majorWords.Set(wl);
+ break;
+ case 1:
+ this->m_minorWords.Clear();
+ this->m_minorWords.Set(wl);
+ break;
+ case 2:
+ this->m_unsupportedMajor.Clear();
+ this->m_unsupportedMajor.Set(wl);
+ break;
+ case 3:
+ this->m_unsupportedMinor.Clear();
+ this->m_unsupportedMinor.Set(wl);
+ break;
+ case 4:
+ this->m_codeFoldingStart.Clear();
+ this->m_codeFoldingStart.Set(wl);
+ break;
+ case 5:
+ this->m_codeFoldingEnd.Clear();
+ this->m_codeFoldingEnd.Set(wl);
+ break;
+ default:
+ return -1;
+ break;
+ }
+
+ return 0;
+}
+
+const char * SCI_METHOD LexerDMIS::DescribeWordListSets()
+{
+ return this->m_wordListSets;
+}
+
+void SCI_METHOD LexerDMIS::Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess)
+{
+ const unsigned int MAX_STR_LEN = 100;
+
+ LexAccessor styler(pAccess);
+ StyleContext scCTX(startPos, lengthDoc, initStyle, styler);
+ CharacterSet setDMISNumber(CharacterSet::setDigits, ".-+eE");
+ CharacterSet setDMISWordStart(CharacterSet::setAlpha, "-234", 0x80, true);
+ CharacterSet setDMISWord(CharacterSet::setAlpha);
+
+
+ bool isIFLine = false;
+
+ for (; scCTX.More(); scCTX.Forward()) {
+ if (scCTX.atLineEnd) {
+ isIFLine = false;
+ };
+
+ switch (scCTX.state) {
+ case SCE_DMIS_DEFAULT:
+ if (scCTX.Match('$', '$')) {
+ scCTX.SetState(SCE_DMIS_COMMENT);
+ scCTX.Forward();
+ };
+ if (scCTX.Match('\'')) {
+ scCTX.SetState(SCE_DMIS_STRING);
+ };
+ if (IsADigit(scCTX.ch) || ((scCTX.Match('-') || scCTX.Match('+')) && IsADigit(scCTX.chNext))) {
+ scCTX.SetState(SCE_DMIS_NUMBER);
+ break;
+ };
+ if (setDMISWordStart.Contains(scCTX.ch)) {
+ scCTX.SetState(SCE_DMIS_KEYWORD);
+ };
+ if (scCTX.Match('(') && (!isIFLine)) {
+ scCTX.SetState(SCE_DMIS_LABEL);
+ };
+ break;
+
+ case SCE_DMIS_COMMENT:
+ if (scCTX.atLineEnd) {
+ scCTX.SetState(SCE_DMIS_DEFAULT);
+ };
+ break;
+
+ case SCE_DMIS_STRING:
+ if (scCTX.Match('\'')) {
+ scCTX.SetState(SCE_DMIS_DEFAULT);
+ };
+ break;
+
+ case SCE_DMIS_NUMBER:
+ if (!setDMISNumber.Contains(scCTX.ch)) {
+ scCTX.SetState(SCE_DMIS_DEFAULT);
+ };
+ break;
+
+ case SCE_DMIS_KEYWORD:
+ if (!setDMISWord.Contains(scCTX.ch)) {
+ char tmpStr[MAX_STR_LEN];
+ memset(tmpStr, 0, MAX_STR_LEN*sizeof(char));
+ scCTX.GetCurrent(tmpStr, (MAX_STR_LEN-1));
+ strncpy(tmpStr, this->UpperCase(tmpStr), (MAX_STR_LEN-1));
+
+ if (this->m_minorWords.InList(tmpStr)) {
+ scCTX.ChangeState(SCE_DMIS_MINORWORD);
+ };
+ if (this->m_majorWords.InList(tmpStr)) {
+ isIFLine = (strcmp(tmpStr, "IF") == 0);
+ scCTX.ChangeState(SCE_DMIS_MAJORWORD);
+ };
+ if (this->m_unsupportedMajor.InList(tmpStr)) {
+ scCTX.ChangeState(SCE_DMIS_UNSUPPORTED_MAJOR);
+ };
+ if (this->m_unsupportedMinor.InList(tmpStr)) {
+ scCTX.ChangeState(SCE_DMIS_UNSUPPORTED_MINOR);
+ };
+
+ if (scCTX.Match('(') && (!isIFLine)) {
+ scCTX.SetState(SCE_DMIS_LABEL);
+ } else {
+ scCTX.SetState(SCE_DMIS_DEFAULT);
+ };
+ };
+ break;
+
+ case SCE_DMIS_LABEL:
+ if (scCTX.Match(')')) {
+ scCTX.SetState(SCE_DMIS_DEFAULT);
+ };
+ break;
+ };
+ };
+ scCTX.Complete();
+}
+
+void SCI_METHOD LexerDMIS::Fold(unsigned int startPos, int lengthDoc, int, IDocument *pAccess)
+{
+ const int MAX_STR_LEN = 100;
+
+ LexAccessor styler(pAccess);
+ unsigned int endPos = startPos + lengthDoc;
+ char chNext = styler[startPos];
+ int lineCurrent = styler.GetLine(startPos);
+ int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
+ int levelCurrent = levelPrev;
+ int strPos = 0;
+ bool foldWordPossible = false;
+ CharacterSet setDMISFoldWord(CharacterSet::setAlpha);
+ char *tmpStr;
+
+
+ tmpStr = new char[MAX_STR_LEN];
+ memset(tmpStr, 0, MAX_STR_LEN*sizeof(char));
+
+ for (unsigned int i=startPos; i<endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i+1);
+
+ bool atEOL = ((ch == '\r' && chNext != '\n') || (ch == '\n'));
+
+ if (strPos >= (MAX_STR_LEN-1)) {
+ strPos = MAX_STR_LEN-1;
+ };
+
+ int style = styler.StyleAt(i);
+ bool noFoldPos = ((style == SCE_DMIS_COMMENT) || (style == SCE_DMIS_STRING));
+
+ if (foldWordPossible) {
+ if (setDMISFoldWord.Contains(ch)) {
+ tmpStr[strPos++] = ch;
+ } else {
+ tmpStr = this->UpperCase(tmpStr);
+ if (this->m_codeFoldingStart.InList(tmpStr) && (!noFoldPos)) {
+ levelCurrent++;
+ };
+ if (this->m_codeFoldingEnd.InList(tmpStr) && (!noFoldPos)) {
+ levelCurrent--;
+ };
+ memset(tmpStr, 0, MAX_STR_LEN*sizeof(char));
+ strPos = 0;
+ foldWordPossible = false;
+ };
+ } else {
+ if (setDMISFoldWord.Contains(ch)) {
+ tmpStr[strPos++] = ch;
+ foldWordPossible = true;
+ };
+ };
+
+ if (atEOL || (i == (endPos-1))) {
+ int lev = levelPrev;
+
+ if (levelCurrent > levelPrev) {
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ };
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ };
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ };
+ };
+ delete[] tmpStr;
+}
+
+
+LexerModule lmDMIS(SCLEX_DMIS, LexerDMIS::LexerFactoryDMIS, "DMIS", DMISWordListDesc);
diff --git a/scintilla/lexers/LexFortran.cxx b/scintilla/lexers/LexFortran.cxx
index d6da177..70234f3 100644
--- a/scintilla/lexers/LexFortran.cxx
+++ b/scintilla/lexers/LexFortran.cxx
@@ -1,7 +1,7 @@
// Scintilla source code edit control
/** @file LexFortran.cxx
** Lexer for Fortran.
- ** Writen by Chuan-jian Shen, Last changed Sep. 2003
+ ** Written by Chuan-jian Shen, Last changed Sep. 2003
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
diff --git a/scintilla/lexers/LexHTML.cxx b/scintilla/lexers/LexHTML.cxx
index 279b86c..904772b 100644
--- a/scintilla/lexers/LexHTML.cxx
+++ b/scintilla/lexers/LexHTML.cxx
@@ -577,7 +577,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords
// Lexer for HTML requires more lexical states (8 bits worth) than most lexers
- styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
+ styler.StartAt(startPos, static_cast<unsigned char>(STYLE_MAX));
char prevWord[200];
prevWord[0] = '\0';
char phpStringDelimiter[200]; // PHP is not limited in length, we are
@@ -609,7 +609,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
if (startPos == 0)
state = SCE_H_DEFAULT;
}
- styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
+ styler.StartAt(startPos, static_cast<unsigned char>(STYLE_MAX));
int lineCurrent = styler.GetLine(startPos);
int lineState;
@@ -811,8 +811,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
}
styler.SetLineState(lineCurrent,
((inScriptType & 0x03) << 0) |
- ((tagOpened & 0x01) << 2) |
- ((tagClosing & 0x01) << 3) |
+ ((tagOpened ? 1 : 0) << 2) |
+ ((tagClosing ? 1 : 0) << 3) |
((aspScript & 0x0F) << 4) |
((clientScript & 0x0F) << 8) |
((beforePreProc & 0xFF) << 12));
diff --git a/scintilla/lexers/LexLua.cxx b/scintilla/lexers/LexLua.cxx
index a571320..d8a3e18 100644
--- a/scintilla/lexers/LexLua.cxx
+++ b/scintilla/lexers/LexLua.cxx
@@ -141,7 +141,7 @@ static void ColouriseLuaDoc(
char s[100];
while (setWord.Contains(c = sc.GetRelative(ln))) { // get potential label
if (i < 90)
- s[i++] = c;
+ s[i++] = static_cast<char>(c);
ln++;
}
s[i] = '\0'; int lbl = ln;
diff --git a/scintilla/lexers/LexPerl.cxx b/scintilla/lexers/LexPerl.cxx
index 94c63d0..fde90a0 100644
--- a/scintilla/lexers/LexPerl.cxx
+++ b/scintilla/lexers/LexPerl.cxx
@@ -662,7 +662,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
} else if (initStyle == SCE_PL_POD
|| initStyle == SCE_PL_POD_VERB
) {
- // POD backtracking finds preceeding blank lines and goes back past them
+ // POD backtracking finds preceding blank lines and goes back past them
int ln = styler.GetLine(startPos);
if (ln > 0) {
initStyle = styler.StyleAt(styler.LineStart(--ln));
@@ -1159,12 +1159,12 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
sc.ForwardSetState(SCE_PL_DEFAULT);
HereDoc.State = 3;
} else {
- // invalid indentifier; inexact fallback, but hey
+ // invalid identifier; inexact fallback, but hey
sc.ChangeState(SCE_PL_IDENTIFIER);
sc.SetState(SCE_PL_DEFAULT);
}
} else {
- sc.ChangeState(SCE_PL_DEFAULT); // invalid indentifier
+ sc.ChangeState(SCE_PL_DEFAULT); // invalid identifier
}
backFlag = BACK_NONE;
break;
diff --git a/scintilla/lexers/LexRuby.cxx b/scintilla/lexers/LexRuby.cxx
index 32b8433..b75a4ca 100644
--- a/scintilla/lexers/LexRuby.cxx
+++ b/scintilla/lexers/LexRuby.cxx
@@ -731,7 +731,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// If anyone runs into this problem, I recommend raising this
// value slightly higher to replacing the fixed array with a linked
- // list. Keep in mind this code will be called everytime the lexer
+ // list. Keep in mind this code will be called every time the lexer
// is invoked.
#define INNER_STRINGS_MAX_COUNT 5
diff --git a/scintilla/lexlib/LexerModule.h b/scintilla/lexlib/LexerModule.h
index 22f4a60..f0b3163 100644
--- a/scintilla/lexlib/LexerModule.h
+++ b/scintilla/lexlib/LexerModule.h
@@ -72,7 +72,7 @@ inline int Maximum(int a, int b) {
// Shut up annoying Visual C++ warnings:
#ifdef _MSC_VER
-#pragma warning(disable: 4244 4309 4514 4710)
+#pragma warning(disable: 4244 4309)
#endif
#ifdef SCI_NAMESPACE
diff --git a/scintilla/lexlib/PropSetSimple.cxx b/scintilla/lexlib/PropSetSimple.cxx
index 77ab88e..c2b1f2c 100644
--- a/scintilla/lexlib/PropSetSimple.cxx
+++ b/scintilla/lexlib/PropSetSimple.cxx
@@ -11,11 +11,6 @@
#include <string.h>
#include <stdio.h>
-#ifdef _MSC_VER
-// Visual C++ doesn't like unreachable code in its own headers.
-#pragma warning(disable: 4018 4100 4245 4511 4512 4663 4702)
-#endif
-
#include <string>
#include <map>
diff --git a/scintilla/scripts/ScintillaData.py b/scintilla/scripts/ScintillaData.py
index bb21c22..f9c7718 100644
--- a/scintilla/scripts/ScintillaData.py
+++ b/scintilla/scripts/ScintillaData.py
@@ -30,7 +30,7 @@
from __future__ import with_statement
-import datetime, glob, os, textwrap
+import codecs, datetime, glob, os, sys, textwrap
import FileGenerator
@@ -118,7 +118,7 @@ def FindPropertyDocumentation(lexFile):
def FindCredits(historyFile):
credits = []
stage = 0
- with open(historyFile) as f:
+ with codecs.open(historyFile, "r", "utf-8") as f:
for l in f.readlines():
l = l.strip()
if stage == 0 and l == "<table>":
@@ -136,7 +136,7 @@ def FindCredits(historyFile):
if credit:
credit += " "
credit += name + " " + url
- credits.append(credit.decode("utf-8"))
+ credits.append(credit)
return credits
def ciCompare(a,b):
@@ -219,4 +219,7 @@ if __name__=="__main__":
subsequent_indent=" "))
print("Credits:")
for c in sci.credits:
- print(" " + c.encode("utf-8"))
+ if sys.version_info[0] == 2:
+ print(" " + c.encode("utf-8"))
+ else:
+ sys.stdout.buffer.write(b" " + c.encode("utf-8") + b"\n")
diff --git a/scintilla/src/AutoComplete.h b/scintilla/src/AutoComplete.h
index fc172aa..49c7601 100644
--- a/scintilla/src/AutoComplete.h
+++ b/scintilla/src/AutoComplete.h
@@ -65,7 +65,7 @@ public:
void SetSeparator(char separator_);
char GetSeparator() const;
- /// The typesep character is used for seperating the word from the type
+ /// The typesep character is used for separating the word from the type
void SetTypesep(char separator_);
char GetTypesep() const;
diff --git a/scintilla/src/CallTip.cxx b/scintilla/src/CallTip.cxx
index 1ec5f72..f0f2a20 100644
--- a/scintilla/src/CallTip.cxx
+++ b/scintilla/src/CallTip.cxx
@@ -109,13 +109,15 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
int endSeg = ends[seg];
if (endSeg > startSeg) {
if (IsArrowCharacter(s[startSeg])) {
+ xEnd = x + widthArrow;
bool upArrow = s[startSeg] == '\001';
- rcClient.left = x;
- rcClient.right = rcClient.left + widthArrow;
+ rcClient.left = static_cast<XYPOSITION>(x);
+ rcClient.right = static_cast<XYPOSITION>(xEnd);
if (draw) {
const int halfWidth = widthArrow / 2 - 3;
- const int centreX = rcClient.left + widthArrow / 2 - 1;
- const int centreY = (rcClient.top + rcClient.bottom) / 2;
+ const int quarterWidth = halfWidth / 2;
+ const int centreX = x + widthArrow / 2 - 1;
+ const int centreY = static_cast<int>(rcClient.top + rcClient.bottom) / 2;
surface->FillRectangle(rcClient, colourBG);
PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1,
rcClient.right - 2, rcClient.bottom - 1);
@@ -123,21 +125,20 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
if (upArrow) { // Up arrow
Point pts[] = {
- Point(centreX - halfWidth, centreY + halfWidth / 2),
- Point(centreX + halfWidth, centreY + halfWidth / 2),
- Point(centreX, centreY - halfWidth + halfWidth / 2),
+ Point::FromInts(centreX - halfWidth, centreY + quarterWidth),
+ Point::FromInts(centreX + halfWidth, centreY + quarterWidth),
+ Point::FromInts(centreX, centreY - halfWidth + quarterWidth),
};
surface->Polygon(pts, ELEMENTS(pts), colourBG, colourBG);
} else { // Down arrow
Point pts[] = {
- Point(centreX - halfWidth, centreY - halfWidth / 2),
- Point(centreX + halfWidth, centreY - halfWidth / 2),
- Point(centreX, centreY + halfWidth - halfWidth / 2),
+ Point::FromInts(centreX - halfWidth, centreY - quarterWidth),
+ Point::FromInts(centreX + halfWidth, centreY - quarterWidth),
+ Point::FromInts(centreX, centreY + halfWidth - quarterWidth),
};
surface->Polygon(pts, ELEMENTS(pts), colourBG, colourBG);
}
}
- xEnd = rcClient.right;
offsetMain = xEnd;
if (upArrow) {
rectUp = rcClient;
@@ -147,11 +148,11 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
} else if (IsTabCharacter(s[startSeg])) {
xEnd = NextTabPos(x);
} else {
- xEnd = x + surface->WidthText(font, s + startSeg, endSeg - startSeg);
+ xEnd = x + RoundXYPosition(surface->WidthText(font, s + startSeg, endSeg - startSeg));
if (draw) {
- rcClient.left = x;
- rcClient.right = xEnd;
- surface->DrawTextTransparent(rcClient, font, ytext,
+ rcClient.left = static_cast<XYPOSITION>(x);
+ rcClient.right = static_cast<XYPOSITION>(xEnd);
+ surface->DrawTextTransparent(rcClient, font, static_cast<XYPOSITION>(ytext),
s+startSeg, endSeg - startSeg,
highlight ? colourSel : colourUnSel);
}
@@ -164,16 +165,16 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
PRectangle rcClientPos = wCallTip.GetClientPosition();
- PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left,
+ PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
rcClientPos.bottom - rcClientPos.top);
- PRectangle rcClient(1, 1, rcClientSize.right - 1, rcClientSize.bottom - 1);
+ PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
// To make a nice small call tip window, it is only sized to fit most normal characters without accents
- int ascent = surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font);
+ int ascent = RoundXYPosition(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font));
// For each line...
// Draw the definition in three parts: before highlight, highlighted, after highlight
- int ytext = rcClient.top + ascent + 1;
+ int ytext = static_cast<int>(rcClient.top) + ascent + 1;
rcClient.bottom = ytext + surfaceWindow->Descent(font) + 1;
const char *chunkVal = val.c_str();
bool moreChunks = true;
@@ -185,8 +186,8 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
chunkEnd = chunkVal + strlen(chunkVal);
moreChunks = false;
}
- int chunkOffset = chunkVal - val.c_str();
- int chunkLength = chunkEnd - chunkVal;
+ int chunkOffset = static_cast<int>(chunkVal - val.c_str());
+ int chunkLength = static_cast<int>(chunkEnd - chunkVal);
int chunkEndOffset = chunkOffset + chunkLength;
int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset);
thisStartHighlight = Platform::Minimum(thisStartHighlight, chunkEndOffset);
@@ -194,7 +195,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
int thisEndHighlight = Platform::Maximum(endHighlight, chunkOffset);
thisEndHighlight = Platform::Minimum(thisEndHighlight, chunkEndOffset);
thisEndHighlight -= chunkOffset;
- rcClient.top = ytext - ascent - 1;
+ rcClient.top = static_cast<XYPOSITION>(ytext - ascent - 1);
int x = insetX; // start each line at this inset
@@ -217,9 +218,9 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
if (val.empty())
return;
PRectangle rcClientPos = wCallTip.GetClientPosition();
- PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left,
+ PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
rcClientPos.bottom - rcClientPos.top);
- PRectangle rcClient(1, 1, rcClientSize.right - 1, rcClientSize.bottom - 1);
+ PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
surfaceWindow->FillRectangle(rcClient, colourBG);
@@ -229,13 +230,13 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
#ifndef __APPLE__
// OSX doesn't put borders on "help tags"
// Draw a raised border around the edges of the window
- surfaceWindow->MoveTo(0, rcClientSize.bottom - 1);
+ surfaceWindow->MoveTo(0, static_cast<int>(rcClientSize.bottom) - 1);
surfaceWindow->PenColour(colourShade);
- surfaceWindow->LineTo(rcClientSize.right - 1, rcClientSize.bottom - 1);
- surfaceWindow->LineTo(rcClientSize.right - 1, 0);
+ surfaceWindow->LineTo(static_cast<int>(rcClientSize.right) - 1, static_cast<int>(rcClientSize.bottom) - 1);
+ surfaceWindow->LineTo(static_cast<int>(rcClientSize.right) - 1, 0);
surfaceWindow->PenColour(colourLight);
surfaceWindow->LineTo(0, 0);
- surfaceWindow->LineTo(0, rcClientSize.bottom - 1);
+ surfaceWindow->LineTo(0, static_cast<int>(rcClientSize.bottom) - 1);
#endif
}
@@ -264,7 +265,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *
endHighlight = 0;
inCallTipMode = true;
posStartCallTip = pos;
- int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
+ XYPOSITION deviceHeight = static_cast<XYPOSITION>(surfaceMeasure->DeviceHeightFont(size));
FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet);
font.Create(fp);
// Look for multiple lines in the text
@@ -280,12 +281,12 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *
look = newline + 1;
numLines++;
}
- lineHeight = surfaceMeasure->Height(font);
+ lineHeight = RoundXYPosition(surfaceMeasure->Height(font));
// The returned
// rectangle is aligned to the right edge of the last arrow encountered in
// the tip text, else to the tip text left edge.
- int height = lineHeight * numLines - surfaceMeasure->InternalLeading(font) + borderHeight * 2;
+ int height = lineHeight * numLines - static_cast<int>(surfaceMeasure->InternalLeading(font)) + borderHeight * 2;
delete surfaceMeasure;
if (above) {
return PRectangle(pt.x - offsetMain, pt.y - verticalOffset - height, pt.x + width - offsetMain, pt.y - verticalOffset);
diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx
index 541b0ab..f29f2ba 100644
--- a/scintilla/src/Catalogue.cxx
+++ b/scintilla/src/Catalogue.cxx
@@ -107,6 +107,7 @@ int Scintilla_LinkLexers() {
//LINK_LEXER(lmD);
LINK_LEXER(lmDiff);
//LINK_LEXER(lmDMAP);
+ //LINK_LEXER(lmDMIS);
//LINK_LEXER(lmECL);
//LINK_LEXER(lmEiffel);
//LINK_LEXER(lmEiffelkw);
diff --git a/scintilla/src/CharClassify.cxx b/scintilla/src/CharClassify.cxx
index abe39f8..d4e5aa4 100644
--- a/scintilla/src/CharClassify.cxx
+++ b/scintilla/src/CharClassify.cxx
@@ -14,11 +14,6 @@
using namespace Scintilla;
#endif
-// Shut up annoying Visual C++ warnings:
-#ifdef _MSC_VER
-#pragma warning(disable: 4514)
-#endif
-
CharClassify::CharClassify() {
SetDefaultCharClasses(true);
}
diff --git a/scintilla/src/ContractionState.cxx b/scintilla/src/ContractionState.cxx
index ac8939e..08b7b0c 100644
--- a/scintilla/src/ContractionState.cxx
+++ b/scintilla/src/ContractionState.cxx
@@ -76,6 +76,10 @@ int ContractionState::DisplayFromDoc(int lineDoc) const {
}
}
+int ContractionState::DisplayLastFromDoc(int lineDoc) const {
+ return DisplayFromDoc(lineDoc) + GetHeight(lineDoc) - 1;
+}
+
int ContractionState::DocFromDisplay(int lineDisplay) const {
if (OneToOne()) {
return lineDisplay;
diff --git a/scintilla/src/ContractionState.h b/scintilla/src/ContractionState.h
index 445dd45..9f11191 100644
--- a/scintilla/src/ContractionState.h
+++ b/scintilla/src/ContractionState.h
@@ -39,6 +39,7 @@ public:
int LinesInDoc() const;
int LinesDisplayed() const;
int DisplayFromDoc(int lineDoc) const;
+ int DisplayLastFromDoc(int lineDoc) const;
int DocFromDisplay(int lineDisplay) const;
void InsertLine(int lineDoc);
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx
index 9d68c1e..44b9618 100644
--- a/scintilla/src/Document.cxx
+++ b/scintilla/src/Document.cxx
@@ -98,6 +98,7 @@ Document::Document() {
enteredModification = 0;
enteredStyling = 0;
enteredReadOnlyCount = 0;
+ insertionSet = false;
tabInChars = 8;
indentInChars = 0;
actualIndentInChars = 8;
@@ -919,37 +920,56 @@ bool Document::DeleteChars(int pos, int len) {
/**
* Insert a string with a length.
*/
-bool Document::InsertString(int position, const char *s, int insertLength) {
+int Document::InsertString(int position, const char *s, int insertLength) {
if (insertLength <= 0) {
- return false;
+ return 0;
+ }
+ CheckReadOnly(); // Application may change read only state here
+ if (cb.IsReadOnly()) {
+ return 0;
}
- CheckReadOnly();
if (enteredModification != 0) {
- return false;
- } else {
- enteredModification++;
- if (!cb.IsReadOnly()) {
- NotifyModified(
- DocModification(
- SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
- position, insertLength,
- 0, s));
- int prevLinesTotal = LinesTotal();
- bool startSavePoint = cb.IsSavePoint();
- bool startSequence = false;
- const char *text = cb.InsertString(position, s, insertLength, startSequence);
- if (startSavePoint && cb.IsCollectingUndo())
- NotifySavePoint(!startSavePoint);
- ModifiedAt(position);
- NotifyModified(
- DocModification(
- SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
- position, insertLength,
- LinesTotal() - prevLinesTotal, text));
- }
- enteredModification--;
+ return 0;
}
- return !cb.IsReadOnly();
+ enteredModification++;
+ insertionSet = false;
+ insertion.clear();
+ NotifyModified(
+ DocModification(
+ SC_MOD_INSERTCHECK,
+ position, insertLength,
+ 0, s));
+ if (insertionSet) {
+ s = insertion.c_str();
+ insertLength = static_cast<int>(insertion.length());
+ }
+ NotifyModified(
+ DocModification(
+ SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
+ position, insertLength,
+ 0, s));
+ int prevLinesTotal = LinesTotal();
+ bool startSavePoint = cb.IsSavePoint();
+ bool startSequence = false;
+ const char *text = cb.InsertString(position, s, insertLength, startSequence);
+ if (startSavePoint && cb.IsCollectingUndo())
+ NotifySavePoint(!startSavePoint);
+ ModifiedAt(position);
+ NotifyModified(
+ DocModification(
+ SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
+ position, insertLength,
+ LinesTotal() - prevLinesTotal, text));
+ if (insertionSet) { // Free memory as could be large
+ std::string().swap(insertion);
+ }
+ enteredModification--;
+ return insertLength;
+}
+
+void Document::ChangeInsertion(const char *s, int length) {
+ insertionSet = true;
+ insertion.assign(s, length);
}
int SCI_METHOD Document::AddData(char *data, int length) {
@@ -1113,22 +1133,6 @@ int Document::Redo() {
return newPos;
}
-/**
- * Insert a single character.
- */
-bool Document::InsertChar(int pos, char ch) {
- char chs[1];
- chs[0] = ch;
- return InsertString(pos, chs, 1);
-}
-
-/**
- * Insert a null terminated string.
- */
-bool Document::InsertCString(int position, const char *s) {
- return InsertString(position, s, static_cast<int>(s ? strlen(s) : 0));
-}
-
void Document::DelChar(int pos) {
DeleteChars(pos, LenChar(pos));
}
@@ -1183,7 +1187,7 @@ int SCI_METHOD Document::GetLineIndentation(int line) {
return indent;
}
-void Document::SetLineIndentation(int line, int indent) {
+int Document::SetLineIndentation(int line, int indent) {
int indentOfLine = GetLineIndentation(line);
if (indent < 0)
indent = 0;
@@ -1193,7 +1197,10 @@ void Document::SetLineIndentation(int line, int indent) {
int indentPos = GetLineIndentPosition(line);
UndoGroup ug(this);
DeleteChars(thisLineStart, indentPos - thisLineStart);
- InsertCString(thisLineStart, linebuf.c_str());
+ return thisLineStart + InsertString(thisLineStart, linebuf.c_str(),
+ static_cast<int>(linebuf.length()));
+ } else {
+ return GetLineIndentPosition(line);
}
}
@@ -1325,21 +1332,21 @@ void Document::ConvertLineEnds(int eolModeSet) {
} else {
// CR
if (eolModeSet == SC_EOL_CRLF) {
- InsertString(pos + 1, "\n", 1); // Insert LF
- pos++;
+ pos += InsertString(pos + 1, "\n", 1); // Insert LF
} else if (eolModeSet == SC_EOL_LF) {
- InsertString(pos, "\n", 1); // Insert LF
- DeleteChars(pos + 1, 1); // Delete CR
+ pos += InsertString(pos, "\n", 1); // Insert LF
+ DeleteChars(pos, 1); // Delete CR
+ pos--;
}
}
} else if (cb.CharAt(pos) == '\n') {
// LF
if (eolModeSet == SC_EOL_CRLF) {
- InsertString(pos, "\r", 1); // Insert CR
- pos++;
+ pos += InsertString(pos, "\r", 1); // Insert CR
} else if (eolModeSet == SC_EOL_CR) {
- InsertString(pos, "\r", 1); // Insert CR
- DeleteChars(pos + 1, 1); // Delete LF
+ pos += InsertString(pos, "\r", 1); // Insert CR
+ DeleteChars(pos, 1); // Delete LF
+ pos--;
}
}
}
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h
index 75fdc09..a0448a6 100644
--- a/scintilla/src/Document.h
+++ b/scintilla/src/Document.h
@@ -43,6 +43,14 @@ public:
return (start != invalidPosition) && (end != invalidPosition);
}
+ Position First() const {
+ return (start <= end) ? start : end;
+ }
+
+ Position Last() const {
+ return (start > end) ? start : end;
+ }
+
// Is the position within the range?
bool Contains(Position pos) const {
if (start < end) {
@@ -205,6 +213,9 @@ private:
int enteredStyling;
int enteredReadOnlyCount;
+ bool insertionSet;
+ std::string insertion;
+
std::vector<WatcherWithUserData> watchers;
// ldSize is not real data - it is for dimensions and loops
@@ -274,7 +285,8 @@ public:
void ModifiedAt(int pos);
void CheckReadOnly();
bool DeleteChars(int pos, int len);
- bool InsertString(int position, const char *s, int insertLength);
+ int InsertString(int position, const char *s, int insertLength);
+ void ChangeInsertion(const char *s, int length);
int SCI_METHOD AddData(char *data, int length);
void * SCI_METHOD ConvertToDocument();
int Undo();
@@ -296,7 +308,7 @@ public:
int GapPosition() const { return cb.GapPosition(); }
int SCI_METHOD GetLineIndentation(int line);
- void SetLineIndentation(int line, int indent);
+ int SetLineIndentation(int line, int indent);
int GetLineIndentPosition(int line) const;
int GetColumn(int position);
int CountCharacters(int startPos, int endPos);
@@ -307,8 +319,6 @@ public:
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
bool IsReadOnly() const { return cb.IsReadOnly(); }
- bool InsertChar(int pos, char ch);
- bool InsertCString(int position, const char *s);
void DelChar(int pos);
void DelCharBack(int pos);
@@ -390,7 +400,7 @@ public:
void AnnotationSetStyles(int line, const unsigned char *styles);
int AnnotationLines(int line) const;
void AnnotationClearAll();
-
+
bool AddWatcher(DocWatcher *watcher, void *userData);
bool RemoveWatcher(DocWatcher *watcher, void *userData);
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx
index 334643c..8f33350 100644
--- a/scintilla/src/Editor.cxx
+++ b/scintilla/src/Editor.cxx
@@ -88,10 +88,6 @@ Timer::Timer() :
Idler::Idler() :
state(false), idlerID(0) {}
-static int RoundXYPosition(XYPOSITION xyPos) {
- return int(xyPos+0.5);
-}
-
static inline bool IsControlCharacter(int ch) {
// iscntrl returns true for lots of chars > 127 which are displayable
return ch >= 0 && ch < ' ';
@@ -117,7 +113,7 @@ Editor::Editor() {
stylesValid = false;
technology = SC_TECHNOLOGY_DEFAULT;
- scaleRGBAImage = 100;
+ scaleRGBAImage = 100.0f;
cursorMode = SC_CURSORNORMAL;
@@ -401,7 +397,7 @@ PRectangle Editor::GetTextRectangle() {
int Editor::LinesOnScreen() {
PRectangle rcClient = GetClientRectangle();
- int htClient = rcClient.bottom - rcClient.top;
+ int htClient = static_cast<int>(rcClient.bottom - rcClient.top);
//Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1);
return htClient / vs.lineHeight;
}
@@ -510,16 +506,16 @@ Point Editor::LocationFromPosition(int pos) {
int Editor::XFromPosition(int pos) {
Point pt = LocationFromPosition(pos);
- return pt.x - vs.textStart + xOffset;
+ return static_cast<int>(pt.x) - vs.textStart + xOffset;
}
int Editor::XFromPosition(SelectionPosition sp) {
Point pt = LocationFromPosition(sp);
- return pt.x - vs.textStart + xOffset;
+ return static_cast<int>(pt.x) - vs.textStart + xOffset;
}
int Editor::LineFromLocation(Point pt) const {
- return cs.DocFromDisplay(pt.y / vs.lineHeight + topLine);
+ return cs.DocFromDisplay(static_cast<int>(pt.y) / vs.lineHeight + topLine);
}
void Editor::SetTopLine(int topLineNew) {
@@ -546,7 +542,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
}
pt = DocumentPointFromView(pt);
pt.x = pt.x - vs.textStart;
- int visibleLine = floor(pt.y / vs.lineHeight);
+ int visibleLine = static_cast<int>(floor(pt.y / vs.lineHeight));
if (!canReturnInvalid && (visibleLine < 0))
visibleLine = 0;
const int lineDoc = cs.DocFromDisplay(visibleLine);
@@ -572,8 +568,8 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
}
if (virtualSpace) {
const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth;
- const int spaceOffset = (pt.x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) /
- spaceWidth;
+ const int spaceOffset = static_cast<int>(
+ (pt.x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth);
return SelectionPosition(rangeSubLine.end + posLineStart, spaceOffset);
} else if (canReturnInvalid) {
if (pt.x < (ll->positions[rangeSubLine.end] - subLineStart)) {
@@ -615,7 +611,8 @@ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) {
return SelectionPosition(pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1));
}
const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth;
- const int spaceOffset = (x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth;
+ const int spaceOffset = static_cast<int>(
+ (x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth);
return SelectionPosition(rangeSubLine.end + posLineStart, spaceOffset);
}
return SelectionPosition(0);
@@ -679,8 +676,7 @@ void Editor::RedrawSelMargin(int line, bool allAfter) {
PRectangle rcSelMargin = GetClientRectangle();
rcSelMargin.right = rcSelMargin.left + vs.fixedColumnWidth;
if (line != -1) {
- int position = pdoc->LineStart(line);
- PRectangle rcLine = RectangleFromRange(position, position);
+ PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)));
// Inflate line rectangle if there are image markers with height larger than line height
if (vs.largestMarkerHeight > vs.lineHeight) {
@@ -710,31 +706,25 @@ void Editor::RedrawSelMargin(int line, bool allAfter) {
}
}
-PRectangle Editor::RectangleFromRange(int start, int end) {
- int minPos = start;
- if (minPos > end)
- minPos = end;
- int maxPos = start;
- if (maxPos < end)
- maxPos = end;
- int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(minPos));
- int lineDocMax = pdoc->LineFromPosition(maxPos);
- int maxLine = cs.DisplayFromDoc(lineDocMax) + cs.GetHeight(lineDocMax) - 1;
- PRectangle rcClient = GetTextRectangle();
+PRectangle Editor::RectangleFromRange(Range r) {
+ const int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(r.First()));
+ const int maxLine = cs.DisplayLastFromDoc(pdoc->LineFromPosition(r.Last()));
+ const PRectangle rcClientDrawing = GetClientDrawingRectangle();
PRectangle rc;
const int leftTextOverlap = ((xOffset == 0) && (vs.leftMarginWidth > 0)) ? 1 : 0;
- rc.left = vs.textStart - leftTextOverlap;
- rc.top = (minLine - TopLineOfMain()) * vs.lineHeight;
- if (rc.top < rcClient.top)
- rc.top = rcClient.top;
- rc.right = rcClient.right;
- rc.bottom = (maxLine - TopLineOfMain() + 1) * vs.lineHeight;
+ rc.left = static_cast<XYPOSITION>(vs.textStart - leftTextOverlap);
+ rc.top = static_cast<XYPOSITION>((minLine - TopLineOfMain()) * vs.lineHeight);
+ if (rc.top < rcClientDrawing.top)
+ rc.top = rcClientDrawing.top;
+ // Extend to right of prepared area if any to prevent artifacts from caret line highlight
+ rc.right = rcClientDrawing.right;
+ rc.bottom = static_cast<XYPOSITION>((maxLine - TopLineOfMain() + 1) * vs.lineHeight);
return rc;
}
void Editor::InvalidateRange(int start, int end) {
- RedrawRect(RectangleFromRange(start, end));
+ RedrawRect(RectangleFromRange(Range(start, end)));
}
int Editor::CurrentPosition() const {
@@ -1033,7 +1023,7 @@ Point Editor::PointMainCaret() {
*/
void Editor::SetLastXChosen() {
Point pt = PointMainCaret();
- lastXChosen = pt.x + xOffset;
+ lastXChosen = static_cast<int>(pt.x) + xOffset;
}
void Editor::ScrollTo(int line, bool moveThumb) {
@@ -1096,7 +1086,7 @@ void Editor::VerticalCentreCaret() {
// Avoid 64 bit compiler warnings.
// Scintilla does not support text buffers larger than 2**31
static int istrlen(const char *s) {
- return static_cast<int>(strlen(s));
+ return static_cast<int>(s ? strlen(s) : 0);
}
void Editor::MoveSelectedLines(int lineDelta) {
@@ -1150,13 +1140,13 @@ void Editor::MoveSelectedLines(int lineDelta) {
const char *eol = StringFromEOLMode(pdoc->eolMode);
if (currentLine + lineDelta >= pdoc->LinesTotal())
- pdoc->InsertCString(pdoc->Length(), eol);
+ pdoc->InsertString(pdoc->Length(), eol, istrlen(eol));
GoToLine(currentLine + lineDelta);
- pdoc->InsertCString(CurrentPosition(), selectedText.Data());
+ selectionLength = pdoc->InsertString(CurrentPosition(), selectedText.Data(), selectionLength);
if (appendEol) {
- pdoc->InsertCString(CurrentPosition() + selectionLength, eol);
- selectionLength += istrlen(eol);
+ const int lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol, istrlen(eol));
+ selectionLength += lengthInserted;
}
SetSelection(CurrentPosition(), CurrentPosition() + selectionLength);
}
@@ -1174,13 +1164,13 @@ void Editor::MoveCaretInsideView(bool ensureVisible) {
Point pt = PointMainCaret();
if (pt.y < rcClient.top) {
MovePositionTo(SPositionFromLocation(
- Point(lastXChosen - xOffset, rcClient.top),
+ Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top)),
false, false, UserVirtualSpace()),
Selection::noSel, ensureVisible);
} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
- int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight;
+ int yOfLastLineFullyDisplayed = static_cast<int>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight;
MovePositionTo(SPositionFromLocation(
- Point(lastXChosen - xOffset, rcClient.top + yOfLastLineFullyDisplayed),
+ Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed),
false, false, UserVirtualSpace()),
Selection::noSel, ensureVisible);
}
@@ -1229,7 +1219,7 @@ so the caret can move in the same direction longer before the policy is applied
If even is not set, instead of having symmetrical UZs,
the left and bottom UZs are extended up to right and top UZs respectively.
-This way, we favour the displaying of useful information: the begining of lines,
+This way, we favour the displaying of useful information: the beginning of lines,
where most code reside, and the lines after the caret, eg. the body of a function.
| | | | |
@@ -1370,7 +1360,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
// Horizontal positioning
if ((options & xysHorizontal) && !Wrapping()) {
- const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2;
+ const int halfScreen = Platform::Maximum(static_cast<int>(rcClient.Width()) - 4, 4) / 2;
const bool bSlop = (caretXPolicy & CARET_SLOP) != 0;
const bool bStrict = (caretXPolicy & CARET_STRICT) != 0;
const bool bJump = (caretXPolicy & CARET_JUMPS) != 0;
@@ -1391,7 +1381,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
if (bEven) {
xMarginL = xMarginR;
} else {
- xMarginL = rcClient.Width() - xMarginR - 4;
+ xMarginL = static_cast<int>(rcClient.Width()) - xMarginR - 4;
}
}
if (bJump && bEven) {
@@ -1406,7 +1396,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
newXY.xOffset -= xMoveL;
} else {
// Move just enough to allow to display the caret
- newXY.xOffset -= (rcClient.left + xMarginL) - pt.x;
+ newXY.xOffset -= static_cast<int>((rcClient.left + xMarginL) - pt.x);
}
} else if (pt.x >= rcClient.right - xMarginR) {
// Caret is on the right of the display
@@ -1414,7 +1404,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
newXY.xOffset += xMoveR;
} else {
// Move just enough to allow to display the caret
- newXY.xOffset += pt.x - (rcClient.right - xMarginR) + 1;
+ newXY.xOffset += static_cast<int>(pt.x - (rcClient.right - xMarginR) + 1);
}
}
} else { // Not strict
@@ -1423,7 +1413,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
if (bEven) {
xMoveL = xMoveR;
} else {
- xMoveL = rcClient.Width() - xMoveR - 4;
+ xMoveL = static_cast<int>(rcClient.Width()) - xMoveR - 4;
}
if (pt.x < rcClient.left) {
// Caret is on the left of the display
@@ -1439,31 +1429,31 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
// Strict or going out of display
if (bEven) {
// Center caret
- newXY.xOffset += pt.x - rcClient.left - halfScreen;
+ newXY.xOffset += static_cast<int>(pt.x - rcClient.left - halfScreen);
} else {
// Put caret on right
- newXY.xOffset += pt.x - rcClient.right + 1;
+ newXY.xOffset += static_cast<int>(pt.x - rcClient.right + 1);
}
} else {
// Move just enough to allow to display the caret
if (pt.x < rcClient.left) {
// Caret is on the left of the display
if (bEven) {
- newXY.xOffset -= rcClient.left - pt.x;
+ newXY.xOffset -= static_cast<int>(rcClient.left - pt.x);
} else {
- newXY.xOffset += pt.x - rcClient.right + 1;
+ newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1;
}
} else if (pt.x >= rcClient.right) {
// Caret is on the right of the display
- newXY.xOffset += pt.x - rcClient.right + 1;
+ newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1;
}
}
}
// In case of a jump (find result) largely out of display, adjust the offset to display the caret
if (pt.x + xOffset < rcClient.left + newXY.xOffset) {
- newXY.xOffset = pt.x + xOffset - rcClient.left - 2;
+ newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 2;
} else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) {
- newXY.xOffset = pt.x + xOffset - rcClient.right + 2;
+ newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 2;
if (vs.caretStyle == CARETSTYLE_BLOCK) {
// Ensure we can see a good portion of the block caret
newXY.xOffset += static_cast<int>(vs.aveCharWidth);
@@ -1472,14 +1462,14 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
if (!(range.caret == range.anchor)) {
if (ptAnchor.x < pt.x) {
// Shift to left to show anchor or as much of range as possible
- int maxOffset = ptAnchor.x + xOffset - rcClient.left - 1;
- int minOffset = pt.x + xOffset - rcClient.right + 1;
+ int maxOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.left) - 1;
+ int minOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 1;
newXY.xOffset = std::min(newXY.xOffset, maxOffset);
newXY.xOffset = std::max(newXY.xOffset, minOffset);
} else {
// Shift to right to show anchor or as much of range as possible
- int minOffset = ptAnchor.x + xOffset - rcClient.right + 1;
- int maxOffset = pt.x + xOffset - rcClient.left - 1;
+ int minOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.right) + 1;
+ int maxOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 1;
newXY.xOffset = std::max(newXY.xOffset, minOffset);
newXY.xOffset = std::min(newXY.xOffset, maxOffset);
}
@@ -1505,7 +1495,7 @@ void Editor::SetXYScroll(XYScrollPosition newXY) {
PRectangle rcText = GetTextRectangle();
if (horizontalScrollBarVisible &&
rcText.Width() + xOffset > scrollWidth) {
- scrollWidth = xOffset + rcText.Width();
+ scrollWidth = xOffset + static_cast<int>(rcText.Width());
SetScrollBars();
}
}
@@ -1542,6 +1532,14 @@ void Editor::DropCaret() {
InvalidateCaret();
}
+void Editor::CaretSetPeriod(int period) {
+ if (caret.period != period) {
+ caret.period = period;
+ caret.on = true;
+ InvalidateCaret();
+ }
+}
+
void Editor::InvalidateCaret() {
if (posDrag.IsValid()) {
InvalidateRange(posDrag.Position(), posDrag.Position() + 1);
@@ -1641,9 +1639,9 @@ bool Editor::WrapLines(enum wrapScope ws) {
if (lineToWrap < lineToWrapEnd) {
PRectangle rcTextArea = GetClientRectangle();
- rcTextArea.left = vs.textStart;
+ rcTextArea.left = static_cast<XYPOSITION>(vs.textStart);
rcTextArea.right -= vs.rightMarginWidth;
- wrapWidth = rcTextArea.Width();
+ wrapWidth = static_cast<int>(rcTextArea.Width());
RefreshStyleData();
AutoSurface surface(this);
if (surface) {
@@ -1686,8 +1684,8 @@ void Editor::LinesJoin() {
pdoc->DelChar(pos);
if (prevNonWS) {
// Ensure at least one space separating previous lines
- pdoc->InsertChar(pos, ' ');
- targetEnd++;
+ const int lengthInserted = pdoc->InsertString(pos, " ", 1);
+ targetEnd += lengthInserted;
}
} else {
prevNonWS = pdoc->CharAt(pos) != ' ';
@@ -1710,7 +1708,7 @@ void Editor::LinesSplit(int pixelWidth) {
if (!RangeContainsProtected(targetStart, targetEnd)) {
if (pixelWidth == 0) {
PRectangle rcText = GetTextRectangle();
- pixelWidth = rcText.Width();
+ pixelWidth = static_cast<int>(rcText.Width());
}
int lineStart = pdoc->LineFromPosition(targetStart);
int lineEnd = pdoc->LineFromPosition(targetEnd);
@@ -1722,12 +1720,14 @@ void Editor::LinesSplit(int pixelWidth) {
if (surface && ll) {
unsigned int posLineStart = pdoc->LineStart(line);
LayoutLine(line, surface, vs, ll, pixelWidth);
+ int lengthInsertedTotal = 0;
for (int subLine = 1; subLine < ll->lines; subLine++) {
- pdoc->InsertCString(
- static_cast<int>(posLineStart + (subLine - 1) * strlen(eol) +
+ const int lengthInserted = pdoc->InsertString(
+ static_cast<int>(posLineStart + lengthInsertedTotal +
ll->LineStart(subLine)),
- eol);
- targetEnd += static_cast<int>(strlen(eol));
+ eol, istrlen(eol));
+ targetEnd += lengthInserted;
+ lengthInsertedTotal += lengthInserted;
}
}
lineEnd = pdoc->LineFromPosition(targetEnd);
@@ -1763,8 +1763,8 @@ 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,
- static_cast<int>(endSegment - start + 1));
+ width += static_cast<int>(surface->WidthText(vs.styles[style + styleOffset].font, text + start,
+ static_cast<int>(endSegment - start + 1)));
start = endSegment + 1;
}
return width;
@@ -1779,8 +1779,8 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con
if (st.multipleStyles) {
widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine);
} else {
- widthSubLine = surface->WidthText(vs.styles[styleOffset + st.style].font,
- st.text + start, static_cast<int>(lenLine));
+ widthSubLine = static_cast<int>(surface->WidthText(vs.styles[styleOffset + st.style].font,
+ st.text + start, static_cast<int>(lenLine)));
}
if (widthSubLine > widthMax)
widthMax = widthSubLine;
@@ -1793,7 +1793,7 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle
const StyledText &st, size_t start, size_t length) {
if (st.multipleStyles) {
- int x = rcText.left;
+ int x = static_cast<int>(rcText.left);
size_t i = 0;
while (i < length) {
size_t end = i;
@@ -1801,13 +1801,13 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle
while (end < length-1 && st.styles[start+end+1] == style)
end++;
style += styleOffset;
- int width = surface->WidthText(vs.styles[style].font,
- st.text + start + i, static_cast<int>(end - i + 1));
+ int width = static_cast<int>(surface->WidthText(vs.styles[style].font,
+ st.text + start + i, static_cast<int>(end - i + 1)));
PRectangle rcSegment = rcText;
- rcSegment.left = x;
- rcSegment.right = x + width + 1;
+ rcSegment.left = static_cast<XYPOSITION>(x);
+ rcSegment.right = static_cast<XYPOSITION>(x + width + 1);
surface->DrawTextNoClip(rcSegment, vs.styles[style].font,
- ascent, st.text + start + i,
+ static_cast<XYPOSITION>(ascent), st.text + start + i,
static_cast<int>(end - i + 1),
vs.styles[style].fore,
vs.styles[style].back);
@@ -1836,7 +1836,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
Point ptOrigin = GetVisibleOriginInMain();
rcMargin.Move(0, -ptOrigin.y);
rcMargin.left = 0;
- rcMargin.right = vs.fixedColumnWidth;
+ rcMargin.right = static_cast<XYPOSITION>(vs.fixedColumnWidth);
if (!rc.Intersects(rcMargin))
return;
@@ -1892,9 +1892,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back);
}
- const int lineStartPaint = (rcMargin.top + ptOrigin.y) / vs.lineHeight;
+ const int lineStartPaint = static_cast<int>(rcMargin.top + ptOrigin.y) / vs.lineHeight;
int visibleLine = TopLineOfMain() + lineStartPaint;
- int yposScreen = lineStartPaint * vs.lineHeight - ptOrigin.y;
+ int yposScreen = lineStartPaint * vs.lineHeight - static_cast<int>(ptOrigin.y);
// Work out whether the top line is whitespace located after a
// lessening of fold level which implies a 'fold tail' but which should not
// be displayed until the last of a sequence of whitespace.
@@ -1920,18 +1920,18 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
}
// Old code does not know about new markers needed to distinguish all cases
- int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
+ const int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
SC_MARKNUM_FOLDEROPEN);
- int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
+ const int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
SC_MARKNUM_FOLDER);
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rc.bottom) {
PLATFORM_ASSERT(visibleLine < cs.LinesDisplayed());
- int lineDoc = cs.DocFromDisplay(visibleLine);
+ const int lineDoc = cs.DocFromDisplay(visibleLine);
PLATFORM_ASSERT(cs.GetVisible(lineDoc));
- bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc);
- bool lastSubLine = visibleLine == (cs.DisplayFromDoc(lineDoc + 1) - 1);
+ const bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc);
+ const bool lastSubLine = visibleLine == cs.DisplayLastFromDoc(lineDoc);
int marks = pdoc->GetMark(lineDoc);
if (!firstSubLine)
@@ -1941,10 +1941,10 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
// Decide which fold indicator should be displayed
- int level = pdoc->GetLevel(lineDoc);
- int levelNext = pdoc->GetLevel(lineDoc + 1);
- int levelNum = level & SC_FOLDLEVELNUMBERMASK;
- int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;
+ const int level = pdoc->GetLevel(lineDoc);
+ const int levelNext = pdoc->GetLevel(lineDoc + 1);
+ const int levelNum = level & SC_FOLDLEVELNUMBERMASK;
+ const int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;
if (level & SC_FOLDLEVELHEADERFLAG) {
if (firstSubLine) {
if (levelNum < levelNextNum) {
@@ -1974,9 +1974,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
}
}
needWhiteClosure = false;
- int firstFollowupLine = cs.DocFromDisplay(cs.DisplayFromDoc(lineDoc + 1));
- int firstFollowupLineLevel = pdoc->GetLevel(firstFollowupLine);
- int secondFollowupLineLevelNum = pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK;
+ const int firstFollowupLine = cs.DocFromDisplay(cs.DisplayFromDoc(lineDoc + 1));
+ const int firstFollowupLineLevel = pdoc->GetLevel(firstFollowupLine);
+ const int secondFollowupLineLevelNum = pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK;
if (!cs.GetExpanded(lineDoc)) {
if ((firstFollowupLineLevel & SC_FOLDLEVELWHITEFLAG) &&
(levelNum > secondFollowupLineLevelNum))
@@ -2031,21 +2031,26 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
marks &= vs.ms[margin].mask;
PRectangle rcMarker = rcSelMargin;
- rcMarker.top = yposScreen;
- rcMarker.bottom = yposScreen + vs.lineHeight;
+ rcMarker.top = static_cast<XYPOSITION>(yposScreen);
+ rcMarker.bottom = static_cast<XYPOSITION>(yposScreen + vs.lineHeight);
if (vs.ms[margin].style == SC_MARGIN_NUMBER) {
if (firstSubLine) {
char number[100] = "";
if (lineDoc >= 0)
sprintf(number, "%d", lineDoc + 1);
- if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
- int lev = pdoc->GetLevel(lineDoc);
- sprintf(number, "%c%c %03X %03X",
- (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
- (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
- lev & SC_FOLDLEVELNUMBERMASK,
- lev >> 16
- );
+ if (foldFlags & (SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE)) {
+ if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
+ int lev = pdoc->GetLevel(lineDoc);
+ sprintf(number, "%c%c %03X %03X",
+ (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
+ (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
+ lev & SC_FOLDLEVELNUMBERMASK,
+ lev >> 16
+ );
+ } else {
+ int state = pdoc->GetLineState(lineDoc);
+ sprintf(number, "%0X", state);
+ }
}
PRectangle rcNumber = rcMarker;
// Right justify
@@ -2072,7 +2077,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin);
rcMarker.left = rcMarker.right - width - 3;
}
- DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent,
+ DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, static_cast<int>(rcMarker.top) + vs.maxAscent,
stMargin, 0, stMargin.length);
}
}
@@ -2121,19 +2126,19 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
}
void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) {
- int ydiff = (rcTab.bottom - rcTab.top) / 2;
- int xhead = rcTab.right - 1 - ydiff;
+ int ydiff = static_cast<int>(rcTab.bottom - rcTab.top) / 2;
+ int xhead = static_cast<int>(rcTab.right) - 1 - ydiff;
if (xhead <= rcTab.left) {
- ydiff -= rcTab.left - xhead - 1;
- xhead = rcTab.left - 1;
+ ydiff -= static_cast<int>(rcTab.left) - xhead - 1;
+ xhead = static_cast<int>(rcTab.left) - 1;
}
if ((rcTab.left + 2) < (rcTab.right - 1))
- surface->MoveTo(rcTab.left + 2, ymid);
+ surface->MoveTo(static_cast<int>(rcTab.left) + 2, ymid);
else
- surface->MoveTo(rcTab.right - 1, ymid);
- surface->LineTo(rcTab.right - 1, ymid);
+ surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid);
+ surface->LineTo(static_cast<int>(rcTab.right) - 1, ymid);
surface->LineTo(xhead, ymid - ydiff);
- surface->MoveTo(rcTab.right - 1, ymid);
+ surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid);
surface->LineTo(xhead, ymid + ydiff);
}
@@ -2218,7 +2223,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
ll->edgeColumn = -1;
}
- char styleByte;
const int styleMask = pdoc->stylingBitsMask;
ll->styleBitsSet = 0;
// Fill base line layout
@@ -2228,12 +2232,12 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
int numCharsBeforeEOL = pdoc->LineEnd(line) - posLineStart;
const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL;
for (int styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) {
- styleByte = ll->styles[styleInLine];
+ const unsigned char styleByte = ll->styles[styleInLine];
ll->styleBitsSet |= styleByte;
- ll->styles[styleInLine] = static_cast<char>(styleByte & styleMask);
+ ll->styles[styleInLine] = styleByte & styleMask;
ll->indicators[styleInLine] = static_cast<char>(styleByte & ~styleMask);
}
- styleByte = static_cast<char>(((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask);
+ const unsigned char styleByteLast = ((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask;
if (vstyle.someStylesForceCase) {
for (int charInLine = 0; charInLine<lineLength; charInLine++) {
char chDoc = ll->chars[charInLine];
@@ -2246,7 +2250,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
ll->xHighlightGuide = 0;
// Extra element at the end of the line to hold end x position and act as
ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character
- ll->styles[numCharsInLine] = styleByte; // For eolFilled
+ ll->styles[numCharsInLine] = styleByteLast; // For eolFilled
ll->indicators[numCharsInLine] = 0;
// Layout the line, determining the position of each character,
@@ -2418,8 +2422,8 @@ ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
}
void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight) {
- Point from(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
- PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom);
+ Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
+ PRectangle rcCopyArea = PRectangle::FromInts(start + 1, static_cast<int>(rcSegment.top), start + 2, static_cast<int>(rcSegment.bottom));
surface->Copy(rcCopyArea, from,
highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide);
}
@@ -2429,15 +2433,15 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
surface->PenColour(wrapColour);
enum { xa = 1 }; // gap before start
- int w = rcPlace.right - rcPlace.left - xa - 1;
+ int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1;
bool xStraight = isEndMarker; // x-mirrored symbol for start marker
- int x0 = xStraight ? rcPlace.left : rcPlace.right - 1;
- int y0 = rcPlace.top;
+ int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1);
+ int y0 = static_cast<int>(rcPlace.top);
- int dy = (rcPlace.bottom - rcPlace.top) / 5;
- int y = (rcPlace.bottom - rcPlace.top) / 2 + dy;
+ int dy = static_cast<int>(rcPlace.bottom - rcPlace.top) / 5;
+ int y = static_cast<int>(rcPlace.bottom - rcPlace.top) / 2 + dy;
struct Relative {
Surface *surface;
@@ -2480,8 +2484,8 @@ void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment,
surface->FillRectangle(rcSegment, textBack);
}
Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font;
- int normalCharHeight = surface->Ascent(ctrlCharsFont) -
- surface->InternalLeading(ctrlCharsFont);
+ int normalCharHeight = static_cast<int>(surface->Ascent(ctrlCharsFont) -
+ surface->InternalLeading(ctrlCharsFont));
PRectangle rcCChar = rcSegment;
rcCChar.left = rcCChar.left + 1;
rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
@@ -2513,7 +2517,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth;
}
- XYPOSITION xEol = ll->positions[lineEnd] - subLineStart;
+ XYPOSITION xEol = static_cast<XYPOSITION>(ll->positions[lineEnd] - subLineStart);
// Fill the virtual space and show selections within it
if (virtualSpace) {
@@ -2528,8 +2532,10 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange);
if (!portion.Empty()) {
const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
- rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth;
- rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth;
+ rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] -
+ static_cast<XYPOSITION>(subLineStart) + portion.start.VirtualSpace() * spaceWidth;
+ rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] -
+ static_cast<XYPOSITION>(subLineStart) + portion.end.VirtualSpace() * spaceWidth;
rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left;
rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right;
surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main()));
@@ -2551,8 +2557,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
XYPOSITION blobsWidth = 0;
if (lastSubLine) {
for (int eolPos=ll->numCharsBeforeEOL; eolPos<ll->numCharsInLine; eolPos++) {
- rcSegment.left = xStart + ll->positions[eolPos] - subLineStart + virtualSpace;
- rcSegment.right = xStart + ll->positions[eolPos+1] - subLineStart + virtualSpace;
+ rcSegment.left = xStart + ll->positions[eolPos] - static_cast<XYPOSITION>(subLineStart) + virtualSpace;
+ rcSegment.right = xStart + ll->positions[eolPos + 1] - static_cast<XYPOSITION>(subLineStart) + virtualSpace;
blobsWidth += rcSegment.Width();
char hexits[4];
const char *ctrlChar;
@@ -2742,23 +2748,23 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x
void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine) {
- int indent = pdoc->GetLineIndentation(line) * vsDraw.spaceWidth;
+ int indent = static_cast<int>(pdoc->GetLineIndentation(line) * vsDraw.spaceWidth);
PRectangle rcSegment = rcLine;
int annotationLine = subLine - ll->lines;
const StyledText stAnnotation = pdoc->AnnotationStyledText(line);
if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) {
surface->FillRectangle(rcSegment, vsDraw.styles[0].back);
- rcSegment.left = xStart;
+ rcSegment.left = static_cast<XYPOSITION>(xStart);
if (trackLineWidth || (vs.annotationVisible == ANNOTATION_BOXED)) {
// Only care about calculating width if tracking or need to draw box
int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation);
if (vs.annotationVisible == ANNOTATION_BOXED) {
- widthAnnotation += vsDraw.spaceWidth * 2; // Margins
+ widthAnnotation += static_cast<int>(vsDraw.spaceWidth * 2); // Margins
}
if (widthAnnotation > lineWidthMaxSeen)
lineWidthMaxSeen = widthAnnotation;
if (vs.annotationVisible == ANNOTATION_BOXED) {
- rcSegment.left = xStart + indent;
+ rcSegment.left = static_cast<XYPOSITION>(xStart + indent);
rcSegment.right = rcSegment.left + widthAnnotation;
}
}
@@ -2777,21 +2783,21 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back);
rcText.left += vsDraw.spaceWidth;
}
- DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent,
+ DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, static_cast<int>(rcText.top + vsDraw.maxAscent),
stAnnotation, start, lengthAnnotation);
if (vs.annotationVisible == ANNOTATION_BOXED) {
surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore);
- surface->MoveTo(rcSegment.left, rcSegment.top);
- surface->LineTo(rcSegment.left, rcSegment.bottom);
- surface->MoveTo(rcSegment.right, rcSegment.top);
- surface->LineTo(rcSegment.right, rcSegment.bottom);
+ surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top));
+ surface->LineTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.bottom));
+ surface->MoveTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.top));
+ surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.bottom));
if (subLine == ll->lines) {
- surface->MoveTo(rcSegment.left, rcSegment.top);
- surface->LineTo(rcSegment.right, rcSegment.top);
+ surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top));
+ surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.top));
}
if (subLine == ll->lines+annotationLines-1) {
- surface->MoveTo(rcSegment.left, rcSegment.bottom - 1);
- surface->LineTo(rcSegment.right, rcSegment.bottom - 1);
+ surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.bottom - 1));
+ surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.bottom - 1));
}
}
}
@@ -2893,7 +2899,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
// draw continuation rect
PRectangle rcPlace = rcSegment;
- rcPlace.left = ll->positions[startseg] + xStart - subLineStart;
+ rcPlace.left = ll->positions[startseg] + xStart - static_cast<XYPOSITION>(subLineStart);
rcPlace.right = rcPlace.left + ll->wrapIndent;
// default bgnd here..
@@ -2937,8 +2943,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
const int i = ts.end() - 1;
const int iDoc = i + posLineStart;
- rcSegment.left = ll->positions[ts.start] + xStart - subLineStart;
- rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart;
+ rcSegment.left = ll->positions[ts.start] + xStart - static_cast<XYPOSITION>(subLineStart);
+ rcSegment.right = ll->positions[ts.end()] + xStart - static_cast<XYPOSITION>(subLineStart);
// Only try to draw if really visible - enhances performance by not calling environment to
// draw strings that are completely past the right side of the window.
if (rcSegment.Intersects(rcLine)) {
@@ -2972,9 +2978,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
if (ll->chars[cpos + ts.start] == ' ') {
if (drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
- PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart,
+ PRectangle rcSpace(
+ ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.top,
- ll->positions[cpos + ts.start + 1] + xStart - subLineStart,
+ ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.bottom);
surface->FillRectangle(rcSpace, vsDraw.whitespaceColours.back);
}
@@ -2997,8 +3004,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true);
if (vsDraw.edgeState == EDGE_LINE) {
- int edgeX = vsDraw.theEdge * vsDraw.spaceWidth;
- rcSegment.left = edgeX + xStart;
+ int edgeX = static_cast<int>(vsDraw.theEdge * vsDraw.spaceWidth);
+ rcSegment.left = static_cast<XYPOSITION>(edgeX + xStart);
if ((ll->wrapIndent != 0) && (lineStart != 0))
rcSegment.left -= ll->wrapIndent;
rcSegment.right = rcSegment.left + 1;
@@ -3029,8 +3036,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
const int i = ts.end() - 1;
const int iDoc = i + posLineStart;
- rcSegment.left = ll->positions[ts.start] + xStart - subLineStart;
- rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart;
+ rcSegment.left = ll->positions[ts.start] + xStart - static_cast<XYPOSITION>(subLineStart);
+ rcSegment.right = ll->positions[ts.end()] + xStart - static_cast<XYPOSITION>(subLineStart);
// Only try to draw if really visible - enhances performance by not calling environment to
// draw strings that are completely past the right side of the window.
if (rcSegment.Intersects(rcLine)) {
@@ -3058,11 +3065,11 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
surface->FillRectangle(rcSegment, textBack);
}
if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
- for (int indentCount = (ll->positions[i] + epsilon) / indentWidth;
+ for (int indentCount = static_cast<int>((ll->positions[i] + epsilon) / indentWidth);
indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth;
indentCount++) {
if (indentCount > 0) {
- int xIndent = indentCount * indentWidth;
+ int xIndent = static_cast<int>(indentCount * indentWidth);
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
(ll->xHighlightGuide == xIndent));
}
@@ -3075,7 +3082,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
surface->PenColour(textFore);
PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
- DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+ DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2));
}
}
} else {
@@ -3114,24 +3121,26 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
if (!twoPhaseDraw && drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
textBack = vsDraw.whitespaceColours.back;
- PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart,
+ PRectangle rcSpace(
+ ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.top,
- ll->positions[cpos + ts.start + 1] + xStart - subLineStart,
+ ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.bottom);
surface->FillRectangle(rcSpace, textBack);
}
- PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
+ PRectangle rcDot(xmid + xStart - static_cast<XYPOSITION>(subLineStart),
+ rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f);
rcDot.right = rcDot.left + vs.whitespaceSize;
rcDot.bottom = rcDot.top + vs.whitespaceSize;
surface->FillRectangle(rcDot, textFore);
}
}
if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
- for (int indentCount = (ll->positions[cpos + ts.start] + epsilon) / indentWidth;
+ for (int indentCount = static_cast<int>((ll->positions[cpos + ts.start] + epsilon) / indentWidth);
indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth;
indentCount++) {
if (indentCount > 0) {
- int xIndent = indentCount * indentWidth;
+ int xIndent = static_cast<int>(indentCount * indentWidth);
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
(ll->xHighlightGuide == xIndent));
}
@@ -3164,7 +3173,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth)
&& (subLine == 0)) {
int indentSpace = pdoc->GetLineIndentation(line);
- int xStartText = ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart];
+ int xStartText = static_cast<int>(ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart]);
// Find the most recent line with some text
@@ -3203,7 +3212,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
for (int indentPos = pdoc->IndentSize(); indentPos < indentSpace; indentPos += pdoc->IndentSize()) {
- int xIndent = indentPos * vsDraw.spaceWidth;
+ int xIndent = static_cast<int>(indentPos * vsDraw.spaceWidth);
if (xIndent < xStartText) {
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
(ll->xHighlightGuide == xIndent));
@@ -3234,8 +3243,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange);
if (!portion.Empty()) {
const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
- rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth;
- rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth;
+ rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] -
+ static_cast<XYPOSITION>(subLineStart) + portion.start.VirtualSpace() * spaceWidth;
+ rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] -
+ static_cast<XYPOSITION>(subLineStart) + portion.end.VirtualSpace() * spaceWidth;
if ((ll->wrapIndent != 0) && (lineStart != 0)) {
if ((portion.start.Position() - posLineStart) == lineStart && sel.Range(r).ContainsCharacter(portion.start.Position() - 1))
rcSegment.left -= static_cast<int>(ll->wrapIndent); // indentation added to xStart was truncated to int, so we do the same here
@@ -3352,7 +3363,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
// for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half
// way between the chrome colour and the chrome highlight colour making a nice transition
// between the window chrome and the content area. And it works in low colour depths.
- PRectangle rcPattern(0, 0, patternSize, patternSize);
+ PRectangle rcPattern = PRectangle::FromInts(0, 0, patternSize, patternSize);
// Initialize default colours based on the chrome colour scheme. Typically the highlight is white.
ColourDesired colourFMFill = vs.selbar;
@@ -3377,7 +3388,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
pixmapSelPatternOffset1->FillRectangle(rcPattern, colourFMStripes);
for (int y = 0; y < patternSize; y++) {
for (int x = y % 2; x < patternSize; x+=2) {
- PRectangle rcPixel(x, y, x+1, y+1);
+ PRectangle rcPixel = PRectangle::FromInts(x, y, x + 1, y + 1);
pixmapSelPattern->FillRectangle(rcPixel, colourFMStripes);
pixmapSelPatternOffset1->FillRectangle(rcPixel, colourFMFill);
}
@@ -3388,13 +3399,13 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
// 1 extra pixel in height so can handle odd/even positions and so produce a continuous line
pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID());
pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID());
- PRectangle rcIG(0, 0, 1, vs.lineHeight);
+ PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vs.lineHeight);
pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back);
pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore);
pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back);
pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore);
for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) {
- PRectangle rcPixel(0, stripe, 1, stripe+1);
+ PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1);
pixmapIndentGuide->FillRectangle(rcPixel, vs.styles[STYLE_INDENTGUIDE].fore);
pixmapIndentGuideHighlight->FillRectangle(rcPixel, vs.styles[STYLE_BRACELIGHT].fore);
}
@@ -3403,10 +3414,10 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
if (bufferedDraw) {
if (!pixmapLine->Initialised()) {
PRectangle rcClient = GetClientRectangle();
- pixmapLine->InitPixMap(rcClient.Width(), vs.lineHeight,
+ pixmapLine->InitPixMap(static_cast<int>(rcClient.Width()), vs.lineHeight,
surfaceWindow, wMain.GetID());
pixmapSelMargin->InitPixMap(vs.fixedColumnWidth,
- rcClient.Height(), surfaceWindow, wMain.GetID());
+ static_cast<int>(rcClient.Height()), surfaceWindow, wMain.GetID());
}
}
}
@@ -3460,7 +3471,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
xposCaret += xStart;
if (posDrag.IsValid()) {
/* Dragging text, use a line caret */
- rcCaret.left = RoundXYPosition(xposCaret - caretWidthOffset);
+ rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset));
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
} else if (inOverstrike && drawOverstrikeCaret) {
/* Overstrike (insert mode), use a modified bar caret */
@@ -3478,7 +3489,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
}
} else {
/* Line caret */
- rcCaret.left = RoundXYPosition(xposCaret - caretWidthOffset);
+ rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset));
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
}
ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
@@ -3513,9 +3524,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
//Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n",
// rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
- int screenLinePaintFirst = rcArea.top / vs.lineHeight;
+ int screenLinePaintFirst = static_cast<int>(rcArea.top) / vs.lineHeight;
- int xStart = vs.textStart - xOffset + ptOrigin.x;
+ int xStart = vs.textStart - xOffset + static_cast<int>(ptOrigin.x);
int ypos = 0;
if (!bufferedDraw)
ypos += screenLinePaintFirst * vs.lineHeight;
@@ -3646,8 +3657,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
GetHotSpotRange(ll->hsStart, ll->hsEnd);
PRectangle rcLine = rcTextArea;
- rcLine.top = ypos;
- rcLine.bottom = ypos + vs.lineHeight;
+ rcLine.top = static_cast<XYPOSITION>(ypos);
+ rcLine.bottom = static_cast<XYPOSITION>(ypos + vs.lineHeight);
bool bracesIgnoreStyle = false;
if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) ||
@@ -3657,7 +3668,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1));
// Highlight the current braces if any
ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle),
- highlightGuideColumn * vs.spaceWidth, bracesIgnoreStyle);
+ static_cast<int>(highlightGuideColumn * vs.spaceWidth), bracesIgnoreStyle);
if (leftTextOverlap && bufferedDraw) {
PRectangle rcSpacer = rcLine;
@@ -3699,14 +3710,15 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
DrawCarets(surface, vs, lineDoc, xStart, rcLine, ll, subLine);
if (bufferedDraw) {
- Point from(vs.textStart-leftTextOverlap, 0);
- PRectangle rcCopyArea(vs.textStart-leftTextOverlap, yposScreen,
- rcClient.right - vs.rightMarginWidth, yposScreen + vs.lineHeight);
+ Point from = Point::FromInts(vs.textStart-leftTextOverlap, 0);
+ PRectangle rcCopyArea = PRectangle::FromInts(vs.textStart - leftTextOverlap, yposScreen,
+ static_cast<int>(rcClient.right - vs.rightMarginWidth),
+ yposScreen + vs.lineHeight);
surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
}
lineWidthMaxSeen = Platform::Maximum(
- lineWidthMaxSeen, ll->positions[ll->numCharsInLine]);
+ lineWidthMaxSeen, static_cast<int>(ll->positions[ll->numCharsInLine]));
//durCopy += et.Duration(true);
}
@@ -3725,14 +3737,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
// Right column limit indicator
PRectangle rcBeyondEOF = (vs.marginInside) ? rcClient : rcArea;
- rcBeyondEOF.left = vs.textStart;
+ rcBeyondEOF.left = static_cast<XYPOSITION>(vs.textStart);
rcBeyondEOF.right = rcBeyondEOF.right - ((vs.marginInside) ? vs.rightMarginWidth : 0);
- rcBeyondEOF.top = (cs.LinesDisplayed() - TopLineOfMain()) * vs.lineHeight;
+ rcBeyondEOF.top = static_cast<XYPOSITION>((cs.LinesDisplayed() - TopLineOfMain()) * vs.lineHeight);
if (rcBeyondEOF.top < rcBeyondEOF.bottom) {
surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back);
if (vs.edgeState == EDGE_LINE) {
- int edgeX = vs.theEdge * vs.spaceWidth;
- rcBeyondEOF.left = edgeX + xStart;
+ int edgeX = static_cast<int>(vs.theEdge * vs.spaceWidth);
+ rcBeyondEOF.left = static_cast<XYPOSITION>(edgeX + xStart);
rcBeyondEOF.right = rcBeyondEOF.left + 1;
surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour);
}
@@ -3834,11 +3846,11 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
vsPrint.rightMarginWidth = 0;
vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars);
- // Determining width must hapen after fonts have been realised in Refresh
+ // Determining width must happen after fonts have been realised in Refresh
int lineNumberWidth = 0;
if (lineNumberIndex >= 0) {
- lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font,
- "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
+ lineNumberWidth = static_cast<int>(surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font,
+ "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace)));
vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars); // Recalculate fixedColumnWidth
}
@@ -3886,11 +3898,11 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
ll.containsCaret = false;
- PRectangle rcLine;
- rcLine.left = pfr->rc.left;
- rcLine.top = ypos;
- rcLine.right = pfr->rc.right - 1;
- rcLine.bottom = ypos + vsPrint.lineHeight;
+ PRectangle rcLine = PRectangle::FromInts(
+ pfr->rc.left,
+ ypos,
+ pfr->rc.right - 1,
+ ypos + vsPrint.lineHeight);
// When document line is wrapped over multiple display lines, find where
// to start printing from to ensure a particular position is on the first
@@ -3920,7 +3932,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number));
surface->FlushCachedState();
surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
- ypos + vsPrint.maxAscent, number, istrlen(number),
+ static_cast<XYPOSITION>(ypos + vsPrint.maxAscent), number, istrlen(number),
vsPrint.styles[STYLE_LINENUMBER].fore,
vsPrint.styles[STYLE_LINENUMBER].back);
}
@@ -3932,8 +3944,8 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
if (ypos + vsPrint.lineHeight <= pfr->rc.bottom) {
if (visibleLine >= 0) {
if (draw) {
- rcLine.top = ypos;
- rcLine.bottom = ypos + vsPrint.lineHeight;
+ rcLine.top = static_cast<XYPOSITION>(ypos);
+ rcLine.bottom = static_cast<XYPOSITION>(ypos + vsPrint.lineHeight);
DrawLine(surface, vsPrint, lineDoc, visibleLine, xStart, rcLine, &ll, iwl);
}
ypos += vsPrint.lineHeight;
@@ -3959,7 +3971,7 @@ int Editor::TextWidth(int style, const char *text) {
RefreshStyleData();
AutoSurface surface(this);
if (surface) {
- return surface->WidthText(vs.styles[style].font, text, istrlen(text));
+ return static_cast<int>(surface->WidthText(vs.styles[style].font, text, istrlen(text)));
} else {
return 1;
}
@@ -3997,7 +4009,7 @@ void Editor::ChangeSize() {
SetScrollBars();
if (Wrapping()) {
PRectangle rcTextArea = GetClientRectangle();
- rcTextArea.left = vs.textStart;
+ rcTextArea.left = static_cast<XYPOSITION>(vs.textStart);
rcTextArea.right -= vs.rightMarginWidth;
if (wrapWidth != rcTextArea.Width()) {
NeedWrapping();
@@ -4009,8 +4021,8 @@ void Editor::ChangeSize() {
int Editor::InsertSpace(int position, unsigned int spaces) {
if (spaces > 0) {
std::string spaceText(spaces, ' ');
- pdoc->InsertString(position, spaceText.c_str(), spaces);
- position += spaces;
+ const int lengthInserted = pdoc->InsertString(position, spaceText.c_str(), spaces);
+ position += lengthInserted;
}
return position;
}
@@ -4069,9 +4081,10 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
}
}
positionInsert = InsertSpace(positionInsert, currentSel->caret.VirtualSpace());
- if (pdoc->InsertString(positionInsert, s, len)) {
- currentSel->caret.SetPosition(positionInsert + len);
- currentSel->anchor.SetPosition(positionInsert + len);
+ const int lengthInserted = pdoc->InsertString(positionInsert, s, len);
+ if (lengthInserted > 0) {
+ currentSel->caret.SetPosition(positionInsert + lengthInserted);
+ currentSel->anchor.SetPosition(positionInsert + lengthInserted);
}
currentSel->ClearVirtualSpace();
// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
@@ -4143,11 +4156,13 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
}
}
-void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len) {
+void Editor::InsertPaste(const char *text, int len) {
if (multiPasteMode == SC_MULTIPASTE_ONCE) {
+ SelectionPosition selStart = sel.Start();
selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace()));
- if (pdoc->InsertString(selStart.Position(), text, len)) {
- SetEmptySelection(selStart.Position() + len);
+ const int lengthInserted = pdoc->InsertString(selStart.Position(), text, len);
+ if (lengthInserted > 0) {
+ SetEmptySelection(selStart.Position() + lengthInserted);
}
} else {
// SC_MULTIPASTE_EACH
@@ -4165,9 +4180,10 @@ void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len)
}
}
positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
- if (pdoc->InsertString(positionInsert, text, len)) {
- sel.Range(r).caret.SetPosition(positionInsert + len);
- sel.Range(r).anchor.SetPosition(positionInsert + len);
+ const int lengthInserted = pdoc->InsertString(positionInsert, text, len);
+ if (lengthInserted > 0) {
+ sel.Range(r).caret.SetPosition(positionInsert + lengthInserted);
+ sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted);
}
sel.Range(r).ClearVirtualSpace();
}
@@ -4175,6 +4191,35 @@ void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len)
}
}
+void Editor::InsertPasteShape(const char *text, int len, PasteShape shape) {
+ std::string convertedText;
+ if (convertPastes) {
+ // Convert line endings of the paste into our local line-endings mode
+ convertedText = Document::TransformLineEnds(text, len, pdoc->eolMode);
+ len = static_cast<int>(convertedText.length());
+ text = convertedText.c_str();
+ }
+ if (shape == pasteRectangular) {
+ PasteRectangular(sel.Start(), text, len);
+ } else {
+ if (shape == pasteLine) {
+ int insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()));
+ int lengthInserted = pdoc->InsertString(insertPos, text, len);
+ // add the newline if necessary
+ if ((len > 0) && (text[len - 1] != '\n' && text[len - 1] != '\r')) {
+ const char *endline = StringFromEOLMode(pdoc->eolMode);
+ int length = static_cast<int>(strlen(endline));
+ lengthInserted += pdoc->InsertString(insertPos + lengthInserted, endline, length);
+ }
+ if (sel.MainCaret() == insertPos) {
+ SetEmptySelection(sel.MainCaret() + lengthInserted);
+ }
+ } else {
+ InsertPaste(text, len);
+ }
+ }
+}
+
void Editor::ClearSelection(bool retainMultipleSelections) {
if (!sel.IsRectangular() && !retainMultipleSelections)
FilterSelections();
@@ -4263,22 +4308,22 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
line++;
if (line >= pdoc->LinesTotal()) {
if (pdoc->eolMode != SC_EOL_LF)
- pdoc->InsertChar(pdoc->Length(), '\r');
+ pdoc->InsertString(pdoc->Length(), "\r", 1);
if (pdoc->eolMode != SC_EOL_CR)
- pdoc->InsertChar(pdoc->Length(), '\n');
+ pdoc->InsertString(pdoc->Length(), "\n", 1);
}
// Pad the end of lines with spaces if required
sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert));
if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) {
while (XFromPosition(sel.MainCaret()) < xInsert) {
- pdoc->InsertChar(sel.MainCaret(), ' ');
- sel.RangeMain().caret.Add(1);
+ const int lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1);
+ sel.RangeMain().caret.Add(lengthInserted);
}
}
prevCr = ptr[i] == '\r';
} else {
- pdoc->InsertString(sel.MainCaret(), ptr + i, 1);
- sel.RangeMain().caret.Add(1);
+ const int lengthInserted = pdoc->InsertString(sel.MainCaret(), ptr + i, 1);
+ sel.RangeMain().caret.Add(lengthInserted);
prevCr = false;
}
}
@@ -4374,14 +4419,12 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
UndoGroup ugInner(pdoc, !ug.Needed());
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
- if (indentation % indentationStep == 0) {
- pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
- } else {
- pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep));
- }
+ int indentationChange = indentation % indentationStep;
+ if (indentationChange == 0)
+ indentationChange = indentationStep;
+ const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationChange);
// SetEmptySelection
- sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos),
- pdoc->GetLineIndentPosition(lineCurrentPos));
+ sel.Range(r) = SelectionRange(posSelect);
} else {
pdoc->DelCharBack(sel.Range(r).caret.Position());
}
@@ -4603,8 +4646,8 @@ void Editor::NotifyDwelling(Point pt, bool state) {
SCNotification scn = {};
scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND;
scn.position = PositionFromLocation(pt, true);
- scn.x = pt.x + vs.ExternalMarginWidth();
- scn.y = pt.y;
+ scn.x = static_cast<int>(pt.x + vs.ExternalMarginWidth());
+ scn.y = static_cast<int>(pt.y);
NotifyParent(scn);
}
@@ -4970,17 +5013,17 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
int topStutterLine = topLine + caretYSlop;
int bottomStutterLine =
pdoc->LineFromPosition(PositionFromLocation(
- Point(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll())))
+ Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll())))
- caretYSlop - 1;
if (stuttered && (direction < 0 && currentLine > topStutterLine)) {
topLineNew = topLine;
- newPos = SPositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * caretYSlop),
+ newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * caretYSlop),
false, false, UserVirtualSpace());
} else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) {
topLineNew = topLine;
- newPos = SPositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)),
+ newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)),
false, false, UserVirtualSpace());
} else {
@@ -4989,7 +5032,7 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
topLineNew = Platform::Clamp(
topLine + direction * LinesToScroll(), 0, MaxScrollPos());
newPos = SPositionFromLocation(
- Point(lastXChosen - xOffset, pt.y + direction * (vs.lineHeight * LinesToScroll())),
+ Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * LinesToScroll())),
false, false, UserVirtualSpace());
}
@@ -5029,12 +5072,13 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
pdoc->DeleteChars(
static_cast<int>(currentNoVS.Start().Position() + firstDifference),
static_cast<int>(rangeBytes - firstDifference - endDifferenceText));
- pdoc->InsertString(
+ const int lengthChange = static_cast<int>(lastDifferenceMapped - firstDifference + 1);
+ const int lengthInserted = pdoc->InsertString(
static_cast<int>(currentNoVS.Start().Position() + firstDifference),
sMapped.c_str() + firstDifference,
- static_cast<int>(lastDifferenceMapped - firstDifference + 1));
+ lengthChange);
// Automatic movement changes selection so reset to exactly the same as it was.
- int diffSizes = static_cast<int>(sMapped.size() - sText.size());
+ int diffSizes = static_cast<int>(sMapped.size() - sText.size()) + lengthInserted - lengthChange;
if (diffSizes != 0) {
if (current.anchor > current.caret)
current.anchor.Add(diffSizes);
@@ -5051,19 +5095,23 @@ void Editor::LineTranspose() {
int line = pdoc->LineFromPosition(sel.MainCaret());
if (line > 0) {
UndoGroup ug(pdoc);
- int startPrev = pdoc->LineStart(line - 1);
- int endPrev = pdoc->LineEnd(line - 1);
- int start = pdoc->LineStart(line);
- int end = pdoc->LineEnd(line);
- std::string line1 = RangeText(startPrev, endPrev);
- int len1 = endPrev - startPrev;
- std::string line2 = RangeText(start, end);
- int len2 = end - start;
- pdoc->DeleteChars(start, len2);
- pdoc->DeleteChars(startPrev, len1);
- pdoc->InsertString(startPrev, line2.c_str(), len2);
- pdoc->InsertString(start - len1 + len2, line1.c_str(), len1);
- MovePositionTo(SelectionPosition(start - len1 + len2));
+
+ const int startPrevious = pdoc->LineStart(line - 1);
+ const std::string linePrevious = RangeText(startPrevious, pdoc->LineEnd(line - 1));
+
+ int startCurrent = pdoc->LineStart(line);
+ const std::string lineCurrent = RangeText(startCurrent, pdoc->LineEnd(line));
+
+ pdoc->DeleteChars(startCurrent, static_cast<int>(lineCurrent.length()));
+ pdoc->DeleteChars(startPrevious, static_cast<int>(linePrevious.length()));
+ startCurrent -= static_cast<int>(linePrevious.length());
+
+ startCurrent += pdoc->InsertString(startPrevious, lineCurrent.c_str(),
+ static_cast<int>(lineCurrent.length()));
+ pdoc->InsertString(startCurrent, linePrevious.c_str(),
+ static_cast<int>(linePrevious.length()));
+ // Move caret to start of current line
+ MovePositionTo(SelectionPosition(startCurrent));
}
}
@@ -5087,9 +5135,10 @@ void Editor::Duplicate(bool forLine) {
end = SelectionPosition(pdoc->LineEnd(line));
}
std::string text = RangeText(start.Position(), end.Position());
+ int lengthInserted = eolLen;
if (forLine)
- pdoc->InsertString(end.Position(), eol, eolLen);
- pdoc->InsertString(end.Position() + eolLen, text.c_str(), SelectionRange(end, start).Length());
+ lengthInserted = pdoc->InsertString(end.Position(), eol, eolLen);
+ pdoc->InsertString(end.Position() + lengthInserted, text.c_str(), static_cast<int>(text.length()));
}
if (sel.Count() && sel.IsRectangular()) {
SelectionPosition last = sel.Last();
@@ -5128,12 +5177,12 @@ void Editor::NewLine() {
} else if (pdoc->eolMode == SC_EOL_CR) {
eol = "\r";
} // else SC_EOL_LF -> "\n" already set
- bool inserted = pdoc->InsertCString(sel.MainCaret(), eol);
+ const int insertLength = pdoc->InsertString(sel.MainCaret(), eol, istrlen(eol));
// Want to end undo group before NotifyChar as applications often modify text here
if (needGroupUndo)
pdoc->EndUndoAction();
- if (inserted) {
- SetEmptySelection(sel.MainCaret() + istrlen(eol));
+ if (insertLength > 0) {
+ SetEmptySelection(sel.MainCaret() + insertLength);
while (*eol) {
NotifyChar(*eol);
if (recordingMacro) {
@@ -5168,7 +5217,7 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
if (vs.annotationVisible) {
int lineDoc = pdoc->LineFromPosition(caretToUse.Position());
Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
- int subLine = (pt.y - ptStartLine.y) / vs.lineHeight;
+ int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight;
if (direction < 0 && subLine == 0) {
int lineDisplay = cs.DisplayFromDoc(lineDoc);
@@ -5180,9 +5229,9 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
}
}
- int newY = pt.y + (1 + skipLines) * direction * vs.lineHeight;
+ int newY = static_cast<int>(pt.y) + (1 + skipLines) * direction * vs.lineHeight;
SelectionPosition posNew = SPositionFromLocation(
- Point(lastXChosen - xOffset, newY), false, false, UserVirtualSpace());
+ Point::FromInts(lastXChosen - xOffset, newY), false, false, UserVirtualSpace());
if (direction < 0) {
// Line wrapping may lead to a location on the same line, so
@@ -5771,7 +5820,7 @@ int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) {
if (msg) {
if (consumed)
*consumed = true;
- return WndProc(msg, 0, 0);
+ return static_cast<int>(WndProc(msg, 0, 0));
} else {
if (consumed)
*consumed = false;
@@ -5797,21 +5846,22 @@ void Editor::Indent(bool forwards) {
pdoc->tabIndents) {
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
- pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
- sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos));
+ const int posSelect = pdoc->SetLineIndentation(
+ lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
+ sel.Range(r) = SelectionRange(posSelect);
} else {
if (pdoc->useTabs) {
- pdoc->InsertChar(caretPosition, '\t');
- sel.Range(r) = SelectionRange(caretPosition+1);
+ const int lengthInserted = pdoc->InsertString(caretPosition, "\t", 1);
+ sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
} else {
int numSpaces = (pdoc->tabInChars) -
(pdoc->GetColumn(caretPosition) % (pdoc->tabInChars));
if (numSpaces < 1)
numSpaces = pdoc->tabInChars;
- for (int i = 0; i < numSpaces; i++) {
- pdoc->InsertChar(caretPosition + i, ' ');
- }
- sel.Range(r) = SelectionRange(caretPosition+numSpaces);
+ const std::string spaceText(numSpaces, ' ');
+ const int lengthInserted = pdoc->InsertString(caretPosition, spaceText.c_str(),
+ static_cast<int>(spaceText.length()));
+ sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
}
}
} else {
@@ -5819,8 +5869,8 @@ void Editor::Indent(bool forwards) {
pdoc->tabIndents) {
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
- pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
- sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos));
+ const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
+ sel.Range(r) = SelectionRange(posSelect);
} else {
int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) *
pdoc->tabInChars;
@@ -5890,7 +5940,7 @@ long Editor::FindText(
(wParam & SCFIND_WHOLEWORD) != 0,
(wParam & SCFIND_WORDSTART) != 0,
(wParam & SCFIND_REGEXP) != 0,
- wParam,
+ static_cast<int>(wParam),
&lengthFound);
if (pos != -1) {
ft->chrgText.cpMin = pos;
@@ -5936,7 +5986,7 @@ long Editor::SearchText(
(wParam & SCFIND_WHOLEWORD) != 0,
(wParam & SCFIND_WORDSTART) != 0,
(wParam & SCFIND_REGEXP) != 0,
- wParam,
+ static_cast<int>(wParam),
&lengthFound);
} else {
pos = pdoc->FindText(searchAnchor, 0, txt,
@@ -5944,7 +5994,7 @@ long Editor::SearchText(
(wParam & SCFIND_WHOLEWORD) != 0,
(wParam & SCFIND_WORDSTART) != 0,
(wParam & SCFIND_REGEXP) != 0,
- wParam,
+ static_cast<int>(wParam),
&lengthFound);
}
if (pos != -1) {
@@ -6098,8 +6148,8 @@ void Editor::DisplayCursor(Window::Cursor c) {
}
bool Editor::DragThreshold(Point ptStart, Point ptNow) {
- int xMove = ptStart.x - ptNow.x;
- int yMove = ptStart.y - ptNow.y;
+ int xMove = static_cast<int>(ptStart.x - ptNow.x);
+ int yMove = static_cast<int>(ptStart.y - ptNow.y);
int distanceSquared = xMove * xMove + yMove * yMove;
return distanceSquared > 16;
}
@@ -6150,16 +6200,20 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length
}
position = positionAfterDeletion;
+ std::string convertedText = Document::TransformLineEnds(value, lengthValue, pdoc->eolMode);
+
if (rectangular) {
- PasteRectangular(position, value, static_cast<int>(lengthValue));
+ PasteRectangular(position, convertedText.c_str(), static_cast<int>(convertedText.length()));
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
SetEmptySelection(position);
} else {
position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());
position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace()));
- if (pdoc->InsertString(position.Position(), value, static_cast<int>(lengthValue))) {
+ const int lengthInserted = pdoc->InsertString(
+ position.Position(), convertedText.c_str(), static_cast<int>(convertedText.length()));
+ if (lengthInserted > 0) {
SelectionPosition posAfterInsertion = position;
- posAfterInsertion.Add(static_cast<int>(lengthValue));
+ posAfterInsertion.Add(lengthInserted);
SetSelection(posAfterInsertion, position);
}
}
@@ -6214,8 +6268,8 @@ bool Editor::PointInSelMargin(Point pt) {
// Really means: "Point in a margin"
if (vs.fixedColumnWidth > 0) { // There is a margin
PRectangle rcSelMargin = GetClientRectangle();
- rcSelMargin.right = vs.textStart - vs.leftMarginWidth;
- rcSelMargin.left = vs.textStart - vs.fixedColumnWidth;
+ rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart - vs.leftMarginWidth);
+ rcSelMargin.left = static_cast<XYPOSITION>(vs.textStart - vs.fixedColumnWidth);
return rcSelMargin.Contains(pt);
} else {
return false;
@@ -6371,7 +6425,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
doubleClick = true;
} else if (selectionType == selWord) {
// 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.
+ // whole line regardless of word wrap being enabled or not.
selectionType = selWholeLine;
} else {
selectionType = selChar;
@@ -6489,7 +6543,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
}
lastClickTime = curTime;
lastClick = pt;
- lastXChosen = pt.x + xOffset;
+ lastXChosen = static_cast<int>(pt.x) + xOffset;
ShowCaretAtCurrentPosition();
}
@@ -6697,20 +6751,27 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
SelectionPosition selEnd = SelectionEnd();
if (selStart < selEnd) {
if (drag.Length()) {
+ const int length = static_cast<int>(drag.Length());
if (ctrl) {
- if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
- SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
+ const int lengthInserted = pdoc->InsertString(
+ newPos.Position(), drag.Data(), length);
+ if (lengthInserted > 0) {
+ SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else if (newPos < selStart) {
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
- if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
- SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
+ const int lengthInserted = pdoc->InsertString(
+ newPos.Position(), drag.Data(), length);
+ if (lengthInserted > 0) {
+ SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else if (newPos > selEnd) {
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
newPos.Add(-static_cast<int>(drag.Length()));
- if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
- SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
+ const int lengthInserted = pdoc->InsertString(
+ newPos.Position(), drag.Data(), length);
+ if (lengthInserted > 0) {
+ SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else {
SetEmptySelection(newPos.Position());
@@ -6734,7 +6795,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
SetRectangularRange();
lastClickTime = curTime;
lastClick = pt;
- lastXChosen = pt.x + xOffset;
+ lastXChosen = static_cast<int>(pt.x) + xOffset;
if (sel.selType == Selection::selStream) {
SetLastXChosen();
}
@@ -6792,7 +6853,7 @@ bool Editor::Idle() {
// Add more idle things to do here, but make sure idleDone is
// set correctly before the function returns. returning
- // false will stop calling this idle funtion until SetIdle() is
+ // false will stop calling this idle function until SetIdle() is
// called again.
idleDone = wrappingDone; // && thatDone && theOtherThingDone...
@@ -6815,7 +6876,7 @@ int Editor::PositionAfterArea(PRectangle rcArea) const {
// The start of the document line after the display line after the area
// This often means that the line after a modification is restyled which helps
// detect multiline comment additions and heals single line comments
- int lineAfter = TopLineOfMain() + (rcArea.bottom - 1) / vs.lineHeight + 1;
+ int lineAfter = TopLineOfMain() + static_cast<int>(rcArea.bottom - 1) / vs.lineHeight + 1;
if (lineAfter < cs.LinesDisplayed())
return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1);
else
@@ -6869,7 +6930,7 @@ bool Editor::PaintContainsMargin() {
return false;
}
PRectangle rcSelMargin = GetClientRectangle();
- rcSelMargin.right = vs.textStart;
+ rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart);
return PaintContains(rcSelMargin);
}
@@ -6879,7 +6940,7 @@ void Editor::CheckForChangeOutsidePaint(Range r) {
if (!r.Valid())
return;
- PRectangle rcRange = RectangleFromRange(r.start, r.end);
+ PRectangle rcRange = RectangleFromRange(r);
PRectangle rcText = GetTextRectangle();
if (rcRange.top < rcText.top) {
rcRange.top = rcText.top;
@@ -7258,8 +7319,8 @@ int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {
if (targetStart != targetEnd)
pdoc->DeleteChars(targetStart, targetEnd - targetStart);
targetEnd = targetStart;
- pdoc->InsertString(targetStart, text, length);
- targetEnd = targetStart + length;
+ const int lengthInserted = pdoc->InsertString(targetStart, text, length);
+ targetEnd = targetStart + lengthInserted;
return length;
}
@@ -7294,16 +7355,16 @@ void Editor::AddStyledText(char *buffer, int appendLength) {
for (i = 0; i < textLength; i++) {
text[i] = buffer[i*2];
}
- pdoc->InsertString(CurrentPosition(), text.c_str(), textLength);
+ const int lengthInserted = 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->StartStyling(CurrentPosition(), static_cast<unsigned char>(0xff));
pdoc->SetStyles(textLength, text.c_str());
- SetEmptySelection(sel.MainCaret() + textLength);
+ SetEmptySelection(sel.MainCaret() + lengthInserted);
}
-static bool ValidMargin(unsigned long wParam) {
+static bool ValidMargin(uptr_t wParam) {
return wParam <= SC_MAX_MARGIN;
}
@@ -7315,16 +7376,16 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
vs.EnsureStyle(wParam);
switch (iMessage) {
case SCI_STYLESETFORE:
- vs.styles[wParam].fore = ColourDesired(lParam);
+ vs.styles[wParam].fore = ColourDesired(static_cast<long>(lParam));
break;
case SCI_STYLESETBACK:
- vs.styles[wParam].back = ColourDesired(lParam);
+ vs.styles[wParam].back = ColourDesired(static_cast<long>(lParam));
break;
case SCI_STYLESETBOLD:
vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL;
break;
case SCI_STYLESETWEIGHT:
- vs.styles[wParam].weight = lParam;
+ vs.styles[wParam].weight = static_cast<int>(lParam);
break;
case SCI_STYLESETITALIC:
vs.styles[wParam].italic = lParam != 0;
@@ -7333,14 +7394,14 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
vs.styles[wParam].eolFilled = lParam != 0;
break;
case SCI_STYLESETSIZE:
- vs.styles[wParam].size = lParam * SC_FONT_SIZE_MULTIPLIER;
+ vs.styles[wParam].size = static_cast<int>(lParam * SC_FONT_SIZE_MULTIPLIER);
break;
case SCI_STYLESETSIZEFRACTIONAL:
- vs.styles[wParam].size = lParam;
+ vs.styles[wParam].size = static_cast<int>(lParam);
break;
case SCI_STYLESETFONT:
if (lParam != 0) {
- vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam));
+ vs.SetStyleFontName(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
}
break;
case SCI_STYLESETUNDERLINE:
@@ -7350,7 +7411,7 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam);
break;
case SCI_STYLESETCHARACTERSET:
- vs.styles[wParam].characterSet = lParam;
+ vs.styles[wParam].characterSet = static_cast<int>(lParam);
pdoc->SetCaseFolder(NULL);
break;
case SCI_STYLESETVISIBLE:
@@ -7455,7 +7516,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
UndoGroup ug(pdoc);
pdoc->DeleteChars(0, pdoc->Length());
SetEmptySelection(0);
- pdoc->InsertCString(0, CharPtrFromSPtr(lParam));
+ const char *text = CharPtrFromSPtr(lParam);
+ pdoc->InsertString(0, text, istrlen(text));
return 1;
}
@@ -7488,11 +7550,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_COPYRANGE:
- CopyRangeToClipboard(wParam, lParam);
+ CopyRangeToClipboard(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_COPYTEXT:
- CopyText(wParam, CharPtrFromSPtr(lParam));
+ CopyText(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
break;
case SCI_PASTE:
@@ -7525,12 +7587,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return topLine;
case SCI_SETFIRSTVISIBLELINE:
- ScrollTo(wParam);
+ ScrollTo(static_cast<int>(wParam));
break;
case SCI_GETLINE: { // Risk of overwriting the end of the buffer
- int lineStart = pdoc->LineStart(wParam);
- int lineEnd = pdoc->LineStart(wParam + 1);
+ int lineStart = pdoc->LineStart(static_cast<int>(wParam));
+ int lineEnd = pdoc->LineStart(static_cast<int>(wParam + 1));
if (lParam == 0) {
return lineEnd - lineStart;
}
@@ -7587,7 +7649,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_LINEFROMPOSITION:
if (static_cast<int>(wParam) < 0)
return 0;
- return pdoc->LineFromPosition(wParam);
+ return pdoc->LineFromPosition(static_cast<int>(wParam));
case SCI_POSITIONFROMLINE:
if (static_cast<int>(wParam) < 0)
@@ -7598,14 +7660,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return -1;
//if (wParam > pdoc->LineFromPosition(pdoc->Length())) // Useful test, anyway...
// return -1;
- return pdoc->LineStart(wParam);
+ return pdoc->LineStart(static_cast<int>(wParam));
// Replacement of the old Scintilla interpretation of EM_LINELENGTH
case SCI_LINELENGTH:
if ((static_cast<int>(wParam) < 0) ||
(static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length())))
return 0;
- return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam);
+ return pdoc->LineStart(static_cast<int>(wParam) + 1) - pdoc->LineStart(static_cast<int>(wParam));
case SCI_REPLACESEL: {
if (lParam == 0)
@@ -7613,21 +7675,22 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
UndoGroup ug(pdoc);
ClearSelection();
char *replacement = CharPtrFromSPtr(lParam);
- pdoc->InsertCString(sel.MainCaret(), replacement);
- SetEmptySelection(sel.MainCaret() + istrlen(replacement));
+ const int lengthInserted = pdoc->InsertString(
+ sel.MainCaret(), replacement, istrlen(replacement));
+ SetEmptySelection(sel.MainCaret() + lengthInserted);
EnsureCaretVisible();
}
break;
case SCI_SETTARGETSTART:
- targetStart = wParam;
+ targetStart = static_cast<int>(wParam);
break;
case SCI_GETTARGETSTART:
return targetStart;
case SCI_SETTARGETEND:
- targetEnd = wParam;
+ targetEnd = static_cast<int>(wParam);
break;
case SCI_GETTARGETEND:
@@ -7645,42 +7708,42 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_REPLACETARGET:
PLATFORM_ASSERT(lParam);
- return ReplaceTarget(false, CharPtrFromSPtr(lParam), wParam);
+ return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<int>(wParam));
case SCI_REPLACETARGETRE:
PLATFORM_ASSERT(lParam);
- return ReplaceTarget(true, CharPtrFromSPtr(lParam), wParam);
+ return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast<int>(wParam));
case SCI_SEARCHINTARGET:
PLATFORM_ASSERT(lParam);
- return SearchInTarget(CharPtrFromSPtr(lParam), wParam);
+ return SearchInTarget(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
case SCI_SETSEARCHFLAGS:
- searchFlags = wParam;
+ searchFlags = static_cast<int>(wParam);
break;
case SCI_GETSEARCHFLAGS:
return searchFlags;
case SCI_GETTAG:
- return GetTag(CharPtrFromSPtr(lParam), wParam);
+ return GetTag(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
case SCI_POSITIONBEFORE:
- return pdoc->MovePositionOutsideChar(wParam - 1, -1, true);
+ return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) - 1, -1, true);
case SCI_POSITIONAFTER:
- return pdoc->MovePositionOutsideChar(wParam + 1, 1, true);
+ return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) + 1, 1, true);
case SCI_POSITIONRELATIVE:
- return Platform::Clamp(pdoc->GetRelativePosition(wParam, lParam), 0, pdoc->Length());
+ return Platform::Clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length());
case SCI_LINESCROLL:
- ScrollTo(topLine + lParam);
- HorizontalScrollTo(xOffset + static_cast<int>(wParam) * vs.spaceWidth);
+ ScrollTo(topLine + static_cast<int>(lParam));
+ HorizontalScrollTo(xOffset + static_cast<int>(wParam)* static_cast<int>(vs.spaceWidth));
return 1;
case SCI_SETXOFFSET:
- xOffset = wParam;
+ xOffset = static_cast<int>(wParam);
ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
SetHorizontalScrollPos();
Redraw();
@@ -7711,17 +7774,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (lParam < 0) {
return 0;
} else {
- Point pt = LocationFromPosition(lParam);
+ Point pt = LocationFromPosition(static_cast<int>(lParam));
// Convert to view-relative
- return pt.x - vs.textStart + vs.fixedColumnWidth;
+ return static_cast<int>(pt.x) - vs.textStart + vs.fixedColumnWidth;
}
case SCI_POINTYFROMPOSITION:
if (lParam < 0) {
return 0;
} else {
- Point pt = LocationFromPosition(lParam);
- return pt.y;
+ Point pt = LocationFromPosition(static_cast<int>(lParam));
+ return static_cast<int>(pt.y);
}
case SCI_FINDTEXT:
@@ -7757,13 +7820,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.rightMarginWidth;
case SCI_SETMARGINLEFT:
- lastXChosen += lParam - vs.leftMarginWidth;
- vs.leftMarginWidth = lParam;
+ lastXChosen += static_cast<int>(lParam) - vs.leftMarginWidth;
+ vs.leftMarginWidth = static_cast<int>(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETMARGINRIGHT:
- vs.rightMarginWidth = lParam;
+ vs.rightMarginWidth = static_cast<int>(lParam);
InvalidateStyleRedraw();
break;
@@ -7772,33 +7835,39 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_ADDTEXT: {
if (lParam == 0)
return 0;
- pdoc->InsertString(CurrentPosition(), CharPtrFromSPtr(lParam), wParam);
- SetEmptySelection(sel.MainCaret() + wParam);
+ const int lengthInserted = pdoc->InsertString(
+ CurrentPosition(), CharPtrFromSPtr(lParam), static_cast<int>(wParam));
+ SetEmptySelection(sel.MainCaret() + lengthInserted);
return 0;
}
case SCI_ADDSTYLEDTEXT:
if (lParam)
- AddStyledText(CharPtrFromSPtr(lParam), wParam);
+ AddStyledText(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
return 0;
case SCI_INSERTTEXT: {
if (lParam == 0)
return 0;
- int insertPos = wParam;
+ int insertPos = static_cast<int>(wParam);
if (static_cast<int>(wParam) == -1)
insertPos = CurrentPosition();
int newCurrent = CurrentPosition();
char *sz = CharPtrFromSPtr(lParam);
- pdoc->InsertCString(insertPos, sz);
+ const int lengthInserted = pdoc->InsertString(insertPos, sz, istrlen(sz));
if (newCurrent > insertPos)
- newCurrent += istrlen(sz);
+ newCurrent += lengthInserted;
SetEmptySelection(newCurrent);
return 0;
}
+ case SCI_CHANGEINSERTION:
+ PLATFORM_ASSERT(lParam);
+ pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
+ return 0;
+
case SCI_APPENDTEXT:
- pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), wParam);
+ pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), static_cast<int>(wParam));
return 0;
case SCI_CLEARALL:
@@ -7806,7 +7875,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return 0;
case SCI_DELETERANGE:
- pdoc->DeleteChars(wParam, lParam);
+ pdoc->DeleteChars(static_cast<int>(wParam), static_cast<int>(lParam));
return 0;
case SCI_CLEARDOCUMENTSTYLE:
@@ -7832,7 +7901,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return caret.period;
case SCI_SETCARETPERIOD:
- caret.period = wParam;
+ CaretSetPeriod(static_cast<int>(wParam));
break;
case SCI_GETWORDCHARS:
@@ -7874,19 +7943,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->Length();
case SCI_ALLOCATE:
- pdoc->Allocate(wParam);
+ pdoc->Allocate(static_cast<int>(wParam));
break;
case SCI_GETCHARAT:
- return pdoc->CharAt(wParam);
+ return pdoc->CharAt(static_cast<int>(wParam));
case SCI_SETCURRENTPOS:
if (sel.IsRectangular()) {
- sel.Rectangular().caret.SetPosition(wParam);
+ sel.Rectangular().caret.SetPosition(static_cast<int>(wParam));
SetRectangularRange();
Redraw();
} else {
- SetSelection(wParam, sel.MainAnchor());
+ SetSelection(static_cast<int>(wParam), sel.MainAnchor());
}
break;
@@ -7895,11 +7964,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETANCHOR:
if (sel.IsRectangular()) {
- sel.Rectangular().anchor.SetPosition(wParam);
+ sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam));
SetRectangularRange();
Redraw();
} else {
- SetSelection(sel.MainCaret(), wParam);
+ SetSelection(sel.MainCaret(), static_cast<int>(wParam));
}
break;
@@ -7907,32 +7976,32 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor();
case SCI_SETSELECTIONSTART:
- SetSelection(Platform::Maximum(sel.MainCaret(), wParam), wParam);
+ SetSelection(Platform::Maximum(sel.MainCaret(), static_cast<int>(wParam)), static_cast<int>(wParam));
break;
case SCI_GETSELECTIONSTART:
return sel.LimitsForRectangularElseMain().start.Position();
case SCI_SETSELECTIONEND:
- SetSelection(wParam, Platform::Minimum(sel.MainAnchor(), wParam));
+ SetSelection(static_cast<int>(wParam), Platform::Minimum(sel.MainAnchor(), static_cast<int>(wParam)));
break;
case SCI_GETSELECTIONEND:
return sel.LimitsForRectangularElseMain().end.Position();
case SCI_SETEMPTYSELECTION:
- SetEmptySelection(wParam);
+ SetEmptySelection(static_cast<int>(wParam));
break;
case SCI_SETPRINTMAGNIFICATION:
- printParameters.magnification = wParam;
+ printParameters.magnification = static_cast<int>(wParam);
break;
case SCI_GETPRINTMAGNIFICATION:
return printParameters.magnification;
case SCI_SETPRINTCOLOURMODE:
- printParameters.colourMode = wParam;
+ printParameters.colourMode = static_cast<int>(wParam);
break;
case SCI_GETPRINTCOLOURMODE:
@@ -7949,7 +8018,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (static_cast<int>(wParam) >= pdoc->Length())
return 0;
else
- return pdoc->StyleAt(wParam);
+ return pdoc->StyleAt(static_cast<int>(wParam));
case SCI_REDO:
Redo();
@@ -7981,10 +8050,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0;
case SCI_MARKERLINEFROMHANDLE:
- return pdoc->LineFromHandle(wParam);
+ return pdoc->LineFromHandle(static_cast<int>(wParam));
case SCI_MARKERDELETEHANDLE:
- pdoc->DeleteMarkFromHandle(wParam);
+ pdoc->DeleteMarkFromHandle(static_cast<int>(wParam));
break;
case SCI_GETVIEWWS:
@@ -8004,27 +8073,27 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_POSITIONFROMPOINT:
- return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam),
+ return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
false, false);
case SCI_POSITIONFROMPOINTCLOSE:
- return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam),
+ return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
true, false);
case SCI_CHARPOSITIONFROMPOINT:
- return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam),
+ return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
false, true);
case SCI_CHARPOSITIONFROMPOINTCLOSE:
- return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam),
+ return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
true, true);
case SCI_GOTOLINE:
- GoToLine(wParam);
+ GoToLine(static_cast<int>(wParam));
break;
case SCI_GOTOPOS:
- SetEmptySelection(wParam);
+ SetEmptySelection(static_cast<int>(wParam));
EnsureCaretVisible();
break;
@@ -8052,11 +8121,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->eolMode;
case SCI_SETEOLMODE:
- pdoc->eolMode = wParam;
+ pdoc->eolMode = static_cast<int>(wParam);
break;
case SCI_SETLINEENDTYPESALLOWED:
- if (pdoc->SetLineEndTypesAllowed(wParam)) {
+ if (pdoc->SetLineEndTypesAllowed(static_cast<int>(wParam))) {
cs.Clear();
cs.InsertLines(0, pdoc->LinesTotal() - 1);
SetAnnotationHeights(0, pdoc->LinesTotal());
@@ -8071,17 +8140,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->GetLineEndTypesActive();
case SCI_STARTSTYLING:
- pdoc->StartStyling(wParam, static_cast<char>(lParam));
+ pdoc->StartStyling(static_cast<int>(wParam), static_cast<char>(lParam));
break;
case SCI_SETSTYLING:
- pdoc->SetStyleFor(wParam, static_cast<char>(lParam));
+ pdoc->SetStyleFor(static_cast<int>(wParam), static_cast<char>(lParam));
break;
case SCI_SETSTYLINGEX: // Specify a complete styling buffer
if (lParam == 0)
return 0;
- pdoc->SetStyles(wParam, CharPtrFromSPtr(lParam));
+ pdoc->SetStyles(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
break;
case SCI_SETBUFFEREDDRAW:
@@ -8110,7 +8179,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETTABWIDTH:
if (wParam > 0) {
- pdoc->tabInChars = wParam;
+ pdoc->tabInChars = static_cast<int>(wParam);
if (pdoc->indentInChars == 0)
pdoc->actualIndentInChars = pdoc->tabInChars;
}
@@ -8121,7 +8190,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->tabInChars;
case SCI_SETINDENT:
- pdoc->indentInChars = wParam;
+ pdoc->indentInChars = static_cast<int>(wParam);
if (pdoc->indentInChars != 0)
pdoc->actualIndentInChars = pdoc->indentInChars;
else
@@ -8141,14 +8210,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->useTabs;
case SCI_SETLINEINDENTATION:
- pdoc->SetLineIndentation(wParam, lParam);
+ pdoc->SetLineIndentation(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_GETLINEINDENTATION:
- return pdoc->GetLineIndentation(wParam);
+ return pdoc->GetLineIndentation(static_cast<int>(wParam));
case SCI_GETLINEINDENTPOSITION:
- return pdoc->GetLineIndentPosition(wParam);
+ return pdoc->GetLineIndentPosition(static_cast<int>(wParam));
case SCI_SETTABINDENTS:
pdoc->tabIndents = wParam != 0;
@@ -8165,7 +8234,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->backspaceUnindents;
case SCI_SETMOUSEDWELLTIME:
- dwellDelay = wParam;
+ dwellDelay = static_cast<int>(wParam);
ticksToDwell = dwellDelay;
break;
@@ -8173,13 +8242,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return dwellDelay;
case SCI_WORDSTARTPOSITION:
- return pdoc->ExtendWordSelect(wParam, -1, lParam != 0);
+ return pdoc->ExtendWordSelect(static_cast<int>(wParam), -1, lParam != 0);
case SCI_WORDENDPOSITION:
- return pdoc->ExtendWordSelect(wParam, 1, lParam != 0);
+ return pdoc->ExtendWordSelect(static_cast<int>(wParam), 1, lParam != 0);
case SCI_SETWRAPMODE:
- if (vs.SetWrapState(wParam)) {
+ if (vs.SetWrapState(static_cast<int>(wParam))) {
xOffset = 0;
ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
InvalidateStyleRedraw();
@@ -8191,7 +8260,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.wrapState;
case SCI_SETWRAPVISUALFLAGS:
- if (vs.SetWrapVisualFlags(wParam)) {
+ if (vs.SetWrapVisualFlags(static_cast<int>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
@@ -8201,7 +8270,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.wrapVisualFlags;
case SCI_SETWRAPVISUALFLAGSLOCATION:
- if (vs.SetWrapVisualFlagsLocation(wParam)) {
+ if (vs.SetWrapVisualFlagsLocation(static_cast<int>(wParam))) {
InvalidateStyleRedraw();
}
break;
@@ -8210,7 +8279,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.wrapVisualFlagsLocation;
case SCI_SETWRAPSTARTINDENT:
- if (vs.SetWrapVisualStartIndent(wParam)) {
+ if (vs.SetWrapVisualStartIndent(static_cast<int>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
@@ -8220,7 +8289,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.wrapVisualStartIndent;
case SCI_SETWRAPINDENTMODE:
- if (vs.SetWrapIndentMode(wParam)) {
+ if (vs.SetWrapIndentMode(static_cast<int>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
@@ -8230,7 +8299,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.wrapIndentMode;
case SCI_SETLAYOUTCACHE:
- llc.SetLevel(wParam);
+ llc.SetLevel(static_cast<int>(wParam));
break;
case SCI_GETLAYOUTCACHE:
@@ -8247,7 +8316,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
PLATFORM_ASSERT(wParam > 0);
if ((wParam > 0) && (wParam != static_cast<unsigned int >(scrollWidth))) {
lineWidthMaxSeen = 0;
- scrollWidth = wParam;
+ scrollWidth = static_cast<int>(wParam);
SetScrollBars();
}
break;
@@ -8267,13 +8336,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_LINESSPLIT:
- LinesSplit(wParam);
+ LinesSplit(static_cast<int>(wParam));
break;
case SCI_TEXTWIDTH:
PLATFORM_ASSERT(wParam < vs.styles.size());
PLATFORM_ASSERT(lParam);
- return TextWidth(wParam, CharPtrFromSPtr(lParam));
+ return TextWidth(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
case SCI_TEXTHEIGHT:
return vs.lineHeight;
@@ -8292,7 +8361,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETCARETSTICKY:
PLATFORM_ASSERT(wParam <= SC_CARETSTICKY_WHITESPACE);
if (wParam <= SC_CARETSTICKY_WHITESPACE) {
- caretSticky = wParam;
+ caretSticky = static_cast<int>(wParam);
}
break;
@@ -8304,10 +8373,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETCOLUMN:
- return pdoc->GetColumn(wParam);
+ return pdoc->GetColumn(static_cast<int>(wParam));
case SCI_FINDCOLUMN:
- return pdoc->FindColumn(wParam, lParam);
+ return pdoc->FindColumn(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_SETHSCROLLBAR :
if (horizontalScrollBarVisible != (wParam != 0)) {
@@ -8343,7 +8412,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETHIGHLIGHTGUIDE:
if ((highlightGuideColumn != static_cast<int>(wParam)) || (wParam > 0)) {
- highlightGuideColumn = wParam;
+ highlightGuideColumn = static_cast<int>(wParam);
Redraw();
}
break;
@@ -8352,11 +8421,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return highlightGuideColumn;
case SCI_GETLINEENDPOSITION:
- return pdoc->LineEnd(wParam);
+ return pdoc->LineEnd(static_cast<int>(wParam));
case SCI_SETCODEPAGE:
- if (ValidCodePage(wParam)) {
- if (pdoc->SetDBCSCodePage(wParam)) {
+ if (ValidCodePage(static_cast<int>(wParam))) {
+ if (pdoc->SetDBCSCodePage(static_cast<int>(wParam))) {
cs.Clear();
cs.InsertLines(0, pdoc->LinesTotal() - 1);
SetAnnotationHeights(0, pdoc->LinesTotal());
@@ -8381,7 +8450,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
// Marker definition and setting
case SCI_MARKERDEFINE:
if (wParam <= MARKER_MAX) {
- vs.markers[wParam].markType = lParam;
+ vs.markers[wParam].markType = static_cast<int>(lParam);
vs.CalcLargestMarkerHeight();
}
InvalidateStyleData();
@@ -8396,13 +8465,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_MARKERSETFORE:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].fore = ColourDesired(lParam);
+ vs.markers[wParam].fore = ColourDesired(static_cast<long>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_MARKERSETBACKSELECTED:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].backSelected = ColourDesired(lParam);
+ vs.markers[wParam].backSelected = ColourDesired(static_cast<long>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
@@ -8412,26 +8481,26 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_MARKERSETBACK:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].back = ColourDesired(lParam);
+ vs.markers[wParam].back = ColourDesired(static_cast<long>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_MARKERSETALPHA:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].alpha = lParam;
+ vs.markers[wParam].alpha = static_cast<int>(lParam);
InvalidateStyleRedraw();
break;
case SCI_MARKERADD: {
- int markerID = pdoc->AddMark(wParam, lParam);
+ int markerID = pdoc->AddMark(static_cast<int>(wParam), static_cast<int>(lParam));
return markerID;
}
case SCI_MARKERADDSET:
if (lParam != 0)
- pdoc->AddMarkSet(wParam, lParam);
+ pdoc->AddMarkSet(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_MARKERDELETE:
- pdoc->DeleteMark(wParam, lParam);
+ pdoc->DeleteMark(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_MARKERDELETEALL:
@@ -8439,13 +8508,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_MARKERGET:
- return pdoc->GetMark(wParam);
+ return pdoc->GetMark(static_cast<int>(wParam));
case SCI_MARKERNEXT:
- return pdoc->MarkerNext(wParam, lParam);
+ return pdoc->MarkerNext(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_MARKERPREVIOUS: {
- for (int iLine = wParam; iLine >= 0; iLine--) {
+ for (int iLine = static_cast<int>(wParam); iLine >= 0; iLine--) {
if ((pdoc->GetMark(iLine) & lParam) != 0)
return iLine;
}
@@ -8462,20 +8531,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_RGBAIMAGESETWIDTH:
- sizeRGBAImage.x = wParam;
+ sizeRGBAImage.x = static_cast<XYPOSITION>(wParam);
break;
case SCI_RGBAIMAGESETHEIGHT:
- sizeRGBAImage.y = wParam;
+ sizeRGBAImage.y = static_cast<XYPOSITION>(wParam);
break;
case SCI_RGBAIMAGESETSCALE:
- scaleRGBAImage = wParam;
+ scaleRGBAImage = static_cast<float>(wParam);
break;
case SCI_MARKERDEFINERGBAIMAGE:
if (wParam <= MARKER_MAX) {
- vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0, reinterpret_cast<unsigned char *>(lParam));
+ vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, reinterpret_cast<unsigned char *>(lParam));
vs.CalcLargestMarkerHeight();
}
InvalidateStyleData();
@@ -8484,7 +8553,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETMARGINTYPEN:
if (ValidMargin(wParam)) {
- vs.ms[wParam].style = lParam;
+ vs.ms[wParam].style = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
@@ -8499,8 +8568,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (ValidMargin(wParam)) {
// Short-circuit if the width is unchanged, to avoid unnecessary redraw.
if (vs.ms[wParam].width != lParam) {
- lastXChosen += lParam - vs.ms[wParam].width;
- vs.ms[wParam].width = lParam;
+ lastXChosen += static_cast<int>(lParam) - vs.ms[wParam].width;
+ vs.ms[wParam].width = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
}
@@ -8514,7 +8583,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETMARGINMASKN:
if (ValidMargin(wParam)) {
- vs.ms[wParam].mask = lParam;
+ vs.ms[wParam].mask = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
@@ -8540,7 +8609,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETMARGINCURSORN:
if (ValidMargin(wParam))
- vs.ms[wParam].cursor = lParam;
+ vs.ms[wParam].cursor = static_cast<int>(lParam);
break;
case SCI_GETMARGINCURSORN:
@@ -8595,17 +8664,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETSTYLEBITS:
vs.EnsureStyle((1 << wParam) - 1);
- pdoc->SetStylingBits(wParam);
+ pdoc->SetStylingBits(static_cast<int>(wParam));
break;
case SCI_GETSTYLEBITS:
return pdoc->stylingBits;
case SCI_SETLINESTATE:
- return pdoc->SetLineState(wParam, lParam);
+ return pdoc->SetLineState(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_GETLINESTATE:
- return pdoc->GetLineState(wParam);
+ return pdoc->GetLineState(static_cast<int>(wParam));
case SCI_GETMAXLINESTATE:
return pdoc->GetMaxLineState();
@@ -8626,114 +8695,114 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETCARETLINEBACK:
return vs.caretLineBackground.AsLong();
case SCI_SETCARETLINEBACK:
- vs.caretLineBackground = wParam;
+ vs.caretLineBackground = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case SCI_GETCARETLINEBACKALPHA:
return vs.caretLineAlpha;
case SCI_SETCARETLINEBACKALPHA:
- vs.caretLineAlpha = wParam;
+ vs.caretLineAlpha = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
// Folding messages
case SCI_VISIBLEFROMDOCLINE:
- return cs.DisplayFromDoc(wParam);
+ return cs.DisplayFromDoc(static_cast<int>(wParam));
case SCI_DOCLINEFROMVISIBLE:
- return cs.DocFromDisplay(wParam);
+ return cs.DocFromDisplay(static_cast<int>(wParam));
case SCI_WRAPCOUNT:
- return WrapCount(wParam);
+ return WrapCount(static_cast<int>(wParam));
case SCI_SETFOLDLEVEL: {
- int prev = pdoc->SetLevel(wParam, lParam);
- if (prev != lParam)
+ int prev = pdoc->SetLevel(static_cast<int>(wParam), static_cast<int>(lParam));
+ if (prev != static_cast<int>(lParam))
RedrawSelMargin();
return prev;
}
case SCI_GETFOLDLEVEL:
- return pdoc->GetLevel(wParam);
+ return pdoc->GetLevel(static_cast<int>(wParam));
case SCI_GETLASTCHILD:
- return pdoc->GetLastChild(wParam, lParam);
+ return pdoc->GetLastChild(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_GETFOLDPARENT:
- return pdoc->GetFoldParent(wParam);
+ return pdoc->GetFoldParent(static_cast<int>(wParam));
case SCI_SHOWLINES:
- cs.SetVisible(wParam, lParam, true);
+ cs.SetVisible(static_cast<int>(wParam), static_cast<int>(lParam), true);
SetScrollBars();
Redraw();
break;
case SCI_HIDELINES:
if (wParam > 0)
- cs.SetVisible(wParam, lParam, false);
+ cs.SetVisible(static_cast<int>(wParam), static_cast<int>(lParam), false);
SetScrollBars();
Redraw();
break;
case SCI_GETLINEVISIBLE:
- return cs.GetVisible(wParam);
+ return cs.GetVisible(static_cast<int>(wParam));
case SCI_GETALLLINESVISIBLE:
return cs.HiddenLines() ? 0 : 1;
case SCI_SETFOLDEXPANDED:
- SetFoldExpanded(wParam, lParam != 0);
+ SetFoldExpanded(static_cast<int>(wParam), lParam != 0);
break;
case SCI_GETFOLDEXPANDED:
- return cs.GetExpanded(wParam);
+ return cs.GetExpanded(static_cast<int>(wParam));
case SCI_SETAUTOMATICFOLD:
- foldAutomatic = wParam;
+ foldAutomatic = static_cast<int>(wParam);
break;
case SCI_GETAUTOMATICFOLD:
return foldAutomatic;
case SCI_SETFOLDFLAGS:
- foldFlags = wParam;
+ foldFlags = static_cast<int>(wParam);
Redraw();
break;
case SCI_TOGGLEFOLD:
- FoldLine(wParam, SC_FOLDACTION_TOGGLE);
+ FoldLine(static_cast<int>(wParam), SC_FOLDACTION_TOGGLE);
break;
case SCI_FOLDLINE:
- FoldLine(wParam, lParam);
+ FoldLine(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_FOLDCHILDREN:
- FoldExpand(wParam, lParam, pdoc->GetLevel(wParam));
+ FoldExpand(static_cast<int>(wParam), static_cast<int>(lParam), pdoc->GetLevel(static_cast<int>(wParam)));
break;
case SCI_FOLDALL:
- FoldAll(wParam);
+ FoldAll(static_cast<int>(wParam));
break;
case SCI_EXPANDCHILDREN:
- FoldExpand(wParam, SC_FOLDACTION_EXPAND, lParam);
+ FoldExpand(static_cast<int>(wParam), SC_FOLDACTION_EXPAND, static_cast<int>(lParam));
break;
case SCI_CONTRACTEDFOLDNEXT:
- return ContractedFoldNext(wParam);
+ return ContractedFoldNext(static_cast<int>(wParam));
case SCI_ENSUREVISIBLE:
- EnsureLineVisible(wParam, false);
+ EnsureLineVisible(static_cast<int>(wParam), false);
break;
case SCI_ENSUREVISIBLEENFORCEPOLICY:
- EnsureLineVisible(wParam, true);
+ EnsureLineVisible(static_cast<int>(wParam), true);
break;
case SCI_SCROLLRANGE:
- ScrollRange(SelectionRange(lParam, wParam));
+ ScrollRange(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam)));
break;
case SCI_SEARCHANCHOR:
@@ -8745,18 +8814,18 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return SearchText(iMessage, wParam, lParam);
case SCI_SETXCARETPOLICY:
- caretXPolicy = wParam;
- caretXSlop = lParam;
+ caretXPolicy = static_cast<int>(wParam);
+ caretXSlop = static_cast<int>(lParam);
break;
case SCI_SETYCARETPOLICY:
- caretYPolicy = wParam;
- caretYSlop = lParam;
+ caretYPolicy = static_cast<int>(wParam);
+ caretYSlop = static_cast<int>(lParam);
break;
case SCI_SETVISIBLEPOLICY:
- visiblePolicy = wParam;
- visibleSlop = lParam;
+ visiblePolicy = static_cast<int>(wParam);
+ visibleSlop = static_cast<int>(lParam);
break;
case SCI_LINESONSCREEN:
@@ -8764,19 +8833,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETSELFORE:
vs.selColours.fore = ColourOptional(wParam, lParam);
- vs.selAdditionalForeground = ColourDesired(lParam);
+ vs.selAdditionalForeground = ColourDesired(static_cast<long>(lParam));
InvalidateStyleRedraw();
break;
case SCI_SETSELBACK:
vs.selColours.back = ColourOptional(wParam, lParam);
- vs.selAdditionalBackground = ColourDesired(lParam);
+ vs.selAdditionalBackground = ColourDesired(static_cast<long>(lParam));
InvalidateStyleRedraw();
break;
case SCI_SETSELALPHA:
- vs.selAlpha = wParam;
- vs.selAdditionalAlpha = wParam;
+ vs.selAlpha = static_cast<int>(wParam);
+ vs.selAdditionalAlpha = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -8802,7 +8871,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETCARETFORE:
- vs.caretcolour = ColourDesired(wParam);
+ vs.caretcolour = ColourDesired(static_cast<long>(wParam));
InvalidateStyleRedraw();
break;
@@ -8811,7 +8880,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETCARETSTYLE:
if (wParam <= CARETSTYLE_BLOCK)
- vs.caretStyle = wParam;
+ vs.caretStyle = static_cast<int>(wParam);
else
/* Default to the line caret */
vs.caretStyle = CARETSTYLE_LINE;
@@ -8827,7 +8896,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
else if (wParam >= 3)
vs.caretWidth = 3;
else
- vs.caretWidth = wParam;
+ vs.caretWidth = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -8835,13 +8904,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.caretWidth;
case SCI_ASSIGNCMDKEY:
- kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
- Platform::HighShortFromLong(wParam), lParam);
+ kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)),
+ Platform::HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam));
break;
case SCI_CLEARCMDKEY:
- kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
- Platform::HighShortFromLong(wParam), SCI_NULL);
+ kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)),
+ Platform::HighShortFromLong(static_cast<long>(wParam)), SCI_NULL);
break;
case SCI_CLEARALLCMDKEYS:
@@ -8850,7 +8919,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETSTYLE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].style = lParam;
+ vs.indicators[wParam].style = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
@@ -8860,7 +8929,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETFORE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].fore = ColourDesired(lParam);
+ vs.indicators[wParam].fore = ColourDesired(static_cast<long>(lParam));
InvalidateStyleRedraw();
}
break;
@@ -8880,7 +8949,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETALPHA:
if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) {
- vs.indicators[wParam].fillAlpha = lParam;
+ vs.indicators[wParam].fillAlpha = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
@@ -8890,7 +8959,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETOUTLINEALPHA:
if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) {
- vs.indicators[wParam].outlineAlpha = lParam;
+ vs.indicators[wParam].outlineAlpha = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
@@ -8899,35 +8968,35 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].outlineAlpha : 0;
case SCI_SETINDICATORCURRENT:
- pdoc->decorations.SetCurrentIndicator(wParam);
+ pdoc->decorations.SetCurrentIndicator(static_cast<int>(wParam));
break;
case SCI_GETINDICATORCURRENT:
return pdoc->decorations.GetCurrentIndicator();
case SCI_SETINDICATORVALUE:
- pdoc->decorations.SetCurrentValue(wParam);
+ pdoc->decorations.SetCurrentValue(static_cast<int>(wParam));
break;
case SCI_GETINDICATORVALUE:
return pdoc->decorations.GetCurrentValue();
case SCI_INDICATORFILLRANGE:
- pdoc->DecorationFillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam);
+ pdoc->DecorationFillRange(static_cast<int>(wParam), pdoc->decorations.GetCurrentValue(), static_cast<int>(lParam));
break;
case SCI_INDICATORCLEARRANGE:
- pdoc->DecorationFillRange(wParam, 0, lParam);
+ pdoc->DecorationFillRange(static_cast<int>(wParam), 0, static_cast<int>(lParam));
break;
case SCI_INDICATORALLONFOR:
- return pdoc->decorations.AllOnFor(wParam);
+ return pdoc->decorations.AllOnFor(static_cast<int>(wParam));
case SCI_INDICATORVALUEAT:
- return pdoc->decorations.ValueAt(wParam, lParam);
+ return pdoc->decorations.ValueAt(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_INDICATORSTART:
- return pdoc->decorations.Start(wParam, lParam);
+ return pdoc->decorations.Start(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_INDICATOREND:
- return pdoc->decorations.End(wParam, lParam);
+ return pdoc->decorations.End(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_LINEDOWN:
case SCI_LINEDOWNEXTEND:
@@ -9024,13 +9093,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return KeyCommand(iMessage);
case SCI_BRACEHIGHLIGHT:
- SetBraceHighlight(static_cast<int>(wParam), lParam, STYLE_BRACELIGHT);
+ SetBraceHighlight(static_cast<int>(wParam), static_cast<int>(lParam), STYLE_BRACELIGHT);
break;
case SCI_BRACEHIGHLIGHTINDICATOR:
if (lParam >= 0 && lParam <= INDIC_MAX) {
vs.braceHighlightIndicatorSet = wParam != 0;
- vs.braceHighlightIndicator = lParam;
+ vs.braceHighlightIndicator = static_cast<int>(lParam);
}
break;
@@ -9041,14 +9110,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_BRACEBADLIGHTINDICATOR:
if (lParam >= 0 && lParam <= INDIC_MAX) {
vs.braceBadLightIndicatorSet = wParam != 0;
- vs.braceBadLightIndicator = lParam;
+ vs.braceBadLightIndicator = static_cast<int>(lParam);
}
break;
case SCI_BRACEMATCH:
// wParam is position of char to find brace for,
// lParam is maximum amount of text to restyle to find it
- return pdoc->BraceMatch(wParam, lParam);
+ return pdoc->BraceMatch(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_GETVIEWEOL:
return vs.viewEOL;
@@ -9059,7 +9128,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETZOOM:
- vs.zoomLevel = wParam;
+ vs.zoomLevel = static_cast<int>(wParam);
InvalidateStyleRedraw();
NotifyZoom();
break;
@@ -9071,7 +9140,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.theEdge;
case SCI_SETEDGECOLUMN:
- vs.theEdge = wParam;
+ vs.theEdge = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -9079,7 +9148,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.edgeState;
case SCI_SETEDGEMODE:
- vs.edgeState = wParam;
+ vs.edgeState = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -9087,7 +9156,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.edgecolour.AsLong();
case SCI_SETEDGECOLOUR:
- vs.edgecolour = ColourDesired(wParam);
+ vs.edgecolour = ColourDesired(static_cast<long>(wParam));
InvalidateStyleRedraw();
break;
@@ -9116,25 +9185,25 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_CREATELOADER: {
Document *doc = new Document();
doc->AddRef();
- doc->Allocate(wParam);
+ doc->Allocate(static_cast<int>(wParam));
doc->SetUndoCollection(false);
return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc));
}
case SCI_SETMODEVENTMASK:
- modEventMask = wParam;
+ modEventMask = static_cast<int>(wParam);
return 0;
case SCI_GETMODEVENTMASK:
return modEventMask;
case SCI_CONVERTEOLS:
- pdoc->ConvertLineEnds(wParam);
+ pdoc->ConvertLineEnds(static_cast<int>(wParam));
SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document
return 0;
case SCI_SETLENGTHFORENCODE:
- lengthForEncode = wParam;
+ lengthForEncode = static_cast<int>(wParam);
return 0;
case SCI_SELECTIONISRECTANGLE:
@@ -9180,8 +9249,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
case SCI_GETLINESELSTARTPOSITION:
case SCI_GETLINESELENDPOSITION: {
- SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)),
- SelectionPosition(pdoc->LineEnd(wParam)));
+ SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(static_cast<int>(wParam))),
+ SelectionPosition(pdoc->LineEnd(static_cast<int>(wParam))));
for (size_t r=0; r<sel.Count(); r++) {
SelectionSegment portion = sel.Range(r).Intersect(segmentLine);
if (portion.start.IsValid()) {
@@ -9206,7 +9275,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return hasFocus;
case SCI_SETSTATUS:
- errorStatus = wParam;
+ errorStatus = static_cast<int>(wParam);
break;
case SCI_GETSTATUS:
@@ -9220,7 +9289,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return mouseDownCaptures;
case SCI_SETCURSOR:
- cursorMode = wParam;
+ cursorMode = static_cast<int>(wParam);
DisplayCursor(Window::cursorText);
break;
@@ -9228,7 +9297,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return cursorMode;
case SCI_SETCONTROLCHARSYMBOL:
- vs.controlCharSymbol = wParam;
+ vs.controlCharSymbol = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -9317,13 +9386,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return reinterpret_cast<sptr_t>(pdoc->BufferPointer());
case SCI_GETRANGEPOINTER:
- return reinterpret_cast<sptr_t>(pdoc->RangePointer(wParam, lParam));
+ return reinterpret_cast<sptr_t>(pdoc->RangePointer(static_cast<int>(wParam), static_cast<int>(lParam)));
case SCI_GETGAPPOSITION:
return pdoc->GapPosition();
case SCI_SETEXTRAASCENT:
- vs.extraAscent = wParam;
+ vs.extraAscent = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -9331,7 +9400,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.extraAscent;
case SCI_SETEXTRADESCENT:
- vs.extraDescent = wParam;
+ vs.extraDescent = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -9339,7 +9408,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.extraDescent;
case SCI_MARGINSETSTYLEOFFSET:
- vs.marginStyleOffset = wParam;
+ vs.marginStyleOffset = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -9347,36 +9416,36 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.marginStyleOffset;
case SCI_SETMARGINOPTIONS:
- marginOptions = wParam;
+ marginOptions = static_cast<int>(wParam);
break;
case SCI_GETMARGINOPTIONS:
return marginOptions;
case SCI_MARGINSETTEXT:
- pdoc->MarginSetText(wParam, CharPtrFromSPtr(lParam));
+ pdoc->MarginSetText(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
break;
case SCI_MARGINGETTEXT: {
- const StyledText st = pdoc->MarginStyledText(wParam);
+ const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam));
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
}
case SCI_MARGINSETSTYLE:
- pdoc->MarginSetStyle(wParam, lParam);
+ pdoc->MarginSetStyle(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_MARGINGETSTYLE: {
- const StyledText st = pdoc->MarginStyledText(wParam);
+ const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam));
return st.style;
}
case SCI_MARGINSETSTYLES:
- pdoc->MarginSetStyles(wParam, reinterpret_cast<const unsigned char *>(lParam));
+ pdoc->MarginSetStyles(static_cast<int>(wParam), reinterpret_cast<const unsigned char *>(lParam));
break;
case SCI_MARGINGETSTYLES: {
- const StyledText st = pdoc->MarginStyledText(wParam);
+ const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam));
return BytesResult(lParam, st.styles, st.length);
}
@@ -9385,48 +9454,48 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_ANNOTATIONSETTEXT:
- pdoc->AnnotationSetText(wParam, CharPtrFromSPtr(lParam));
+ pdoc->AnnotationSetText(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
break;
case SCI_ANNOTATIONGETTEXT: {
- const StyledText st = pdoc->AnnotationStyledText(wParam);
+ const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam));
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
}
case SCI_ANNOTATIONGETSTYLE: {
- const StyledText st = pdoc->AnnotationStyledText(wParam);
+ const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam));
return st.style;
}
case SCI_ANNOTATIONSETSTYLE:
- pdoc->AnnotationSetStyle(wParam, lParam);
+ pdoc->AnnotationSetStyle(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_ANNOTATIONSETSTYLES:
- pdoc->AnnotationSetStyles(wParam, reinterpret_cast<const unsigned char *>(lParam));
+ pdoc->AnnotationSetStyles(static_cast<int>(wParam), reinterpret_cast<const unsigned char *>(lParam));
break;
case SCI_ANNOTATIONGETSTYLES: {
- const StyledText st = pdoc->AnnotationStyledText(wParam);
+ const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam));
return BytesResult(lParam, st.styles, st.length);
}
case SCI_ANNOTATIONGETLINES:
- return pdoc->AnnotationLines(wParam);
+ return pdoc->AnnotationLines(static_cast<int>(wParam));
case SCI_ANNOTATIONCLEARALL:
pdoc->AnnotationClearAll();
break;
case SCI_ANNOTATIONSETVISIBLE:
- SetAnnotationVisible(wParam);
+ SetAnnotationVisible(static_cast<int>(wParam));
break;
case SCI_ANNOTATIONGETVISIBLE:
return vs.annotationVisible;
case SCI_ANNOTATIONSETSTYLEOFFSET:
- vs.annotationStyleOffset = wParam;
+ vs.annotationStyleOffset = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -9438,10 +9507,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_ALLOCATEEXTENDEDSTYLES:
- return vs.AllocateExtendedStyles(wParam);
+ return vs.AllocateExtendedStyles(static_cast<int>(wParam));
case SCI_ADDUNDOACTION:
- pdoc->AddUndoAction(wParam, lParam & UNDO_MAY_COALESCE);
+ pdoc->AddUndoAction(static_cast<int>(wParam), lParam & UNDO_MAY_COALESCE);
break;
case SCI_SETMOUSESELECTIONRECTANGULARSWITCH:
@@ -9468,7 +9537,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return additionalSelectionTyping;
case SCI_SETMULTIPASTE:
- multiPasteMode = wParam;
+ multiPasteMode = static_cast<int>(wParam);
break;
case SCI_GETMULTIPASTE:
@@ -9502,22 +9571,22 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETSELECTION:
- sel.SetSelection(SelectionRange(wParam, lParam));
+ sel.SetSelection(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam)));
Redraw();
break;
case SCI_ADDSELECTION:
- sel.AddSelection(SelectionRange(wParam, lParam));
+ sel.AddSelection(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam)));
Redraw();
break;
case SCI_DROPSELECTIONN:
- sel.DropSelection(wParam);
+ sel.DropSelection(static_cast<int>(wParam));
Redraw();
break;
case SCI_SETMAINSELECTION:
- sel.SetMain(wParam);
+ sel.SetMain(static_cast<int>(wParam));
Redraw();
break;
@@ -9525,7 +9594,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.Main();
case SCI_SETSELECTIONNCARET:
- sel.Range(wParam).caret.SetPosition(lParam);
+ sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam));
Redraw();
break;
@@ -9533,14 +9602,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.Range(wParam).caret.Position();
case SCI_SETSELECTIONNANCHOR:
- sel.Range(wParam).anchor.SetPosition(lParam);
+ sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam));
Redraw();
break;
case SCI_GETSELECTIONNANCHOR:
return sel.Range(wParam).anchor.Position();
case SCI_SETSELECTIONNCARETVIRTUALSPACE:
- sel.Range(wParam).caret.SetVirtualSpace(lParam);
+ sel.Range(wParam).caret.SetVirtualSpace(static_cast<int>(lParam));
Redraw();
break;
@@ -9548,7 +9617,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.Range(wParam).caret.VirtualSpace();
case SCI_SETSELECTIONNANCHORVIRTUALSPACE:
- sel.Range(wParam).anchor.SetVirtualSpace(lParam);
+ sel.Range(wParam).anchor.SetVirtualSpace(static_cast<int>(lParam));
Redraw();
break;
@@ -9556,7 +9625,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.Range(wParam).anchor.VirtualSpace();
case SCI_SETSELECTIONNSTART:
- sel.Range(wParam).anchor.SetPosition(lParam);
+ sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam));
Redraw();
break;
@@ -9564,7 +9633,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.Range(wParam).Start().Position();
case SCI_SETSELECTIONNEND:
- sel.Range(wParam).caret.SetPosition(lParam);
+ sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam));
Redraw();
break;
@@ -9575,7 +9644,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::selRectangle;
- sel.Rectangular().caret.SetPosition(wParam);
+ sel.Rectangular().caret.SetPosition(static_cast<int>(wParam));
SetRectangularRange();
Redraw();
break;
@@ -9587,7 +9656,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::selRectangle;
- sel.Rectangular().anchor.SetPosition(wParam);
+ sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam));
SetRectangularRange();
Redraw();
break;
@@ -9599,7 +9668,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::selRectangle;
- sel.Rectangular().caret.SetVirtualSpace(wParam);
+ sel.Rectangular().caret.SetVirtualSpace(static_cast<int>(wParam));
SetRectangularRange();
Redraw();
break;
@@ -9611,7 +9680,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::selRectangle;
- sel.Rectangular().anchor.SetVirtualSpace(wParam);
+ sel.Rectangular().anchor.SetVirtualSpace(static_cast<int>(wParam));
SetRectangularRange();
Redraw();
break;
@@ -9620,24 +9689,24 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.Rectangular().anchor.VirtualSpace();
case SCI_SETVIRTUALSPACEOPTIONS:
- virtualSpaceOptions = wParam;
+ virtualSpaceOptions = static_cast<int>(wParam);
break;
case SCI_GETVIRTUALSPACEOPTIONS:
return virtualSpaceOptions;
case SCI_SETADDITIONALSELFORE:
- vs.selAdditionalForeground = ColourDesired(wParam);
+ vs.selAdditionalForeground = ColourDesired(static_cast<long>(wParam));
InvalidateStyleRedraw();
break;
case SCI_SETADDITIONALSELBACK:
- vs.selAdditionalBackground = ColourDesired(wParam);
+ vs.selAdditionalBackground = ColourDesired(static_cast<long>(wParam));
InvalidateStyleRedraw();
break;
case SCI_SETADDITIONALSELALPHA:
- vs.selAdditionalAlpha = wParam;
+ vs.selAdditionalAlpha = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
@@ -9645,7 +9714,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.selAdditionalAlpha;
case SCI_SETADDITIONALCARETFORE:
- vs.additionalCaretColour = ColourDesired(wParam);
+ vs.additionalCaretColour = ColourDesired(static_cast<long>(wParam));
InvalidateStyleRedraw();
break;
@@ -9663,11 +9732,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_CHANGELEXERSTATE:
- pdoc->ChangeLexerState(wParam, lParam);
+ pdoc->ChangeLexerState(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_SETIDENTIFIER:
- SetCtrlID(wParam);
+ SetCtrlID(static_cast<int>(wParam));
break;
case SCI_GETIDENTIFIER:
@@ -9681,7 +9750,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return technology;
case SCI_COUNTCHARACTERS:
- return pdoc->CountCharacters(wParam, lParam);
+ return pdoc->CountCharacters(static_cast<int>(wParam), static_cast<int>(lParam));
default:
return DefWndProc(iMessage, wParam, lParam);
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h
index 7579b3f..468b5bb 100644
--- a/scintilla/src/Editor.h
+++ b/scintilla/src/Editor.h
@@ -356,12 +356,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
int LineFromLocation(Point pt) const;
void SetTopLine(int topLineNew);
- bool AbandonPaint();
+ virtual bool AbandonPaint();
virtual void RedrawRect(PRectangle rc);
virtual void DiscardOverdraw();
virtual void Redraw();
void RedrawSelMargin(int line=-1, bool allAfter=false);
- PRectangle RectangleFromRange(int start, int end);
+ PRectangle RectangleFromRange(Range r);
void InvalidateRange(int start, int end);
bool UserVirtualSpace() const {
@@ -420,6 +420,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void ScrollRange(SelectionRange range);
void ShowCaretAtCurrentPosition();
void DropCaret();
+ void CaretSetPeriod(int period);
void InvalidateCaret();
virtual void UpdateSystemCaret();
@@ -472,8 +473,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
int InsertSpace(int position, unsigned int spaces);
void AddChar(char ch);
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
- void InsertPaste(SelectionPosition selStart, const char *text, int len);
- void ClearSelection(bool retainMultipleSelections=false);
+ void InsertPaste(const char *text, int len);
+ enum PasteShape { pasteStream=0, pasteRectangular = 1, pasteLine = 2 };
+ void InsertPasteShape(const char *text, int len, PasteShape shape);
+ void ClearSelection(bool retainMultipleSelections = false);
void ClearAll();
void ClearDocumentStyle();
void Cut();
diff --git a/scintilla/src/Indicator.cxx b/scintilla/src/Indicator.cxx
index 0127320..c552797 100644
--- a/scintilla/src/Indicator.cxx
+++ b/scintilla/src/Indicator.cxx
@@ -20,17 +20,17 @@ using namespace Scintilla;
static PRectangle PixelGridAlign(const PRectangle &rc) {
// Move left and right side to nearest pixel to avoid blurry visuals
- return PRectangle(int(rc.left + 0.5), rc.top, int(rc.right + 0.5), rc.bottom);
+ return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom));
}
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) {
surface->PenColour(fore);
- int ymid = (rc.bottom + rc.top) / 2;
+ int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
if (style == INDIC_SQUIGGLE) {
int x = int(rc.left+0.5);
int xLast = int(rc.right+0.5);
int y = 0;
- surface->MoveTo(x, rc.top + y);
+ surface->MoveTo(x, static_cast<int>(rc.top) + y);
while (x < xLast) {
if ((x + 2) > xLast) {
if (xLast > x)
@@ -40,12 +40,12 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
x += 2;
y = 2 - y;
}
- surface->LineTo(x, rc.top + y);
+ surface->LineTo(x, static_cast<int>(rc.top) + y);
}
} else if (style == INDIC_SQUIGGLEPIXMAP) {
PRectangle rcSquiggle = PixelGridAlign(rc);
- int width = Platform::Minimum(4000, rcSquiggle.Width());
+ int width = Platform::Minimum(4000, static_cast<int>(rcSquiggle.Width()));
RGBAImage image(width, 3, 1.0, 0);
enum { alphaFull = 0xff, alphaSide = 0x2f, alphaSide2=0x5f };
for (int x = 0; x < width; x++) {
@@ -62,19 +62,19 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
surface->DrawRGBAImage(rcSquiggle, image.GetWidth(), image.GetHeight(), image.Pixels());
} else if (style == INDIC_SQUIGGLELOW) {
- surface->MoveTo(rc.left, rc.top);
- int x = rc.left + 3;
+ surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top));
+ int x = static_cast<int>(rc.left) + 3;
int y = 0;
while (x < rc.right) {
- surface->LineTo(x-1, rc.top + y);
+ surface->LineTo(x - 1, static_cast<int>(rc.top) + y);
y = 1 - y;
- surface->LineTo(x, rc.top + y);
+ surface->LineTo(x, static_cast<int>(rc.top) + y);
x += 3;
}
- surface->LineTo(rc.right, rc.top + y); // Finish the line
+ surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) + y); // Finish the line
} else if (style == INDIC_TT) {
- surface->MoveTo(rc.left, ymid);
- int x = rc.left + 5;
+ surface->MoveTo(static_cast<int>(rc.left), ymid);
+ int x = static_cast<int>(rc.left) + 5;
while (x < rc.right) {
surface->LineTo(x, ymid);
surface->MoveTo(x-3, ymid);
@@ -83,35 +83,35 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
surface->MoveTo(x, ymid);
x += 5;
}
- surface->LineTo(rc.right, ymid); // Finish the line
+ surface->LineTo(static_cast<int>(rc.right), ymid); // Finish the line
if (x - 3 <= rc.right) {
surface->MoveTo(x-3, ymid);
surface->LineTo(x-3, ymid+2);
}
} else if (style == INDIC_DIAGONAL) {
- int x = rc.left;
+ int x = static_cast<int>(rc.left);
while (x < rc.right) {
- surface->MoveTo(x, rc.top+2);
+ surface->MoveTo(x, static_cast<int>(rc.top) + 2);
int endX = x+3;
- int endY = rc.top - 1;
+ int endY = static_cast<int>(rc.top) - 1;
if (endX > rc.right) {
- endY += endX - rc.right;
- endX = rc.right;
+ endY += endX - static_cast<int>(rc.right);
+ endX = static_cast<int>(rc.right);
}
surface->LineTo(endX, endY);
x += 4;
}
} else if (style == INDIC_STRIKE) {
- surface->MoveTo(rc.left, rc.top - 4);
- surface->LineTo(rc.right, rc.top - 4);
+ surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top) - 4);
+ surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) - 4);
} else if (style == INDIC_HIDDEN) {
// Draw nothing
} else if (style == INDIC_BOX) {
- surface->MoveTo(rc.left, ymid+1);
- surface->LineTo(rc.right, ymid+1);
- surface->LineTo(rc.right, rcLine.top+1);
- surface->LineTo(rc.left, rcLine.top+1);
- surface->LineTo(rc.left, ymid+1);
+ surface->MoveTo(static_cast<int>(rc.left), ymid + 1);
+ surface->LineTo(static_cast<int>(rc.right), ymid + 1);
+ surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rcLine.top) + 1);
+ surface->LineTo(static_cast<int>(rc.left), static_cast<int>(rcLine.top) + 1);
+ surface->LineTo(static_cast<int>(rc.left), ymid + 1);
} else if (style == INDIC_ROUNDBOX || style == INDIC_STRAIGHTBOX) {
PRectangle rcBox = rcLine;
rcBox.top = rcLine.top + 1;
@@ -123,32 +123,32 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
rcBox.top = rcLine.top + 1;
rcBox.bottom = rcLine.bottom;
// Cap width at 4000 to avoid large allocations when mistakes made
- int width = Platform::Minimum(rcBox.Width(), 4000);
- RGBAImage image(width, rcBox.Height(), 1.0, 0);
+ int width = Platform::Minimum(static_cast<int>(rcBox.Width()), 4000);
+ RGBAImage image(width, static_cast<int>(rcBox.Height()), 1.0, 0);
// Draw horizontal lines top and bottom
for (int x=0; x<width; x++) {
- for (int y=0; y<rcBox.Height(); y += rcBox.Height()-1) {
+ for (int y = 0; y<static_cast<int>(rcBox.Height()); y += static_cast<int>(rcBox.Height()) - 1) {
image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
// Draw vertical lines left and right
- for (int y=1; y<rcBox.Height(); y++) {
+ for (int y = 1; y<static_cast<int>(rcBox.Height()); y++) {
for (int x=0; x<width; x += width-1) {
image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels());
} else if (style == INDIC_DASH) {
- int x = rc.left;
+ int x = static_cast<int>(rc.left);
while (x < rc.right) {
surface->MoveTo(x, ymid);
- surface->LineTo(Platform::Minimum(x + 4, rc.right), ymid);
+ surface->LineTo(Platform::Minimum(x + 4, static_cast<int>(rc.right)), ymid);
x += 7;
}
} else if (style == INDIC_DOTS) {
- int x = rc.left;
- while (x < rc.right) {
- PRectangle rcDot(x, ymid, x+1, ymid+1);
+ int x = static_cast<int>(rc.left);
+ while (x < static_cast<int>(rc.right)) {
+ PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1);
surface->FillRectangle(rcDot, fore);
x += 2;
}
@@ -156,8 +156,8 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
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);
+ surface->MoveTo(static_cast<int>(rc.left), ymid);
+ surface->LineTo(static_cast<int>(rc.right), ymid);
}
}
diff --git a/scintilla/src/LineMarker.cxx b/scintilla/src/LineMarker.cxx
index 2a332ab..b5d9f88 100644
--- a/scintilla/src/LineMarker.cxx
+++ b/scintilla/src/LineMarker.cxx
@@ -37,37 +37,37 @@ void LineMarker::SetXPM(const char *const *linesForm) {
void LineMarker::SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage) {
delete image;
- image = new RGBAImage(sizeRGBAImage.x, sizeRGBAImage.y, scale, pixelsRGBAImage);
+ image = new RGBAImage(static_cast<int>(sizeRGBAImage.x), static_cast<int>(sizeRGBAImage.y), scale, pixelsRGBAImage);
markType = SC_MARK_RGBAIMAGE;
}
static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) {
- PRectangle rc;
- rc.left = centreX - armSize;
- rc.top = centreY - armSize;
- rc.right = centreX + armSize + 1;
- rc.bottom = centreY + armSize + 1;
+ PRectangle rc = PRectangle::FromInts(
+ centreX - armSize,
+ centreY - armSize,
+ centreX + armSize + 1,
+ centreY + armSize + 1);
surface->RectangleDraw(rc, back, fore);
}
static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) {
- PRectangle rcCircle;
- rcCircle.left = centreX - armSize;
- rcCircle.top = centreY - armSize;
- rcCircle.right = centreX + armSize + 1;
- rcCircle.bottom = centreY + armSize + 1;
+ PRectangle rcCircle = PRectangle::FromInts(
+ centreX - armSize,
+ centreY - armSize,
+ centreX + armSize + 1,
+ centreY + armSize + 1);
surface->Ellipse(rcCircle, back, fore);
}
static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) {
- PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
+ PRectangle rcV = PRectangle::FromInts(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
surface->FillRectangle(rcV, fore);
- PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
+ PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1);
surface->FillRectangle(rcH, fore);
}
static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) {
- PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
+ PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1);
surface->FillRectangle(rcH, fore);
}
@@ -102,9 +102,9 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
if ((markType == SC_MARK_RGBAIMAGE) && (image)) {
// Make rectangle just large enough to fit image centred on centre of rcWhole
PRectangle rcImage;
- rcImage.top = static_cast<int>(((rcWhole.top + rcWhole.bottom) - image->GetScaledHeight()) / 2);
+ rcImage.top = ((rcWhole.top + rcWhole.bottom) - image->GetScaledHeight()) / 2;
rcImage.bottom = rcImage.top + image->GetScaledHeight();
- rcImage.left = static_cast<int>(((rcWhole.left + rcWhole.right) - image->GetScaledWidth()) / 2);
+ rcImage.left = ((rcWhole.left + rcWhole.right) - image->GetScaledWidth()) / 2;
rcImage.right = rcImage.left + image->GetScaledWidth();
surface->DrawRGBAImage(rcImage, image->GetWidth(), image->GetHeight(), image->Pixels());
return;
@@ -113,17 +113,17 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
PRectangle rc = rcWhole;
rc.top++;
rc.bottom--;
- int minDim = Platform::Minimum(rc.Width(), rc.Height());
+ int minDim = Platform::Minimum(static_cast<int>(rc.Width()), static_cast<int>(rc.Height()));
minDim--; // Ensure does not go beyond edge
- int centreX = floor((rc.right + rc.left) / 2.0);
- int centreY = floor((rc.bottom + rc.top) / 2.0);
+ int centreX = static_cast<int>(floor((rc.right + rc.left) / 2.0));
+ int centreY = static_cast<int>(floor((rc.bottom + rc.top) / 2.0));
int dimOn2 = minDim / 2;
int dimOn4 = minDim / 4;
int blobSize = dimOn2-1;
int armSize = dimOn2-2;
if (marginStyle == SC_MARGIN_NUMBER || marginStyle == SC_MARGIN_TEXT || marginStyle == SC_MARGIN_RTEXT) {
// On textual margins move marker to the left to try to avoid overlapping the text
- centreX = rc.left + dimOn2 + 1;
+ centreX = static_cast<int>(rc.left) + dimOn2 + 1;
}
if (markType == SC_MARK_ROUNDRECT) {
PRectangle rcRounded = rc;
@@ -131,51 +131,51 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
rcRounded.right = rc.right - 1;
surface->RoundedRectangle(rcRounded, fore, back);
} else if (markType == SC_MARK_CIRCLE) {
- PRectangle rcCircle;
- rcCircle.left = centreX - dimOn2;
- rcCircle.top = centreY - dimOn2;
- rcCircle.right = centreX + dimOn2;
- rcCircle.bottom = centreY + dimOn2;
+ PRectangle rcCircle = PRectangle::FromInts(
+ centreX - dimOn2,
+ centreY - dimOn2,
+ centreX + dimOn2,
+ centreY + dimOn2);
surface->Ellipse(rcCircle, fore, back);
} else if (markType == SC_MARK_ARROW) {
Point pts[] = {
- Point(centreX - dimOn4, centreY - dimOn2),
- Point(centreX - dimOn4, centreY + dimOn2),
- Point(centreX + dimOn2 - dimOn4, centreY),
+ Point::FromInts(centreX - dimOn4, centreY - dimOn2),
+ Point::FromInts(centreX - dimOn4, centreY + dimOn2),
+ Point::FromInts(centreX + dimOn2 - dimOn4, centreY),
};
surface->Polygon(pts, ELEMENTS(pts), fore, back);
} else if (markType == SC_MARK_ARROWDOWN) {
Point pts[] = {
- Point(centreX - dimOn2, centreY - dimOn4),
- Point(centreX + dimOn2, centreY - dimOn4),
- Point(centreX, centreY + dimOn2 - dimOn4),
+ Point::FromInts(centreX - dimOn2, centreY - dimOn4),
+ Point::FromInts(centreX + dimOn2, centreY - dimOn4),
+ Point::FromInts(centreX, centreY + dimOn2 - dimOn4),
};
surface->Polygon(pts, ELEMENTS(pts), fore, back);
} else if (markType == SC_MARK_PLUS) {
Point pts[] = {
- Point(centreX - armSize, centreY - 1),
- Point(centreX - 1, centreY - 1),
- Point(centreX - 1, centreY - armSize),
- Point(centreX + 1, centreY - armSize),
- Point(centreX + 1, centreY - 1),
- Point(centreX + armSize, centreY -1),
- Point(centreX + armSize, centreY +1),
- Point(centreX + 1, centreY + 1),
- Point(centreX + 1, centreY + armSize),
- Point(centreX - 1, centreY + armSize),
- Point(centreX - 1, centreY + 1),
- Point(centreX - armSize, centreY + 1),
+ Point::FromInts(centreX - armSize, centreY - 1),
+ Point::FromInts(centreX - 1, centreY - 1),
+ Point::FromInts(centreX - 1, centreY - armSize),
+ Point::FromInts(centreX + 1, centreY - armSize),
+ Point::FromInts(centreX + 1, centreY - 1),
+ Point::FromInts(centreX + armSize, centreY -1),
+ Point::FromInts(centreX + armSize, centreY +1),
+ Point::FromInts(centreX + 1, centreY + 1),
+ Point::FromInts(centreX + 1, centreY + armSize),
+ Point::FromInts(centreX - 1, centreY + armSize),
+ Point::FromInts(centreX - 1, centreY + 1),
+ Point::FromInts(centreX - armSize, centreY + 1),
};
surface->Polygon(pts, ELEMENTS(pts), fore, back);
} else if (markType == SC_MARK_MINUS) {
Point pts[] = {
- Point(centreX - armSize, centreY - 1),
- Point(centreX + armSize, centreY -1),
- Point(centreX + armSize, centreY +1),
- Point(centreX - armSize, centreY + 1),
+ Point::FromInts(centreX - armSize, centreY - 1),
+ Point::FromInts(centreX + armSize, centreY -1),
+ Point::FromInts(centreX + armSize, centreY +1),
+ Point::FromInts(centreX - armSize, centreY + 1),
};
surface->Polygon(pts, ELEMENTS(pts), fore, back);
@@ -193,46 +193,46 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_VLINE) {
surface->PenColour(body);
- surface->MoveTo(centreX, rcWhole.top);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
} else if (markType == SC_MARK_LCORNER) {
surface->PenColour(tail);
- surface->MoveTo(centreX, rcWhole.top);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
surface->LineTo(centreX, centreY);
- surface->LineTo(rc.right - 1, centreY);
+ surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
} else if (markType == SC_MARK_TCORNER) {
surface->PenColour(tail);
surface->MoveTo(centreX, centreY);
- surface->LineTo(rc.right - 1, centreY);
+ surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
surface->PenColour(body);
- surface->MoveTo(centreX, rcWhole.top);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
surface->LineTo(centreX, centreY + 1);
surface->PenColour(head);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
} else if (markType == SC_MARK_LCORNERCURVE) {
surface->PenColour(tail);
- surface->MoveTo(centreX, rcWhole.top);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
surface->LineTo(centreX, centreY-3);
surface->LineTo(centreX+3, centreY);
- surface->LineTo(rc.right - 1, centreY);
+ surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
} else if (markType == SC_MARK_TCORNERCURVE) {
surface->PenColour(tail);
surface->MoveTo(centreX, centreY-3);
surface->LineTo(centreX+3, centreY);
- surface->LineTo(rc.right - 1, centreY);
+ surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
surface->PenColour(body);
- surface->MoveTo(centreX, rcWhole.top);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
surface->LineTo(centreX, centreY-2);
surface->PenColour(head);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
} else if (markType == SC_MARK_BOXPLUS) {
DrawBox(surface, centreX, centreY, blobSize, fore, head);
@@ -244,10 +244,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
else
surface->PenColour(body);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
surface->PenColour(body);
- surface->MoveTo(centreX, rcWhole.top);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
surface->LineTo(centreX, centreY - blobSize);
DrawBox(surface, centreX, centreY, blobSize, fore, head);
@@ -270,7 +270,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
surface->PenColour(head);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
} else if (markType == SC_MARK_BOXMINUSCONNECTED) {
DrawBox(surface, centreX, centreY, blobSize, fore, head);
@@ -278,10 +278,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
surface->PenColour(head);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
surface->PenColour(body);
- surface->MoveTo(centreX, rcWhole.top);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
surface->LineTo(centreX, centreY - blobSize);
if (tFold == LineMarker::body) {
@@ -305,10 +305,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
else
surface->PenColour(body);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
surface->PenColour(body);
- surface->MoveTo(centreX, rcWhole.top);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
surface->LineTo(centreX, centreY - blobSize);
DrawCircle(surface, centreX, centreY, blobSize, fore, head);
@@ -317,7 +317,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_CIRCLEMINUS) {
surface->PenColour(head);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
DrawCircle(surface, centreX, centreY, blobSize, fore, head);
DrawMinus(surface, centreX, centreY, blobSize, tail);
@@ -325,10 +325,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) {
surface->PenColour(head);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, rcWhole.bottom);
+ surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
surface->PenColour(body);
- surface->MoveTo(centreX, rcWhole.top);
+ surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
surface->LineTo(centreX, centreY - blobSize);
DrawCircle(surface, centreX, centreY, blobSize, fore, head);
@@ -344,11 +344,11 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
character, 1, fore, back);
} else if (markType == SC_MARK_DOTDOTDOT) {
- int right = centreX - 6;
+ XYPOSITION right = static_cast<XYPOSITION>(centreX - 6);
for (int b=0; b<3; b++) {
PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom-2);
surface->FillRectangle(rcBlob, fore);
- right += 5;
+ right += 5.0f;
}
} else if (markType == SC_MARK_ARROWS) {
surface->PenColour(fore);
@@ -363,14 +363,14 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
}
} else if (markType == SC_MARK_SHORTARROW) {
Point pts[] = {
- Point(centreX, centreY + dimOn2),
- Point(centreX + dimOn2, centreY),
- Point(centreX, centreY - dimOn2),
- Point(centreX, centreY - dimOn4),
- Point(centreX - dimOn4, centreY - dimOn4),
- Point(centreX - dimOn4, centreY + dimOn4),
- Point(centreX, centreY + dimOn4),
- Point(centreX, centreY + dimOn2),
+ Point::FromInts(centreX, centreY + dimOn2),
+ Point::FromInts(centreX + dimOn2, centreY),
+ Point::FromInts(centreX, centreY - dimOn2),
+ Point::FromInts(centreX, centreY - dimOn4),
+ Point::FromInts(centreX - dimOn4, centreY - dimOn4),
+ Point::FromInts(centreX - dimOn4, centreY + dimOn4),
+ Point::FromInts(centreX, centreY + dimOn4),
+ Point::FromInts(centreX, centreY + dimOn2),
};
surface->Polygon(pts, ELEMENTS(pts), fore, back);
} else if (markType == SC_MARK_LEFTRECT) {
@@ -380,11 +380,11 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_BOOKMARK) {
int halfHeight = minDim / 3;
Point pts[] = {
- Point(rc.left, centreY-halfHeight),
- Point(rc.right-3, centreY-halfHeight),
- Point(rc.right-3-halfHeight, centreY),
- Point(rc.right-3, centreY+halfHeight),
- Point(rc.left, centreY+halfHeight),
+ Point::FromInts(static_cast<int>(rc.left), centreY-halfHeight),
+ Point::FromInts(static_cast<int>(rc.right) - 3, centreY - halfHeight),
+ Point::FromInts(static_cast<int>(rc.right) - 3 - halfHeight, centreY),
+ Point::FromInts(static_cast<int>(rc.right) - 3, centreY + halfHeight),
+ Point::FromInts(static_cast<int>(rc.left), centreY + halfHeight),
};
surface->Polygon(pts, ELEMENTS(pts), fore, back);
} else { // SC_MARK_FULLRECT
diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx
index 040bf85..b6a591e 100644
--- a/scintilla/src/PositionCache.cxx
+++ b/scintilla/src/PositionCache.cxx
@@ -232,7 +232,7 @@ Point LineLayout::PointFromPosition(int posInLine, int lineHeight) const {
for (int subLine = 0; subLine < lines; subLine++) {
const Range rangeSubLine = SubLineRange(subLine);
if (posInLine >= rangeSubLine.start) {
- pt.y = subLine*lineHeight;
+ pt.y = static_cast<XYPOSITION>(subLine*lineHeight);
if (posInLine <= rangeSubLine.end) {
pt.x = positions[posInLine] - positions[rangeSubLine.start];
if (rangeSubLine.start != 0) // Wrapped lines may be indented
@@ -462,7 +462,7 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL
// Search for first visible break
// First find the first visible character
if (xStart > 0.0f)
- nextBreak = ll->FindBefore(xStart, lineStart, lineEnd);
+ nextBreak = ll->FindBefore(static_cast<XYPOSITION>(xStart), lineStart, lineEnd);
// Now back to a style break
while ((nextBreak > lineStart) && (ll->styles[nextBreak] == ll->styles[nextBreak - 1])) {
nextBreak--;
@@ -563,7 +563,7 @@ void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_,
if (s_ && positions_) {
positions = new XYPOSITION[len + (len / 4) + 1];
for (unsigned int i=0; i<len; i++) {
- positions[i] = static_cast<XYPOSITION>(positions_[i]);
+ positions[i] = positions_[i];
}
memcpy(reinterpret_cast<char *>(positions + len), s_, len);
}
@@ -594,7 +594,7 @@ bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_,
}
}
-int PositionCacheEntry::Hash(unsigned int styleNumber_, const char *s, unsigned int len_) {
+unsigned int PositionCacheEntry::Hash(unsigned int styleNumber_, const char *s, unsigned int len_) {
unsigned int ret = s[0] << 7;
for (unsigned int i=0; i<len_; i++) {
ret *= 1000003;
@@ -646,18 +646,18 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned
const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc) {
allClear = false;
- int probe = -1;
+ size_t probe = pces.size(); // Out of bounds
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 % pces.size());
+ unsigned int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
+ probe = hashValue % pces.size();
if (pces[probe].Retrieve(styleNumber, s, len, positions)) {
return;
}
- int probe2 = static_cast<int>((hashValue * 37) % pces.size());
+ unsigned int probe2 = (hashValue * 37) % pces.size();
if (pces[probe2].Retrieve(styleNumber, s, len, positions)) {
return;
}
@@ -682,7 +682,8 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned
} else {
surface->MeasureWidths(vstyle.styles[styleNumber].font, s, len, positions);
}
- if (probe >= 0) {
+ if (probe < pces.size()) {
+ // Store into cache
clock++;
if (clock > 60000) {
// Since there are only 16 bits for the clock, wrap it round and
diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h
index 5739d45..e186d9a 100644
--- a/scintilla/src/PositionCache.h
+++ b/scintilla/src/PositionCache.h
@@ -111,7 +111,7 @@ public:
void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock);
void Clear();
bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const;
- static int Hash(unsigned int styleNumber_, const char *s, unsigned int len);
+ static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len);
bool NewerThan(const PositionCacheEntry &other) const;
void ResetClock();
};
diff --git a/scintilla/src/RESearch.cxx b/scintilla/src/RESearch.cxx
index ccb7c1f..4c2957b 100644
--- a/scintilla/src/RESearch.cxx
+++ b/scintilla/src/RESearch.cxx
@@ -207,11 +207,6 @@
#include "CharClassify.h"
#include "RESearch.h"
-// Shut up annoying Visual C++ warnings:
-#ifdef _MSC_VER
-#pragma warning(disable: 4514)
-#endif
-
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
@@ -789,7 +784,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
c = *(ap+1);
while ((lp < endp) && (static_cast<unsigned char>(ci.CharAt(lp)) != c))
lp++;
- if (lp >= endp) /* if EOS, fail, else fall thru. */
+ if (lp >= endp) /* if EOS, fail, else fall through. */
return 0;
default: /* regular matching all the way. */
while (lp < endp) {
@@ -819,7 +814,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
*
* special case optimizations: (nfa[n], nfa[n+1])
* CLO ANY
- * We KNOW .* will match everything upto the
+ * We KNOW .* will match everything up to the
* end of line. Thus, directly go to the end of
* line, without recursive PMatch calls. As in
* the other closure cases, the remaining pattern
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx
index da0bb58..b4e11b6 100644
--- a/scintilla/src/ScintillaBase.cxx
+++ b/scintilla/src/ScintillaBase.cxx
@@ -198,8 +198,8 @@ void ScintillaBase::AutoCompleteDoubleClick(void *p) {
void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) {
UndoGroup ug(pdoc);
pdoc->DeleteChars(startPos, removeLen);
- pdoc->InsertString(startPos, text, textLen);
- SetEmptySelection(startPos + textLen);
+ const int lengthInserted = pdoc->InsertString(startPos, text, textLen);
+ SetEmptySelection(startPos + lengthInserted);
}
void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
@@ -233,7 +233,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
int heightLB = ac.heightLBDefault;
int widthLB = ac.widthLBDefault;
if (pt.x >= rcClient.right - widthLB) {
- HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB);
+ HorizontalScrollTo(static_cast<int>(xOffset + pt.x - rcClient.right + widthLB));
Redraw();
pt = PointMainCaret();
}
@@ -248,17 +248,17 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
pt.y >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2) { // and there is more room above.
rcac.top = pt.y - heightLB;
if (rcac.top < rcPopupBounds.top) {
- heightLB -= (rcPopupBounds.top - rcac.top);
+ heightLB -= static_cast<int>(rcPopupBounds.top - rcac.top);
rcac.top = rcPopupBounds.top;
}
} else {
rcac.top = pt.y + vs.lineHeight;
}
rcac.right = rcac.left + widthLB;
- rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcPopupBounds.bottom);
+ rcac.bottom = static_cast<XYPOSITION>(Platform::Minimum(static_cast<int>(rcac.top) + heightLB, static_cast<int>(rcPopupBounds.bottom)));
ac.lb->SetPositionRelative(rcac, wMain);
ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);
- unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth;
+ unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[STYLE_DEFAULT].aveCharWidth);
ac.lb->SetAverageCharWidth(aveCharWidth);
ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this);
@@ -266,8 +266,8 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
// Fiddle the position of the list so it is right next to the target and wide enough for all its strings
PRectangle rcList = ac.lb->GetDesiredRect();
- int heightAlloced = rcList.bottom - rcList.top;
- widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left);
+ int heightAlloced = static_cast<int>(rcList.bottom - rcList.top);
+ widthLB = Platform::Maximum(widthLB, static_cast<int>(rcList.right - rcList.left));
if (maxListWidth != 0)
widthLB = Platform::Minimum(widthLB, aveCharWidth*maxListWidth);
// Make an allowance for large strings in list
@@ -416,7 +416,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
// If the call-tip window would be out of the client
// space
PRectangle rcClient = GetClientRectangle();
- int offset = vs.lineHeight + rc.Height();
+ int offset = vs.lineHeight + static_cast<int>(rc.Height());
// adjust so it displays above the text.
if (rc.bottom > rcClient.bottom) {
rc.top -= offset;
@@ -749,7 +749,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
switch (iMessage) {
case SCI_AUTOCSHOW:
listType = 0;
- AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam));
+ AutoCompleteStart(static_cast<int>(wParam), reinterpret_cast<const char *>(lParam));
break;
case SCI_AUTOCCANCEL:
@@ -813,21 +813,21 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return ac.ignoreCase;
case SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR:
- ac.ignoreCaseBehaviour = wParam;
+ ac.ignoreCaseBehaviour = static_cast<unsigned int>(wParam);
break;
case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR:
return ac.ignoreCaseBehaviour;
case SCI_AUTOCSETORDER:
- ac.autoSort = wParam;
+ ac.autoSort = static_cast<int>(wParam);
break;
case SCI_AUTOCGETORDER:
return ac.autoSort;
case SCI_USERLISTSHOW:
- listType = wParam;
+ listType = static_cast<int>(wParam);
AutoCompleteStart(0, reinterpret_cast<const char *>(lParam));
break;
@@ -846,25 +846,26 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return ac.dropRestOfWord;
case SCI_AUTOCSETMAXHEIGHT:
- ac.lb->SetVisibleRows(wParam);
+ ac.lb->SetVisibleRows(static_cast<int>(wParam));
break;
case SCI_AUTOCGETMAXHEIGHT:
return ac.lb->GetVisibleRows();
case SCI_AUTOCSETMAXWIDTH:
- maxListWidth = wParam;
+ maxListWidth = static_cast<int>(wParam);
break;
case SCI_AUTOCGETMAXWIDTH:
return maxListWidth;
case SCI_REGISTERIMAGE:
- ac.lb->RegisterImage(wParam, reinterpret_cast<const char *>(lParam));
+ ac.lb->RegisterImage(static_cast<int>(wParam), reinterpret_cast<const char *>(lParam));
break;
case SCI_REGISTERRGBAIMAGE:
- ac.lb->RegisterRGBAImage(wParam, sizeRGBAImage.x, sizeRGBAImage.y, reinterpret_cast<unsigned char *>(lParam));
+ ac.lb->RegisterRGBAImage(static_cast<int>(wParam), static_cast<int>(sizeRGBAImage.x), static_cast<int>(sizeRGBAImage.y),
+ reinterpret_cast<unsigned char *>(lParam));
break;
case SCI_CLEARREGISTEREDIMAGES:
@@ -879,7 +880,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return ac.GetTypesep();
case SCI_CALLTIPSHOW:
- CallTipShow(LocationFromPosition(wParam),
+ CallTipShow(LocationFromPosition(static_cast<int>(wParam)),
reinterpret_cast<const char *>(lParam));
break;
@@ -894,32 +895,32 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return ct.posStartCallTip;
case SCI_CALLTIPSETPOSSTART:
- ct.posStartCallTip = wParam;
+ ct.posStartCallTip = static_cast<int>(wParam);
break;
case SCI_CALLTIPSETHLT:
- ct.SetHighlight(wParam, lParam);
+ ct.SetHighlight(static_cast<int>(wParam), static_cast<int>(lParam));
break;
case SCI_CALLTIPSETBACK:
- ct.colourBG = ColourDesired(wParam);
+ ct.colourBG = ColourDesired(static_cast<long>(wParam));
vs.styles[STYLE_CALLTIP].back = ct.colourBG;
InvalidateStyleRedraw();
break;
case SCI_CALLTIPSETFORE:
- ct.colourUnSel = ColourDesired(wParam);
+ ct.colourUnSel = ColourDesired(static_cast<long>(wParam));
vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel;
InvalidateStyleRedraw();
break;
case SCI_CALLTIPSETFOREHLT:
- ct.colourSel = ColourDesired(wParam);
+ ct.colourSel = ColourDesired(static_cast<long>(wParam));
InvalidateStyleRedraw();
break;
case SCI_CALLTIPUSESTYLE:
- ct.SetTabSize((int)wParam);
+ ct.SetTabSize(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
@@ -934,7 +935,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
#ifdef SCI_LEXER
case SCI_SETLEXER:
- DocumentLexState()->SetLexer(wParam);
+ DocumentLexState()->SetLexer(static_cast<int>(wParam));
break;
case SCI_GETLEXER:
@@ -942,10 +943,10 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_COLOURISE:
if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) {
- pdoc->ModifiedAt(wParam);
- NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam);
+ pdoc->ModifiedAt(static_cast<int>(wParam));
+ NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : static_cast<int>(lParam));
} else {
- DocumentLexState()->Colourise(wParam, lParam);
+ DocumentLexState()->Colourise(static_cast<int>(wParam), static_cast<int>(lParam));
}
Redraw();
break;
@@ -963,7 +964,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
reinterpret_cast<char *>(lParam));
case SCI_GETPROPERTYINT:
- return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam), lParam);
+ return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam), static_cast<int>(lParam));
case SCI_SETKEYWORDS:
DocumentLexState()->SetWordList(wParam, reinterpret_cast<const char *>(lParam));
diff --git a/scintilla/src/Selection.cxx b/scintilla/src/Selection.cxx
index fcc7d38..6465aae 100644
--- a/scintilla/src/Selection.cxx
+++ b/scintilla/src/Selection.cxx
@@ -230,6 +230,14 @@ SelectionRange &Selection::RangeMain() {
return ranges[mainRange];
}
+SelectionPosition Selection::Start() const {
+ if (IsRectangular()) {
+ return rangeRectangular.Start();
+ } else {
+ return ranges[mainRange].Start();
+ }
+}
+
bool Selection::MoveExtends() const {
return moveExtends;
}
diff --git a/scintilla/src/Selection.h b/scintilla/src/Selection.h
index b951224..eb74481 100644
--- a/scintilla/src/Selection.h
+++ b/scintilla/src/Selection.h
@@ -157,6 +157,7 @@ public:
void SetMain(size_t r);
SelectionRange &Range(size_t r);
SelectionRange &RangeMain();
+ SelectionPosition Start() const;
bool MoveExtends() const;
void SetMoveExtends(bool moveExtends_);
bool Empty() const;
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx
index 8dfa614..ee654f7 100644
--- a/scintilla/src/ViewStyle.cxx
+++ b/scintilla/src/ViewStyle.cxx
@@ -75,12 +75,12 @@ void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, cons
if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1
sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
- float deviceHeight = surface.DeviceHeightFont(sizeZoomed);
+ float deviceHeight = static_cast<float>(surface.DeviceHeightFont(sizeZoomed));
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);
+ ascent = static_cast<unsigned int>(surface.Ascent(font));
+ descent = static_cast<unsigned int>(surface.Descent(font));
aveCharWidth = surface.AverageCharWidth(font);
spaceWidth = surface.WidthChar(font, ' ');
}
@@ -347,7 +347,7 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) {
controlCharWidth = 0.0;
if (controlCharSymbol >= 32) {
- controlCharWidth = surface.WidthChar(styles[STYLE_CONTROLCHAR].font, controlCharSymbol);
+ controlCharWidth = surface.WidthChar(styles[STYLE_CONTROLCHAR].font, static_cast<char>(controlCharSymbol));
}
fixedColumnWidth = marginInside ? leftMarginWidth : 0;
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h
index 21d10b7..5bea4ba 100644
--- a/scintilla/src/ViewStyle.h
+++ b/scintilla/src/ViewStyle.h
@@ -63,7 +63,7 @@ public:
bool isSet;
ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) : ColourDesired(colour_), isSet(isSet_) {
}
- ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(lParam), isSet(wParam != 0) {
+ ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(static_cast<long>(lParam)), isSet(wParam != 0) {
}
};
diff --git a/scintilla/src/XPM.cxx b/scintilla/src/XPM.cxx
index cce6ab7..3e3faf0 100644
--- a/scintilla/src/XPM.cxx
+++ b/scintilla/src/XPM.cxx
@@ -47,7 +47,7 @@ ColourDesired XPM::ColourFromCode(int ch) const {
void XPM::FillRun(Surface *surface, int code, int startX, int y, int x) {
if ((code != codeTransparent) && (startX != x)) {
- PRectangle rc(startX, y, x, y+1);
+ PRectangle rc = PRectangle::FromInts(startX, y, x, y + 1);
surface->FillRectangle(rc, ColourFromCode(code));
}
}
@@ -109,7 +109,7 @@ void XPM::Init(const char *const *linesForm) {
if (*colourDef == '#') {
colour.Set(colourDef);
} else {
- codeTransparent = code;
+ codeTransparent = static_cast<char>(code);
}
colourCodeTable[code] = colour;
}
@@ -127,8 +127,8 @@ void XPM::Draw(Surface *surface, PRectangle &rc) {
return;
}
// Centre the pixmap
- int startY = rc.top + (rc.Height() - height) / 2;
- int startX = rc.left + (rc.Width() - width) / 2;
+ int startY = static_cast<int>(rc.top + (rc.Height() - height) / 2);
+ int startX = static_cast<int>(rc.left + (rc.Width() - width) / 2);
for (int y=0; y<height; y++) {
int prevCode = 0;
int xStartRun = 0;
diff --git a/scintilla/version.txt b/scintilla/version.txt
index 8d6b017..cf9db31 100644
--- a/scintilla/version.txt
+++ b/scintilla/version.txt
@@ -1 +1 @@
-341
+342
diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx
index 985b870..d6c8c58 100644
--- a/scintilla/win32/PlatWin.cxx
+++ b/scintilla/win32/PlatWin.cxx
@@ -103,6 +103,9 @@ ID2D1Factory *pD2DFactory = 0;
IDWriteRenderingParams *defaultRenderingParams = 0;
IDWriteRenderingParams *customClearTypeRenderingParams = 0;
+static HMODULE hDLLD2D = NULL;
+static HMODULE hDLLDWrite = NULL;
+
bool LoadD2D() {
static bool triedLoadingD2D = false;
if (!triedLoadingD2D) {
@@ -111,7 +114,7 @@ bool LoadD2D() {
typedef HRESULT (WINAPI *DWriteCFSig)(DWRITE_FACTORY_TYPE factoryType, REFIID iid,
IUnknown **factory);
- HMODULE hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/);
+ hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/);
if (hDLLD2D) {
D2D1CFSig fnD2DCF = (D2D1CFSig)::GetProcAddress(hDLLD2D, "D2D1CreateFactory");
if (fnD2DCF) {
@@ -122,7 +125,7 @@ bool LoadD2D() {
reinterpret_cast<IUnknown**>(&pD2DFactory));
}
}
- HMODULE hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/);
+ hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/);
if (hDLLDWrite) {
DWriteCFSig fnDWCF = (DWriteCFSig)::GetProcAddress(hDLLDWrite, "DWriteCreateFactory");
if (fnDWCF) {
@@ -710,7 +713,8 @@ void SurfaceGDI::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired
void SurfaceGDI::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {
PenColour(fore);
BrushColor(back);
- ::Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
+ const RECT rcw = RectFromPRectangle(rc);
+ ::Rectangle(hdc, rcw.left, rcw.top, rcw.right, rcw.bottom);
}
void SurfaceGDI::FillRectangle(PRectangle rc, ColourDesired back) {
@@ -718,7 +722,7 @@ void SurfaceGDI::FillRectangle(PRectangle rc, ColourDesired back) {
// There is no need to allocate a brush either.
RECT rcw = RectFromPRectangle(rc);
::SetBkColor(hdc, back.AsLong());
- ::ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE, &rcw, TEXT(""), 0, NULL);
+ ::ExtTextOut(hdc, rcw.left, rcw.top, ETO_OPAQUE, &rcw, TEXT(""), 0, NULL);
}
void SurfaceGDI::FillRectangle(PRectangle rc, Surface &surfacePattern) {
@@ -735,9 +739,10 @@ void SurfaceGDI::FillRectangle(PRectangle rc, Surface &surfacePattern) {
void SurfaceGDI::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) {
PenColour(fore);
BrushColor(back);
+ const RECT rcw = RectFromPRectangle(rc);
::RoundRect(hdc,
- rc.left + 1, rc.top,
- rc.right - 1, rc.bottom,
+ rcw.left + 1, rcw.top,
+ rcw.right - 1, rcw.bottom,
8, 8);
}
@@ -770,10 +775,11 @@ static DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) {
void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
ColourDesired outline, int alphaOutline, int /* flags*/ ) {
+ const RECT rcw = RectFromPRectangle(rc);
if (AlphaBlendFn && rc.Width() > 0) {
HDC hMemDC = ::CreateCompatibleDC(reinterpret_cast<HDC>(hdc));
- int width = rc.Width();
- int height = rc.Height();
+ int width = static_cast<int>(rc.Width());
+ int height = static_cast<int>(rc.Height());
// Ensure not distorted too much by corners when small
cornerSize = Platform::Minimum(cornerSize, (Platform::Minimum(width, height) / 2) - 2);
BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}};
@@ -816,7 +822,7 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil
BLENDFUNCTION merge = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
- AlphaBlendFn(reinterpret_cast<HDC>(hdc), rc.left, rc.top, width, height, hMemDC, 0, 0, width, height, merge);
+ AlphaBlendFn(reinterpret_cast<HDC>(hdc), rcw.left, rcw.top, width, height, hMemDC, 0, 0, width, height, merge);
SelectBitmap(hMemDC, hbmOld);
::DeleteObject(hbmMem);
@@ -824,7 +830,6 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil
::DeleteDC(hMemDC);
} else {
BrushColor(outline);
- RECT rcw = RectFromPRectangle(rc);
FrameRect(hdc, &rcw, brush);
}
}
@@ -860,7 +865,8 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig
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);
+ AlphaBlendFn(reinterpret_cast<HDC>(hdc), static_cast<int>(rc.left), static_cast<int>(rc.top),
+ static_cast<int>(rc.Width()), static_cast<int>(rc.Height()), hMemDC, 0, 0, width, height, merge);
SelectBitmap(hMemDC, hbmOld);
::DeleteObject(hbmMem);
@@ -873,13 +879,16 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig
void SurfaceGDI::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {
PenColour(fore);
BrushColor(back);
- ::Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);
+ const RECT rcw = RectFromPRectangle(rc);
+ ::Ellipse(hdc, rcw.left, rcw.top, rcw.right, rcw.bottom);
}
void SurfaceGDI::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
::BitBlt(hdc,
- rc.left, rc.top, rc.Width(), rc.Height(),
- static_cast<SurfaceGDI &>(surfaceSource).hdc, from.x, from.y, SRCCOPY);
+ static_cast<int>(rc.left), static_cast<int>(rc.top),
+ static_cast<int>(rc.Width()), static_cast<int>(rc.Height()),
+ static_cast<SurfaceGDI &>(surfaceSource).hdc,
+ static_cast<int>(from.x), static_cast<int>(from.y), SRCCOPY);
}
typedef VarBuffer<int, stackBufferLength> TextPositionsI;
@@ -889,7 +898,8 @@ void SurfaceGDI::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, co
RECT rcw = RectFromPRectangle(rc);
SIZE sz={0,0};
int pos = 0;
- int x = rc.left;
+ int x = static_cast<int>(rc.left);
+ const int yBaseInt = static_cast<int>(ybase);
// Text drawing may fail if the text is too big.
// If it does fail, slice up into segments and draw each segment.
@@ -898,10 +908,10 @@ void SurfaceGDI::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, co
if ((!unicodeMode) && (IsNT() || (codePage==0) || win9xACPSame)) {
// Use ANSI calls
int lenDraw = Platform::Minimum(len, maxLenText);
- if (!::ExtTextOutA(hdc, x, ybase, fuOptions, &rcw, s, lenDraw, NULL)) {
+ if (!::ExtTextOutA(hdc, x, yBaseInt, fuOptions, &rcw, s, lenDraw, NULL)) {
while (lenDraw > pos) {
int seglen = Platform::Minimum(maxSegmentLength, lenDraw - pos);
- if (!::ExtTextOutA(hdc, x, ybase, fuOptions, &rcw, s+pos, seglen, NULL)) {
+ if (!::ExtTextOutA(hdc, x, yBaseInt, fuOptions, &rcw, s + pos, seglen, NULL)) {
PLATFORM_ASSERT(false);
return;
}
@@ -913,10 +923,10 @@ void SurfaceGDI::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, co
} else {
// Use Unicode calls
const TextWide tbuf(s, len, unicodeMode, codePage);
- if (!::ExtTextOutW(hdc, x, ybase, fuOptions, &rcw, tbuf.buffer, tbuf.tlen, NULL)) {
+ if (!::ExtTextOutW(hdc, x, yBaseInt, fuOptions, &rcw, tbuf.buffer, tbuf.tlen, NULL)) {
while (tbuf.tlen > pos) {
int seglen = Platform::Minimum(maxSegmentLength, tbuf.tlen - pos);
- if (!::ExtTextOutW(hdc, x, ybase, fuOptions, &rcw, tbuf.buffer+pos, seglen, NULL)) {
+ if (!::ExtTextOutW(hdc, x, yBaseInt, fuOptions, &rcw, tbuf.buffer + pos, seglen, NULL)) {
PLATFORM_ASSERT(false);
return;
}
@@ -965,7 +975,7 @@ XYPOSITION SurfaceGDI::WidthText(Font &font_, const char *s, int len) {
const TextWide tbuf(s, len, unicodeMode, codePage);
::GetTextExtentPoint32W(hdc, tbuf.buffer, tbuf.tlen, &sz);
}
- return sz.cx;
+ return static_cast<XYPOSITION>(sz.cx);
}
void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) {
@@ -1001,11 +1011,11 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *
lenChar = 2;
}
for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
- positions[i++] = poses.buffer[ui];
+ positions[i++] = static_cast<XYPOSITION>(poses.buffer[ui]);
}
ui++;
}
- int lastPos = 0;
+ XYPOSITION lastPos = 0.0f;
if (i > 0)
lastPos = positions[i-1];
while (i<len) {
@@ -1031,7 +1041,7 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *
poses.buffer[i] = poses.buffer[fit-1];
}
for (int i=0; i<lenBlock; i++)
- positions[i] = poses.buffer[i] + startOffset;
+ positions[i] = static_cast<XYPOSITION>(poses.buffer[i] + startOffset);
startOffset = poses.buffer[lenBlock-1];
len -= lenBlock;
positions += lenBlock;
@@ -1049,11 +1059,11 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *
int ui = 0;
for (int i=0; i<len;) {
if (Platform::IsDBCSLeadByte(codePage, s[i])) {
- positions[i] = poses.buffer[ui];
- positions[i+1] = poses.buffer[ui];
+ positions[i] = static_cast<XYPOSITION>(poses.buffer[ui]);
+ positions[i + 1] = static_cast<XYPOSITION>(poses.buffer[ui]);
i += 2;
} else {
- positions[i] = poses.buffer[ui];
+ positions[i] = static_cast<XYPOSITION>(poses.buffer[ui]);
i++;
}
@@ -1066,53 +1076,54 @@ XYPOSITION SurfaceGDI::WidthChar(Font &font_, char ch) {
SetFont(font_);
SIZE sz;
::GetTextExtentPoint32A(hdc, &ch, 1, &sz);
- return sz.cx;
+ return static_cast<XYPOSITION>(sz.cx);
}
XYPOSITION SurfaceGDI::Ascent(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
- return tm.tmAscent;
+ return static_cast<XYPOSITION>(tm.tmAscent);
}
XYPOSITION SurfaceGDI::Descent(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
- return tm.tmDescent;
+ return static_cast<XYPOSITION>(tm.tmDescent);
}
XYPOSITION SurfaceGDI::InternalLeading(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
- return tm.tmInternalLeading;
+ return static_cast<XYPOSITION>(tm.tmInternalLeading);
}
XYPOSITION SurfaceGDI::ExternalLeading(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
- return tm.tmExternalLeading;
+ return static_cast<XYPOSITION>(tm.tmExternalLeading);
}
XYPOSITION SurfaceGDI::Height(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
- return tm.tmHeight;
+ return static_cast<XYPOSITION>(tm.tmHeight);
}
XYPOSITION SurfaceGDI::AverageCharWidth(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
- return tm.tmAveCharWidth;
+ return static_cast<XYPOSITION>(tm.tmAveCharWidth);
}
void SurfaceGDI::SetClip(PRectangle rc) {
- ::IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
+ ::IntersectClipRect(hdc, static_cast<int>(rc.left), static_cast<int>(rc.top),
+ static_cast<int>(rc.right), static_cast<int>(rc.bottom));
}
void SurfaceGDI::FlushCachedState() {
@@ -1289,7 +1300,7 @@ void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID)
SetScale();
SurfaceD2D *psurfOther = static_cast<SurfaceD2D *>(surface_);
ID2D1BitmapRenderTarget *pCompatibleRenderTarget = NULL;
- D2D1_SIZE_F desiredSize = D2D1::SizeF(width, height);
+ D2D1_SIZE_F desiredSize = D2D1::SizeF(static_cast<float>(width), static_cast<float>(height));
D2D1_PIXEL_FORMAT desiredFormat;
#ifdef __MINGW32__
desiredFormat.format = DXGI_FORMAT_UNKNOWN;
@@ -1313,10 +1324,10 @@ void SurfaceD2D::PenColour(ColourDesired fore) {
void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) {
if (pRenderTarget) {
D2D_COLOR_F col;
- col.r = (fore.AsLong() & 0xff) / 255.0;
- col.g = ((fore.AsLong() & 0xff00) >> 8) / 255.0;
- col.b = (fore.AsLong() >> 16) / 255.0;
- col.a = alpha / 255.0;
+ col.r = (fore.AsLong() & 0xff) / 255.0f;
+ col.g = ((fore.AsLong() & 0xff00) >> 8) / 255.0f;
+ col.b = (fore.AsLong() >> 16) / 255.0f;
+ col.a = alpha / 255.0f;
if (pBrush) {
pBrush->SetColor(col);
} else {
@@ -1375,8 +1386,8 @@ static int Delta(int difference) {
return 0;
}
-static int RoundFloat(float f) {
- return int(f+0.5);
+static float RoundFloat(float f) {
+ return float(int(f+0.5f));
}
void SurfaceD2D::LineTo(int x_, int y_) {
@@ -1393,16 +1404,17 @@ void SurfaceD2D::LineTo(int x_, int y_) {
int yEnd = y_ - yDelta;
int top = Platform::Minimum(y, yEnd);
int height = abs(y - yEnd) + 1;
- D2D1_RECT_F rectangle1 = D2D1::RectF(left, top, left+width, top+height);
+ D2D1_RECT_F rectangle1 = D2D1::RectF(static_cast<float>(left), static_cast<float>(top),
+ static_cast<float>(left+width), static_cast<float>(top+height));
pRenderTarget->FillRectangle(&rectangle1, pBrush);
} else if ((abs(xDiff) == abs(yDiff))) {
// 45 degree slope
- pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5, y + 0.5),
- D2D1::Point2F(x_ + 0.5 - xDelta, y_ + 0.5 - yDelta), pBrush);
+ pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5f, y + 0.5f),
+ D2D1::Point2F(x_ + 0.5f - xDelta, y_ + 0.5f - yDelta), pBrush);
} else {
// Line has a different slope so difficult to avoid last pixel
- pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5, y + 0.5),
- D2D1::Point2F(x_ + 0.5, y_ + 0.5), pBrush);
+ pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5f, y + 0.5f),
+ D2D1::Point2F(x_ + 0.5f, y_ + 0.5f), pBrush);
}
x = x_;
y = y_;
@@ -1440,7 +1452,7 @@ void SurfaceD2D::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired
void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {
if (pRenderTarget) {
- D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left) + 0.5, rc.top+0.5, RoundFloat(rc.right) - 0.5, rc.bottom-0.5);
+ D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top+0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom-0.5f);
D2DPenColour(back);
pRenderTarget->FillRectangle(&rectangle1, pBrush);
D2DPenColour(fore);
@@ -1483,13 +1495,13 @@ void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) {
void SurfaceD2D::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) {
if (pRenderTarget) {
D2D1_ROUNDED_RECT roundedRectFill = {
- D2D1::RectF(rc.left+1.0, rc.top+1.0, rc.right-1.0, rc.bottom-1.0),
+ D2D1::RectF(rc.left+1.0f, rc.top+1.0f, rc.right-1.0f, rc.bottom-1.0f),
4, 4};
D2DPenColour(back);
pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush);
D2D1_ROUNDED_RECT roundedRect = {
- D2D1::RectF(rc.left + 0.5, rc.top+0.5, rc.right - 0.5, rc.bottom-0.5),
+ D2D1::RectF(rc.left + 0.5f, rc.top+0.5f, rc.right - 0.5f, rc.bottom-0.5f),
4, 4};
D2DPenColour(fore);
pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush);
@@ -1501,23 +1513,23 @@ void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil
if (pRenderTarget) {
if (cornerSize == 0) {
// When corner size is zero, draw square rectangle to prevent blurry pixels at corners
- D2D1_RECT_F rectFill = D2D1::RectF(RoundFloat(rc.left) + 1.0, rc.top + 1.0, RoundFloat(rc.right) - 1.0, rc.bottom - 1.0);
+ D2D1_RECT_F rectFill = D2D1::RectF(RoundFloat(rc.left) + 1.0f, rc.top + 1.0f, RoundFloat(rc.right) - 1.0f, rc.bottom - 1.0f);
D2DPenColour(fill, alphaFill);
pRenderTarget->FillRectangle(rectFill, pBrush);
- D2D1_RECT_F rectOutline = D2D1::RectF(RoundFloat(rc.left) + 0.5, rc.top + 0.5, RoundFloat(rc.right) - 0.5, rc.bottom - 0.5);
+ D2D1_RECT_F rectOutline = D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top + 0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom - 0.5f);
D2DPenColour(outline, alphaOutline);
pRenderTarget->DrawRectangle(rectOutline, pBrush);
} else {
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),
+ D2D1::RectF(RoundFloat(rc.left) + 1.0f, rc.top + 1.0f, RoundFloat(rc.right) - 1.0f, rc.bottom - 1.0f),
cornerSizeF, cornerSizeF};
D2DPenColour(fill, alphaFill);
pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush);
D2D1_ROUNDED_RECT roundedRect = {
- D2D1::RectF(RoundFloat(rc.left) + 0.5, rc.top + 0.5, RoundFloat(rc.right) - 0.5, rc.bottom - 0.5),
+ D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top + 0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom - 0.5f),
cornerSizeF, cornerSizeF};
D2DPenColour(outline, alphaOutline);
pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush);
@@ -1721,7 +1733,7 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *
}
ui++;
}
- int lastPos = 0;
+ XYPOSITION lastPos = 0.0f;
if (i > 0)
lastPos = positions[i-1];
while (i<len) {
@@ -1866,12 +1878,13 @@ bool Window::HasFocus() {
PRectangle Window::GetPosition() {
RECT rc;
::GetWindowRect(reinterpret_cast<HWND>(wid), &rc);
- return PRectangle(rc.left, rc.top, rc.right, rc.bottom);
+ return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom);
}
void Window::SetPosition(PRectangle rc) {
::SetWindowPos(reinterpret_cast<HWND>(wid),
- 0, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER|SWP_NOACTIVATE);
+ 0, static_cast<int>(rc.left), static_cast<int>(rc.top),
+ static_cast<int>(rc.Width()), static_cast<int>(rc.Height()), SWP_NOZORDER | SWP_NOACTIVATE);
}
static RECT RectFromMonitor(HMONITOR hMonitor) {
@@ -1897,7 +1910,7 @@ void Window::SetPositionRelative(PRectangle rc, Window w) {
if (style & WS_POPUP) {
POINT ptOther = {0, 0};
::ClientToScreen(reinterpret_cast<HWND>(w.GetID()), &ptOther);
- rc.Move(ptOther.x, ptOther.y);
+ rc.Move(static_cast<XYPOSITION>(ptOther.x), static_cast<XYPOSITION>(ptOther.y));
RECT rcMonitor = RectFromPRectangle(rc);
@@ -1930,7 +1943,7 @@ PRectangle Window::GetClientPosition() {
RECT rc={0,0,0,0};
if (wid)
::GetClientRect(reinterpret_cast<HWND>(wid), &rc);
- return PRectangle(rc.left, rc.top, rc.right, rc.bottom);
+ return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom);
}
void Window::Show(bool show) {
@@ -2138,14 +2151,14 @@ class ListBoxX : public ListBox {
int ItemHeight() const;
int MinClientWidth() const;
int TextOffset() const;
- Point GetClientExtent() const;
+ POINT GetClientExtent() const;
POINT MinTrackSize() const;
POINT MaxTrackSize() const;
void SetRedraw(bool on);
void OnDoubleClick();
void ResizeToCursor();
void StartResize(WPARAM);
- int NcHitTest(WPARAM, LPARAM) const;
+ LRESULT NcHitTest(WPARAM, LPARAM) const;
void CentreItem(int n);
void Paint(HDC);
static LRESULT PASCAL ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
@@ -2222,7 +2235,7 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei
POINT locationw = {static_cast<LONG>(location.x), static_cast<LONG>(location.y)};
::MapWindowPoints(hwndParent, NULL, &locationw, 1);
- location = Point(locationw.x, locationw.y);
+ location = Point::FromInts(locationw.x, locationw.y);
}
void ListBoxX::SetFont(Font &font) {
@@ -2295,13 +2308,13 @@ PRectangle ListBoxX::GetDesiredRect() {
int ListBoxX::TextOffset() const {
int pixWidth = images.GetWidth();
- return pixWidth == 0 ? ItemInset.x : ItemInset.x + pixWidth + (ImageInset.x * 2);
+ return static_cast<int>(pixWidth == 0 ? ItemInset.x : ItemInset.x + pixWidth + (ImageInset.x * 2));
}
int ListBoxX::CaretFromEdge() {
PRectangle rc;
AdjustWindowRect(&rc);
- return TextOffset() + TextInset.x + (0 - rc.left) - 1;
+ return TextOffset() + static_cast<int>(TextInset.x + (0 - rc.left) - 1);
}
void ListBoxX::Clear() {
@@ -2331,7 +2344,7 @@ void ListBoxX::Select(int n) {
}
int ListBoxX::GetSelection() {
- return ::SendMessage(lb, LB_GETCURSEL, 0, 0);
+ return static_cast<int>(::SendMessage(lb, LB_GETCURSEL, 0, 0));
}
// This is not actually called at present
@@ -2382,7 +2395,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) {
int len = static_cast<int>(strlen(text));
RECT rcText = rcBox;
- ::InsetRect(&rcText, TextInset.x, TextInset.y);
+ ::InsetRect(&rcText, static_cast<int>(TextInset.x), static_cast<int>(TextInset.y));
if (unicodeMode) {
const TextWide tbuf(text, len, unicodeMode);
@@ -2401,8 +2414,8 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) {
if (surfaceItem) {
if (technology == SCWIN_TECH_GDI) {
surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem);
- int left = pDrawItem->rcItem.left + ItemInset.x + ImageInset.x;
- PRectangle rcImage(left, pDrawItem->rcItem.top,
+ long left = pDrawItem->rcItem.left + static_cast<int>(ItemInset.x + ImageInset.x);
+ PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top,
left + images.GetWidth(), pDrawItem->rcItem.bottom);
surfaceItem->DrawRGBAImage(rcImage,
pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels());
@@ -2429,8 +2442,8 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) {
if (SUCCEEDED(hr)) {
surfaceItem->Init(pDCRT, pDrawItem->hwndItem);
pDCRT->BeginDraw();
- int left = pDrawItem->rcItem.left + ItemInset.x + ImageInset.x;
- PRectangle rcImage(left, pDrawItem->rcItem.top,
+ long left = pDrawItem->rcItem.left + static_cast<long>(ItemInset.x + ImageInset.x);
+ PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top,
left + images.GetWidth(), pDrawItem->rcItem.bottom);
surfaceItem->DrawRGBAImage(rcImage,
pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels());
@@ -2507,12 +2520,12 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) {
void ListBoxX::AdjustWindowRect(PRectangle *rc) {
RECT rcw = RectFromPRectangle(*rc);
::AdjustWindowRectEx(&rcw, WS_THICKFRAME, false, WS_EX_WINDOWEDGE);
- *rc = PRectangle(rcw.left, rcw.top, rcw.right, rcw.bottom);
+ *rc = PRectangle::FromInts(rcw.left, rcw.top, rcw.right, rcw.bottom);
}
int ListBoxX::ItemHeight() const {
- int itemHeight = lineHeight + (TextInset.y * 2);
- int pixHeight = images.GetHeight() + (ImageInset.y * 2);
+ int itemHeight = lineHeight + (static_cast<int>(TextInset.y) * 2);
+ int pixHeight = images.GetHeight() + (static_cast<int>(ImageInset.y) * 2);
if (itemHeight < pixHeight) {
itemHeight = pixHeight;
}
@@ -2524,16 +2537,16 @@ int ListBoxX::MinClientWidth() const {
}
POINT ListBoxX::MinTrackSize() const {
- PRectangle rc(0, 0, MinClientWidth(), ItemHeight());
+ PRectangle rc = PRectangle::FromInts(0, 0, MinClientWidth(), ItemHeight());
AdjustWindowRect(&rc);
POINT ret = {static_cast<LONG>(rc.Width()), static_cast<LONG>(rc.Height())};
return ret;
}
POINT ListBoxX::MaxTrackSize() const {
- PRectangle rc(0, 0,
+ PRectangle rc = PRectangle::FromInts(0, 0,
Platform::Maximum(MinClientWidth(),
- maxCharWidth * maxItemCharacters + TextInset.x * 2 +
+ maxCharWidth * maxItemCharacters + static_cast<int>(TextInset.x) * 2 +
TextOffset() + ::GetSystemMetrics(SM_CXVSCROLL)),
ItemHeight() * lti.Count());
AdjustWindowRect(&rc);
@@ -2547,11 +2560,25 @@ void ListBoxX::SetRedraw(bool on) {
::InvalidateRect(lb, NULL, TRUE);
}
+static XYPOSITION XYMinimum(XYPOSITION a, XYPOSITION b) {
+ if (a < b)
+ return a;
+ else
+ return b;
+}
+
+static XYPOSITION XYMaximum(XYPOSITION a, XYPOSITION b) {
+ if (a > b)
+ return a;
+ else
+ return b;
+}
+
void ListBoxX::ResizeToCursor() {
PRectangle rc = GetPosition();
POINT ptw;
::GetCursorPos(&ptw);
- Point pt(ptw.x, ptw.y);
+ Point pt = Point::FromInts(ptw.x, ptw.y);
pt.x += dragOffset.x;
pt.y += dragOffset.y;
@@ -2589,10 +2616,10 @@ void ListBoxX::ResizeToCursor() {
POINT ptMin = MinTrackSize();
POINT ptMax = MaxTrackSize();
// We don't allow the left edge to move at present, but just in case
- rc.left = Platform::Maximum(Platform::Minimum(rc.left, rcPreSize.right - ptMin.x), rcPreSize.right - ptMax.x);
- rc.top = Platform::Maximum(Platform::Minimum(rc.top, rcPreSize.bottom - ptMin.y), rcPreSize.bottom - ptMax.y);
- rc.right = Platform::Maximum(Platform::Minimum(rc.right, rcPreSize.left + ptMax.x), rcPreSize.left + ptMin.x);
- rc.bottom = Platform::Maximum(Platform::Minimum(rc.bottom, rcPreSize.top + ptMax.y), rcPreSize.top + ptMin.y);
+ rc.left = XYMaximum(XYMinimum(rc.left, rcPreSize.right - ptMin.x), rcPreSize.right - ptMax.x);
+ rc.top = XYMaximum(XYMinimum(rc.top, rcPreSize.bottom - ptMin.y), rcPreSize.bottom - ptMax.y);
+ rc.right = XYMaximum(XYMinimum(rc.right, rcPreSize.left + ptMax.x), rcPreSize.left + ptMin.x);
+ rc.bottom = XYMaximum(XYMinimum(rc.bottom, rcPreSize.top + ptMax.y), rcPreSize.top + ptMin.y);
SetPosition(rc);
}
@@ -2633,11 +2660,11 @@ void ListBoxX::StartResize(WPARAM hitCode) {
}
::SetCapture(GetHWND());
- resizeHit = hitCode;
+ resizeHit = static_cast<int>(hitCode);
}
-int ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const {
- int hit = ::DefWindowProc(GetHWND(), WM_NCHITTEST, wParam, lParam);
+LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const {
+ LRESULT hit = ::DefWindowProc(GetHWND(), WM_NCHITTEST, wParam, lParam);
// There is an apparent bug in the DefWindowProc hit test code whereby it will
// return HTTOPXXX if the window in question is shorter than the default
// window caption height + frame, even if one is hovering over the bottom edge of
@@ -2689,18 +2716,21 @@ void ListBoxX::OnDoubleClick() {
}
}
-Point ListBoxX::GetClientExtent() const {
+POINT ListBoxX::GetClientExtent() const {
PRectangle rc = const_cast<ListBoxX*>(this)->GetClientPosition();
- return Point(rc.Width(), rc.Height());
+ POINT ret;
+ ret.x = static_cast<LONG>(rc.Width());
+ ret.y = static_cast<LONG>(rc.Height());
+ return ret;
}
void ListBoxX::CentreItem(int n) {
// If below mid point, scroll up to centre, but with more items below if uneven
if (n >= 0) {
- Point extent = GetClientExtent();
+ POINT extent = GetClientExtent();
int visible = extent.y/ItemHeight();
if (visible < Length()) {
- int top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0);
+ LRESULT top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0);
int half = (visible - 1) / 2;
if (n > (top + half))
::SendMessage(lb, LB_SETTOPINDEX, n - half , 0);
@@ -2710,14 +2740,14 @@ void ListBoxX::CentreItem(int n) {
// Performs a double-buffered paint operation to avoid flicker
void ListBoxX::Paint(HDC hDC) {
- Point extent = GetClientExtent();
+ POINT extent = GetClientExtent();
HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, extent.x, extent.y);
HDC bitmapDC = ::CreateCompatibleDC(hDC);
HBITMAP hBitmapOld = SelectBitmap(bitmapDC, hBitmap);
// The list background is mainly erased during painting, but can be a small
// unpainted area when at the end of a non-integrally sized list with a
// vertical scroll bar
- RECT rc = { 0, 0, static_cast<LONG>(extent.x), static_cast<LONG>(extent.y) };
+ RECT rc = { 0, 0, extent.x, extent.y };
::FillRect(bitmapDC, &rc, reinterpret_cast<HBRUSH>(COLOR_WINDOW+1));
// Paint the entire client area and vertical scrollbar
::SendMessage(lb, WM_PRINT, reinterpret_cast<WPARAM>(bitmapDC), PRF_CLIENT|PRF_NONCLIENT);
@@ -2897,7 +2927,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
linesToScroll = 3;
}
linesToScroll *= (wheelDelta / WHEEL_DELTA);
- int top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0) + linesToScroll;
+ LRESULT top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0) + linesToScroll;
if (top < 0) {
top = 0;
}
@@ -2973,7 +3003,7 @@ void Menu::Destroy() {
void Menu::Show(Point pt, Window &w) {
::TrackPopupMenu(reinterpret_cast<HMENU>(mid),
- 0, pt.x - 4, pt.y, 0,
+ 0, static_cast<int>(pt.x - 4), static_cast<int>(pt.y), 0,
reinterpret_cast<HWND>(w.GetID()), NULL);
Destroy();
}
@@ -3011,7 +3041,7 @@ double ElapsedTime::Duration(bool reset) {
LARGE_INTEGER lBegin;
lBegin.HighPart = bigBit;
lBegin.LowPart = littleBit;
- double elapsed = lEnd.QuadPart - lBegin.QuadPart;
+ double elapsed = static_cast<double>(lEnd.QuadPart - lBegin.QuadPart);
result = elapsed / static_cast<double>(frequency.QuadPart);
} else {
endBigBit = clock();
@@ -3096,12 +3126,14 @@ bool Platform::IsKeyDown(int key) {
}
long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) {
- return ::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, lParam);
+ // This should never be called - its here to satisfy an old interface
+ return static_cast<long>(::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, lParam));
}
long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) {
- return ::SendMessage(reinterpret_cast<HWND>(w), msg, wParam,
- reinterpret_cast<LPARAM>(lParam));
+ // This should never be called - its here to satisfy an old interface
+ return static_cast<long>(::SendMessage(reinterpret_cast<HWND>(w), msg, wParam,
+ reinterpret_cast<LPARAM>(lParam)));
}
bool Platform::IsDBCSLeadByte(int codePage, char ch) {
@@ -3258,11 +3290,35 @@ void Platform_Finalise() {
customClearTypeRenderingParams->Release();
customClearTypeRenderingParams = 0;
}
+ if (pIDWriteFactory) {
+ pIDWriteFactory->Release();
+ pIDWriteFactory = 0;
+ }
+ if (pD2DFactory) {
+ pD2DFactory->Release();
+ pD2DFactory = 0;
+ }
+ if (hDLLDWrite) {
+ FreeLibrary(hDLLDWrite);
+ hDLLDWrite = NULL;
+ }
+ if (hDLLD2D) {
+ FreeLibrary(hDLLD2D);
+ hDLLD2D = NULL;
+ }
#endif
if (reverseArrowCursor != NULL)
::DestroyCursor(reverseArrowCursor);
ListBoxX_Unregister();
::DeleteCriticalSection(&crPlatformLock);
+ if (hDLLUser32) {
+ FreeLibrary(hDLLUser32);
+ hDLLUser32 = NULL;
+ }
+ if (hDLLImage) {
+ FreeLibrary(hDLLImage);
+ hDLLImage = NULL;
+ }
}
#ifdef SCI_NAMESPACE
diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx
index 7bc542f..1b2cde4 100644
--- a/scintilla/win32/ScintillaWin.cxx
+++ b/scintilla/win32/ScintillaWin.cxx
@@ -121,10 +121,16 @@ static void SetWindowID(HWND hWnd, int identifier) {
::SetWindowLongPtr(hWnd, GWLP_ID, identifier);
}
+static Point PointFromPOINT(POINT pt) {
+ return Point::FromInts(pt.x, pt.y);
+}
+
class ScintillaWin; // Forward declaration for COM interface subobjects
typedef void VFunction(void);
+static HMODULE commctrl32 = 0;
+
/**
*/
class FormatEnumerator {
@@ -211,7 +217,7 @@ class ScintillaWin :
HWND MainHWND();
static sptr_t DirectFunction(
- ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam);
+ sptr_t ptr, UINT iMessage, uptr_t wParam, sptr_t lParam);
static sptr_t PASCAL SWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, sptr_t lParam);
static sptr_t PASCAL CTWndProc(
@@ -271,8 +277,8 @@ class ScintillaWin :
virtual int SetScrollInfo(int nBar, LPCSCROLLINFO lpsi, BOOL bRedraw);
virtual bool GetScrollInfo(int nBar, LPSCROLLINFO lpsi);
void ChangeScrollPos(int barType, int pos);
-
- void InsertPasteText(const char *text, int len, SelectionPosition selStart, bool isRectangular, bool isLine);
+ sptr_t GetTextLength();
+ sptr_t GetText(uptr_t wParam, sptr_t lParam);
public:
// Public for benefit of Scintilla_DirectFunction
@@ -383,7 +389,8 @@ void ScintillaWin::Initialise() {
TrackMouseEventFn = (TrackMouseEventSig)::GetProcAddress(user32, "TrackMouseEvent");
if (TrackMouseEventFn == NULL) {
// Windows 95 has an emulation in comctl32.dll:_TrackMouseEvent
- HMODULE commctrl32 = ::LoadLibrary(TEXT("comctl32.dll"));
+ if (!commctrl32)
+ commctrl32 = ::LoadLibrary(TEXT("comctl32.dll"));
if (commctrl32 != NULL) {
TrackMouseEventFn = (TrackMouseEventSig)
::GetProcAddress(commctrl32, "_TrackMouseEvent");
@@ -464,8 +471,8 @@ HWND ScintillaWin::MainHWND() {
}
bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) {
- int xMove = abs(ptStart.x - ptNow.x);
- int yMove = abs(ptStart.y - ptNow.y);
+ int xMove = static_cast<int>(abs(ptStart.x - ptNow.x));
+ int yMove = static_cast<int>(abs(ptStart.y - ptNow.y));
return (xMove > ::GetSystemMetrics(SM_CXDRAG)) ||
(yMove > ::GetSystemMetrics(SM_CYDRAG));
}
@@ -493,11 +500,11 @@ void ScintillaWin::StartDrag() {
}
// Avoid warnings everywhere for old style casts by concentrating them here
-static WORD LoWord(DWORD l) {
+static WORD LoWord(uptr_t l) {
return LOWORD(l);
}
-static WORD HiWord(DWORD l) {
+static WORD HiWord(uptr_t l) {
return HIWORD(l);
}
@@ -566,7 +573,7 @@ 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);
+ rcPaint = PRectangle::FromInts(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom);
PRectangle rcClient = GetClientRectangle();
paintingAllText = rcPaint.Contains(rcClient);
if (technology == SC_TECHNOLOGY_DEFAULT) {
@@ -642,8 +649,8 @@ sptr_t ScintillaWin::HandleComposition(uptr_t wParam, sptr_t lParam) {
Point pos = PointMainCaret();
COMPOSITIONFORM CompForm;
CompForm.dwStyle = CFS_POINT;
- CompForm.ptCurrentPos.x = pos.x;
- CompForm.ptCurrentPos.y = pos.y;
+ CompForm.ptCurrentPos.x = static_cast<int>(pos.x);
+ CompForm.ptCurrentPos.y = static_cast<int>(pos.y);
::ImmSetCompositionWindow(hIMC, &CompForm);
::ImmReleaseContext(MainHWND(), hIMC);
}
@@ -673,9 +680,7 @@ static unsigned int SciMessageFromEM(unsigned int iMessage) {
case WM_CLEAR: return SCI_CLEAR;
case WM_COPY: return SCI_COPY;
case WM_CUT: return SCI_CUT;
- case WM_GETTEXT: return SCI_GETTEXT;
case WM_SETTEXT: return SCI_SETTEXT;
- case WM_GETTEXTLENGTH: return SCI_GETTEXTLENGTH;
case WM_PASTE: return SCI_PASTE;
case WM_UNDO: return SCI_UNDO;
}
@@ -717,6 +722,70 @@ UINT ScintillaWin::CodePageOfDocument() {
return CodePageFromCharSet(vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage);
}
+sptr_t ScintillaWin::GetTextLength() {
+ if (::IsWindowUnicode(MainHWND())) {
+ if (pdoc->Length() == 0)
+ return 0;
+ std::vector<char> docBytes(pdoc->Length(), '\0');
+ pdoc->GetCharRange(&docBytes[0], 0, pdoc->Length());
+ if (IsUnicodeMode()) {
+ return UTF16Length(&docBytes[0], static_cast<unsigned int>(docBytes.size()));
+ } else {
+ return ::MultiByteToWideChar(CodePageOfDocument(), 0, &docBytes[0],
+ static_cast<int>(docBytes.size()), NULL, 0);
+ }
+ } else {
+ return pdoc->Length();
+ }
+}
+
+sptr_t ScintillaWin::GetText(uptr_t wParam, sptr_t lParam) {
+ if (::IsWindowUnicode(MainHWND())) {
+ wchar_t *ptr = reinterpret_cast<wchar_t *>(lParam);
+ if (pdoc->Length() == 0) {
+ *ptr = L'\0';
+ return 0;
+ }
+ std::vector<char> docBytes(pdoc->Length(), '\0');
+ pdoc->GetCharRange(&docBytes[0], 0, pdoc->Length());
+ if (IsUnicodeMode()) {
+ unsigned int lengthUTF16 = UTF16Length(&docBytes[0], static_cast<unsigned int>(docBytes.size()));
+ if (lParam == 0)
+ return lengthUTF16;
+ if (wParam == 0)
+ return 0;
+ unsigned int uLen = UTF16FromUTF8(&docBytes[0], static_cast<unsigned int>(docBytes.size()),
+ ptr, static_cast<int>(wParam) - 1);
+ ptr[uLen] = L'\0';
+ return uLen;
+ } else {
+ // Not Unicode mode
+ // Convert to Unicode using the current Scintilla code page
+ const UINT cpSrc = CodePageOfDocument();
+ int lengthUTF16 = ::MultiByteToWideChar(cpSrc, 0, &docBytes[0],
+ static_cast<int>(docBytes.size()), NULL, 0);
+ if (lengthUTF16 >= static_cast<int>(wParam))
+ lengthUTF16 = static_cast<int>(wParam)-1;
+ ::MultiByteToWideChar(cpSrc, 0, &docBytes[0],
+ static_cast<int>(docBytes.size()),
+ ptr, lengthUTF16);
+ ptr[lengthUTF16] = L'\0';
+ return lengthUTF16;
+ }
+ } else {
+ if (lParam == 0)
+ return pdoc->Length() + 1;
+ if (wParam == 0)
+ return 0;
+ char *ptr = reinterpret_cast<char *>(lParam);
+ unsigned int iChar = 0;
+ for (; iChar < wParam - 1; iChar++)
+ ptr[iChar] = pdoc->CharAt(iChar);
+ ptr[iChar] = '\0';
+ return iChar;
+ }
+}
+
sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
try {
//Platform::DebugPrintf("S M:%x WP:%x L:%x\n", iMessage, wParam, lParam);
@@ -836,7 +905,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// the low priority events have a turn (after which the timer will fire again).
DWORD dwCurrent = GetTickCount();
- DWORD dwStart = wParam ? wParam : dwCurrent;
+ DWORD dwStart = wParam ? static_cast<DWORD>(wParam) : dwCurrent;
const DWORD maxWorkTime = 50;
if (dwCurrent >= dwStart && dwCurrent > maxWorkTime && dwCurrent - maxWorkTime < dwStart)
@@ -862,7 +931,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// Platform::IsKeyDown(VK_CONTROL),
// Platform::IsKeyDown(VK_MENU));
::SetFocus(MainHWND());
- ButtonDown(Point::FromLong(lParam), ::GetMessageTime(),
+ ButtonDown(Point::FromLong(static_cast<long>(lParam)), ::GetMessageTime(),
(wParam & MK_SHIFT) != 0,
(wParam & MK_CONTROL) != 0,
Platform::IsKeyDown(VK_MENU));
@@ -871,7 +940,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_MOUSEMOVE:
SetTrackMouseLeaveEvent(true);
- ButtonMoveWithModifiers(Point::FromLong(lParam),
+ ButtonMoveWithModifiers(Point::FromLong(static_cast<long>(lParam)),
((wParam & MK_SHIFT) != 0 ? SCI_SHIFT : 0) |
((wParam & MK_CONTROL) != 0 ? SCI_CTRL : 0) |
(Platform::IsKeyDown(VK_MENU) ? SCI_ALT : 0));
@@ -883,16 +952,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_LBUTTONUP:
- ButtonUp(Point::FromLong(lParam),
+ ButtonUp(Point::FromLong(static_cast<long>(lParam)),
::GetMessageTime(),
(wParam & MK_CONTROL) != 0);
break;
case WM_RBUTTONDOWN:
::SetFocus(MainHWND());
- if (!PointInSelection(Point::FromLong(lParam))) {
+ if (!PointInSelection(Point::FromLong(static_cast<long>(lParam)))) {
CancelModes();
- SetEmptySelection(PositionFromLocation(Point::FromLong(lParam)));
+ SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast<long>(lParam))));
}
break;
@@ -905,11 +974,11 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
POINT pt;
if (0 != ::GetCursorPos(&pt)) {
::ScreenToClient(MainHWND(), &pt);
- if (PointInSelMargin(Point(pt.x, pt.y))) {
- DisplayCursor(GetMarginCursor(Point(pt.x, pt.y)));
- } else if (PointInSelection(Point(pt.x, pt.y)) && !SelectionEmpty()) {
+ if (PointInSelMargin(PointFromPOINT(pt))) {
+ DisplayCursor(GetMarginCursor(PointFromPOINT(pt)));
+ } else if (PointInSelection(PointFromPOINT(pt)) && !SelectionEmpty()) {
DisplayCursor(Window::cursorArrow);
- } else if (PointIsHotspot(Point(pt.x, pt.y))) {
+ } else if (PointIsHotspot(PointFromPOINT(pt))) {
DisplayCursor(Window::cursorHand);
} else {
DisplayCursor(Window::cursorText);
@@ -922,7 +991,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
case WM_CHAR:
- if (((wParam >= 128) || !iscntrl(wParam)) || !lastKeyDownConsumed) {
+ if (((wParam >= 128) || !iscntrl(static_cast<int>(wParam))) || !lastKeyDownConsumed) {
if (::IsWindowUnicode(MainHWND()) || keysAlwaysUnicode) {
wchar_t wcs[2] = {static_cast<wchar_t>(wParam), 0};
if (IsUnicodeMode()) {
@@ -971,7 +1040,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_KEYDOWN: {
//Platform::DebugPrintf("S keydown %d %x %x %x %x\n",iMessage, wParam, lParam, ::IsKeyDown(VK_SHIFT), ::IsKeyDown(VK_CONTROL));
lastKeyDownConsumed = false;
- int ret = KeyDown(KeyTranslate(wParam),
+ int ret = KeyDown(KeyTranslate(static_cast<int>(wParam)),
Platform::IsKeyDown(VK_SHIFT),
Platform::IsKeyDown(VK_CONTROL),
Platform::IsKeyDown(VK_MENU),
@@ -1040,13 +1109,13 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_CONTEXTMENU:
if (displayPopupMenu) {
- Point pt = Point::FromLong(lParam);
+ Point pt = Point::FromLong(static_cast<long>(lParam));
if ((pt.x == -1) && (pt.y == -1)) {
// Caused by keyboard so display menu near caret
pt = PointMainCaret();
POINT spt = {static_cast<int>(pt.x), static_cast<int>(pt.y)};
::ClientToScreen(MainHWND(), &spt);
- pt = Point(spt.x, spt.y);
+ pt = PointFromPOINT(spt);
}
ContextMenu(pt);
return 0;
@@ -1084,14 +1153,20 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_WINDOWPOSCHANGED:
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_GETTEXTLENGTH:
+ return GetTextLength();
+
+ case WM_GETTEXT:
+ return GetText(wParam, lParam);
+
case EM_LINEFROMCHAR:
if (static_cast<int>(wParam) < 0) {
wParam = SelectionStart().Position();
}
- return pdoc->LineFromPosition(wParam);
+ return pdoc->LineFromPosition(static_cast<int>(wParam));
case EM_EXLINEFROMCHAR:
- return pdoc->LineFromPosition(lParam);
+ return pdoc->LineFromPosition(static_cast<int>(lParam));
case EM_GETSEL:
if (wParam) {
@@ -1174,7 +1249,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
return 0;
#endif
}
- technology = wParam;
+ technology = static_cast<int>(wParam);
// Invalidate all cached information including layout.
DropGraphics(true);
InvalidateStyleRedraw();
@@ -1275,7 +1350,7 @@ bool ScintillaWin::PaintContains(PRectangle rc) {
contains = false;
} else {
// In bounding rectangle so check more accurately using region
- HRGN hRgnRange = ::CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
+ HRGN hRgnRange = ::CreateRectRgn(static_cast<int>(rc.left), static_cast<int>(rc.top), static_cast<int>(rc.right), static_cast<int>(rc.bottom));
if (hRgnRange) {
HRGN hRgnDest = ::CreateRectRgn(0, 0, 0, 0);
if (hRgnDest) {
@@ -1308,7 +1383,7 @@ void ScintillaWin::UpdateSystemCaret() {
CreateSystemCaret();
}
Point pos = PointMainCaret();
- ::SetCaretPos(pos.x, pos.y);
+ ::SetCaretPos(static_cast<int>(pos.x), static_cast<int>(pos.y));
}
}
@@ -1370,7 +1445,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
int horizEndPreferred = scrollWidth;
if (horizEndPreferred < 0)
horizEndPreferred = 0;
- unsigned int pageWidth = rcText.Width();
+ unsigned int pageWidth = static_cast<unsigned int>(rcText.Width());
if (!horizontalScrollBarVisible || Wrapping())
pageWidth = horizEndPreferred + 1;
sci.fMask = SIF_PAGE | SIF_RANGE;
@@ -1645,44 +1720,12 @@ public:
}
};
-void ScintillaWin::InsertPasteText(const char *text, int len, SelectionPosition selStart, bool isRectangular, bool isLine) {
- if (isRectangular) {
- PasteRectangular(selStart, text, len);
- } else {
- std::string convertedText;
- if (convertPastes) {
- // Convert line endings of the paste into our local line-endings mode
- 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()));
- pdoc->InsertString(insertPos, text, len);
- // add the newline if necessary
- if ((len > 0) && (text[len-1] != '\n' && text[len-1] != '\r')) {
- const char *endline = StringFromEOLMode(pdoc->eolMode);
- pdoc->InsertString(insertPos + len, endline, static_cast<int>(strlen(endline)));
- len += static_cast<int>(strlen(endline));
- }
- if (sel.MainCaret() == insertPos) {
- SetEmptySelection(sel.MainCaret() + len);
- }
- } else {
- InsertPaste(selStart, text, len);
- }
- }
-}
-
void ScintillaWin::Paste() {
if (!::OpenClipboard(MainHWND()))
return;
UndoGroup ug(pdoc);
- bool isLine = SelectionEmpty() && (::IsClipboardFormatAvailable(cfLineSelect) != 0);
+ const bool isLine = SelectionEmpty() && (::IsClipboardFormatAvailable(cfLineSelect) != 0);
ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH);
- SelectionPosition selStart = sel.IsRectangular() ?
- sel.Rectangular().Start() :
- sel.Range(sel.Main()).Start();
bool isRectangular = (::IsClipboardFormatAvailable(cfColumnSelect) != 0);
if (!isRectangular) {
@@ -1693,6 +1736,7 @@ void ScintillaWin::Paste() {
memBorlandSelection.Unlock();
}
}
+ const PasteShape pasteShape = isRectangular ? pasteRectangular : (isLine ? pasteLine : pasteStream);
// Always use CF_UNICODETEXT if available
GlobalMemory memUSelection(::GetClipboardData(CF_UNICODETEXT));
@@ -1703,7 +1747,7 @@ void ScintillaWin::Paste() {
std::vector<char> putf;
// Default Scintilla behaviour in Unicode mode
if (IsUnicodeMode()) {
- unsigned int bytes = memUSelection.Size();
+ unsigned int bytes = static_cast<unsigned int>(memUSelection.Size());
len = UTF8Length(uptr, bytes / 2);
putf.resize(len + 1);
UTF8FromUTF16(uptr, bytes / 2, &putf[0], len);
@@ -1718,7 +1762,7 @@ void ScintillaWin::Paste() {
&putf[0], len + 1, NULL, NULL);
}
- InsertPasteText(&putf[0], len, selStart, isRectangular, isLine);
+ InsertPasteShape(&putf[0], len, pasteShape);
}
memUSelection.Unlock();
} else {
@@ -1727,7 +1771,7 @@ void ScintillaWin::Paste() {
if (memSelection) {
char *ptr = static_cast<char *>(memSelection.ptr);
if (ptr) {
- unsigned int bytes = memSelection.Size();
+ unsigned int bytes = static_cast<unsigned int>(memSelection.Size());
unsigned int len = bytes;
for (unsigned int i = 0; i < bytes; i++) {
if ((len == bytes) && (0 == ptr[i]))
@@ -1746,9 +1790,9 @@ void ScintillaWin::Paste() {
// CP_UTF8 not available on Windows 95, so use UTF8FromUTF16()
UTF8FromUTF16(&uptr[0], ulen, &putf[0], mlen);
- InsertPasteText(&putf[0], mlen, selStart, isRectangular, isLine);
+ InsertPasteShape(&putf[0], mlen, pasteShape);
} else {
- InsertPasteText(ptr, len, selStart, isRectangular, isLine);
+ InsertPasteShape(ptr, len, pasteShape);
}
}
memSelection.Unlock();
@@ -2099,8 +2143,8 @@ void ScintillaWin::ImeStartComposition() {
Point pos = PointMainCaret();
COMPOSITIONFORM CompForm;
CompForm.dwStyle = CFS_POINT;
- CompForm.ptCurrentPos.x = pos.x;
- CompForm.ptCurrentPos.y = pos.y;
+ CompForm.ptCurrentPos.x = static_cast<int>(pos.x);
+ CompForm.ptCurrentPos.y = static_cast<int>(pos.y);
::ImmSetCompositionWindow(hIMC, &CompForm);
@@ -2287,7 +2331,7 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) {
void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {
int xPos = xOffset;
PRectangle rcText = GetTextRectangle();
- int pageWidth = rcText.Width() * 2 / 3;
+ int pageWidth = static_cast<int>(rcText.Width() * 2 / 3);
switch (LoWord(wParam)) {
case SB_LINEUP:
xPos -= 20;
@@ -2301,7 +2345,7 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {
case SB_PAGEDOWN:
xPos += pageWidth;
if (xPos > scrollWidth - rcText.Width()) { // Hit the end exactly
- xPos = scrollWidth - rcText.Width();
+ xPos = scrollWidth - static_cast<int>(rcText.Width());
}
break;
case SB_TOP:
@@ -2459,7 +2503,7 @@ STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffe
// Update the cursor.
POINT rpt = {pt.x, pt.y};
::ScreenToClient(MainHWND(), &rpt);
- SetDragPosition(SPositionFromLocation(Point(rpt.x, rpt.y), false, false, UserVirtualSpace()));
+ SetDragPosition(SPositionFromLocation(PointFromPOINT(rpt), false, false, UserVirtualSpace()));
return S_OK;
} catch (...) {
@@ -2499,7 +2543,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
wchar_t *udata = static_cast<wchar_t *>(memUDrop.ptr);
if (udata) {
if (IsUnicodeMode()) {
- int tlen = memUDrop.Size();
+ int tlen = static_cast<int>(memUDrop.Size());
// Convert UTF-16 to UTF-8
int dataLen = UTF8Length(udata, tlen/2);
data.resize(dataLen+1);
@@ -2531,12 +2575,6 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
}
}
- if (!data.empty() && convertPastes) {
- // Convert line endings of the drop into our local line-endings mode
- std::string convertedText = Document::TransformLineEnds(&data[0], data.size() - 1, pdoc->eolMode);
- data.assign(convertedText.c_str(), convertedText.c_str()+convertedText.length()+1);
- }
-
if (!SUCCEEDED(hr) || data.empty()) {
//Platform::DebugPrintf("Bad data format: 0x%x\n", hres);
return hr;
@@ -2547,7 +2585,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
POINT rpt = {pt.x, pt.y};
::ScreenToClient(MainHWND(), &rpt);
- SelectionPosition movePos = SPositionFromLocation(Point(rpt.x, rpt.y), false, false, UserVirtualSpace());
+ SelectionPosition movePos = SPositionFromLocation(PointFromPOINT(rpt), false, false, UserVirtualSpace());
DropAt(movePos, &data[0], data.size() - 1, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK);
@@ -2787,12 +2825,12 @@ sptr_t PASCAL ScintillaWin::CTWndProc(
pt.x = static_cast<short>(LOWORD(lParam));
pt.y = static_cast<short>(HIWORD(lParam));
ScreenToClient(hWnd, &pt);
- sciThis->ct.MouseClick(Point(pt.x, pt.y));
+ sciThis->ct.MouseClick(PointFromPOINT(pt));
sciThis->CallTipClick();
return 0;
} else if (iMessage == WM_LBUTTONDOWN) {
// This does not fire due to the hit test code
- sciThis->ct.MouseClick(Point::FromLong(lParam));
+ sciThis->ct.MouseClick(Point::FromLong(static_cast<long>(lParam)));
sciThis->CallTipClick();
return 0;
} else if (iMessage == WM_SETCURSOR) {
@@ -2811,9 +2849,9 @@ sptr_t PASCAL ScintillaWin::CTWndProc(
}
sptr_t ScintillaWin::DirectFunction(
- ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam) {
- PLATFORM_ASSERT(::GetCurrentThreadId() == ::GetWindowThreadProcessId(sci->MainHWND(), NULL));
- return sci->WndProc(iMessage, wParam, lParam);
+ sptr_t ptr, UINT iMessage, uptr_t wParam, sptr_t lParam) {
+ PLATFORM_ASSERT(::GetCurrentThreadId() == ::GetWindowThreadProcessId(reinterpret_cast<ScintillaWin *>(ptr)->MainHWND(), NULL));
+ return reinterpret_cast<ScintillaWin *>(ptr)->WndProc(iMessage, wParam, lParam);
}
extern "C"
@@ -2872,6 +2910,10 @@ int Scintilla_RegisterClasses(void *hInstance) {
// This function is externally visible so it can be called from container when building statically.
int Scintilla_ReleaseResources() {
bool result = ScintillaWin::Unregister();
+ if (commctrl32) {
+ FreeLibrary(commctrl32);
+ commctrl32 = NULL;
+ }
Platform_Finalise();
return result;
}