diff options
45 files changed, 1682 insertions, 416 deletions
diff --git a/scintilla/doc/Indicators.png b/scintilla/doc/Indicators.png Binary files differindex b67566e..a1f6867 100644 --- a/scintilla/doc/Indicators.png +++ b/scintilla/doc/Indicators.png diff --git a/scintilla/doc/ScintillaDoc.html b/scintilla/doc/ScintillaDoc.html index adf3b99..b20249b 100644 --- a/scintilla/doc/ScintillaDoc.html +++ b/scintilla/doc/ScintillaDoc.html @@ -88,7 +88,7 @@ <h1>Scintilla Documentation</h1> - <p>Last edited 29 September 2016 NH</p> + <p>Last edited 4 December 2016 NH</p> <p>There is <a class="jump" href="Design.html">an overview of the internal design of Scintilla</a>.<br /> @@ -347,22 +347,26 @@ <tr> <td>o <a class="toc" href="#Notifications">Notifications</a></td> - <td>o <a class="toc" href="#Images">Images</a></td> + <td>o <a class="toc" href="#Accessibility">Accessibility</a></td> - <td>o <a class="toc" href="#GTK">GTK+</a></td> + <td>o <a class="toc" href="#Images">Images</a></td> </tr> <tr> + <td>o <a class="toc" href="#GTK">GTK+</a></td> + <td>o <a class="toc" href="#ProvisionalMessages"><span class="provisional">Provisional messages</span></a></td> <td>o <a class="toc" href="#DeprecatedMessages">Deprecated messages</a></td> + </tr> + <tr> <td>o <a class="toc" href="#EditMessagesNeverSupportedByScintilla">Edit messages never supported by Scintilla</a></td> - </tr> - <tr> + <td>o <a class="toc" href="#RemovedFeatures">Removed features</a></td> + <td>o <a class="toc" href="#BuildingScintilla">Building Scintilla</a></td> </tr> @@ -2105,6 +2109,8 @@ struct Sci_TextToFind { <a class="message" href="#SCI_SETWHITESPACESIZE">SCI_SETWHITESPACESIZE(int size)</a><br /> <a class="message" href="#SCI_GETWHITESPACESIZE">SCI_GETWHITESPACESIZE → int</a><br /> + <a class="message" href="#SCI_SETTABDRAWMODE">SCI_SETTABDRAWMODE(int tabDrawMode)</a><br /> + <a class="message" href="#SCI_GETTABDRAWMODE">SCI_GETTABDRAWMODE → int</a><br /> <a class="message" href="#SCI_SETEXTRAASCENT">SCI_SETEXTRAASCENT(int extraAscent)</a><br /> <a class="message" href="#SCI_GETEXTRAASCENT">SCI_GETEXTRAASCENT → int</a><br /> <a class="message" href="#SCI_SETEXTRADESCENT">SCI_SETEXTRADESCENT(int extraDescent)</a><br /> @@ -2172,6 +2178,33 @@ struct Sci_TextToFind { The <code>SCI_GETWHITESPACESIZE</code> message retrieves the current size. </p> + <p><b id="SCI_SETTABDRAWMODE">SCI_SETTABDRAWMODE(int tabDrawMode)</b><br /> + <b id="SCI_GETTABDRAWMODE">SCI_GETTABDRAWMODE → int</b><br /> + These two messages get and set how tab characters are drawn when white space is visible. + The <code class="parameter">tabDrawMode</code> argument can be one of:</p> + + <table cellpadding="1" cellspacing="2" border="0" summary="White space policy"> + <tbody valign="top"> + <tr> + <th align="left"><code>SCTD_LONGARROW</code></th> + + <td>0</td> + + <td>The default mode of an arrow stretching until the tabstop.</td> + </tr> + + <tr> + <th align="left"><code>SCTD_STRIKEOUT</code></th> + + <td>1</td> + + <td>A horizontal line stretching until the tabstop.</td> + </tr> + </tbody> + </table> + + <p>The effect of using any other <code class="parameter">tabDrawMode</code> value is undefined.</p> + <p> <b id="SCI_SETEXTRAASCENT">SCI_SETEXTRAASCENT(int extraAscent)</b><br /> <b id="SCI_GETEXTRAASCENT">SCI_GETEXTRAASCENT → int</b><br /> @@ -2665,14 +2698,20 @@ struct Sci_TextToFind { </tr> <tr> + <th align="left"><code>STYLE_FOLDDISPLAYTEXT</code></th> + + <td>39</td> + + <td>This is the style used for drawing text tags attached to folded text.</td> + </tr> + + <tr> <th align="left"><code>STYLE_LASTPREDEFINED</code></th> <td>39</td> <td>To make it easier for client code to discover the range of styles that are - predefined, this is set to the style number of the last predefined style. This is - currently set to 39 and the last style with an identifier is 38, which reserves space - for one future predefined style.</td> + predefined, this is set to the style number of the last predefined style.</td> </tr> <tr> @@ -3125,7 +3164,7 @@ struct Sci_TextToFind { 5 margins are allocated initially numbered from 0 to <code>SC_MAX_MARGIN</code> (4) but this may be changed by calling <a class="message" href="#SCI_SETMARGINS"><code>SCI_SETMARGINS</code></a>. - Each margin can be set to display only symbols, line numbers, or text with + Each margin can be set to display only symbols, line numbers, or text with <a class="message" href="#SCI_SETMARGINTYPEN"><code>SCI_SETMARGINTYPEN</code></a>. Textual margins may also display symbols. The markers @@ -3134,7 +3173,8 @@ struct Sci_TextToFind { a visible margin will be displayed as changes in background colour in the text. A width in pixels can be set for each margin. Margins with a zero width are ignored completely. You can choose if a mouse click in a margin sends a <a class="message" - href="#SCN_MARGINCLICK"><code>SCN_MARGINCLICK</code></a> notification to the container or + href="#SCN_MARGINCLICK"><code>SCN_MARGINCLICK</code></a> or <a class="message" + href="#SCN_MARGINRIGHTCLICK"><code>SCN_MARGINRIGHTCLICK</code></a> notification to the container or selects a line of text.</p> <p>Using a margin number outside the valid range has no @@ -3244,7 +3284,8 @@ struct Sci_TextToFind { <b id="SCI_GETMARGINSENSITIVEN">SCI_GETMARGINSENSITIVEN(int margin) → bool</b><br /> Each of the five margins can be set sensitive or insensitive to mouse clicks. A click in a sensitive margin sends a <a class="message" - href="#SCN_MARGINCLICK"><code>SCN_MARGINCLICK</code></a> <a class="jump" + href="#SCN_MARGINCLICK"><code>SCN_MARGINCLICK</code></a> or <a class="message" + href="#SCN_MARGINRIGHTCLICK"><code>SCN_MARGINRIGHTCLICK</code></a> <a class="jump" href="#Notifications">notification</a> to the container. Margins that are not sensitive act as selection margins which make it easy to select ranges of lines. By default, all margins are insensitive.</p> @@ -4339,6 +4380,22 @@ struct Sci_TextToFind { <td>Change the colour of the text to the indicator's fore colour.</td> </tr> + <tr> + <td align="left"><code>INDIC_POINT</code></td> + + <td align="center">18</td> + + <td>Draw a triangle below the start of the indicator range.</td> + </tr> + + <tr> + <td align="left"><code>INDIC_POINTCHARACTER</code></td> + + <td align="center">19</td> + + <td>Draw a triangle below the centre of the first character of the indicator range.</td> + </tr> + </tbody> </table> @@ -5111,7 +5168,7 @@ struct Sci_TextToFind { <p>The <code>SCI_WORDPART*</code> commands are used to move between word segments marked by capitalisation (aCamelCaseIdentifier) or underscores (an_under_bar_ident).</p> - <p>The <code>SCI_WORD[LEFT|RIGHT]END*</code> commands are + <p>The <code>SCI_WORD[LEFT|RIGHT]END*</code> commands are similar to <code>SCI_WORD[LEFT|RIGHT]*</code> but move between word ends instead of word starts.</p> <p>The <code>SCI_HOME*</code> commands move the caret to the start of the line, while the @@ -5200,15 +5257,58 @@ struct Sci_TextToFind { <h2 id="PopupEditMenu">Popup edit menu</h2> - <code><a class="message" href="#SCI_USEPOPUP">SCI_USEPOPUP(bool allowPopUp)</a><br /> + <code><a class="message" href="#SCI_USEPOPUP">SCI_USEPOPUP(int popUpMode)</a><br /> </code> - <p><b id="SCI_USEPOPUP">SCI_USEPOPUP(bool allowPopUp)</b><br /> + <p><b id="SCI_USEPOPUP">SCI_USEPOPUP(int popUpMode)</b><br /> Clicking the wrong button on the mouse pops up a short default editing menu. This may be - turned off with <code>SCI_USEPOPUP(0)</code>. If you turn it off, context menu commands (in + turned off with <code>SCI_USEPOPUP(SC_POPUP_NEVER)</code>. If you turn it off, context menu commands (in Windows, <code>WM_CONTEXTMENU</code>) will not be handled by Scintilla, so the parent of the Scintilla window will have the opportunity to handle the message.</p> + <table cellpadding="1" cellspacing="2" border="0" summary="Display context menu mode"> + <tbody> + <tr> + <th align="left">Symbol</th> + + <th>Value</th> + + <th align="left">Meaning</th> + + </tr> + </tbody> + + <tbody valign="top"> + <tr> + <td align="left"><code>SC_POPUP_NEVER</code></td> + + <td align="center">0x01</td> + + <td>Never show default editing menu.</td> + + </tr> + + <tr> + <td align="left"><code>SC_POPUP_ALL</code></td> + + <td align="center">0x02</td> + + <td>Show default editing menu if clicking on scintilla.</td> + + </tr> + + <tr> + <td align="left"><code>SC_POPUP_TEXT</code></td> + + <td align="center">0x04</td> + + <td>Show default editing menu only if clicking on text area.</td> + + </tr> + + </tbody> + </table> + <h2 id="MacroRecording">Macro recording</h2> <p>Start and stop macro recording mode. In macro recording mode, actions are reported to the @@ -5566,8 +5666,9 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <code>AddData</code> will return SC_STATUS_OK unless a failure, such as memory exhaustion occurs. If a failure occurs in <code>AddData</code> or in a file reading call then loading can be abandoned and the loader released with the <code>Release</code> call. - When the whole file has been read, the <code>ConvertToDocument</code> method should be called to produce a Scintilla - document pointer which can be used in the same way as a document pointer returned from + When the whole file has been read, <code>ConvertToDocument</code> should be called to produce a Scintilla + document pointer. The newly created document will have a reference count of 1 in the same way as a document pointer + returned from <a class="seealso" href="#SCI_CREATEDOCUMENT">SCI_CREATEDOCUMENT</a>. There is no need to call <code>Release</code> after <code>ConvertToDocument</code>.</p> @@ -5618,6 +5719,8 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <a class="message" href="#SCI_GETFOLDEXPANDED">SCI_GETFOLDEXPANDED(int line) → bool</a><br /> <a class="message" href="#SCI_CONTRACTEDFOLDNEXT">SCI_CONTRACTEDFOLDNEXT(int lineStart) → int</a><br /> <a class="message" href="#SCI_TOGGLEFOLD">SCI_TOGGLEFOLD(int line)</a><br /> + <a class="message" href="#SCI_TOGGLEFOLDSHOWTEXT">SCI_TOGGLEFOLDSHOWTEXT(int line, const char *text)</a><br /> + <a class="message" href="#SCI_FOLDDISPLAYTEXTSETSTYLE">SCI_FOLDDISPLAYTEXTSETSTYLE(int style)</a><br /> <a class="message" href="#SCI_FOLDLINE">SCI_FOLDLINE(int line, int action)</a><br /> <a class="message" href="#SCI_FOLDCHILDREN">SCI_FOLDCHILDREN(int line, int action)</a><br /> <a class="message" href="#SCI_FOLDALL">SCI_FOLDALL(int action)</a><br /> @@ -5769,10 +5872,49 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ inconsistent, the return value is -1.</p> <p><b id="SCI_TOGGLEFOLD">SCI_TOGGLEFOLD(int line)</b><br /> + <b id="SCI_TOGGLEFOLDSHOWTEXT">SCI_TOGGLEFOLDSHOWTEXT(int line, const char *text)</b><br /> Each fold point may be either expanded, displaying all its child lines, or contracted, hiding - all the child lines. This message toggles the folding state of the given line as long as it has - the <code>SC_FOLDLEVELHEADERFLAG</code> set. This message takes care of folding or expanding + all the child lines. These messages toggle the folding state of the given line as long as it has + the <code>SC_FOLDLEVELHEADERFLAG</code> set. These messages take care of folding or expanding all the lines that depend on the line. The display updates after this message.</p> + <p>An optional text tag may be shown to the right of the folded text with the + <code class="parameter">text</code> argument to + <code>SCI_TOGGLEFOLDSHOWTEXT</code>. + The text is drawn with the + <code><a class="message" href="#StyleDefinition">STYLE_FOLDDISPLAYTEXT</a></code> style.</p> + + <p><b id="SCI_FOLDDISPLAYTEXTSETSTYLE">SCI_FOLDDISPLAYTEXTSETSTYLE(int style)</b><br /> + This message changes the appearance of fold text tags.</p> + <table cellpadding="1" cellspacing="2" border="0" summary="Fold flags"> + <tbody> + <tr> + <th align="left">Symbol</th> + <th align="left">Value</th> + <th align="left">Effect</th> + </tr> + </tbody> + + <tbody valign="top"> + <tr> + <td align="left">SC_FOLDDISPLAYTEXT_HIDDEN</td> + <td align="left">0</td> + <td align="left">Do not display the text tags. This is the default.</td> + </tr> + + <tr> + <td align="left">SC_FOLDDISPLAYTEXT_STANDARD</td> + <td align="left">1</td> + <td align="left">Display the text tags.</td> + </tr> + + <tr> + <td align="left">SC_FOLDDISPLAYTEXT_BOXED</td> + <td align="left">2</td> + <td align="left">Display the text tags with a box drawn around them.</td> + </tr> + + </tbody> + </table> <p><b id="SCI_SETFOLDEXPANDED">SCI_SETFOLDEXPANDED(int line, bool expanded)</b><br /> <b id="SCI_GETFOLDEXPANDED">SCI_GETFOLDEXPANDED(int line) → bool</b><br /> @@ -6707,9 +6849,9 @@ struct SCNotification { struct Sci_NotifyHeader nmhdr; Sci_Position position; /* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, */ - /* SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, */ - /* SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, */ - /* SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ + /* SCN_MARGINRIGHTCLICK, SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, */ + /* SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */ + /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */ int ch; @@ -6731,7 +6873,7 @@ struct SCNotification { Sci_Position line; /* SCN_MODIFIED */ int foldLevelNow; /* SCN_MODIFIED */ int foldLevelPrev; /* SCN_MODIFIED */ - int margin; /* SCN_MARGINCLICK */ + int margin; /* SCN_MARGINCLICK, SCN_MARGINRIGHTCLICK */ int listType; /* SCN_USERLISTSELECTION */ int x; /* SCN_DWELLSTART, SCN_DWELLEND */ int y; /* SCN_DWELLSTART, SCN_DWELLEND */ @@ -6776,6 +6918,7 @@ struct SCNotification { <a class="message" href="#SCN_FOCUSIN">SCN_FOCUSIN</a><br /> <a class="message" href="#SCN_FOCUSOUT">SCN_FOCUSOUT</a><br /> <a class="message" href="#SCN_AUTOCCOMPLETED">SCN_AUTOCCOMPLETED</a><br /> + <a class="message" href="#SCN_MARGINRIGHTCLICK">SCN_MARGINRIGHTCLICK</a><br /> </code> <p>The following <code>SCI_*</code> messages are associated with these notifications:</p> @@ -7335,7 +7478,8 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); </table> <p><b id="SCN_MARGINCLICK">SCN_MARGINCLICK</b><br /> - This notification tells the container that the mouse was clicked inside a <a class="jump" + <b id="SCN_MARGINRIGHTCLICK">SCN_MARGINRIGHTCLICK</b><br /> + These notifications tell the container that the mouse was clicked or right clicked inside a <a class="jump" href="#Margins">margin</a> that was marked as sensitive (see <a class="message" href="#SCI_SETMARGINSENSITIVEN"><code>SCI_SETMARGINSENSITIVEN</code></a>). This can be used to perform folding or to place breakpoints. The following <code>SCNotification</code> fields are @@ -7655,6 +7799,15 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next <a class="jump" href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</a></code> notification.</p> + <h2 id="Accessibility">Accessibility</h2> + + <p>Scintilla supports some platform accessibility features. + This support differs between platforms. + On GTK+ and Cocoa the platform accessibility APIs are implemented sufficiently to + make screen readers work. + On Win32, the system caret is manipulated to help screen readers. + </p> + <h2 id="Images">Images</h2> <p>Two formats are supported for images used in margin markers and autocompletion lists, RGBA and XPM.</p> @@ -7717,7 +7870,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next widgets.</p> <p><b id="scintilla_set_id">void scintilla_set_id(ScintillaObject *sci, uptr_t id)</b><br /> - Set the control ID which will be used in the idFrom field of the NotifyHeader structure of all + Set the control ID which will be used in the idFrom field of the Sci_NotifyHeader structure of all notifications for this instance. This is equivalent to <a class="seealso" href="#SCI_SETIDENTIFIER">SCI_SETIDENTIFIER</a>.</p> @@ -7796,8 +7949,7 @@ EM_FORMATRANGE <code>INCLUDE_DEPRECATED_FEATURES</code> in <code>Scintilla.h</code>. To ensure future compatibility you should change them as indicated.</p> - <code><a class="message" href="#SCI_SETUSEPALETTE">SCI_SETUSEPALETTE(bool usePalette)</a><br /> - <a class="message" href="#SCI_GETUSEPALETTE">SCI_GETUSEPALETTE → bool</a><br /> + <code> <a class="message" href="#SCI_SETKEYSUNICODE">SCI_SETKEYSUNICODE(bool keysUnicode)</a><br /> <a class="message" href="#SCI_GETKEYSUNICODE">SCI_GETKEYSUNICODE → bool</a><br /> <a class="message" href="#SCI_SETSTYLEBITS">SCI_SETSTYLEBITS(int bits)</a><br /> @@ -7805,15 +7957,6 @@ EM_FORMATRANGE <a class="message" href="#SCI_GETSTYLEBITSNEEDED">SCI_GETSTYLEBITSNEEDED → int</a><br /> </code> - <p><b id="SC_CP_DBCS">SC_CP_DBCS</b> Deprecated<br /> - This was used to set a DBCS (Double Byte Character Set) mode on GTK+. - An explicit DBCS code page should be used when calling <a class="seealso" href="#SCI_SETCODEPAGE">SCI_SETCODEPAGE</a></p> - - <p><b id="SCI_SETUSEPALETTE">SCI_SETUSEPALETTE(bool usePalette)</b> Deprecated<br /> - <b id="SCI_GETUSEPALETTE">SCI_GETUSEPALETTE → bool</b> Deprecated<br /> - Scintilla no longer supports palette mode. The last version to support palettes was 2.29. - Any calls to these methods should be removed.</p> - <p><b id="SCI_SETKEYSUNICODE">SCI_SETKEYSUNICODE(bool keysUnicode)</b> Deprecated<br /> <b id="SCI_GETKEYSUNICODE">SCI_GETKEYSUNICODE → bool</b> Deprecated<br /> On Windows, Scintilla no longer supports narrow character windows so input is always treated as Unicode.</p> @@ -7867,6 +8010,17 @@ EM_SETTARGETDEVICE <h2 id="RemovedFeatures">Removed features</h2> + <p>These features have now been removed completely.</p> + + <p><b id="SC_CP_DBCS">SC_CP_DBCS</b> Removed in 2016 with release 3.7.1<br /> + This was used to set a DBCS (Double Byte Character Set) mode on GTK+. + An explicit DBCS code page should be used when calling <a class="seealso" href="#SCI_SETCODEPAGE">SCI_SETCODEPAGE</a></p> + + <p><b id="SCI_SETUSEPALETTE">SCI_SETUSEPALETTE(bool usePalette)</b> Removed in 2016 with release 3.7.1<br /> + <b id="SCI_GETUSEPALETTE">SCI_GETUSEPALETTE → bool</b> Removed in 2016 with release 3.7.1<br /> + Scintilla no longer supports palette mode. The last version to support palettes was 2.29. + Any calls to these methods must be removed.</p> + <p>Previous versions of Scintilla allowed indicators to be stored in bits of each style byte. This was deprecated in 2007 and removed in 2014 with release 3.4.3. All uses of style byte indicators should be replaced with <a href="#Indicators">standard indicators</a>.</p> diff --git a/scintilla/doc/ScintillaDownload.html b/scintilla/doc/ScintillaDownload.html index 7d14eee..3a54beb 100644 --- a/scintilla/doc/ScintillaDownload.html +++ b/scintilla/doc/ScintillaDownload.html @@ -26,9 +26,9 @@ <table bgcolor="#CCCCCC" width="100%" cellspacing="0" cellpadding="8" border="0">
<tr>
<td>
- <font size="4"> <a href="http://www.scintilla.org/scintilla370.zip">
+ <font size="4"> <a href="http://www.scintilla.org/scintilla371.zip">
Windows</a>
- <a href="http://www.scintilla.org/scintilla370.tgz">
+ <a href="http://www.scintilla.org/scintilla371.tgz">
GTK+/Linux</a>
</font>
</td>
@@ -42,7 +42,7 @@ containing very few restrictions.
</p>
<h3>
- Release 3.7.0
+ Release 3.7.1
</h3>
<h4>
Source Code
@@ -50,8 +50,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://www.scintilla.org/scintilla370.zip">zip format</a> (1500K) commonly used on Windows</li>
- <li><a href="http://www.scintilla.org/scintilla370.tgz">tgz format</a> (1400K) commonly used on Linux and compatible operating systems</li>
+ <li><a href="http://www.scintilla.org/scintilla371.zip">zip format</a> (1600K) commonly used on Windows</li>
+ <li><a href="http://www.scintilla.org/scintilla371.tgz">tgz format</a> (1400K) 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 623903b..93f28b4 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -505,6 +505,7 @@ </tr><tr>
<td>Roberto Rossi</td>
<td>Kenny Liu</td>
+ <td>Iain Clarke</td>
</tr>
</table>
<p>
@@ -521,18 +522,69 @@ </h3>
<ul>
<li>
- Released 16 October 2016.
+ Released 4 December 2016.
+ </li>
+ <li>
+ The Scintilla namespace is no longer applied to struct definitions in Scintilla.h even
+ when SCI_NAMESPACE defined.
+ Client code should not define SCI_NAMESPACE.
+ </li>
+ <li>
+ Structure names in Scintilla.h without prefixes are deprecated and will now only
+ be usable with INCLUDE_DEPRECATED_FEATURES defined.<br />
+ Use the newer names with the "Sci_" prefix:<br />
+ CharacterRange → Sci_CharacterRange<br />
+ TextRange → Sci_TextRange<br />
+ TextToFind → Sci_TextToFind<br />
+ RangeToFormat → Sci_RangeToFormat<br />
+ NotifyHeader → Sci_NotifyHeader
+ </li>
+ <li>
+ Previously deprecated features SC_CP_DBCS, SCI_SETUSEPALETTE. and SCI_GETUSEPALETTE
+ have been removed and can no longer be used in client code.
+ </li>
+ <li>
+ Accessibility support allowing screen readers to work added on GTK+ and Cocoa.
+ </li>
+ <li>
+ Textual tags may be displayed to the right on folded lines with SCI_TOGGLEFOLDSHOWTEXT.
+ This is commonly something like "{ ... }" or "<tr>...</tr>".
+ It is displayed with the STYLE_FOLDDISPLAYTEXT style and may have a box drawn around it
+ with SCI_FOLDDISPLAYTEXTSETSTYLE.
+ </li>
+ <li>
+ A mouse right-click over the margin may send an SCN_MARGINRIGHTCLICK event.
+ This only occurs when popup menus are turned off.
+ SCI_USEPOPUP now has three states: SC_POPUP_NEVER, SC_POPUP_ALL, or SC_POPUP_TEXT.
+ </li>
+ <li>
+ INDIC_POINT and INDIC_POINTCHARACTER indicators added to display small arrows
+ underneath positions or characters.
</li>
<li>
- Accessibility supported on GTK+.
+ Added alternate appearance for visible tabs which looks like a horizontal line.
+ Controlled with SCI_SETTABDRAWMODE.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1165/">Feature #1165.</a>
</li>
<li>
- Baan folder accomodates main sections and lexer fixes definition of SCE_BAAN_FUNCDEF.
+ On Cocoa, a modulemap file is included to allow Scintilla to be treated as a module.
+ This makes it easier to use Scintilla from the Swift language.
+ </li>
+ <li>
+ Baan folder accommodates sections and lexer fixes definition of SCE_BAAN_FUNCDEF.
+ </li>
+ <li>
+ EDIFACT lexer and folder added.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1166/">Feature #1166.</a>
</li>
<li>
JSON folder fixed where it didn't resume folding with the correct fold level.
</li>
<li>
+ Matlab folder based on syntax instead of indentation so more accurate.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1692/">Bug #1692</a>.
+ </li>
+ <li>
YAML lexer fixed style of references and keywords when followed by a comment.
<a href="http://sourceforge.net/p/scintilla/bugs/1872/">Bug #1872</a>.
</li>
@@ -548,8 +600,25 @@ target Scintilla instance was destroyed.
</li>
<li>
+ Cocoa IME made more compliant with documented behaviour to avoid bugs that caused
+ huge allocations.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1881/">Bug #1881</a>.
+ </li>
+ <li>
+ On Win32 fix EM_SETSEL to match Microsoft documentation..
+ <a href="http://sourceforge.net/p/scintilla/bugs/1886/">Bug #1886</a>.
+ </li>
+ <li>
+ SciTE on GTK+ allows localising tool bar tool tips.
+ <a href="http://sourceforge.net/p/scintilla/feature-requests/1167/">Feature #1167.</a>
+ </li>
+ <li>
SciTE on Windows restores focus to edit pane after closing user strip.
</li>
+ <li>
+ SciTE measures files larger that 2 GB which allows it to refuse to open huge files more consistently
+ and to show better warning messages.
+ </li>
</ul>
<h3>
<a href="http://www.scintilla.org/scite370.zip">Release 3.7.0</a>
diff --git a/scintilla/doc/index.html b/scintilla/doc/index.html index 4048458..131b49d 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="20161016" />
+ <meta name="Date.Modified" content="20161204" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
#versionlist {
@@ -56,8 +56,8 @@ GTK+, and OS X</font>
</td>
<td width="40%" align="right">
- <font color="#FFCC99" size="3"> Release version 3.7.0<br />
- Site last modified October 16 2016</font>
+ <font color="#FFCC99" size="3"> Release version 3.7.1<br />
+ Site last modified December 4 2016</font>
</td>
<td width="20%">
@@ -72,12 +72,11 @@ </tr>
</table>
<ul id="versionlist">
+ <li>Version 3.7.1 supports accessibility on GTK+ and Cocoa.
+ The Scintilla namespace is not exposed in Scintilla.h and some deprecated APIs were removed.</li>
<li>Version 3.7.0 improves word selection, navigation, and manipulation for UTF-8 documents.</li>
<li>Version 3.6.7 changes SC_CHARSET_DEFAULT on Windows to mean European code page 1252 unless a code page is set.</li>
<li>Version 3.6.6 enables C++11 <regex> by default.</li>
- <li>Version 3.6.5 adds a JSON lexer and removes the font cache on GTK+.
- Type definitions Sci_Position, Sci_PositionU, and Sci_PositionCR allow client
- code to prepare for a future change allowing larger than 2 GB documents.</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 28d34f4..0d8e072 100644 --- a/scintilla/include/Platform.h +++ b/scintilla/include/Platform.h @@ -526,8 +526,4 @@ public: }
#endif
-#if defined(__GNUC__) && defined(SCINTILLA_QT)
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
-#endif
-
#endif
diff --git a/scintilla/include/SciLexer.h b/scintilla/include/SciLexer.h index 6fc19eb..b1e88d8 100644 --- a/scintilla/include/SciLexer.h +++ b/scintilla/include/SciLexer.h @@ -133,6 +133,7 @@ #define SCLEX_IHEX 118
#define SCLEX_TEHEX 119
#define SCLEX_JSON 120
+#define SCLEX_EDIFACT 121
#define SCLEX_AHK 200
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
@@ -1819,6 +1820,15 @@ #define SCE_JSON_KEYWORD 11
#define SCE_JSON_LDKEYWORD 12
#define SCE_JSON_ERROR 13
+#define SCE_EDI_DEFAULT 0
+#define SCE_EDI_SEGMENTSTART 1
+#define SCE_EDI_SEGMENTEND 2
+#define SCE_EDI_SEP_ELEMENT 3
+#define SCE_EDI_SEP_COMPOSITE 4
+#define SCE_EDI_SEP_RELEASE 5
+#define SCE_EDI_UNA 6
+#define SCE_EDI_UNH 7
+#define SCE_EDI_BADSEGMENT 8
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif
diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index c0c0506..a3f9b21 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -11,8 +11,6 @@ #ifndef SCINTILLA_H
#define SCINTILLA_H
-#include "Sci_Position.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -28,20 +26,21 @@ int Scintilla_LinkLexers(void); }
#endif
-/* Here should be placed typedefs for uptr_t, an unsigned integer type large enough to
- * hold a pointer and sptr_t, a signed integer large enough to hold a pointer.
- * May need to be changed for 64 bit platforms. */
-#if defined(_WIN32)
-#include <basetsd.h>
-#endif
-#ifdef MAXULONG_PTR
-typedef ULONG_PTR uptr_t;
-typedef LONG_PTR sptr_t;
+// Include header that defines basic numeric types.
+#if defined(_MSC_VER)
+// Older releases of MSVC did not have stdint.h.
+#include <stddef.h>
#else
-typedef unsigned long uptr_t;
-typedef long sptr_t;
+#include <stdint.h>
#endif
+// Define uptr_t, an unsigned integer type large enough to hold a pointer.
+typedef uintptr_t uptr_t;
+// Define sptr_t, a signed integer large enough to hold a pointer.
+typedef intptr_t sptr_t;
+
+#include "Sci_Position.h"
+
typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam);
/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */
@@ -76,6 +75,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCWS_VISIBLEONLYININDENT 3
#define SCI_GETVIEWWS 2020
#define SCI_SETVIEWWS 2021
+#define SCTD_LONGARROW 0
+#define SCTD_STRIKEOUT 1
+#define SCI_GETTABDRAWMODE 2698
+#define SCI_SETTABDRAWMODE 2699
#define SCI_POSITIONFROMPOINT 2022
#define SCI_POSITIONFROMPOINTCLOSE 2023
#define SCI_GOTOLINE 2024
@@ -189,6 +192,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define STYLE_CONTROLCHAR 36
#define STYLE_INDENTGUIDE 37
#define STYLE_CALLTIP 38
+#define STYLE_FOLDDISPLAYTEXT 39
#define STYLE_LASTPREDEFINED 39
#define STYLE_MAX 255
#define SC_CHARSET_ANSI 0
@@ -287,6 +291,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_COMPOSITIONTHIN 15
#define INDIC_FULLBOX 16
#define INDIC_TEXTFORE 17
+#define INDIC_POINT 18
+#define INDIC_POINTCHARACTER 19
#define INDIC_IME 32
#define INDIC_IME_MAX 35
#define INDIC_MAX 35
@@ -480,6 +486,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETFOLDEXPANDED 2229
#define SCI_GETFOLDEXPANDED 2230
#define SCI_TOGGLEFOLD 2231
+#define SCI_TOGGLEFOLDSHOWTEXT 2700
+#define SC_FOLDDISPLAYTEXT_HIDDEN 0
+#define SC_FOLDDISPLAYTEXT_STANDARD 1
+#define SC_FOLDDISPLAYTEXT_BOXED 2
+#define SCI_FOLDDISPLAYTEXTSETSTYLE 2701
#define SC_FOLDACTION_CONTRACT 0
#define SC_FOLDACTION_EXPAND 1
#define SC_FOLDACTION_TOGGLE 2
@@ -668,6 +679,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SEARCHNEXT 2367
#define SCI_SEARCHPREV 2368
#define SCI_LINESONSCREEN 2370
+#define SC_POPUP_NEVER 0
+#define SC_POPUP_ALL 1
+#define SC_POPUP_TEXT 2
#define SCI_USEPOPUP 2371
#define SCI_SELECTIONISRECTANGLE 2372
#define SCI_SETZOOM 2373
@@ -1080,16 +1094,13 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_FOCUSIN 2028
#define SCN_FOCUSOUT 2029
#define SCN_AUTOCCOMPLETED 2030
+#define SCN_MARGINRIGHTCLICK 2031
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
/* These structures are defined to be exactly the same shape as the Win32
* CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
* So older code that treats Scintilla as a RichEdit will work. */
-#if defined(__cplusplus) && defined(SCI_NAMESPACE)
-namespace Scintilla {
-#endif
-
struct Sci_CharacterRange {
Sci_PositionCR cpMin;
Sci_PositionCR cpMax;
@@ -1106,10 +1117,6 @@ struct Sci_TextToFind { struct Sci_CharacterRange chrgText;
};
-#define CharacterRange Sci_CharacterRange
-#define TextRange Sci_TextRange
-#define TextToFind Sci_TextToFind
-
typedef void *Sci_SurfaceID;
struct Sci_Rectangle {
@@ -1130,8 +1137,6 @@ struct Sci_RangeToFormat { struct Sci_CharacterRange chrg;
};
-#define RangeToFormat Sci_RangeToFormat
-
#ifndef __cplusplus
/* For the GTK+ platform, g-ir-scanner needs to have these typedefs. This
* is not required in C++ code and actually seems to break ScintillaEditPy */
@@ -1148,8 +1153,6 @@ struct Sci_NotifyHeader { unsigned int code;
};
-#define NotifyHeader Sci_NotifyHeader
-
struct SCNotification {
Sci_NotifyHeader nmhdr;
Sci_Position position;
@@ -1189,18 +1192,17 @@ struct SCNotification { /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION, */
};
-#if defined(__cplusplus) && defined(SCI_NAMESPACE)
-}
-#endif
-
#ifdef INCLUDE_DEPRECATED_FEATURES
-#define SC_CP_DBCS 1
-#define SCI_SETUSEPALETTE 2039
-#define SCI_GETUSEPALETTE 2139
#define SCI_SETKEYSUNICODE 2521
#define SCI_GETKEYSUNICODE 2522
+#define CharacterRange Sci_CharacterRange
+#define TextRange Sci_TextRange
+#define TextToFind Sci_TextToFind
+#define RangeToFormat Sci_RangeToFormat
+#define NotifyHeader Sci_NotifyHeader
+
#endif
#endif
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index 4451b53..40fc435 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -168,6 +168,17 @@ get int GetViewWS=2020(,) # Make white space characters invisible, always visible or visible outside indentation.
set void SetViewWS=2021(int viewWS,)
+enu TabDrawMode=SCTD_
+val SCTD_LONGARROW=0
+val SCTD_STRIKEOUT=1
+
+# Retrieve the current tab draw mode.
+# Returns one of SCTD_* constants.
+get int GetTabDrawMode=2698(,)
+
+# Set how tabs are drawn when visible.
+set void SetTabDrawMode=2699(int tabDrawMode,)
+
# Find the position from a point within the window.
fun position PositionFromPoint=2022(int x, int y)
@@ -414,6 +425,7 @@ val STYLE_BRACEBAD=35 val STYLE_CONTROLCHAR=36
val STYLE_INDENTGUIDE=37
val STYLE_CALLTIP=38
+val STYLE_FOLDDISPLAYTEXT=39
val STYLE_LASTPREDEFINED=39
val STYLE_MAX=255
@@ -626,6 +638,8 @@ val INDIC_COMPOSITIONTHICK=14 val INDIC_COMPOSITIONTHIN=15
val INDIC_FULLBOX=16
val INDIC_TEXTFORE=17
+val INDIC_POINT=18
+val INDIC_POINTCHARACTER=19
val INDIC_IME=32
val INDIC_IME_MAX=35
val INDIC_MAX=35
@@ -1198,6 +1212,17 @@ get bool GetFoldExpanded=2230(int line,) # Switch a header line between expanded and contracted.
fun void ToggleFold=2231(int line,)
+# Switch a header line between expanded and contracted and show some text after the line.
+fun void ToggleFoldShowText=2700(int line, string text)
+
+enu foldDisplayTextStyle=SC_FOLDDISPLAYTEXTSTYLE_
+val SC_FOLDDISPLAYTEXT_HIDDEN=0
+val SC_FOLDDISPLAYTEXT_STANDARD=1
+val SC_FOLDDISPLAYTEXT_BOXED=2
+
+# Set the style of fold display text
+set void FoldDisplayTextSetStyle=2701(int style,)
+
enu FoldAction=SC_FOLDACTION_
val SC_FOLDACTION_CONTRACT=0
val SC_FOLDACTION_EXPAND=1
@@ -1723,9 +1748,14 @@ fun int SearchPrev=2368(int searchFlags, string text) # Retrieves the number of lines completely visible.
get int LinesOnScreen=2370(,)
+enu PopUp=SC_POPUP_
+val SC_POPUP_NEVER=0
+val SC_POPUP_ALL=1
+val SC_POPUP_TEXT=2
+
# Set whether a pop up menu is displayed automatically when the user presses
-# the wrong mouse button.
-fun void UsePopUp=2371(bool allowPopUp,)
+# the wrong mouse button on certain areas.
+fun void UsePopUp=2371(int popUpMode,)
# Is the selection rectangular? The alternative is the more common stream selection.
get bool SelectionIsRectangle=2372(,)
@@ -2860,6 +2890,7 @@ val SCLEX_SREC=117 val SCLEX_IHEX=118
val SCLEX_TEHEX=119
val SCLEX_JSON=120
+val SCLEX_EDIFACT=121
## notepad2 custom code for the AHK lexer - start
val SCLEX_AHK=200
## notepad2 custom code for the AHK lexer - end
@@ -4777,6 +4808,16 @@ val SCE_JSON_COMPACTIRI=10 val SCE_JSON_KEYWORD=11
val SCE_JSON_LDKEYWORD=12
val SCE_JSON_ERROR=13
+lex EDIFACT=SCLEX_EDIFACT SCE_EDI_
+val SCE_EDI_DEFAULT=0
+val SCE_EDI_SEGMENTSTART=1
+val SCE_EDI_SEGMENTEND=2
+val SCE_EDI_SEP_ELEMENT=3
+val SCE_EDI_SEP_COMPOSITE=4
+val SCE_EDI_SEP_RELEASE=5
+val SCE_EDI_UNA=6
+val SCE_EDI_UNH=7
+val SCE_EDI_BADSEGMENT=8
# Events
@@ -4811,6 +4852,7 @@ evt void HotSpotReleaseClick=2027(int modifiers, int position) evt void FocusIn=2028(void)
evt void FocusOut=2029(void)
evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethods listCompletionMethod)
+evt void MarginRightClick=2031(int modifiers, int position, int margin)
# There are no provisional APIs currently, but some arguments to SCI_SETTECHNOLOGY are provisional.
@@ -4818,19 +4860,6 @@ cat Provisional cat Deprecated
-# Deprecated in 2.21
-# The SC_CP_DBCS value can be used to indicate a DBCS mode for GTK+.
-val SC_CP_DBCS=1
-
-# Deprecated in 2.30
-
-# In palette mode?
-get bool GetUsePalette=2139(,)
-
-# In palette mode, Scintilla uses the environment's palette calls to display
-# more colours. This may lead to ugly displays.
-set void SetUsePalette=2039(bool usePalette,)
-
# Deprecated in 3.5.5
# Always interpret keyboard input as Unicode
diff --git a/scintilla/lexers/LexBaan.cxx b/scintilla/lexers/LexBaan.cxx index bdc6b32..8439064 100644 --- a/scintilla/lexers/LexBaan.cxx +++ b/scintilla/lexers/LexBaan.cxx @@ -39,7 +39,7 @@ using namespace Scintilla; # endif
namespace {
- // Use an unnamed namespace to protect the functions and classes from name conflicts
+// Use an unnamed namespace to protect the functions and classes from name conflicts
// Options used for LexerBaan
struct OptionsBaan {
@@ -49,6 +49,8 @@ struct OptionsBaan { bool foldCompact;
bool baanFoldSyntaxBased;
bool baanFoldKeywordsBased;
+ bool baanFoldSections;
+ bool baanFoldInnerLevel;
bool baanStylingWithinPreprocessor;
OptionsBaan() {
fold = false;
@@ -57,6 +59,8 @@ struct OptionsBaan { foldCompact = false;
baanFoldSyntaxBased = false;
baanFoldKeywordsBased = false;
+ baanFoldSections = false;
+ baanFoldInnerLevel = false;
baanStylingWithinPreprocessor = false;
}
};
@@ -85,10 +89,18 @@ struct OptionSetBaan : public OptionSet<OptionsBaan> { DefineProperty("fold.baan.syntax.based", &OptionsBaan::baanFoldSyntaxBased,
"Set this property to 0 to disable syntax based folding, which is folding based on '{' & '('.");
-
+
DefineProperty("fold.baan.keywords.based", &OptionsBaan::baanFoldKeywordsBased,
"Set this property to 0 to disable keywords based folding, which is folding based on "
- " for, if, on (case), repeat, select, while and fold ends based on endfor, endif, endcase, until, endselect, endwhile respectively.");
+ " for, if, on (case), repeat, select, while and fold ends based on endfor, endif, endcase, until, endselect, endwhile respectively."
+ "Also folds declarations which are grouped together.");
+
+ DefineProperty("fold.baan.sections", &OptionsBaan::baanFoldSections,
+ "Set this property to 0 to disable folding of Main Sections as well as Sub Sections.");
+
+ DefineProperty("fold.baan.inner.level", &OptionsBaan::baanFoldInnerLevel,
+ "Set this property to 1 to enable folding of inner levels of select statements."
+ "Disabled by default. case and if statements are also eligible" );
DefineProperty("lexer.baan.styling.within.preprocessor", &OptionsBaan::baanStylingWithinPreprocessor,
"For Baan code, determines whether all preprocessor code is styled in the "
@@ -103,10 +115,6 @@ static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '$');
}
-static inline bool IsAWordStart(const int ch) {
- return (ch < 0x80) && (isalnum(ch) || ch == '_');
-}
-
static inline bool IsAnOperator(int ch) {
if (IsAlphaNumeric(ch))
return false;
@@ -216,7 +224,16 @@ static bool IsPreProcLine(Sci_Position line, LexAccessor &styler) { Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
for (Sci_Position i = pos; i < eol_pos; i++) {
char ch = styler[i];
- if (ch == '#' || ch == '|' || ch == '^')
+ int style = styler.StyleAt(i);
+ if (ch == '#' && style == SCE_BAAN_PREPROCESSOR) {
+ if (styler.Match(i, "#elif") || styler.Match(i, "#else") || styler.Match(i, "#endif")
+ || styler.Match(i, "#if") || styler.Match(i, "#ifdef") || styler.Match(i, "#ifndef"))
+ // Above PreProcessors has a seperate fold mechanism.
+ return false;
+ else
+ return true;
+ }
+ else if (ch == '^')
return true;
else if (!IsASpaceOrTab(ch))
return false;
@@ -224,24 +241,112 @@ static bool IsPreProcLine(Sci_Position line, LexAccessor &styler) { return false;
}
-static bool IsMainSectionLine(Sci_Position line, LexAccessor &styler) {
+static int mainOrSubSectionLine(Sci_Position line, LexAccessor &styler) {
Sci_Position pos = styler.LineStart(line);
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
for (Sci_Position i = pos; i < eol_pos; i++) {
char ch = styler[i];
int style = styler.StyleAt(i);
- if (style == SCE_BAAN_WORD5)
- return true;
+ if (style == SCE_BAAN_WORD5 || style == SCE_BAAN_WORD4)
+ return style;
+ else if (IsASpaceOrTab(ch))
+ continue;
+ else
+ break;
+ }
+ return 0;
+}
+
+static bool priorSectionIsSubSection(Sci_Position line, LexAccessor &styler){
+ while (line > 0) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
+ char ch = styler[i];
+ int style = styler.StyleAt(i);
+ if (style == SCE_BAAN_WORD4)
+ return true;
+ else if (style == SCE_BAAN_WORD5)
+ return false;
+ else if (IsASpaceOrTab(ch))
+ continue;
+ else
+ break;
+ }
+ line--;
+ }
+ return false;
+}
+
+static bool nextSectionIsSubSection(Sci_Position line, LexAccessor &styler) {
+ while (line > 0) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
+ char ch = styler[i];
+ int style = styler.StyleAt(i);
+ if (style == SCE_BAAN_WORD4)
+ return true;
+ else if (style == SCE_BAAN_WORD5)
+ return false;
+ else if (IsASpaceOrTab(ch))
+ continue;
+ else
+ break;
+ }
+ line++;
+ }
+ return false;
+}
+
+static bool IsDeclarationLine(Sci_Position line, LexAccessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
+ char ch = styler[i];
+ int style = styler.StyleAt(i);
+ if (style == SCE_BAAN_WORD) {
+ if (styler.Match(i, "table") || styler.Match(i, "extern") || styler.Match(i, "long")
+ || styler.Match(i, "double") || styler.Match(i, "boolean") || styler.Match(i, "string")
+ || styler.Match(i, "domain")) {
+ for (Sci_Position j = eol_pos; j > pos; j--) {
+ int styleFromEnd = styler.StyleAt(j);
+ if (styleFromEnd == SCE_BAAN_COMMENT)
+ continue;
+ else if (IsASpace(styler[j]))
+ continue;
+ else if (styler[j] != ',')
+ //Above conditions ensures, Declaration is not part of any function parameters.
+ return true;
+ else
+ return false;
+ }
+ }
+ else
+ return false;
+ }
else if (!IsASpaceOrTab(ch))
return false;
}
return false;
}
-static inline int ToLowerCase(int c) {
- if (c >= 'A' && c <= 'Z')
- return 'a' + c - 'A';
- return c;
+static bool IsInnerLevelFold(Sci_Position line, LexAccessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
+ char ch = styler[i];
+ int style = styler.StyleAt(i);
+ if (style == SCE_BAAN_WORD && (styler.Match(i, "else" ) || styler.Match(i, "case")
+ || styler.Match(i, "default") || styler.Match(i, "selectdo") || styler.Match(i, "selecteos")
+ || styler.Match(i, "selectempty") || styler.Match(i, "selecterror")))
+ return true;
+ else if (IsASpaceOrTab(ch))
+ continue;
+ else
+ return false;
+ }
+ return false;
}
static inline bool wordInArray(const std::string& value, std::string *array, int length)
@@ -314,7 +419,7 @@ public: return osBaan.DescribeProperty(name);
}
- int SCI_METHOD PropertySet(const char *key, const char *val);
+ Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
const char * SCI_METHOD DescribeWordListSets() {
return osBaan.DescribeWordListSets();
@@ -399,7 +504,12 @@ void SCI_METHOD LexerBaan::Lex(Sci_PositionU startPos, Sci_Position length, int bool lineHasPreProc = false;
bool lineIgnoreString = false;
bool lineHasDefines = false;
+ char word[1000];
+ int wordlen = 0;
+ std::string preProcessorTags[11] = { "#define", "#elif", "#else", "#endif",
+ "#ident", "#if", "#ifdef", "#ifndef",
+ "#include", "#pragma", "#undef" };
LexAccessor styler(pAccess);
StyleContext sc(startPos, length, initStyle, styler);
@@ -537,7 +647,7 @@ void SCI_METHOD LexerBaan::Lex(Sci_PositionU startPos, Sci_Position length, int sc.Forward();
} while ((!sc.atLineEnd) && sc.More());
}
- else if (IsAWordStart(sc.ch)) {
+ else if (iswordstart(sc.ch)) {
sc.SetState(SCE_BAAN_IDENTIFIER);
}
else if (sc.Match('|')) {
@@ -549,15 +659,26 @@ void SCI_METHOD LexerBaan::Lex(Sci_PositionU startPos, Sci_Position length, int else if (sc.ch == '#' && visibleChars == 0) {
// Preprocessor commands are alone on their line
sc.SetState(SCE_BAAN_PREPROCESSOR);
- // Skip whitespace between # and preprocessor word
- do {
+ word[0] = '\0';
+ wordlen = 0;
+ while (sc.More() && !(IsASpace(sc.chNext) || IsAnOperator(sc.chNext))) {
sc.Forward();
- } while (IsASpace(sc.ch) && sc.More());
- if (sc.MatchIgnoreCase("pragma") || sc.MatchIgnoreCase("include")) {
+ wordlen++;
+ }
+ sc.GetCurrentLowered(word, sizeof(word));
+ if (!sc.atLineEnd) {
+ word[wordlen++] = sc.ch;
+ word[wordlen++] = '\0';
+ }
+ if (!wordInArray(word, preProcessorTags, 11))
+ // Colorise only preprocessor built in Baan.
+ sc.ChangeState(SCE_BAAN_IDENTIFIER);
+ if (strcmp(word, "#pragma") == 0 || strcmp(word, "#include") == 0) {
lineHasPreProc = true;
lineIgnoreString = true;
}
- else if (sc.MatchIgnoreCase("define") || sc.MatchIgnoreCase("undef")) {
+ else if (strcmp(word, "#define") == 0 || strcmp(word, "#undef") == 0 ||
+ strcmp(word, "#ifdef") == 0 || strcmp(word, "#if") == 0 || strcmp(word, "#ifndef") == 0) {
lineHasDefines = true;
lineIgnoreString = false;
}
@@ -594,7 +715,9 @@ void SCI_METHOD LexerBaan::Fold(Sci_PositionU startPos, Sci_Position length, int bool foldNextSelect = true;
bool afterFunctionSection = false;
bool beforeDeclarationSection = false;
-
+ int currLineStyle = 0;
+ int nextLineStyle = 0;
+
std::string startTags[6] = { "for", "if", "on", "repeat", "select", "while" };
std::string endTags[6] = { "endcase", "endfor", "endif", "endselect", "endwhile", "until" };
std::string selectCloseTags[5] = { "selectdo", "selecteos", "selectempty", "selecterror", "endselect" };
@@ -646,13 +769,24 @@ void SCI_METHOD LexerBaan::Fold(Sci_PositionU startPos, Sci_Position length, int levelCurrent--;
}
// PreProcessor Folding
- if (options.foldPreprocessor && atEOL && IsPreProcLine(lineCurrent, styler)) {
- if (!IsPreProcLine(lineCurrent - 1, styler)
- && IsPreProcLine(lineCurrent + 1, styler))
- levelCurrent++;
- else if (IsPreProcLine(lineCurrent - 1, styler)
- && !IsPreProcLine(lineCurrent + 1, styler))
- levelCurrent--;
+ if (options.foldPreprocessor) {
+ if (atEOL && IsPreProcLine(lineCurrent, styler)) {
+ if (!IsPreProcLine(lineCurrent - 1, styler)
+ && IsPreProcLine(lineCurrent + 1, styler))
+ levelCurrent++;
+ else if (IsPreProcLine(lineCurrent - 1, styler)
+ && !IsPreProcLine(lineCurrent + 1, styler))
+ levelCurrent--;
+ }
+ else if (style == SCE_BAAN_PREPROCESSOR) {
+ // folds #ifdef/#if/#ifndef - they are not part of the IsPreProcLine folding.
+ if (ch == '#') {
+ if (styler.Match(i, "#ifdef") || styler.Match(i, "#if") || styler.Match(i, "#ifndef"))
+ levelCurrent++;
+ else if (styler.Match(i, "#endif"))
+ levelCurrent--;
+ }
+ }
}
//Syntax Folding
if (options.baanFoldSyntaxBased && (style == SCE_BAAN_OPERATOR)) {
@@ -664,77 +798,100 @@ void SCI_METHOD LexerBaan::Fold(Sci_PositionU startPos, Sci_Position length, int }
}
//Keywords Folding
- if (options.baanFoldKeywordsBased && style == SCE_BAAN_WORD) {
- word[wordlen++] = static_cast<char>(ToLowerCase(ch));
- if (wordlen == 100) { // prevent overflow
- word[0] = '\0';
- wordlen = 1;
+ if (options.baanFoldKeywordsBased) {
+ if (atEOL && IsDeclarationLine(lineCurrent, styler)) {
+ if (!IsDeclarationLine(lineCurrent - 1, styler)
+ && IsDeclarationLine(lineCurrent + 1, styler))
+ levelCurrent++;
+ else if (IsDeclarationLine(lineCurrent - 1, styler)
+ && !IsDeclarationLine(lineCurrent + 1, styler))
+ levelCurrent--;
}
- if (styleNext != SCE_BAAN_WORD) {
- word[wordlen] = '\0';
- wordlen = 0;
- if (strcmp(word, "for") == 0) {
- Sci_PositionU j = i + 1;
- while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
- j++;
- }
- if (styler.Match(j, "update")) {
- // Means this is a "for update" used by Select which is already folded.
- foldStart = false;
- }
+ else if (style == SCE_BAAN_WORD) {
+ word[wordlen++] = static_cast<char>(MakeLowerCase(ch));
+ if (wordlen == 100) { // prevent overflow
+ word[0] = '\0';
+ wordlen = 1;
}
- else if (strcmp(word, "on") == 0) {
- Sci_PositionU j = i + 1;
- while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
- j++;
+ if (styleNext != SCE_BAAN_WORD) {
+ word[wordlen] = '\0';
+ wordlen = 0;
+ if (strcmp(word, "for") == 0) {
+ Sci_PositionU j = i + 1;
+ while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
+ j++;
+ }
+ if (styler.Match(j, "update")) {
+ // Means this is a "for update" used by Select which is already folded.
+ foldStart = false;
+ }
}
- if (!styler.Match(j, "case")) {
- // Means this is not a "on Case" statement... could be "on" used by index.
- foldStart = false;
+ else if (strcmp(word, "on") == 0) {
+ Sci_PositionU j = i + 1;
+ while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
+ j++;
+ }
+ if (!styler.Match(j, "case")) {
+ // Means this is not a "on Case" statement... could be "on" used by index.
+ foldStart = false;
+ }
}
- }
- else if (strcmp(word, "select") == 0) {
- if (foldNextSelect) {
- // Next Selects are sub-clause till reach of selectCloseTags[] array.
- foldNextSelect = false;
+ else if (strcmp(word, "select") == 0) {
+ if (foldNextSelect) {
+ // Next Selects are sub-clause till reach of selectCloseTags[] array.
+ foldNextSelect = false;
+ foldStart = true;
+ }
+ else {
+ foldNextSelect = false;
+ foldStart = false;
+ }
+ }
+ else if (wordInArray(word, selectCloseTags, 5)) {
+ // select clause ends, next select clause can be folded.
+ foldNextSelect = true;
foldStart = true;
}
else {
- foldNextSelect = false;
- foldStart = false;
- }
- }
- else if (wordInArray(word, selectCloseTags, 5)) {
- // select clause ends, next select clause can be folded.
- foldNextSelect = true;
- foldStart = true;
- }
- else {
- foldStart = true;
- }
- if (foldStart) {
- if (wordInArray(word, startTags, 6)) {
- levelCurrent++;
+ foldStart = true;
}
- else if (wordInArray(word, endTags, 6)) {
- levelCurrent--;
+ if (foldStart) {
+ if (wordInArray(word, startTags, 6)) {
+ levelCurrent++;
+ }
+ else if (wordInArray(word, endTags, 6)) {
+ levelCurrent--;
+ }
}
}
}
}
- // Main Section Foldings.
+ // Fold inner level of if/select/case statements
+ if (options.baanFoldInnerLevel && atEOL) {
+ bool currLineInnerLevel = IsInnerLevelFold(lineCurrent, styler);
+ bool nextLineInnerLevel = IsInnerLevelFold(lineCurrent + 1, styler);
+ if (currLineInnerLevel && currLineInnerLevel != nextLineInnerLevel) {
+ levelCurrent++;
+ }
+ else if (nextLineInnerLevel && nextLineInnerLevel != currLineInnerLevel) {
+ levelCurrent--;
+ }
+ }
+ // Section Foldings.
// One way of implementing Section Foldings, as there is no END markings of sections.
// first section ends on the previous line of next section.
// Re-written whole folding to accomodate this.
- if (options.baanFoldKeywordsBased && atEOL) {
- if (IsMainSectionLine(lineCurrent, styler)) {
+ if (options.baanFoldSections && atEOL) {
+ currLineStyle = mainOrSubSectionLine(lineCurrent, styler);
+ nextLineStyle = mainOrSubSectionLine(lineCurrent + 1, styler);
+ if (currLineStyle != 0 && currLineStyle != nextLineStyle) {
if (levelCurrent < levelPrev)
--levelPrev;
for (Sci_Position j = styler.LineStart(lineCurrent); j < styler.LineStart(lineCurrent + 1) - 1; j++) {
- if (IsASpaceOrTab(styler[j]))
+ if (IsASpaceOrTab(styler[j]))
continue;
else if (styler.StyleAt(j) == SCE_BAAN_WORD5) {
- if (styler.Match(j, "functions:")) {
+ if (styler.Match(j, "functions:")) {
// Means functions: is the end of MainSections.
// Nothing to fold after this.
afterFunctionSection = true;
@@ -753,12 +910,14 @@ void SCI_METHOD LexerBaan::Fold(Sci_PositionU startPos, Sci_Position length, int if (!afterFunctionSection)
levelCurrent++;
}
- else if (IsMainSectionLine(lineCurrent + 1, styler)) {
+ else if (nextLineStyle != 0 && currLineStyle != nextLineStyle
+ && (priorSectionIsSubSection(lineCurrent -1 ,styler)
+ || !nextSectionIsSubSection(lineCurrent + 1, styler))) {
for (Sci_Position j = styler.LineStart(lineCurrent + 1); j < styler.LineStart(lineCurrent + 1 + 1) - 1; j++) {
if (IsASpaceOrTab(styler[j]))
continue;
else if (styler.StyleAt(j) == SCE_BAAN_WORD5) {
- if (styler.Match(j, "declaration:")) {
+ if (styler.Match(j, "declaration:")) {
// Means declaration: is the start of MainSections.
// Nothing to fold before this.
beforeDeclarationSection = true;
@@ -774,8 +933,13 @@ void SCI_METHOD LexerBaan::Fold(Sci_PositionU startPos, Sci_Position length, int break;
}
}
- if (!beforeDeclarationSection)
+ if (!beforeDeclarationSection) {
levelCurrent--;
+ if (nextLineStyle == SCE_BAAN_WORD5 && priorSectionIsSubSection(lineCurrent-1, styler))
+ // next levelCurrent--; is to unfold previous subsection fold.
+ // On reaching the next main section, the previous main as well sub section ends.
+ levelCurrent--;
+ }
}
}
if (atEOL) {
diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx index 64387a0..ec040fb 100644 --- a/scintilla/lexers/LexCPP.cxx +++ b/scintilla/lexers/LexCPP.cxx @@ -692,7 +692,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i } } - StyleContext sc(startPos, length, initStyle, styler, static_cast<unsigned char>(0xff)); + StyleContext sc(startPos, length, initStyle, styler); LinePPState preproc = vlls.ForLine(lineCurrent); bool definitionsChanged = false; diff --git a/scintilla/lexers/LexEDIFACT.cxx b/scintilla/lexers/LexEDIFACT.cxx new file mode 100644 index 0000000..53e5bb3 --- /dev/null +++ b/scintilla/lexers/LexEDIFACT.cxx @@ -0,0 +1,319 @@ +// Scintilla Lexer for EDIFACT +// Written by Iain Clarke, IMCSoft & Inobiz AB. +// EDIFACT documented here: https://www.unece.org/cefact/edifact/welcome.html +// and more readably here: https://en.wikipedia.org/wiki/EDIFACT +// This code is subject to the same license terms as the rest of the scintilla project: +// The License.txt file describes the conditions under which this software may be distributed. +// + +// Header order must match order in scripts/HeaderOrder.txt +#include <cstdlib> +#include <cassert> +#include <cstring> +#include <cctype> + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "LexAccessor.h" +#include "LexerModule.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +class LexerEDIFACT : public ILexer +{ +public: + LexerEDIFACT(); + virtual ~LexerEDIFACT() {} // virtual destructor, as we inherit from ILexer + + static ILexer *Factory() { + return new LexerEDIFACT; + } + + virtual int SCI_METHOD Version() const + { + return lvOriginal; + } + virtual void SCI_METHOD Release() + { + delete this; + } + + const char * SCI_METHOD PropertyNames() + { + return "fold"; + } + int SCI_METHOD PropertyType(const char *) + { + return SC_TYPE_BOOLEAN; // Only one property! + } + const char * SCI_METHOD DescribeProperty(const char *name) + { + if (strcmp(name, "fold")) + return NULL; + return "Whether to apply folding to document or not"; + } + + virtual Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) + { + if (strcmp(key, "fold")) + return -1; + m_bFold = strcmp(val, "0") ? true : false; + return 0; + } + const char * SCI_METHOD DescribeWordListSets() + { + return NULL; + } + virtual Sci_Position SCI_METHOD WordListSet(int, const char *) + { + return -1; + } + virtual void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess); + virtual void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess); + virtual void * SCI_METHOD PrivateCall(int, void *) + { + return NULL; + } + +protected: + Sci_Position InitialiseFromUNA(IDocument *pAccess, Sci_PositionU MaxLength); + Sci_Position FindPreviousEnd(IDocument *pAccess, Sci_Position startPos) const; + Sci_Position ForwardPastWhitespace(IDocument *pAccess, Sci_Position startPos, Sci_Position MaxLength) const; + int DetectSegmentHeader(char SegmentHeader[3]) const; + + bool m_bFold; + char m_chComponent; + char m_chData; + char m_chDecimal; + char m_chRelease; + char m_chSegment; +}; + +LexerModule lmEDIFACT(SCLEX_EDIFACT, LexerEDIFACT::Factory, "edifact"); + +/////////////////////////////////////////////////////////////////////////////// + + + +/////////////////////////////////////////////////////////////////////////////// + +LexerEDIFACT::LexerEDIFACT() +{ + m_bFold = false; + m_chComponent = ':'; + m_chData = '+'; + m_chDecimal = '.'; + m_chRelease = '?'; + m_chSegment = '\''; +} + +void LexerEDIFACT::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int, IDocument *pAccess) +{ + Sci_PositionU posFinish = startPos + lengthDoc; + InitialiseFromUNA(pAccess, posFinish); + + // Look backwards for a ' or a document beginning + Sci_PositionU posCurrent = FindPreviousEnd(pAccess, startPos); + // And jump past the ' if this was not the beginning of the document + if (posCurrent != 0) + posCurrent++; + + // Style buffer, so we're not issuing loads of notifications + LexAccessor styler (pAccess); + pAccess->StartStyling(posCurrent, '\377'); + styler.StartSegment(posCurrent); + Sci_Position posSegmentStart = -1; + + while ((posCurrent < posFinish) && (posSegmentStart == -1)) + { + posCurrent = ForwardPastWhitespace(pAccess, posCurrent, posFinish); + // Mark whitespace as default + styler.ColourTo(posCurrent - 1, SCE_EDI_DEFAULT); + if (posCurrent >= posFinish) + break; + + // Does is start with 3 charaters? ie, UNH + char SegmentHeader[4] = { 0 }; + pAccess->GetCharRange(SegmentHeader, posCurrent, 3); + + int SegmentStyle = DetectSegmentHeader(SegmentHeader); + if (SegmentStyle == SCE_EDI_BADSEGMENT) + break; + if (SegmentStyle == SCE_EDI_UNA) + { + posCurrent += 9; + styler.ColourTo(posCurrent - 1, SCE_EDI_UNA); // UNA + continue; + } + posSegmentStart = posCurrent; + posCurrent += 3; + + styler.ColourTo(posCurrent - 1, SegmentStyle); // UNH etc + + // Colour in the rest of the segment + for (char c; posCurrent < posFinish; posCurrent++) + { + pAccess->GetCharRange(&c, posCurrent, 1); + + if (c == m_chRelease) // ? escape character, check first, in case of ?' + posCurrent++; + else if (c == m_chSegment) // ' + { + // Make sure the whole segment is on one line. styler won't let us go back in time, so we'll settle for marking the ' as bad. + Sci_Position lineSegmentStart = pAccess->LineFromPosition(posSegmentStart); + Sci_Position lineSegmentEnd = pAccess->LineFromPosition(posCurrent); + if (lineSegmentStart == lineSegmentEnd) + styler.ColourTo(posCurrent, SCE_EDI_SEGMENTEND); + else + styler.ColourTo(posCurrent, SCE_EDI_BADSEGMENT); + posSegmentStart = -1; + posCurrent++; + break; + } + else if (c == m_chComponent) // : + styler.ColourTo(posCurrent, SCE_EDI_SEP_COMPOSITE); + else if (c == m_chData) // + + styler.ColourTo(posCurrent, SCE_EDI_SEP_ELEMENT); + else + styler.ColourTo(posCurrent, SCE_EDI_DEFAULT); + } + } + styler.Flush(); + + if (posSegmentStart == -1) + return; + + pAccess->StartStyling(posSegmentStart, -1); + pAccess->SetStyleFor(posFinish - posSegmentStart, SCE_EDI_BADSEGMENT); +} + +void LexerEDIFACT::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int, IDocument *pAccess) +{ + if (!m_bFold) + return; + + // Fold at UNx lines. ie, UNx segments = 0, other segments = 1. + // There's no sub folding, so we can be quite simple. + Sci_Position endPos = startPos + lengthDoc; + char SegmentHeader[4] = { 0 }; + + int iIndentPrevious = 0; + Sci_Position lineLast = pAccess->LineFromPosition(endPos); + + for (Sci_Position lineCurrent = pAccess->LineFromPosition(startPos); lineCurrent <= lineLast; lineCurrent++) + { + Sci_Position posLineStart = pAccess->LineStart(lineCurrent); + posLineStart = ForwardPastWhitespace(pAccess, posLineStart, endPos); + Sci_Position lineDataStart = pAccess->LineFromPosition(posLineStart); + // Fill in whitespace lines? + for (; lineCurrent < lineDataStart; lineCurrent++) + pAccess->SetLevel(lineCurrent, SC_FOLDLEVELBASE | SC_FOLDLEVELWHITEFLAG | iIndentPrevious); + pAccess->GetCharRange(SegmentHeader, posLineStart, 3); + //if (DetectSegmentHeader(SegmentHeader) == SCE_EDI_BADSEGMENT) // Abort if this is not a proper segment header + + int level = 0; + if (memcmp(SegmentHeader, "UNH", 3) == 0) // UNH starts blocks + level = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + // Check for UNA,B and Z. All others are inside messages + else if (!memcmp(SegmentHeader, "UNA", 3) || !memcmp(SegmentHeader, "UNB", 3) || !memcmp(SegmentHeader, "UNZ", 3)) + level = SC_FOLDLEVELBASE; + else + level = SC_FOLDLEVELBASE | 1; + pAccess->SetLevel(lineCurrent, level); + iIndentPrevious = level & SC_FOLDLEVELNUMBERMASK; + } +} + +Sci_Position LexerEDIFACT::InitialiseFromUNA(IDocument *pAccess, Sci_PositionU MaxLength) +{ + MaxLength -= 9; // drop 9 chars, to give us room for UNA:+.? ' + + Sci_PositionU startPos = 0; + startPos += ForwardPastWhitespace(pAccess, 0, MaxLength); + if (startPos < MaxLength) + { + char bufUNA[9]; + pAccess->GetCharRange(bufUNA, startPos, 9); + + // Check it's UNA segment + if (!memcmp(bufUNA, "UNA", 3)) + { + m_chComponent = bufUNA[3]; + m_chData = bufUNA[4]; + m_chDecimal = bufUNA[5]; + m_chRelease = bufUNA[6]; + // bufUNA [7] should be space - reserved. + m_chSegment = bufUNA[8]; + + return 0; // success! + } + } + + // We failed to find a UNA, so drop to defaults + m_chComponent = ':'; + m_chData = '+'; + m_chDecimal = '.'; + m_chRelease = '?'; + m_chSegment = '\''; + + return -1; +} + +Sci_Position LexerEDIFACT::ForwardPastWhitespace(IDocument *pAccess, Sci_Position startPos, Sci_Position MaxLength) const +{ + char c; + + while (startPos < MaxLength) + { + pAccess->GetCharRange(&c, startPos, 1); + switch (c) + { + case '\t': + case '\r': + case '\n': + case ' ': + break; + default: + return startPos; + } + + startPos++; + } + + return MaxLength; +} + +int LexerEDIFACT::DetectSegmentHeader(char SegmentHeader[3]) const +{ + if ( + SegmentHeader[0] < 'A' || SegmentHeader[0] > 'Z' || + SegmentHeader[1] < 'A' || SegmentHeader[1] > 'Z' || + SegmentHeader[2] < 'A' || SegmentHeader[2] > 'Z') + return SCE_EDI_BADSEGMENT; + + if (memcmp(SegmentHeader, "UNA", 3) == 0) + return SCE_EDI_UNA; + if (memcmp(SegmentHeader, "UNH", 3) == 0) + return SCE_EDI_UNH; + + return SCE_EDI_SEGMENTSTART; +} + +// Look backwards for a ' or a document beginning +Sci_Position LexerEDIFACT::FindPreviousEnd(IDocument *pAccess, Sci_Position startPos) const +{ + for (char c; startPos > 0; startPos--) + { + pAccess->GetCharRange(&c, startPos, 1); + if (c == m_chSegment) + return startPos; + } + // We didn't find a ', so just go with the beginning + return 0; +} + + diff --git a/scintilla/lexers/LexMatlab.cxx b/scintilla/lexers/LexMatlab.cxx index f20f732..e8e2860 100644 --- a/scintilla/lexers/LexMatlab.cxx +++ b/scintilla/lexers/LexMatlab.cxx @@ -15,6 +15,9 @@ **
** Changes by John Donoghue 2014/08/01
** - fix allowed transpose ' after {} operator
+ **
+ ** Changes by John Donoghue 2016/11/15
+ ** - update matlab code folding
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
@@ -49,14 +52,28 @@ static bool IsOctaveCommentChar(int c) { return (c == '%' || c == '#') ;
}
-static bool IsMatlabComment(Accessor &styler, Sci_Position pos, Sci_Position len) {
- return len > 0 && IsMatlabCommentChar(styler[pos]) ;
+static inline int LowerCase(int c) {
+ if (c >= 'A' && c <= 'Z')
+ return 'a' + c - 'A';
+ return c;
}
-static bool IsOctaveComment(Accessor &styler, Sci_Position pos, Sci_Position len) {
- return len > 0 && IsOctaveCommentChar(styler[pos]) ;
+static int CheckKeywordFoldPoint(char *str) {
+ if (strcmp ("if", str) == 0 ||
+ strcmp ("for", str) == 0 ||
+ strcmp ("switch", str) == 0 ||
+ strcmp ("try", str) == 0 ||
+ strcmp ("do", str) == 0 ||
+ strcmp ("parfor", str) == 0 ||
+ strcmp ("function", str) == 0)
+ return 1;
+ if (strncmp("end", str, 3) == 0 ||
+ strcmp("until", str) == 0)
+ return -1;
+ return 0;
}
+
static void ColouriseMatlabOctaveDoc(
Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList *keywordlists[], Accessor &styler,
@@ -245,58 +262,82 @@ static void ColouriseOctaveDoc(Sci_PositionU startPos, Sci_Position length, int ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar, false);
}
-static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int,
+static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList *[], Accessor &styler,
- bool (*IsComment)(Accessor&, Sci_Position, Sci_Position)) {
-
- Sci_Position endPos = startPos + length;
+ bool (*IsComment)(int ch)) {
- // Backtrack to previous line in case need to fix its fold status
+ Sci_PositionU endPos = startPos + length;
+ int visibleChars = 0;
Sci_Position lineCurrent = styler.GetLine(startPos);
- if (startPos > 0) {
- if (lineCurrent > 0) {
- lineCurrent--;
- startPos = styler.LineStart(lineCurrent);
- }
- }
- int spaceFlags = 0;
- int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsComment);
+ int levelCurrent = SC_FOLDLEVELBASE;
+ if (lineCurrent > 0)
+ levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+ int levelNext = levelCurrent;
char chNext = styler[startPos];
- for (Sci_Position i = startPos; i < endPos; i++) {
+ int styleNext = styler.StyleAt(startPos);
+ int style = initStyle;
+ char word[100];
+ int wordlen = 0;
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
-
- if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) {
- int lev = indentCurrent;
- int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsComment);
- if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
- // Only non whitespace lines can be headers
- if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
- lev |= SC_FOLDLEVELHEADERFLAG;
- } else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
- // Line after is blank so check the next - maybe should continue further?
- int spaceFlags2 = 0;
- int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsComment);
- if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
- lev |= SC_FOLDLEVELHEADERFLAG;
- }
- }
+ style = styleNext;
+ styleNext = styler.StyleAt(i + 1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+ // a line that starts with a comment
+ if (style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) {
+ // start/end of block comment
+ if (chNext == '{')
+ levelNext ++;
+ if (chNext == '}')
+ levelNext --;
+ }
+ // keyword
+ if(style == SCE_MATLAB_KEYWORD) {
+ word[wordlen++] = static_cast<char>(LowerCase(ch));
+ if (wordlen == 100) { // prevent overflow
+ word[0] = '\0';
+ wordlen = 1;
+ }
+ if (styleNext != SCE_MATLAB_KEYWORD) {
+ word[wordlen] = '\0';
+ wordlen = 0;
+
+ levelNext += CheckKeywordFoldPoint(word);
+ }
+ }
+ if (!IsASpace(ch))
+ visibleChars++;
+ if (atEOL || (i == endPos-1)) {
+ int levelUse = levelCurrent;
+ int lev = levelUse | levelNext << 16;
+ if (visibleChars == 0)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if (levelUse < levelNext)
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
}
- indentCurrent = indentNext;
- styler.SetLevel(lineCurrent, lev);
lineCurrent++;
+ levelCurrent = levelNext;
+ if (atEOL && (i == static_cast<Sci_PositionU>(styler.Length() - 1))) {
+ // There is an empty line at end of file so give it same level and empty
+ styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG);
+ }
+ visibleChars = 0;
}
}
}
static void FoldMatlabDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
- FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabComment);
+ FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar);
}
static void FoldOctaveDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
- FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveComment);
+ FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar);
}
static const char * const matlabWordListDesc[] = {
diff --git a/scintilla/lexers/LexPerl.cxx b/scintilla/lexers/LexPerl.cxx index 4e020cc..b02438b 100644 --- a/scintilla/lexers/LexPerl.cxx +++ b/scintilla/lexers/LexPerl.cxx @@ -755,7 +755,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int backPos++;
}
- StyleContext sc(startPos, endPos - startPos, initStyle, styler, static_cast<char>(STYLE_MAX));
+ StyleContext sc(startPos, endPos - startPos, initStyle, styler);
for (; sc.More(); sc.Forward()) {
diff --git a/scintilla/lexers/LexYAML.cxx b/scintilla/lexers/LexYAML.cxx index 7a948f7..a01148c 100644 --- a/scintilla/lexers/LexYAML.cxx +++ b/scintilla/lexers/LexYAML.cxx @@ -55,7 +55,7 @@ static bool KeywordAtChar(char* lineBuffer, char* startComment, const WordList & char* endValue = startComment - 1;
while (endValue >= lineBuffer && *endValue == ' ')
endValue--;
- Sci_PositionU len = endValue - lineBuffer + 1;
+ Sci_PositionU len = static_cast<Sci_PositionU>(endValue - lineBuffer) + 1;
char s[100];
if (len > (sizeof(s) / sizeof(s[0]) - 1))
return false;
diff --git a/scintilla/lexlib/LexerModule.h b/scintilla/lexlib/LexerModule.h index 665e0f9..53c0810 100644 --- a/scintilla/lexlib/LexerModule.h +++ b/scintilla/lexlib/LexerModule.h @@ -67,7 +67,7 @@ inline int Maximum(int a, int b) { // Shut up annoying Visual C++ warnings:
#ifdef _MSC_VER
-#pragma warning(disable: 4244 4309 4456 4457)
+#pragma warning(disable: 4244 4456 4457)
#endif
// Turn off shadow warnings for lexers as may be maintained by others
diff --git a/scintilla/scripts/HeaderCheck.py b/scintilla/scripts/HeaderCheck.py index 6916fe3..e36ffa1 100644 --- a/scintilla/scripts/HeaderCheck.py +++ b/scintilla/scripts/HeaderCheck.py @@ -32,7 +32,8 @@ def ExtractHeaders(filename): def CheckFiles(root): # Find all the lexer source code files - filePaths = glob.glob(root + "/src/*.cxx") + filePaths = glob.glob(root + "/include/*.h") + filePaths += glob.glob(root + "/src/*.cxx") SortListInsensitive(filePaths) filePaths += glob.glob(root + "/lexlib/*.cxx") filePaths += glob.glob(root + "/lexers/*.cxx") diff --git a/scintilla/scripts/HeaderOrder.txt b/scintilla/scripts/HeaderOrder.txt index fdbb3a1..98efd30 100644 --- a/scintilla/scripts/HeaderOrder.txt +++ b/scintilla/scripts/HeaderOrder.txt @@ -5,6 +5,7 @@ // C standard library #include <stddef.h> #include <stdlib.h> +#include <stdint.h> #include <string.h> #include <stdio.h> #include <stdarg.h> @@ -70,6 +71,7 @@ // include #include "Platform.h" +#include "Sci_Position.h" #include "ILexer.h" #include "Scintilla.h" #include "ScintillaWidget.h" diff --git a/scintilla/src/CaseConvert.cxx b/scintilla/src/CaseConvert.cxx index b4c8bcf..66185ba 100644 --- a/scintilla/src/CaseConvert.cxx +++ b/scintilla/src/CaseConvert.cxx @@ -11,6 +11,7 @@ #include <cstring>
#include <stdexcept>
+#include <string>
#include <vector>
#include <algorithm>
@@ -630,6 +631,14 @@ size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixe return pCaseConv->CaseConvertString(converted, sizeConverted, mixed, lenMixed);
}
+std::string CaseConvertString(const std::string &s, enum CaseConversion conversion) {
+ std::string retMapped(s.length() * maxExpansionCaseConversion, 0);
+ size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),
+ conversion);
+ retMapped.resize(lenMapped);
+ return retMapped;
+}
+
#ifdef SCI_NAMESPACE
}
#endif
diff --git a/scintilla/src/CaseConvert.h b/scintilla/src/CaseConvert.h index 60de227..7a01003 100644 --- a/scintilla/src/CaseConvert.h +++ b/scintilla/src/CaseConvert.h @@ -40,6 +40,9 @@ const int maxExpansionCaseConversion=3; // If there is not enough space then 0 is returned. size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed, enum CaseConversion conversion); +// Converts a mixed case string using a particular conversion. +std::string CaseConvertString(const std::string &s, enum CaseConversion conversion); + #ifdef SCI_NAMESPACE } #endif diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx index 0c1e22c..560720d 100644 --- a/scintilla/src/Catalogue.cxx +++ b/scintilla/src/Catalogue.cxx @@ -111,6 +111,7 @@ int Scintilla_LinkLexers() { //LINK_LEXER(lmDMAP);
//LINK_LEXER(lmDMIS);
//LINK_LEXER(lmECL);
+ //LINK_LEXER(lmEDIFACT);
//LINK_LEXER(lmEiffel);
//LINK_LEXER(lmEiffelkw);
//LINK_LEXER(lmErlang);
diff --git a/scintilla/src/CellBuffer.h b/scintilla/src/CellBuffer.h index a515202..323ddfe 100644 --- a/scintilla/src/CellBuffer.h +++ b/scintilla/src/CellBuffer.h @@ -47,22 +47,6 @@ public: int LineStart(int line) const {
return starts.PositionFromPartition(line);
}
-
- int MarkValue(int line);
- int AddMark(int line, int marker);
- void MergeMarkers(int pos);
- void DeleteMark(int line, int markerNum, bool all);
- void DeleteMarkFromHandle(int markerHandle);
- int LineFromHandle(int markerHandle);
-
- void ClearLevels();
- int SetLevel(int line, int level);
- int GetLevel(int line);
-
- int SetLineState(int line, int state);
- int GetLineState(int line);
- int GetMaxLineState();
-
};
enum actionType { insertAction, removeAction, startAction, containerAction };
diff --git a/scintilla/src/ContractionState.cxx b/scintilla/src/ContractionState.cxx index bd2d120..289e669 100644 --- a/scintilla/src/ContractionState.cxx +++ b/scintilla/src/ContractionState.cxx @@ -6,6 +6,7 @@ // The License.txt file describes the conditions under which this software may be distributed.
#include <string.h>
+#include <assert.h>
#include <stdexcept>
#include <algorithm>
@@ -16,13 +17,14 @@ #include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
+#include "SparseVector.h"
#include "ContractionState.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
-ContractionState::ContractionState() : visible(0), expanded(0), heights(0), displayLines(0), linesInDocument(1) {
+ContractionState::ContractionState() : visible(0), expanded(0), heights(0), foldDisplayTexts(0), displayLines(0), linesInDocument(1) {
//InsertLine(0);
}
@@ -35,6 +37,7 @@ void ContractionState::EnsureData() { visible = new RunStyles();
expanded = new RunStyles();
heights = new RunStyles();
+ foldDisplayTexts = new SparseVector<const char *>();
displayLines = new Partitioning(4);
InsertLines(0, linesInDocument);
}
@@ -47,6 +50,8 @@ void ContractionState::Clear() { expanded = 0;
delete heights;
heights = 0;
+ delete foldDisplayTexts;
+ foldDisplayTexts = 0;
delete displayLines;
displayLines = 0;
linesInDocument = 1;
@@ -108,6 +113,8 @@ void ContractionState::InsertLine(int lineDoc) { expanded->SetValueAt(lineDoc, 1);
heights->InsertSpace(lineDoc, 1);
heights->SetValueAt(lineDoc, 1);
+ foldDisplayTexts->InsertSpace(lineDoc, 1);
+ foldDisplayTexts->SetValueAt(lineDoc, NULL);
int lineDisplay = DisplayFromDoc(lineDoc);
displayLines->InsertPartition(lineDoc, lineDisplay);
displayLines->InsertText(lineDoc, 1);
@@ -132,6 +139,7 @@ void ContractionState::DeleteLine(int lineDoc) { visible->DeleteRange(lineDoc, 1);
expanded->DeleteRange(lineDoc, 1);
heights->DeleteRange(lineDoc, 1);
+ foldDisplayTexts->DeletePosition(lineDoc);
}
}
@@ -184,6 +192,24 @@ bool ContractionState::HiddenLines() const { }
}
+const char *ContractionState::GetFoldDisplayText(int lineDoc) const {
+ Check();
+ return foldDisplayTexts->ValueAt(lineDoc);
+}
+
+bool ContractionState::SetFoldDisplayText(int lineDoc, const char *text) {
+ EnsureData();
+ const char *foldText = foldDisplayTexts->ValueAt(lineDoc);
+ if (!foldText || 0 != strcmp(text, foldText)) {
+ foldDisplayTexts->SetValueAt(lineDoc, text);
+ Check();
+ return true;
+ } else {
+ Check();
+ return false;
+ }
+}
+
bool ContractionState::GetExpanded(int lineDoc) const {
if (OneToOne()) {
return true;
@@ -209,6 +235,10 @@ bool ContractionState::SetExpanded(int lineDoc, bool isExpanded) { }
}
+bool ContractionState::GetFoldDisplayTextShown(int lineDoc) const {
+ return !GetExpanded(lineDoc) && GetFoldDisplayText(lineDoc);
+}
+
int ContractionState::ContractedNext(int lineDocStart) const {
if (OneToOne()) {
return -1;
diff --git a/scintilla/src/ContractionState.h b/scintilla/src/ContractionState.h index 70a3e4c..fe6886f 100644 --- a/scintilla/src/ContractionState.h +++ b/scintilla/src/ContractionState.h @@ -12,6 +12,9 @@ namespace Scintilla {
#endif
+template<class T>
+class SparseVector;
+
/**
*/
class ContractionState {
@@ -19,6 +22,7 @@ class ContractionState { RunStyles *visible;
RunStyles *expanded;
RunStyles *heights;
+ SparseVector<const char *> *foldDisplayTexts;
Partitioning *displayLines;
int linesInDocument;
@@ -51,8 +55,12 @@ public: bool SetVisible(int lineDocStart, int lineDocEnd, bool isVisible);
bool HiddenLines() const;
+ const char *GetFoldDisplayText(int lineDoc) const;
+ bool SetFoldDisplayText(int lineDoc, const char *text);
+
bool GetExpanded(int lineDoc) const;
bool SetExpanded(int lineDoc, bool isExpanded);
+ bool GetFoldDisplayTextShown(int lineDoc) const;
int ContractedNext(int lineDocStart) const;
int GetHeight(int lineDoc) const;
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index babf37b..6ad44d6 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -16,8 +16,16 @@ #include <vector>
#include <algorithm>
+#define NOEXCEPT
+
#ifndef NO_CXX11_REGEX
#include <regex>
+#if defined(__GLIBCXX__)
+// If using the GNU implementation of <regex> then have 'noexcept' so can use
+// when defining regex iterators to keep Clang analyze happy.
+#undef NOEXCEPT
+#define NOEXCEPT noexcept
+#endif
#endif
#include "Platform.h"
@@ -2570,7 +2578,7 @@ public: Position position;
ByteIterator(const Document *doc_ = 0, Position position_ = 0) : doc(doc_), position(position_) {
}
- ByteIterator(const ByteIterator &other) {
+ ByteIterator(const ByteIterator &other) NOEXCEPT {
doc = other.doc;
position = other.position;
}
@@ -2745,7 +2753,7 @@ class UTF8Iterator : public std::iterator<std::bidirectional_iterator_tag, wchar public:
UTF8Iterator(const Document *doc_=0, Position position_=0) : doc(doc_), position(position_) {
}
- UTF8Iterator(const UTF8Iterator &other) {
+ UTF8Iterator(const UTF8Iterator &other) NOEXCEPT {
doc = other.doc;
position = other.position;
}
diff --git a/scintilla/src/EditModel.cxx b/scintilla/src/EditModel.cxx index 35903c6..0f64e07 100644 --- a/scintilla/src/EditModel.cxx +++ b/scintilla/src/EditModel.cxx @@ -65,6 +65,7 @@ EditModel::EditModel() { primarySelection = true; imeInteraction = imeWindowed; foldFlags = 0; + foldDisplayTextStyle = SC_FOLDDISPLAYTEXT_HIDDEN; hotspot = Range(invalidPosition); hoverIndicatorPos = invalidPosition; wrapWidth = LineLayout::wrapWidthInfinite; diff --git a/scintilla/src/EditModel.h b/scintilla/src/EditModel.h index 021bf67..847fd72 100644 --- a/scintilla/src/EditModel.h +++ b/scintilla/src/EditModel.h @@ -45,6 +45,7 @@ public: enum IMEInteraction { imeWindowed, imeInline } imeInteraction; int foldFlags; + int foldDisplayTextStyle; ContractionState cs; // Hotspot support Range hotspot; diff --git a/scintilla/src/EditView.cxx b/scintilla/src/EditView.cxx index e6cd8fc..8ffc1bc 100644 --- a/scintilla/src/EditView.cxx +++ b/scintilla/src/EditView.cxx @@ -306,21 +306,25 @@ static const char *ControlCharacterString(unsigned char ch) { } } -static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { - int ydiff = static_cast<int>(rcTab.bottom - rcTab.top) / 2; - int xhead = static_cast<int>(rcTab.right) - 1 - ydiff; - if (xhead <= rcTab.left) { - ydiff -= static_cast<int>(rcTab.left) - xhead - 1; - xhead = static_cast<int>(rcTab.left) - 1; - } +static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid, const ViewStyle &vsDraw) { if ((rcTab.left + 2) < (rcTab.right - 1)) surface->MoveTo(static_cast<int>(rcTab.left) + 2, ymid); else 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(static_cast<int>(rcTab.right) - 1, ymid); - surface->LineTo(xhead, ymid + ydiff); + + // Draw the arrow head if needed + if (vsDraw.tabDrawMode == tdLongArrow) { + int ydiff = static_cast<int>(rcTab.bottom - rcTab.top) / 2; + int xhead = static_cast<int>(rcTab.right) - 1 - ydiff; + if (xhead <= rcTab.left) { + ydiff -= static_cast<int>(rcTab.left) - xhead - 1; + xhead = static_cast<int>(rcTab.left) - 1; + } + surface->LineTo(xhead, ymid - ydiff); + surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid); + surface->LineTo(xhead, ymid + ydiff); + } } void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw) { @@ -596,19 +600,24 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co } } -Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine, const ViewStyle &vs) { +Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine, + const ViewStyle &vs, PointEnd pe) { Point pt; if (pos.Position() == INVALID_POSITION) return pt; - const int line = model.pdoc->LineFromPosition(pos.Position()); - const int lineVisible = model.cs.DisplayFromDoc(line); - //Platform::DebugPrintf("line=%d\n", line); - AutoLineLayout ll(llc, RetrieveLineLayout(line, model)); + int lineDoc = model.pdoc->LineFromPosition(pos.Position()); + int posLineStart = model.pdoc->LineStart(lineDoc); + if ((pe & peLineEnd) && (lineDoc > 0) && (pos.Position() == posLineStart)) { + // Want point at end of first line + lineDoc--; + posLineStart = model.pdoc->LineStart(lineDoc); + } + const int lineVisible = model.cs.DisplayFromDoc(lineDoc); + AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model)); if (surface && ll) { - const int posLineStart = model.pdoc->LineStart(line); - LayoutLine(model, line, surface, vs, ll, model.wrapWidth); + LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth); const int posInLine = pos.Position() - posLineStart; - pt = ll->PointFromPosition(posInLine, vs.lineHeight); + pt = ll->PointFromPosition(posInLine, vs.lineHeight, pe); pt.y += (lineVisible - topLine) * vs.lineHeight; pt.x += vs.textStart - model.xOffset; } @@ -616,6 +625,31 @@ Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, S return pt; } +Range EditView::RangeDisplayLine(Surface *surface, const EditModel &model, int lineVisible, const ViewStyle &vs) { + Range rangeSubLine = Range(0,0); + if (lineVisible < 0) { + return rangeSubLine; + } + const int lineDoc = model.cs.DocFromDisplay(lineVisible); + const int positionLineStart = model.pdoc->LineStart(lineDoc); + AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model)); + if (surface && ll) { + LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth); + const int lineStartSet = model.cs.DisplayFromDoc(lineDoc); + const int subLine = lineVisible - lineStartSet; + if (subLine < ll->lines) { + rangeSubLine = ll->SubLineRange(subLine); + if (subLine == ll->lines-1) { + rangeSubLine.end = model.pdoc->LineStart(lineDoc + 1) - + positionLineStart; + } + } + } + rangeSubLine.start += positionLineStart; + rangeSubLine.end += positionLineStart; + return rangeSubLine; +} + SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditModel &model, Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace, const ViewStyle &vs) { pt.x = pt.x - vs.textStart; int visibleLine = static_cast<int>(floor(pt.y / vs.lineHeight)); @@ -845,7 +879,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle int alpha = SC_ALPHA_NOALPHA; if (!hideSelection) { int posAfterLineEnd = model.pdoc->LineStart(line + 1); - eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0; + eolInSelection = (lastSubLine == true) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0; alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; } @@ -914,25 +948,15 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle } } - // Fill the remainder of the line rcSegment.left = rcSegment.right; if (rcSegment.left < rcLine.left) rcSegment.left = rcLine.left; rcSegment.right = rcLine.right; - if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { - surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection)); - } else { - if (background.isSet) { - surface->FillRectangle(rcSegment, background); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); - } else { - surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back); - } - if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { - SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection), alpha); - } + bool fillRemainder = !lastSubLine || model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_HIDDEN || !model.cs.GetFoldDisplayTextShown(line); + if (fillRemainder) { + // Fill the remainder of the line + FillLineRemainder(surface, model, vsDraw, ll, line, rcSegment, subLine); } bool drawWrapMarkEnd = false; @@ -963,14 +987,23 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle } static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw, - const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Indicator::DrawState drawState, int value) { + const LineLayout *ll, int xStart, PRectangle rcLine, int secondCharacter, int subLine, Indicator::DrawState drawState, int value) { const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; PRectangle rcIndic( ll->positions[startPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent, ll->positions[endPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent + 3); - vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, drawState, value); + PRectangle rcFirstCharacter = rcIndic; + // Allow full descent space for character indicators + rcFirstCharacter.bottom = rcLine.top + vsDraw.maxAscent + vsDraw.maxDescent; + if (secondCharacter >= 0) { + rcFirstCharacter.right = ll->positions[secondCharacter] + xStart - subLineStart; + } else { + // Indicator continued from earlier line so make an empty box and don't draw + rcFirstCharacter.right = rcFirstCharacter.left; + } + vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, rcFirstCharacter, drawState, value); } static void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, @@ -993,8 +1026,9 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS rangeRun.ContainsCharacter(hoverIndicatorPos); const int value = deco->rs.ValueAt(startPos); Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal; + const int posSecond = model.pdoc->MovePositionOutsideChar(rangeRun.First() + 1, 1); DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart, - surface, vsDraw, ll, xStart, rcLine, subLine, drawState, value); + surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, drawState, value); startPos = endPos; if (!deco->rs.ValueAt(startPos)) { startPos = deco->rs.EndRun(startPos); @@ -1012,19 +1046,110 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS if (rangeLine.ContainsCharacter(model.braces[0])) { int braceOffset = model.braces[0] - posLineStart; if (braceOffset < ll->numCharsInLine) { - DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1); + const int secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[0] + 1, 1) - posLineStart; + DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1); } } if (rangeLine.ContainsCharacter(model.braces[1])) { int braceOffset = model.braces[1] - posLineStart; if (braceOffset < ll->numCharsInLine) { - DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1); + const int secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[1] + 1, 1) - posLineStart; + DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1); } } } } } +void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + int line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase) { + const bool lastSubLine = subLine == (ll->lines - 1); + if (!lastSubLine) + return; + + if ((model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_HIDDEN) || !model.cs.GetFoldDisplayTextShown(line)) + return; + + PRectangle rcSegment = rcLine; + const char *foldDisplayText = model.cs.GetFoldDisplayText(line); + const int lengthFoldDisplayText = static_cast<int>(strlen(foldDisplayText)); + FontAlias fontText = vsDraw.styles[STYLE_FOLDDISPLAYTEXT].font; + const int widthFoldDisplayText = static_cast<int>(surface->WidthText(fontText, foldDisplayText, lengthFoldDisplayText)); + + int eolInSelection = 0; + int alpha = SC_ALPHA_NOALPHA; + if (!hideSelection) { + int posAfterLineEnd = model.pdoc->LineStart(line + 1); + eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0; + alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; + } + + const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; + XYPOSITION virtualSpace = model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line)) * spaceWidth; + rcSegment.left = xStart + static_cast<XYPOSITION>(ll->positions[ll->numCharsInLine] - subLineStart) + spaceWidth + virtualSpace; + rcSegment.right = rcSegment.left + static_cast<XYPOSITION>(widthFoldDisplayText); + + ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret); + FontAlias textFont = vsDraw.styles[STYLE_FOLDDISPLAYTEXT].font; + ColourDesired textFore = vsDraw.styles[STYLE_FOLDDISPLAYTEXT].fore; + if (eolInSelection && (vsDraw.selColours.fore.isSet)) { + textFore = (eolInSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground; + } + ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection, + false, STYLE_FOLDDISPLAYTEXT, -1); + + if (model.trackLineWidth) { + if (rcSegment.right + 1> lineWidthMaxSeen) { + // Fold display text border drawn on rcSegment.right with width 1 is the last visble object of the line + lineWidthMaxSeen = static_cast<int>(rcSegment.right + 1); + } + } + + if ((phasesDraw != phasesOne) && (phase & drawBack)) { + surface->FillRectangle(rcSegment, textBack); + + // Fill Remainder of the line + PRectangle rcRemainder = rcSegment; + rcRemainder.left = rcRemainder.right + 1; + if (rcRemainder.left < rcLine.left) + rcRemainder.left = rcLine.left; + rcRemainder.right = rcLine.right; + FillLineRemainder(surface, model, vsDraw, ll, line, rcRemainder, subLine); + } + + if (phase & drawText) { + if (phasesDraw != phasesOne) { + surface->DrawTextTransparent(rcSegment, textFont, + rcSegment.top + vsDraw.maxAscent, foldDisplayText, + lengthFoldDisplayText, textFore); + } else { + surface->DrawTextNoClip(rcSegment, textFont, + rcSegment.top + vsDraw.maxAscent, foldDisplayText, + lengthFoldDisplayText, textFore, textBack); + } + } + + if (phase & drawIndicatorsFore) { + if (model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_BOXED) { + surface->PenColour(textFore); + 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)); + surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top)); + surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.top)); + 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)); + } + } + + if (phase & drawSelectionTranslucent) { + if (eolInSelection && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && alpha != SC_ALPHA_NOALPHA) { + SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection), alpha); + } + } +} + static bool AnnotationBoxedOrIndented(int annotationVisible) { return annotationVisible == ANNOTATION_BOXED || annotationVisible == ANNOTATION_INDENTED; } @@ -1537,7 +1662,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); if (customDrawTabArrow == NULL) - DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2)); + DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2), vsDraw); else customDrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2)); } @@ -1743,6 +1868,8 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl xStart, subLine, subLineStart, background); } + DrawFoldDisplayText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, phase); + if (!hideSelection && (phase & drawSelectionTranslucent)) { DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart); } @@ -1878,7 +2005,8 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan ll->SetBracesHighlight(rangeLine, model.braces, static_cast<char>(model.bracesMatchStyle), static_cast<int>(model.highlightGuideColumn * vsDraw.spaceWidth), bracesIgnoreStyle); - if (leftTextOverlap && bufferedDraw) { + if (leftTextOverlap && (bufferedDraw || ((phasesDraw < phasesMultiple) && (*it & drawBack)))) { + // Clear the left margin PRectangle rcSpacer = rcLine; rcSpacer.right = rcSpacer.left; rcSpacer.left -= 1; @@ -1955,6 +2083,34 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan } } +void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + int line, PRectangle rcArea, int subLine) { + int eolInSelection = 0; + int alpha = SC_ALPHA_NOALPHA; + if (!hideSelection) { + int posAfterLineEnd = model.pdoc->LineStart(line + 1); + eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0; + alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; + } + + ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret); + + if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { + surface->FillRectangle(rcArea, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection)); + } else { + if (background.isSet) { + surface->FillRectangle(rcArea, background); + } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { + surface->FillRectangle(rcArea, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); + } else { + surface->FillRectangle(rcArea, vsDraw.styles[STYLE_DEFAULT].back); + } + if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { + SimpleAlphaRectangle(surface, rcArea, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection), alpha); + } + } +} + // Space (3 space characters) between line numbers and text when printing. #define lineNumberPrintSpace " " diff --git a/scintilla/src/EditView.h b/scintilla/src/EditView.h index 79a8865..83dd8bb 100644 --- a/scintilla/src/EditView.h +++ b/scintilla/src/EditView.h @@ -111,7 +111,9 @@ public: void LayoutLine(const EditModel &model, int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width = LineLayout::wrapWidthInfinite); - Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine, const ViewStyle &vs); + Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine, + const ViewStyle &vs, PointEnd pe); + Range RangeDisplayLine(Surface *surface, const EditModel &model, int lineVisible, const ViewStyle &vs); SelectionPosition SPositionFromLocation(Surface *surface, const EditModel &model, Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace, const ViewStyle &vs); SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, int lineDoc, int x, const ViewStyle &vs); @@ -122,6 +124,8 @@ public: void DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, ColourOptional background); + void DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + int line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase); void DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase); void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line, @@ -138,6 +142,8 @@ public: int lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase); void PaintText(Surface *surfaceWindow, const EditModel &model, PRectangle rcArea, PRectangle rcClient, const ViewStyle &vsDraw); + void FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + int line, PRectangle rcArea, int subLine); long FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, const EditModel &model, const ViewStyle &vs); }; diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index a19feba..5ee9721 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -363,14 +363,14 @@ SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const }
}
-Point Editor::LocationFromPosition(SelectionPosition pos) {
+Point Editor::LocationFromPosition(SelectionPosition pos, PointEnd pe) {
RefreshStyleData();
AutoSurface surface(this);
- return view.LocationFromPosition(surface, *this, pos, topLine, vs);
+ return view.LocationFromPosition(surface, *this, pos, topLine, vs, pe);
}
-Point Editor::LocationFromPosition(int pos) {
- return LocationFromPosition(SelectionPosition(pos));
+Point Editor::LocationFromPosition(int pos, PointEnd pe) {
+ return LocationFromPosition(SelectionPosition(pos), pe);
}
int Editor::XFromPosition(int pos) {
@@ -2424,13 +2424,7 @@ void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctr }
bool Editor::NotifyMarginClick(Point pt, int modifiers) {
- int marginClicked = -1;
- int x = vs.textStart - vs.fixedColumnWidth;
- for (size_t margin = 0; margin < vs.ms.size(); margin++) {
- if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width))
- marginClicked = static_cast<int>(margin);
- x += vs.ms[margin].width;
- }
+ const int marginClicked = vs.MarginFromLocation(pt);
if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) {
int position = pdoc->LineStart(LineFromLocation(pt));
if ((vs.ms[marginClicked].mask & SC_MASK_FOLDERS) && (foldAutomatic & SC_AUTOMATICFOLD_CLICK)) {
@@ -2471,6 +2465,22 @@ bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { return NotifyMarginClick(pt, ModifierFlags(shift, ctrl, alt));
}
+bool Editor::NotifyMarginRightClick(Point pt, int modifiers) {
+ int marginRightClicked = vs.MarginFromLocation(pt);
+ if ((marginRightClicked >= 0) && vs.ms[marginRightClicked].sensitive) {
+ int position = pdoc->LineStart(LineFromLocation(pt));
+ SCNotification scn = {};
+ scn.nmhdr.code = SCN_MARGINRIGHTCLICK;
+ scn.modifiers = modifiers;
+ scn.position = position;
+ scn.margin = marginRightClicked;
+ NotifyParent(scn);
+ return true;
+ } else {
+ return false;
+ }
+}
+
void Editor::NotifyNeedShown(int pos, int len) {
SCNotification scn = {};
scn.nmhdr.code = SCN_NEEDSHOWN;
@@ -3156,6 +3166,12 @@ void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) { } while (!cs.GetVisible(lineDoc));
}
+Range Editor::RangeDisplayLine(int lineVisible) {
+ RefreshStyleData();
+ AutoSurface surface(this);
+ return view.RangeDisplayLine(surface, *this, lineVisible, vs);
+}
+
int Editor::StartEndDisplayLine(int pos, bool start) {
RefreshStyleData();
AutoSurface surface(this);
@@ -3948,7 +3964,7 @@ CaseFolder *Editor::CaseFolderForEncoding() { long Editor::FindText(
uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
- sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range.
+ sptr_t lParam) { ///< @c Sci_TextToFind structure: The text to search for in the given range.
Sci_TextToFind *ft = reinterpret_cast<Sci_TextToFind *>(lParam);
int lengthFound = istrlen(ft->lpstrText);
@@ -4594,6 +4610,11 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie ShowCaretAtCurrentPosition();
}
+void Editor::RightButtonDownWithModifiers(Point pt, unsigned int, int modifiers) {
+ if (NotifyMarginRightClick(pt, modifiers))
+ return;
+}
+
void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
return ButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt));
}
@@ -5589,7 +5610,7 @@ void Editor::AddStyledText(char *buffer, int appendLength) { SetEmptySelection(sel.MainCaret() + lengthInserted);
}
-bool Editor::ValidMargin(uptr_t wParam) {
+bool Editor::ValidMargin(uptr_t wParam) const {
return wParam < vs.ms.size();
}
@@ -6304,6 +6325,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Redraw();
break;
+ case SCI_GETTABDRAWMODE:
+ return vs.tabDrawMode;
+
+ case SCI_SETTABDRAWMODE:
+ vs.tabDrawMode = static_cast<TabDrawMode>(wParam);
+ Redraw();
+ break;
+
case SCI_GETWHITESPACESIZE:
return vs.whitespaceSize;
@@ -6724,15 +6753,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETIMEINTERACTION:
return imeInteraction;
-#ifdef INCLUDE_DEPRECATED_FEATURES
- case SCI_SETUSEPALETTE:
- InvalidateStyleRedraw();
- break;
-
- case SCI_GETUSEPALETTE:
- return 0;
-#endif
-
// Marker definition and setting
case SCI_MARKERDEFINE:
if (wParam <= MARKER_MAX) {
@@ -7076,6 +7096,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Redraw();
break;
+ case SCI_TOGGLEFOLDSHOWTEXT:
+ cs.SetFoldDisplayText(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
+ FoldLine(static_cast<int>(wParam), SC_FOLDACTION_TOGGLE);
+ break;
+
+ case SCI_FOLDDISPLAYTEXTSETSTYLE:
+ foldDisplayTextStyle = static_cast<int>(wParam);
+ Redraw();
+ break;
+
case SCI_TOGGLEFOLD:
FoldLine(static_cast<int>(wParam), SC_FOLDACTION_TOGGLE);
break;
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index 74fc46f..16e6aaa 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -285,8 +285,8 @@ protected: // ScintillaBase subclass needs access to much of Editor int LinesToScroll() const;
int MaxScrollPos() const;
SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const;
- Point LocationFromPosition(SelectionPosition pos);
- Point LocationFromPosition(int pos);
+ Point LocationFromPosition(SelectionPosition pos, PointEnd pe=peDefault);
+ Point LocationFromPosition(int pos, PointEnd pe=peDefault);
int XFromPosition(int pos);
int XFromPosition(SelectionPosition sp);
SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true);
@@ -439,6 +439,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
bool NotifyMarginClick(Point pt, int modifiers);
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
+ bool NotifyMarginRightClick(Point pt, int modifiers);
void NotifyNeedShown(int pos, int len);
void NotifyDwelling(Point pt, bool state);
void NotifyZoom();
@@ -465,6 +466,7 @@ protected: // ScintillaBase subclass needs access to much of Editor SelectionPosition PositionUpOrDown(SelectionPosition spStart, int direction, int lastX);
void CursorUpOrDown(int direction, Selection::selTypes selt);
void ParaUpOrDown(int direction, Selection::selTypes selt);
+ Range RangeDisplayLine(int lineVisible);
int StartEndDisplayLine(int pos, bool start);
int VCHomeDisplayPosition(int position);
int VCHomeWrapPosition(int position);
@@ -507,6 +509,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void DwellEnd(bool mouseMoved);
void MouseLeave();
virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
+ virtual void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
void ButtonMoveWithModifiers(Point pt, int modifiers);
void ButtonMove(Point pt);
@@ -571,7 +574,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void AddStyledText(char *buffer, int appendLength);
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
- bool ValidMargin(uptr_t wParam);
+ bool ValidMargin(uptr_t wParam) const;
void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
diff --git a/scintilla/src/Indicator.cxx b/scintilla/src/Indicator.cxx index bae8130..3fa4588 100644 --- a/scintilla/src/Indicator.cxx +++ b/scintilla/src/Indicator.cxx @@ -24,7 +24,7 @@ static PRectangle PixelGridAlign(const PRectangle &rc) { return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom));
}
-void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const {
+void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const {
StyleAndColour sacDraw = sacNormal;
if (Flags() & SC_INDICFLAG_VALUEFORE) {
sacDraw.fore = value & SC_INDICVALUEMASK;
@@ -170,6 +170,19 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r } else if (sacDraw.style == INDIC_COMPOSITIONTHIN) {
PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1);
surface->FillRectangle(rcComposition, sacDraw.fore);
+ } else if (sacDraw.style == INDIC_POINT || sacDraw.style == INDIC_POINTCHARACTER) {
+ if (rcCharacter.Width() >= 0.1) {
+ const int pixelHeight = static_cast<int>(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase
+ const XYPOSITION x = (sacDraw.style == INDIC_POINT) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2);
+ const int ix = static_cast<int>(x + 0.5f);
+ const int iy = static_cast<int>(rc.top + 1.0f);
+ Point pts[] = {
+ Point::FromInts(ix - pixelHeight, iy + pixelHeight), // Left
+ Point::FromInts(ix + pixelHeight, iy + pixelHeight), // Right
+ Point::FromInts(ix, iy) // Top
+ };
+ surface->Polygon(pts, 3, sacDraw.fore, sacDraw.fore);
+ }
} else { // Either INDIC_PLAIN or unknown
surface->MoveTo(static_cast<int>(rc.left), ymid);
surface->LineTo(static_cast<int>(rc.right), ymid);
diff --git a/scintilla/src/Indicator.h b/scintilla/src/Indicator.h index d6f88ba..72c935a 100644 --- a/scintilla/src/Indicator.h +++ b/scintilla/src/Indicator.h @@ -40,7 +40,7 @@ public: Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) :
sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(0) {
}
- void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const;
+ void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const;
bool IsDynamic() const {
return !(sacNormal == sacHover);
}
diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx index c9cf637..66b634a 100644 --- a/scintilla/src/PositionCache.cxx +++ b/scintilla/src/PositionCache.cxx @@ -217,7 +217,7 @@ int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) return range.end;
}
-Point LineLayout::PointFromPosition(int posInLine, int lineHeight) const {
+Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const {
Point pt;
// In case of very long line put x at arbitrary large position
if (posInLine > maxLineLength) {
@@ -232,6 +232,12 @@ Point LineLayout::PointFromPosition(int posInLine, int lineHeight) const { pt.x = positions[posInLine] - positions[rangeSubLine.start];
if (rangeSubLine.start != 0) // Wrapped lines may be indented
pt.x += wrapIndent;
+ if (pe & peSubLineEnd) // Return end of first subline not start of next
+ break;
+ } else if ((pe & peLineEnd) && (subLine == (lines-1))) {
+ pt.x = positions[numCharsInLine] - positions[rangeSubLine.start];
+ if (rangeSubLine.start != 0) // Wrapped lines may be indented
+ pt.x += wrapIndent;
}
} else {
break;
diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h index 2c4443c..e5b8e8d 100644 --- a/scintilla/src/PositionCache.h +++ b/scintilla/src/PositionCache.h @@ -16,6 +16,15 @@ static inline bool IsEOLChar(char ch) { return (ch == '\r') || (ch == '\n');
}
+// There are two points for some positions and this enumeration
+// can choose between the end of the first line or subline
+// and the start of the next line or subline.
+enum PointEnd {
+ peDefault = 0x0,
+ peLineEnd = 0x1,
+ peSubLineEnd = 0x2
+};
+
/**
*/
class LineLayout {
@@ -28,6 +37,7 @@ private: bool inCache;
public:
enum { wrapWidthInfinite = 0x7ffffff };
+
int maxLineLength;
int numCharsInLine;
int numCharsBeforeEOL;
@@ -64,7 +74,7 @@ public: void RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle);
int FindBefore(XYPOSITION x, int lower, int upper) const;
int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const;
- Point PointFromPosition(int posInLine, int lineHeight) const;
+ Point PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const;
int EndLineStyle() const;
};
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx index ef9aeb0..df899a7 100644 --- a/scintilla/src/ScintillaBase.cxx +++ b/scintilla/src/ScintillaBase.cxx @@ -64,7 +64,7 @@ using namespace Scintilla; #endif
ScintillaBase::ScintillaBase() {
- displayPopupMenu = true;
+ displayPopupMenu = SC_POPUP_ALL;
listType = 0;
maxListWidth = 0;
multiAutoCMode = SC_MULTIAUTOC_ONCE;
@@ -478,6 +478,11 @@ void ScintillaBase::CallTipClick() { NotifyParent(scn);
}
+bool ScintillaBase::ShouldDisplayPopup(Point ptInWindowCoordinates) const {
+ return (displayPopupMenu == SC_POPUP_ALL ||
+ (displayPopupMenu == SC_POPUP_TEXT && !PointInSelMargin(ptInWindowCoordinates)));
+}
+
void ScintillaBase::ContextMenu(Point pt) {
if (displayPopupMenu) {
bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
@@ -510,6 +515,11 @@ void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt));
}
+void ScintillaBase::RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) {
+ CancelModes();
+ Editor::RightButtonDownWithModifiers(pt, curTime, modifiers);
+}
+
#ifdef SCI_LEXER
#ifdef SCI_NAMESPACE
@@ -970,7 +980,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara break;
case SCI_USEPOPUP:
- displayPopupMenu = wParam != 0;
+ displayPopupMenu = static_cast<int>(wParam);
break;
#ifdef SCI_LEXER
diff --git a/scintilla/src/ScintillaBase.h b/scintilla/src/ScintillaBase.h index e2eb7f1..31b1cc8 100644 --- a/scintilla/src/ScintillaBase.h +++ b/scintilla/src/ScintillaBase.h @@ -40,7 +40,7 @@ protected: enum { maxLenInputIME = 200 };
- bool displayPopupMenu;
+ int displayPopupMenu;
Menu popup;
AutoComplete ac;
@@ -84,10 +84,12 @@ protected: virtual void CreateCallTipWindow(PRectangle rc) = 0;
virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0;
+ bool ShouldDisplayPopup(Point ptInWindowCoordinates) const;
void ContextMenu(Point pt);
virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
+ virtual void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
void NotifyStyleToNeeded(int endStyleNeeded);
void NotifyLexerChanged(Document *doc, void *userData);
diff --git a/scintilla/src/SparseVector.h b/scintilla/src/SparseVector.h new file mode 100644 index 0000000..f96b36b --- /dev/null +++ b/scintilla/src/SparseVector.h @@ -0,0 +1,186 @@ +// Scintilla source code edit control +/** @file SparseVector.h + ** Hold data sparsely associated with elements in a range. + **/ +// Copyright 2016 by Neil Hodgson <neilh@scintilla.org> +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef SPARSEVECTOR_H +#define SPARSEVECTOR_H + +#ifdef SCI_NAMESPACE +namespace Scintilla { +#endif + +// SparseVector is similar to RunStyles but is more efficient for cases where values occur +// for one position instead of over a range of positions. +template <typename T> +class SparseVector { +private: + Partitioning *starts; + SplitVector<T> *values; + // Private so SparseVector objects can not be copied + SparseVector(const SparseVector &); + void ClearValue(int partition) { + values->SetValueAt(partition, T()); + } + void CommonSetValueAt(int position, T value) { + // Do the work of setting the value to allow for specialization of SetValueAt. + assert(position < Length()); + const int partition = starts->PartitionFromPosition(position); + const int startPartition = starts->PositionFromPartition(partition); + if (value == T()) { + // Setting the empty value is equivalent to deleting the position + if (position == 0) { + ClearValue(partition); + } else if (position == startPartition) { + // Currently an element at this position, so remove + ClearValue(partition); + starts->RemovePartition(partition); + values->Delete(partition); + } + // Else element remains empty + } else { + if (position == startPartition) { + // Already a value at this position, so replace + ClearValue(partition); + values->SetValueAt(partition, value); + } else { + // Insert a new element + starts->InsertPartition(partition + 1, position); + values->InsertValue(partition + 1, 1, value); + } + } + } +public: + SparseVector() { + starts = new Partitioning(8); + values = new SplitVector<T>(); + values->InsertValue(0, 2, T()); + } + ~SparseVector() { + delete starts; + starts = NULL; + // starts dead here but not used by ClearValue. + for (int part = 0; part < values->Length(); part++) { + ClearValue(part); + } + delete values; + values = NULL; + } + int Length() const { + return starts->PositionFromPartition(starts->Partitions()); + } + int Elements() const { + return starts->Partitions(); + } + int PositionOfElement(int element) const { + return starts->PositionFromPartition(element); + } + T ValueAt(int position) const { + assert(position < Length()); + const int partition = starts->PartitionFromPosition(position); + const int startPartition = starts->PositionFromPartition(partition); + if (startPartition == position) { + return values->ValueAt(partition); + } else { + return T(); + } + } + void SetValueAt(int position, T value) { + CommonSetValueAt(position, value); + } + void InsertSpace(int position, int insertLength) { + assert(position <= Length()); // Only operation that works at end. + const int partition = starts->PartitionFromPosition(position); + const int startPartition = starts->PositionFromPartition(partition); + if (startPartition == position) { + T valueCurrent = values->ValueAt(partition); + // Inserting at start of run so make previous longer + if (partition == 0) { + // Inserting at start of document so ensure 0 + if (valueCurrent != T()) { + ClearValue(0); + starts->InsertPartition(1, 0); + values->InsertValue(1, 1, valueCurrent); + starts->InsertText(0, insertLength); + } else { + starts->InsertText(partition, insertLength); + } + } else { + if (valueCurrent != T()) { + starts->InsertText(partition - 1, insertLength); + } else { + // Insert at end of run so do not extend style + starts->InsertText(partition, insertLength); + } + } + } else { + starts->InsertText(partition, insertLength); + } + } + void DeletePosition(int position) { + assert(position < Length()); + int partition = starts->PartitionFromPosition(position); + const int startPartition = starts->PositionFromPartition(partition); + if (startPartition == position) { + if (partition == 0) { + ClearValue(0); + } else if (partition == starts->Partitions()) { + // This should not be possible + ClearValue(partition); + throw std::runtime_error("SparseVector: deleting end partition."); + } else { + ClearValue(partition); + starts->RemovePartition(partition); + values->Delete(partition); + // Its the previous partition now that gets smaller + partition--; + } + } + starts->InsertText(partition, -1); + } + void Check() const { + if (Length() < 0) { + throw std::runtime_error("SparseVector: Length can not be negative."); + } + if (starts->Partitions() < 1) { + throw std::runtime_error("SparseVector: Must always have 1 or more partitions."); + } + if (starts->Partitions() != values->Length() - 1) { + throw std::runtime_error("SparseVector: Partitions and values different lengths."); + } + // The final element can not be set + if (values->ValueAt(values->Length() - 1) != T()) { + throw std::runtime_error("SparseVector: Unused style at end changed."); + } + } +}; + +// The specialization for const char * makes copies and deletes them as needed. + +template<> +inline void SparseVector<const char *>::ClearValue(int partition) { + const char *value = values->ValueAt(partition); + delete []value; + values->SetValueAt(partition, NULL); +} + +template<> +inline void SparseVector<const char *>::SetValueAt(int position, const char *value) { + // Make a copy of the string + if (value) { + const size_t len = strlen(value); + char *valueCopy = new char[len + 1](); + std::copy(value, value + len, valueCopy); + CommonSetValueAt(position, valueCopy); + } else { + CommonSetValueAt(position, NULL); + } +} + +#ifdef SCI_NAMESPACE +} +#endif + +#endif diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index 0f026c4..292c888 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -153,6 +153,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) { textStart = source.textStart;
zoomLevel = source.zoomLevel;
viewWhitespace = source.viewWhitespace;
+ tabDrawMode = source.tabDrawMode;
whitespaceSize = source.whitespaceSize;
viewIndentationGuides = source.viewIndentationGuides;
viewEOL = source.viewEOL;
@@ -293,6 +294,7 @@ void ViewStyle::Init(size_t stylesSize_) { textStart = marginInside ? fixedColumnWidth : leftMarginWidth;
zoomLevel = 0;
viewWhitespace = wsInvisible;
+ tabDrawMode = tdLongArrow;
whitespaceSize = 1;
viewIndentationGuides = ivNone;
viewEOL = false;
@@ -445,6 +447,17 @@ int ViewStyle::ExternalMarginWidth() const { return marginInside ? 0 : fixedColumnWidth;
}
+int ViewStyle::MarginFromLocation(Point pt) const {
+ int margin = -1;
+ int x = textStart - fixedColumnWidth;
+ for (size_t i = 0; i < ms.size(); i++) {
+ if ((pt.x >= x) && (pt.x < x + ms[i].width))
+ margin = static_cast<int>(i);
+ x += ms[i].width;
+ }
+ return margin;
+}
+
bool ViewStyle::ValidStyle(size_t styleIndex) const {
return styleIndex < styles.size();
}
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h index 381ef79..2f7afe6 100644 --- a/scintilla/src/ViewStyle.h +++ b/scintilla/src/ViewStyle.h @@ -55,6 +55,8 @@ enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth}; enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2, wsVisibleOnlyInIndent=3};
+enum TabDrawMode {tdLongArrow=0, tdStrikeOut=1};
+
typedef std::map<FontSpecification, FontRealised *> FontMap;
enum WrapMode { eWrapNone, eWrapWord, eWrapChar, eWrapWhitespace };
@@ -133,6 +135,7 @@ public: int textStart; ///< Starting x position of text within the view
int zoomLevel;
WhiteSpaceVisibility viewWhitespace;
+ TabDrawMode tabDrawMode;
int whitespaceSize;
IndentView viewIndentationGuides;
bool viewEOL;
@@ -184,6 +187,7 @@ public: void SetStyleFontName(int styleIndex, const char *name);
bool ProtectionActive() const;
int ExternalMarginWidth() const;
+ int MarginFromLocation(Point pt) const;
bool ValidStyle(size_t styleIndex) const;
void CalcLargestMarkerHeight();
ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const;
diff --git a/scintilla/version.txt b/scintilla/version.txt index 93bb739..ee94638 100644 --- a/scintilla/version.txt +++ b/scintilla/version.txt @@ -1 +1 @@ -370
+371
diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index d4da2f8..4dea4b1 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -710,6 +710,35 @@ static bool BoundsContains(PRectangle rcBounds, HRGN hRgnBounds, PRectangle rcCh return contains;
}
+static std::string StringEncode(const std::wstring &s, int codePage) {
+ const int cchMulti = s.length() ? ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast<int>(s.length()), NULL, 0, NULL, NULL) : 0;
+ std::string sMulti(cchMulti, 0);
+ if (cchMulti) {
+ ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast<int>(s.size()), &sMulti[0], cchMulti, NULL, NULL);
+ }
+ return sMulti;
+}
+
+static std::wstring StringDecode(const std::string &s, int codePage) {
+ const int cchWide = s.length() ? ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast<int>(s.length()), NULL, 0) : 0;
+ std::wstring sWide(cchWide, 0);
+ if (cchWide) {
+ ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast<int>(s.length()), &sWide[0], cchWide);
+ }
+ return sWide;
+}
+
+static std::wstring StringMapCase(const std::wstring &ws, DWORD mapFlags) {
+ const int charsConverted = ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags,
+ ws.c_str(), static_cast<int>(ws.length()), NULL, 0);
+ std::wstring wsConverted(charsConverted, 0);
+ if (charsConverted) {
+ ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags,
+ ws.c_str(), static_cast<int>(ws.length()), &wsConverted[0], charsConverted);
+ }
+ return wsConverted;
+}
+
// Returns the target converted to UTF8.
// Return the length in bytes.
int ScintillaWin::TargetAsUTF8(char *text) {
@@ -720,14 +749,11 @@ int ScintillaWin::TargetAsUTF8(char *text) { }
} else {
// Need to convert
- std::string s = RangeText(targetStart, targetEnd);
- int charsLen = ::MultiByteToWideChar(CodePageOfDocument(), 0, &s[0], targetLength, NULL, 0);
- std::wstring characters(charsLen, '\0');
- ::MultiByteToWideChar(CodePageOfDocument(), 0, &s[0], targetLength, &characters[0], charsLen);
-
- int utf8Len = ::WideCharToMultiByte(CP_UTF8, 0, &characters[0], charsLen, NULL, 0, 0, 0);
+ const std::string s = RangeText(targetStart, targetEnd);
+ const std::wstring characters = StringDecode(s, CodePageOfDocument());
+ const int utf8Len = ::WideCharToMultiByte(CP_UTF8, 0, characters.c_str(), static_cast<int>(characters.length()), NULL, 0, 0, 0);
if (text) {
- ::WideCharToMultiByte(CP_UTF8, 0, &characters[0], charsLen, text, utf8Len, 0, 0);
+ ::WideCharToMultiByte(CP_UTF8, 0, characters.c_str(), static_cast<int>(characters.length()), text, utf8Len, 0, 0);
text[utf8Len] = '\0';
}
return utf8Len;
@@ -819,7 +845,7 @@ sptr_t ScintillaWin::WndPaint(uptr_t wParam) { Paint(surfaceWindow, rcPaint);
surfaceWindow->Release();
HRESULT hr = pRenderTarget->EndDraw();
- if (hr == D2DERR_RECREATE_TARGET) {
+ if (hr == static_cast<HRESULT>(D2DERR_RECREATE_TARGET)) {
DropRenderTarget();
paintState = paintAbandoned;
}
@@ -911,28 +937,6 @@ void ScintillaWin::SetCandidateWindowPos() { }
}
-static std::string StringEncode(std::wstring s, int codePage) {
- if (s.length()) {
- int cchMulti = ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast<int>(s.length()), NULL, 0, NULL, NULL);
- std::string sMulti(cchMulti, 0);
- ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast<int>(s.size()), &sMulti[0], cchMulti, NULL, NULL);
- return sMulti;
- } else {
- return std::string();
- }
-}
-
-static std::wstring StringDecode(std::string s, int codePage) {
- if (s.length()) {
- int cchWide = ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast<int>(s.length()), NULL, 0);
- std::wstring sWide(cchWide, 0);
- ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast<int>(s.length()), &sWide[0], cchWide);
- return sWide;
- } else {
- return std::wstring();
- }
-}
-
void ScintillaWin::SelectionToHangul() {
// Convert every hanja to hangul within the main range.
const int selStart = sel.RangeMain().Start().Position();
@@ -1349,6 +1353,12 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam // when there's a message posted. So, several times a second, we stop and let
// the low priority events have a turn (after which the timer will fire again).
+ // Suppress a warning from Code Analysis that the GetTickCount function
+ // wraps after 49 days. The WM_TIMER will kick off another SC_WIN_IDLE
+ // after the wrap.
+#ifdef _MSC_VER
+#pragma warning(suppress: 28159)
+#endif
DWORD dwCurrent = GetTickCount();
DWORD dwStart = wParam ? static_cast<DWORD>(wParam) : dwCurrent;
const DWORD maxWorkTime = 50;
@@ -1408,11 +1418,17 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam (wParam & MK_CONTROL) != 0);
break;
- case WM_RBUTTONDOWN:
- ::SetFocus(MainHWND());
- if (!PointInSelection(Point::FromLong(static_cast<long>(lParam)))) {
- CancelModes();
- SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast<long>(lParam))));
+ case WM_RBUTTONDOWN: {
+ ::SetFocus(MainHWND());
+ Point pt = Point::FromLong(static_cast<long>(lParam));
+ if (!PointInSelection(pt)) {
+ CancelModes();
+ SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast<long>(lParam))));
+ }
+
+ RightButtonDownWithModifiers(pt, ::GetMessageTime(), ModifierFlags((wParam & MK_SHIFT) != 0,
+ (wParam & MK_CONTROL) != 0,
+ Platform::IsKeyDown(VK_MENU)));
}
break;
@@ -1561,18 +1577,22 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return HandleCompositionWindowed(wParam, lParam);
}
- case WM_CONTEXTMENU:
- if (displayPopupMenu) {
+ case WM_CONTEXTMENU: {
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 = PointFromPOINT(spt);
+ POINT rpt = {static_cast<int>(pt.x), static_cast<int>(pt.y)};
+ ::ScreenToClient(MainHWND(), &rpt);
+ const Point ptClient = PointFromPOINT(rpt);
+ if (ShouldDisplayPopup(ptClient)) {
+ 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 = PointFromPOINT(spt);
+ }
+ ContextMenu(pt);
+ return 0;
}
- ContextMenu(pt);
- return 0;
}
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
@@ -1659,11 +1679,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam if (nStart == -1) {
nStart = nEnd; // Remove selection
}
- if (nStart > nEnd) {
- SetSelection(nEnd, nStart);
- } else {
- SetSelection(nStart, nEnd);
- }
+ SetSelection(nEnd, nStart);
EnsureCaretVisible();
}
break;
@@ -2095,44 +2111,24 @@ std::string ScintillaWin::CaseMapString(const std::string &s, int caseMapping) { if ((s.size() == 0) || (caseMapping == cmSame))
return s;
- UINT cpDoc = CodePageOfDocument();
+ const UINT cpDoc = CodePageOfDocument();
if (cpDoc == SC_CP_UTF8) {
- std::string retMapped(s.length() * maxExpansionCaseConversion, 0);
- size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),
- (caseMapping == cmUpper) ? CaseConversionUpper : CaseConversionLower);
- retMapped.resize(lenMapped);
- return retMapped;
+ return CaseConvertString(s, (caseMapping == cmUpper) ? CaseConversionUpper : CaseConversionLower);
}
- unsigned int lengthUTF16 = ::MultiByteToWideChar(cpDoc, 0, s.c_str(),
- static_cast<int>(s.size()), NULL, 0);
- if (lengthUTF16 == 0) // Failed to convert
- return s;
+ // Change text to UTF-16
+ const std::wstring wsText = StringDecode(s, cpDoc);
- DWORD mapFlags = LCMAP_LINGUISTIC_CASING |
+ const DWORD mapFlags = LCMAP_LINGUISTIC_CASING |
((caseMapping == cmUpper) ? LCMAP_UPPERCASE : LCMAP_LOWERCASE);
- // Change text to UTF-16
- std::vector<wchar_t> vwcText(lengthUTF16);
- ::MultiByteToWideChar(cpDoc, 0, s.c_str(), static_cast<int>(s.size()), &vwcText[0], lengthUTF16);
-
// Change case
- int charsConverted = ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags,
- &vwcText[0], lengthUTF16, NULL, 0);
- std::vector<wchar_t> vwcConverted(charsConverted);
- ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags,
- &vwcText[0], lengthUTF16, &vwcConverted[0], charsConverted);
+ const std::wstring wsConverted = StringMapCase(wsText, mapFlags);
// Change back to document encoding
- unsigned int lengthConverted = ::WideCharToMultiByte(cpDoc, 0,
- &vwcConverted[0], static_cast<int>(vwcConverted.size()),
- NULL, 0, NULL, 0);
- std::vector<char> vcConverted(lengthConverted);
- ::WideCharToMultiByte(cpDoc, 0,
- &vwcConverted[0], static_cast<int>(vwcConverted.size()),
- &vcConverted[0], static_cast<int>(vcConverted.size()), NULL, 0);
+ std::string sConverted = StringEncode(wsConverted, cpDoc);
- return std::string(&vcConverted[0], vcConverted.size());
+ return sConverted;
}
void ScintillaWin::Copy() {
@@ -2942,7 +2938,7 @@ void ScintillaWin::FullPaintDC(HDC hdc) { Paint(surfaceWindow, rcPaint);
surfaceWindow->Release();
HRESULT hr = pRenderTarget->EndDraw();
- if (hr == D2DERR_RECREATE_TARGET) {
+ if (hr == static_cast<HRESULT>(D2DERR_RECREATE_TARGET)) {
DropRenderTarget();
}
}
@@ -321,7 +321,7 @@ void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText) //
BOOL EditConvertText(HWND hwnd,UINT cpSource,UINT cpDest,BOOL bSetSavePoint)
{
- struct TextRange tr = { { 0, -1 }, NULL };
+ struct Sci_TextRange tr = { { 0, -1 }, NULL };
int length, cbText, cbwText;
char *pchText;
WCHAR *pwchText;
@@ -2357,7 +2357,7 @@ void EditTabsToSpaces(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS) int iSelEnd;
int iSelCount;
UINT cpEdit;
- struct TextRange tr;
+ struct Sci_TextRange tr;
BOOL bIsLineStart = TRUE;
BOOL bModified = FALSE;
@@ -2492,7 +2492,7 @@ void EditSpacesToTabs(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS) int iSelEnd;
int iSelCount;
UINT cpEdit;
- struct TextRange tr;
+ struct Sci_TextRange tr;
WCHAR space[256];
BOOL bIsLineStart = TRUE;
BOOL bModified = FALSE;
@@ -3506,7 +3506,7 @@ void EditToggleLineComments(HWND hwnd,LPCWSTR pwszComment,BOOL bInsertAtStart) int iCommentPos;
int iIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0);
char tchBuf[32];
- struct TextRange tr;
+ struct Sci_TextRange tr;
if (iIndentPos == SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0))
continue;
@@ -4042,7 +4042,7 @@ void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/) int iSelEnd;
int iSelCount;
UINT cpEdit;
- struct TextRange tr;
+ struct Sci_TextRange tr;
int cEOLMode;
WCHAR wszEOL[] = L"\r\n";
int cchEOL = 2;
@@ -4252,7 +4252,7 @@ void EditJoinLinesEx(HWND hwnd) int iSelStart;
int iSelEnd;
int iSelCount;
- struct TextRange tr;
+ struct Sci_TextRange tr;
int cEOLMode;
char szEOL[] = "\r\n";
int cchEOL = 2;
@@ -4788,7 +4788,7 @@ void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt) WCHAR *p;
DWORD cch = 0;
UINT cpEdit;
- struct TextRange tr;
+ struct Sci_TextRange tr;
char* pszText;
LPWSTR pszTextW;
@@ -5409,7 +5409,7 @@ HWND EditFindReplaceDlg(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bReplace) BOOL EditFindNext(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection)
{
- struct TextToFind ttf;
+ struct Sci_TextToFind ttf;
int iPos;
int iSelPos, iSelAnchor;
char szFind2[512];
@@ -5478,7 +5478,7 @@ BOOL EditFindNext(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection) BOOL EditFindPrev(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection)
{
- struct TextToFind ttf;
+ struct Sci_TextToFind ttf;
int iPos;
int iSelPos, iSelAnchor;
int iLength;
@@ -5549,7 +5549,7 @@ BOOL EditFindPrev(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection) BOOL EditReplace(HWND hwnd,LPCEDITFINDREPLACE lpefr)
{
- struct TextToFind ttf;
+ struct Sci_TextToFind ttf;
int iPos;
int iSelStart;
int iSelEnd;
@@ -5684,7 +5684,7 @@ void CompleteWord(HWND hwnd, BOOL autoInsert) { int iRootLen = 0;
int iDocLen;
int iPosFind;
- struct TextRange tr = { { 0, -1 }, NULL };
+ struct Sci_TextRange tr = { { 0, -1 }, NULL };
struct Sci_TextToFind ft = {{0, 0}, 0, {0, 0}};
BOOL bWordAllNumbers = TRUE;
struct WLIST* lListHead = NULL;
@@ -5804,7 +5804,7 @@ void CompleteWord(HWND hwnd, BOOL autoInsert) { //
void EditMarkAll(HWND hwnd, int iMarkOccurrences, BOOL bMarkOccurrencesMatchCase, BOOL bMarkOccurrencesMatchWords)
{
- struct TextToFind ttf;
+ struct Sci_TextToFind ttf;
int iPos;
char *pszText;
int iTextLen;
@@ -5891,7 +5891,7 @@ void EditMarkAll(HWND hwnd, int iMarkOccurrences, BOOL bMarkOccurrencesMatchCase BOOL EditReplaceAll(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo)
{
- struct TextToFind ttf;
+ struct Sci_TextToFind ttf;
int iPos;
int iCount = 0;
int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET;
@@ -6016,7 +6016,7 @@ BOOL EditReplaceAll(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo) BOOL EditReplaceAllInSelection(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo)
{
- struct TextToFind ttf;
+ struct Sci_TextToFind ttf;
int iPos;
int iCount = 0;
int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET;
diff --git a/src/Notepad2.c b/src/Notepad2.c index 2d44c28..4f26aa8 100644 --- a/src/Notepad2.c +++ b/src/Notepad2.c @@ -5263,7 +5263,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) if (iSize >= 3) {
- struct TextRange tr = { { iStartPos, iCurPos }, tchBuf };
+ struct Sci_TextRange tr = { { iStartPos, iCurPos }, tchBuf };
SendMessage(hwndEdit,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
if (tchBuf[iSize - 2] != '/') {
diff --git a/src/Print.cpp b/src/Print.cpp index 616d26d..40f4977 100644 --- a/src/Print.cpp +++ b/src/Print.cpp @@ -110,7 +110,7 @@ extern "C" BOOL EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) int lengthDocMax;
int lengthPrinted;
- struct RangeToFormat frPrint;
+ struct Sci_RangeToFormat frPrint;
int pageNum;
BOOL printPage;
|