Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 58b5c23

Browse files
committed
Updated SciLexer to v3.7.1 and added new features.
Scintilla.TabDrawMode to change the appearance of visible tabs. Scintilla.UsePopup overload for changing behavior of right-click. Scintilla.FoldDisplayTextStyle, Line.ToggleFoldShowText and Style.FoldDisplayText, for displaying fold text tags. IndicatorStyle.Point and IndicatorStyle.PointCharacter.
1 parent e7f1d59 commit 58b5c23

27 files changed

+242
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ScintillaNET is in active development. If you find any issues or just have a que
1414

1515
Compiled versions which are production ready can be downloaded from [NuGet](https://www.nuget.org/packages/jacobslusser.ScintillaNET) or the [Releases](https://github.com/jacobslusser/ScintillaNET/releases) page.
1616

17-
For the latest and greatest you can build the [Master](https://github.com/jacobslusser/ScintillaNET/archive/master.zip) branch from source using Visual Studio 2013.
17+
For the latest and greatest you can build the [Master](https://github.com/jacobslusser/ScintillaNET/archive/master.zip) branch from source using Visual Studio 2015.
1818

1919
## Background
2020

src/ScintillaNET.Signed.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>jacobslusser.ScintillaNET.Signed</id>
5-
<version>3.6.0</version>
5+
<version>3.6.1</version>
66
<title>ScintillaNET Source Editing Component - Signed</title>
77
<authors>Jacob Slusser</authors>
88
<owners>Jacob Slusser</owners>

src/ScintillaNET.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>jacobslusser.ScintillaNET</id>
5-
<version>3.6.0</version>
5+
<version>3.6.1</version>
66
<title>ScintillaNET Source Editing Component</title>
77
<authors>Jacob Slusser</authors>
88
<owners>Jacob Slusser</owners>

src/ScintillaNET/FoldDisplayText.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace ScintillaNET
7+
{
8+
/// <summary>
9+
/// Display options for fold text tags.
10+
/// </summary>
11+
public enum FoldDisplayText
12+
{
13+
/// <summary>
14+
/// Do not display the text tags. This is the default.
15+
/// </summary>
16+
Hidden = NativeMethods.SC_FOLDDISPLAYTEXT_HIDDEN,
17+
18+
/// <summary>
19+
/// Display the text tags.
20+
/// </summary>
21+
Standard = NativeMethods.SC_FOLDDISPLAYTEXT_STANDARD,
22+
23+
/// <summary>
24+
/// Display the text tags with a box drawn around them.
25+
/// </summary>
26+
Boxed = NativeMethods.SC_FOLDDISPLAYTEXT_BOXED
27+
}
28+
}

src/ScintillaNET/IndicatorStyle.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ public enum IndicatorStyle
9999
/// <summary>
100100
/// An indicator that will change the foreground color of text to the foreground color of the indicator.
101101
/// </summary>
102-
TextFore = NativeMethods.INDIC_TEXTFORE
102+
TextFore = NativeMethods.INDIC_TEXTFORE,
103+
104+
/// <summary>
105+
/// A triangle below the start of the indicator range.
106+
/// </summary>
107+
Point = NativeMethods.INDIC_POINT,
108+
109+
/// <summary>
110+
/// A triangle below the center of the first character of the indicator range.
111+
/// </summary>
112+
PointCharacter = NativeMethods.INDIC_POINTCHARACTER
103113
}
104114
}

src/ScintillaNET/Line.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,32 @@ public int MarkerPrevious(uint markerMask)
144144
/// Toggles the folding state of the line; expanding or contracting all child lines.
145145
/// </summary>
146146
/// <remarks>The line must be set as a <see cref="ScintillaNET.FoldLevelFlags.Header" />.</remarks>
147+
/// <seealso cref="ToggleFoldShowText"/>
147148
public void ToggleFold()
148149
{
149150
scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLD, new IntPtr(Index));
150151
}
151152

153+
/// <summary>
154+
/// Toggles the folding state of the line; expanding or contracting all child lines, and specifies the text tag to display to the right of the fold.
155+
/// </summary>
156+
/// <param name="text">The text tag to show to the right of the folded text.</param>
157+
/// <remarks>The display of fold text tags are determined by the <see cref="Scintilla.FoldDisplayTextSetStyle" /> method.</remarks>
158+
/// <seealso cref="Scintilla.FoldDisplayTextSetStyle" />
159+
public unsafe void ToggleFoldShowText(string text)
160+
{
161+
if (string.IsNullOrEmpty(text))
162+
{
163+
scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLDSHOWTEXT, new IntPtr(Index), IntPtr.Zero);
164+
}
165+
else
166+
{
167+
var bytes = Helpers.GetBytes(text, scintilla.Encoding, zeroTerminated: true);
168+
fixed (byte* bp = bytes)
169+
scintilla.DirectMessage(NativeMethods.SCI_TOGGLEFOLDSHOWTEXT, new IntPtr(Index), new IntPtr(bp));
170+
}
171+
}
172+
152173
#endregion Methods
153174

