Skip to content

Commit f534e5f

Browse files
Sébastien GeiserSébastien Geiser
Sébastien Geiser
authored and
Sébastien Geiser
committed
back in net481 + BEncoding again + Npp easy access
1 parent be816d4 commit f534e5f

36 files changed

+675
-3275
lines changed

CSharpRegexTools4Npp/CSharpRegexTools4Npp.csproj

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>CSharpRegexTools4Npp</RootNamespace>
1212
<AssemblyName>CSharpRegexTools4Npp</AssemblyName>
13-
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
13+
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
1414
<OldToolsVersion>3.5</OldToolsVersion>
1515
<ProjectGuid>{EB8FC3A3-93E8-457B-B281-FAFA5119611A}</ProjectGuid>
16+
<TargetFrameworkProfile />
1617
</PropertyGroup>
1718
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
1819
<DebugSymbols>true</DebugSymbols>
@@ -87,7 +88,6 @@
8788
<Compile Include="PluginInfrastructure\DllExport\DllExportAttribute.cs" />
8889
<Compile Include="PluginInfrastructure\Docking_h.cs" />
8990
<Compile Include="PluginInfrastructure\GatewayDomain.cs" />
90-
<Compile Include="PluginInfrastructure\IScintillaGateway.cs" />
9191
<Compile Include="PluginInfrastructure\MenuCmdID_h.cs" />
9292
<Compile Include="PluginInfrastructure\Msgs_h.cs" />
9393
<Compile Include="PluginInfrastructure\NotepadPPGateway.cs" />
@@ -96,6 +96,7 @@
9696
<Compile Include="PluginInfrastructure\Preference_h.cs" />
9797
<Compile Include="PluginInfrastructure\ScintillaGateway.cs" />
9898
<Compile Include="PluginInfrastructure\Scintilla_iface.cs" />
99+
<Compile Include="PluginInfrastructure\TextPosition.cs" />
99100
<Compile Include="PluginInfrastructure\UnmanagedExports.cs" />
100101
<Compile Include="PluginInfrastructure\Win32.cs" />
101102
<Compile Include="PluginInfrastructure\resource_h.cs" />
@@ -111,6 +112,7 @@
111112
<DesignTime>True</DesignTime>
112113
<DependentUpon>Resources.resx</DependentUpon>
113114
</Compile>
115+
<Compile Include="Utils\BEncoding.cs" />
114116
<!-- tests -->
115117
<!-- other utilities -->
116118
<Compile Include="Utils\FormStyle.cs" />
@@ -130,7 +132,6 @@
130132
</When>
131133
<Otherwise>
132134
<ItemGroup>
133-
<DEPENDENCY_DIR Include="Dependencies\x64" />
134135
<DEPENDENCY_DLLS Include="Dependencies\$(Platform)\*.dll" />
135136
</ItemGroup>
136137
</Otherwise>
@@ -156,23 +157,14 @@
156157
<ItemGroup>
157158
<!-- icons and such -->
158159
<Content Include="Properties\star_bmp.bmp" />
159-
<None Include="Resources\close html tag toolbar darkmode.ico" />
160-
<None Include="Resources\close html tag toolbar.ico" />
161-
<None Include="Resources\close html tag toolbar bmp.bmp" />
162-
<None Include="Resources\about form toolbar darkmode.ico" />
163-
<None Include="Resources\selection remembering form toolbar darkmode.ico" />
164-
<None Include="Resources\about form toolbar.ico" />
165-
<None Include="Resources\selection remembering form toolbar.ico" />
166-
<None Include="Resources\about form toolbar bmp.bmp" />
167-
<None Include="Resources\selection remembering form toolbar bmp.bmp" />
168-
<None Include="Resources\about form icon.PNG" />
169160
</ItemGroup>
170161
<ItemGroup>
171162
<ProjectReference Include="..\RegexDialog\RegexDialog.csproj">
172163
<Project>{c2a3f803-5710-d6b9-f97b-4fbfde7e2af4}</Project>
173164
<Name>RegexDialog</Name>
174165
</ProjectReference>
175166
</ItemGroup>
167+
<ItemGroup />
176168
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
177169
<Import Condition="Exists($(PkgUnmanagedExports_Repack_Upgrade))" Project="$(PkgUnmanagedExports_Repack_Upgrade)\build\UnmanagedExports.Repack.Upgrade.targets" />
178170
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

CSharpRegexTools4Npp/Main.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using RegexDialog;
55
using System;
66
using System.Diagnostics;
7-
using System.Drawing;
87
using System.IO;
98
using System.Linq;
109
using System.Reflection;
@@ -89,7 +88,7 @@ public static void ShowTheDialog()
8988

9089
dialog = new RegExToolDialog
9190
{
92-
GetText = () => Npp.Editor.GetText(),
91+
GetText = () => Npp.Text,
9392

9493
SetText = text =>
9594
{
@@ -98,29 +97,25 @@ public static void ShowTheDialog()
9897
Npp.Notepad.FileNew();
9998
}
10099

101-
Npp.Editor.SetText(text);
100+
Npp.Text = text;
102101
},
103102