154175
#region Properties

src/ScintillaNET/LineCollection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace ScintillaNET
1010
{
11+
// TODO Revisit this following Scintilla v3.7.0 because is said to be better about character handling
12+
1113
/// <summary>
1214
/// An immutable collection of lines of text in a <see cref="Scintilla" /> control.
1315
/// </summary>

src/ScintillaNET/NativeMethods.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ internal static class NativeMethods
9393
public const int INDIC_COMPOSITIONTHIN = 15;
9494
public const int INDIC_FULLBOX = 16;
9595
public const int INDIC_TEXTFORE = 17;
96+
public const int INDIC_POINT = 18;
97+
public const int INDIC_POINTCHARACTER = 19;
9698
public const int INDIC_MAX = 31;
9799
public const int INDIC_CONTAINER = 8;
98100

@@ -167,6 +169,11 @@ internal static class NativeMethods
167169
public const int SC_FOLDFLAG_LEVELNUMBERS = 0x0040;
168170
public const int SC_FOLDFLAG_LINESTATE = 0x0080;
169171

172+
// Fold display text
173+
public const int SC_FOLDDISPLAYTEXT_HIDDEN = 0;
174+
public const int SC_FOLDDISPLAYTEXT_STANDARD = 1;
175+
public const int SC_FOLDDISPLAYTEXT_BOXED = 2;
176+
170177
// Line end type
171178
public const int SC_LINE_END_TYPE_DEFAULT = 0;
172179
public const int SC_LINE_END_TYPE_UNICODE = 1;
@@ -859,6 +866,8 @@ internal static class NativeMethods
859866
public const int SCI_GETADDITIONALCARETSBLINK = 2568;
860867
public const int SCI_SETADDITIONALCARETSVISIBLE = 2608;
861868
public const int SCI_GETADDITIONALCARETSVISIBLE = 2609;
869+
public const int SCI_GETTABDRAWMODE = 2698;
870+
public const int SCI_SETTABDRAWMODE = 2699;
862871
public const int SCI_GETSELECTIONS = 2570;
863872
public const int SCI_GETSELECTIONEMPTY = 2650;
864873
public const int SCI_CLEARSELECTIONS = 2571;
@@ -939,6 +948,8 @@ internal static class NativeMethods
939948
public const int SCI_MULTIEDGECLEARALL = 2695;
940949
public const int SCI_SETMOUSEWHEELCAPTURES = 2696;
941950
public const int SCI_GETMOUSEWHEELCAPTURES = 2697;
951+
public const int SCI_TOGGLEFOLDSHOWTEXT = 2700;
952+
public const int SCI_FOLDDISPLAYTEXTSETSTYLE = 2701;
942953
public const int SCI_STARTRECORD = 3001;
943954
public const int SCI_STOPRECORD = 3002;
944955
public const int SCI_SETLEXER = 4001;
@@ -1024,6 +1035,12 @@ internal static class NativeMethods
10241035
public const int SCN_FOCUSIN = 2028;
10251036
public const int SCN_FOCUSOUT = 2029;
10261037
public const int SCN_AUTOCCOMPLETED = 2030;
1038+
public const int SCN_MARGINRIGHTCLICK = 2031;
1039+
1040+
// Popup
1041+
public const int SC_POPUP_NEVER = 0;
1042+
public const int SC_POPUP_ALL = 1;
1043+
public const int SC_POPUP_TEXT = 2;
10271044

10281045
// Line wrapping
10291046
public const int SC_WRAP_NONE = 0;
@@ -1058,6 +1075,7 @@ internal static class NativeMethods
10581075
public const int STYLE_CONTROLCHAR = 36;
10591076
public const int STYLE_INDENTGUIDE = 37;
10601077
public const int STYLE_CALLTIP = 38;
1078+
public const int STYLE_FOLDDISPLAYTEXT = 39;
10611079
public const int STYLE_LASTPREDEFINED = 39;
10621080
public const int STYLE_MAX = 255;
10631081

@@ -1073,6 +1091,10 @@ internal static class NativeMethods
10731091
public const int SC_TECHNOLOGY_DIRECTWRITERETAIN = 2;
10741092
public const int SC_TECHNOLOGY_DIRECTWRITEDC = 3;
10751093

1094+
// Tab draw
1095+
public const int SCTD_LONGARROW = 0;
1096+
public const int SCTD_STRIKEOUT = 1;
1097+
10761098
// Undo
10771099
public const int UNDO_MAY_COALESCE = 1;
10781100

src/ScintillaNET/PopupMode.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace ScintillaNET
7+
{
8+
/// <summary>
9+
/// Behavior of the standard edit control context menu.
10+
/// </summary>
11+
/// <seealso cref="Scintilla.UsePopup(PopupMode)" />
12+
public enum PopupMode
13+
{
14+
/// <summary>
15+
/// Never show the default editing menu.
16+
/// </summary>
17+
Never = NativeMethods.SC_POPUP_NEVER,
18+
19+
/// <summary>
20+
/// Show default editing menu if clicking on the control.
21+
/// </summary>
22+
All = NativeMethods.SC_POPUP_ALL,
23+
24+
/// <summary>
25+
/// Show default editing menu only if clicking on text area.
26+
/// </summary>
27+
/// <remarks>To receive the <see cref="Scintilla.MarginRightClick" /> event, this value must be used.</remarks>
28+
/// <seealso cref="Scintilla.MarginRightClick" />
29+
Text = NativeMethods.SC_POPUP_TEXT
30+
}
31+
}

src/ScintillaNET/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
// You can specify all the values or you can default the Build and Revision Numbers
3636
// by using the '*' as shown below:
3737
// [assembly: AssemblyVersion("1.0.*")]
38-
[assembly: AssemblyVersion("3.6.0.0")]
39-
[assembly: AssemblyFileVersion("3.6.0.0")]
40-
[assembly: AssemblyInformationalVersion("3.6.0")]
38+
[assembly: AssemblyVersion("3.6.1.0")]
39+
[assembly: AssemblyFileVersion("3.6.1.0")]
40+
[assembly: AssemblyInformationalVersion("3.6.1")]
4141
[assembly: NeutralResourcesLanguageAttribute("en-US")]
4242

4343
#if (DEBUG)

src/ScintillaNET/Scintilla.cs

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class Scintilla : Control
4848
private static readonly object savePointLeftEventKey = new object();
4949
private static readonly object changeAnnotationEventKey = new object();
5050
private static readonly object marginClickEventKey = new object();
51+
private static readonly object marginRightClickEventKey = new object();
5152
private static readonly object charAddedEventKey = new object();
5253
private static readonly object autoCSelectionEventKey = new object();
5354
private static readonly object autoCCompletedEventKey = new object();
@@ -879,6 +880,17 @@ public void FoldAll(FoldAction action)
879880
DirectMessage(NativeMethods.SCI_FOLDALL, new IntPtr((int)action));
880881
}
881882

883+
/// <summary>
884+
/// Changes the appearance of fold text tags.
885+
/// </summary>
886+
/// <param name="style">One of the <see cref="FoldDisplayText" /> enumeration values.</param>
887+
/// <remarks>The text tag to display on a folded line can be set using <see cref="Line.ToggleFoldShowText" />.</remarks>
888+
/// <seealso cref="Line.ToggleFoldShowText" />.
889+
public void FoldDisplayTextSetStyle(FoldDisplayText style)
890+
{
891+
DirectMessage(NativeMethods.SCI_FOLDDISPLAYTEXTSETSTYLE, new IntPtr((int)style));
892+
}
893+
882894
/// <summary>
883895
/// Returns the character as the specified document position.
884896
/// </summary>
@@ -1719,6 +1731,17 @@ protected virtual void OnMarginClick(MarginClickEventArgs e)
17191731
handler(this, e);
17201732
}
17211733

1734+
/// <summary>
1735+
/// Raises the <see cref="MarginRightClick" /> event.
1736+
/// </summary>
1737+
/// <param name="e">A <see cref="MarginClickEventArgs" /> that contains the event data.</param>
1738+
protected virtual void OnMarginRightClick(MarginClickEventArgs e)
1739+
{
1740+
var handler = Events[marginRightClickEventKey] as EventHandler<MarginClickEventArgs>;
1741+
if (handler != null)
1742+
handler(this, e);
1743+
}
1744+
17221745
/// <summary>
17231746
/// Raises the <see cref="ModifyAttempt" /> event.
17241747
/// </summary>
@@ -2056,7 +2079,11 @@ private void ScnMarginClick(ref NativeMethods.SCNotification scn)
20562079
{
20572080
var keys = Keys.Modifiers & (Keys)(scn.modifiers << 16);
20582081
var eventArgs = new MarginClickEventArgs(this, keys, scn.position, scn.margin);
2059-
OnMarginClick(eventArgs);
2082+
2083+
if (scn.nmhdr.code == NativeMethods.SCN_MARGINCLICK)
2084+
OnMarginClick(eventArgs);
2085+
else
2086+
OnMarginRightClick(eventArgs);
20602087
}
20612088