104103
SetTextInNew = text =>
105104
{
106105
Npp.Notepad.FileNew();
107106

108-
Npp.Editor.SetText(text);
107+
Npp.Text = text;
109108
},
110109

111-
GetSelectedText = () => "",
110+
GetSelectedText = () => Npp.SelectedText,
112111

113-
SetPosition = (index, length) =>
114-
{
115-
Npp.Editor.SetSelectionStart(index);
116-
Npp.Editor.SetSelectionEnd(index + length);
117-
},
112+
SetPosition = (index, length) => Npp.SelectTextAndShow(index, index + length),
118113

119-
SetSelection = (index, length) => Npp.Editor.AddSelection(index, index + length),
114+
SetSelection = (index, length) => Npp.AddSelection(index, index + length),
120115

121-
GetSelectionStartIndex = () => Npp.Editor.GetSelectionStart(),
116+
GetSelectionStartIndex = () => Npp.SelectionStart,
122117

123-
GetSelectionLength = () => Npp.Editor.GetSelectionLength(),
118+
GetSelectionLength = () => Npp.SelectionLength,
124119

125120
SaveCurrentDocument = () => Npp.Notepad.SaveCurrentFile(),
126121

CSharpRegexTools4Npp/PluginInfrastructure/GatewayDomain.cs

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -46,113 +46,6 @@ public int Value
4646
}
4747
}
4848

49-
/// <summary>
50-
/// Positions within the Scintilla document refer to a character or the gap before that character.
51-
/// The first character in a document is 0, the second 1 and so on. If a document contains nLen characters, the last character is numbered nLen-1. The caret exists between character positions and can be located from before the first character (0) to after the last character (nLen).
52-
///
53-
/// There are places where the caret can not go where two character bytes make up one character.
54-
/// This occurs when a DBCS character from a language like Japanese is included in the document or when line ends are marked with the CP/M
55-
/// standard of a carriage return followed by a line feed.The INVALID_POSITION constant(-1) represents an invalid position within the document.
56-
///
57-
/// All lines of text in Scintilla are the same height, and this height is calculated from the largest font in any current style.This restriction
58-
/// is for performance; if lines differed in height then calculations involving positioning of text would require the text to be styled first.
59-
///
60-
/// If you use messages, there is nothing to stop you setting a position that is in the middle of a CRLF pair, or in the middle of a 2 byte character.
61-
/// However, keyboard commands will not move the caret into such positions.
62-
/// </summary>
63-
public class Position : IEquatable<Position>
64-
{
65-
private readonly Int64 pos;
66-
67-
public Position(IntPtr ptr) : this(ptr.ToInt64())
68-
{ }
69-
70-
public Position(Int64 pos)
71-
{
72-
this.pos = pos;
73-
}
74-
75-
public Int64 Value
76-
{
77-
get { return pos; }
78-
}
79-
80-
public static Position operator +(Position a, Position b)
81-
{
82-
return new Position(a.pos + b.pos);
83-
}
84-
85-
public static Position operator -(Position a, Position b)
86-
{
87-
return new Position(a.pos - b.pos);
88-
}
89-
90-
public static bool operator ==(Position a, Position b)
91-
{
92-
if (ReferenceEquals(a, b))
93-
return true;
94-
if (ReferenceEquals(a, null))
95-
return false;
96-
if (ReferenceEquals(b, null))
97-
return false;
98-
return a.pos == b.pos;
99-
}
100-
101-
public static bool operator !=(Position a, Position b)
102-
{
103-
return !(a == b);
104-
}
105-
106-
public static bool operator >(Position a, Position b)
107-
{
108-
return a.Value > b.Value;
109-
}
110-
111-
public static bool operator <(Position a, Position b)
112-
{
113-
return a.Value < b.Value;
114-
}
115-
116-
public static Position Min(Position a, Position b)
117-
{
118-
if (a < b)
119-
return a;
120-
return b;
121-
}
122-
123-
public static Position Max(Position a, Position b)
124-
{
125-
if (a > b)
126-
return a;
127-
return b;
128-
}
129-
130-
public override string ToString()
131-
{
132-
return "Postion: " + pos;
133-
}
134-
135-
public bool Equals(Position other)
136-
{
137-
if (ReferenceEquals(null, other)) return false;
138-
if (ReferenceEquals(this, other)) return true;
139-
return pos == other.pos;
140-
}
141-
142-
public override bool Equals(object obj)
143-
{
144-
if (ReferenceEquals(null, obj)) return false;
145-
if (ReferenceEquals(this, obj)) return true;
146-
if (obj.GetType() != this.GetType()) return false;
147-
return Equals((Position)obj);
148-
}
149-
150-
public override int GetHashCode()
151-
{
152-
return pos.GetHashCode();
153-
}
154-
}
155-
15649
/// <summary>
15750
/// Class containing key and modifiers
15851
///

0 commit comments

Comments
 (0)