20622089
private void ScnModified(ref NativeMethods.SCNotification scn)
@@ -2631,12 +2658,23 @@ public void Undo()
26312658
/// Determines whether to show the right-click context menu.
26322659
/// </summary>
26332660
/// <param name="enablePopup">true to enable the popup window; otherwise, false.</param>
2661+
/// <seealso cref="UsePopup(PopupMode)" />
26342662
public void UsePopup(bool enablePopup)
26352663
{
2664+
// NOTE: The behavior of UsePopup has changed in v3.7.1, however, this approach is still valid
26362665
var bEnablePopup = (enablePopup ? new IntPtr(1) : IntPtr.Zero);
26372666
DirectMessage(NativeMethods.SCI_USEPOPUP, bEnablePopup);
26382667
}
26392668

2669+
/// <summary>
2670+
/// Determines the conditions for displaying the standard right-click context menu.
2671+
/// </summary>
2672+
/// <param name="popupMode">One of the <seealso cref="PopupMode" /> enumeration values.</param>
2673+
public void UsePopup(PopupMode popupMode)
2674+
{
2675+
DirectMessage(NativeMethods.SCI_USEPOPUP, new IntPtr((int)popupMode));
2676+
}
2677+
26402678
private void WmDestroy(ref Message m)
26412679
{
26422680
// WM_DESTROY workaround
@@ -2698,6 +2736,7 @@ private void WmReflectNotify(ref Message m)
26982736
break;
26992737

27002738
case NativeMethods.SCN_MARGINCLICK:
2739+
case NativeMethods.SCN_MARGINRIGHTCLICK:
27012740
ScnMarginClick(ref scn);
27022741
break;
27032742

@@ -4920,6 +4959,30 @@ public Status Status
49204959
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
49214960
public StyleCollection Styles { get; private set; }
49224961

4962+
/// <summary>
4963+
/// Gets or sets how tab characters are represented when whitespace is visible.
4964+
/// </summary>
4965+
/// <returns>
4966+
/// One of the <see cref="ScintillaNET.TabDrawMode" /> enumeration values.
4967+
/// The default is <see cref="TabDrawMode.LongArrow" />.
4968+
/// </returns>
4969+
/// <seealso cref="ViewWhitespace" />
4970+
[DefaultValue(TabDrawMode.LongArrow)]
4971+
[Category("Whitespace")]
4972+
[Description("Style of visible tab characters.")]
4973+
public TabDrawMode TabDrawMode
4974+
{
4975+
get
4976+
{
4977+
return (TabDrawMode)DirectMessage(NativeMethods.SCI_GETTABDRAWMODE);
4978+
}
4979+
set
4980+
{
4981+
var tabDrawMode = (int)value;
4982+
DirectMessage(NativeMethods.SCI_SETTABDRAWMODE, new IntPtr(tabDrawMode));
4983+
}
4984+
}
4985+
49234986
/// <summary>
49244987
/// Gets or sets the width of a tab as a multiple of a space character.
49254988
/// </summary>
@@ -5887,6 +5950,27 @@ public event EventHandler<MarginClickEventArgs> MarginClick
58875950
}
58885951
}
58895952

5953+
5954+
// TODO This isn't working in my tests. Could be Windows Forms interfering.
5955+
/// <summary>
5956+
/// Occurs when the mouse was right-clicked inside a margin that was marked as sensitive.
5957+
/// </summary>
5958+
/// <remarks>The <see cref="Margin.Sensitive" /> property and <see cref="PopupMode.Text" /> must be set for a margin to raise this event.</remarks>
5959+
/// <seealso cref="UsePopup(PopupMode)" />
5960+
[Category("Notifications")]
5961+
[Description("Occurs when the mouse is right-clicked in a sensitive margin.")]
5962+
public event EventHandler<MarginClickEventArgs> MarginRightClick
5963+
{
5964+
add
5965+
{
5966+
Events.AddHandler(marginRightClickEventKey, value);
5967+
}
5968+
remove
5969+
{
5970+
Events.RemoveHandler(marginRightClickEventKey, value);
5971+
}
5972+
}
5973+
58905974
/// <summary>
58915975
/// Occurs when a user attempts to change text while the document is in read-only mode.
58925976
/// </summary>

0 commit comments

Comments
 (0)