From 66cf11610265cf87eef4c0b44c919fec223eb128 Mon Sep 17 00:00:00 2001
From: molsonkiko <46202915+molsonkiko@users.noreply.github.com>
Date: Tue, 16 Jan 2024 19:27:30 -0800
Subject: [PATCH] tidy code; fix typos; improve code generation
---
CHANGELOG.md | 1 +
NppCSharpPluginPack/Forms/DarkModeTestForm.cs | 3 +--
.../Properties/AssemblyInfo.cs | 4 ++--
NppCSharpPluginPack/Tests/Benchmarker.cs | 4 ++--
.../Tests/UserInterfaceTests.cs | 1 -
NppCSharpPluginPack/Utils/FormStyle.cs | 4 +---
NppCSharpPluginPack/Utils/NanInf.cs | 2 +-
NppCSharpPluginPack/Utils/Npp.cs | 4 +---
NppCSharpPluginPack/Utils/SelectionManager.cs | 4 ++--
README.md | 10 +++++-----
.../Scintilla_iface_synchronizer/cs.py | 20 +++++++++++--------
docs/README.md | 2 +-
most recent errors.txt | 10 +++++-----
13 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d01af50..8bc0d1e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1. toggle highlighting of `close HTML/XML tag` toolbar icon based on whether the setting is true.
2. add more UI tests for [ScintillaGateway.cs](/NppCSharpPluginPack/PluginInfrastructure/ScintillaGateway.cs) and [NotepadPPGateway.cs](/NppCSharpPluginPack/PluginInfrastructure/NotepadPPGateway.cs) methods to make sure they work.
+3. In [ToolsForMaintainersOfTheProjectTemplate](/ToolsForMaintainersOfTheProjectTemplate/), I need to add auto-generation of calls to `GetNullStrippedStringFromMessageThatReturnsLength(SciMsg msg, IntPtr wParam=default)` instead of the old fixed-size 10000-byte buffers
### To Be Changed
diff --git a/NppCSharpPluginPack/Forms/DarkModeTestForm.cs b/NppCSharpPluginPack/Forms/DarkModeTestForm.cs
index 7f5d057..d82d23e 100644
--- a/NppCSharpPluginPack/Forms/DarkModeTestForm.cs
+++ b/NppCSharpPluginPack/Forms/DarkModeTestForm.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Windows.Forms;
+using System.Windows.Forms;
using Kbg.NppPluginNET;
using NppDemo.Utils;
diff --git a/NppCSharpPluginPack/Properties/AssemblyInfo.cs b/NppCSharpPluginPack/Properties/AssemblyInfo.cs
index 4c6019a..433721a 100644
--- a/NppCSharpPluginPack/Properties/AssemblyInfo.cs
+++ b/NppCSharpPluginPack/Properties/AssemblyInfo.cs
@@ -28,5 +28,5 @@
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.0.1.3")]
-[assembly: AssemblyFileVersion("0.0.1.3")]
+[assembly: AssemblyVersion("0.0.1.4")]
+[assembly: AssemblyFileVersion("0.0.1.4")]
diff --git a/NppCSharpPluginPack/Tests/Benchmarker.cs b/NppCSharpPluginPack/Tests/Benchmarker.cs
index bd713db..008a10c 100644
--- a/NppCSharpPluginPack/Tests/Benchmarker.cs
+++ b/NppCSharpPluginPack/Tests/Benchmarker.cs
@@ -6,7 +6,7 @@
namespace NppDemo.Tests
{
///
- /// contains benchmarking tests for RemesPath, JsonParser, and JsonSchemaValidator
+ /// put performance benchmarks for your code in this file (assuming you want to run them with TestRunner.cs)
///
public class Benchmarker
{
@@ -64,7 +64,7 @@ public class Benchmarker
queryTimesStr[ii] = Math.Round(queryTimes[ii] / 1e4, 3).ToString();
}
Npp.AddLine($"Query times (ms): {String.Join(", ", queryTimesStr)}");
- string resultPreview = "Previow of result";
+ string resultPreview = "Preview of result";
Npp.AddLine($"Preview of result: {resultPreview}");
}
return false;
diff --git a/NppCSharpPluginPack/Tests/UserInterfaceTests.cs b/NppCSharpPluginPack/Tests/UserInterfaceTests.cs
index 443c35e..e37b5c9 100644
--- a/NppCSharpPluginPack/Tests/UserInterfaceTests.cs
+++ b/NppCSharpPluginPack/Tests/UserInterfaceTests.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
-using NppDemo.Forms;
using NppDemo.Utils;
using Kbg.NppPluginNET;
diff --git a/NppCSharpPluginPack/Utils/FormStyle.cs b/NppCSharpPluginPack/Utils/FormStyle.cs
index bf2ebd0..37a9d0a 100644
--- a/NppCSharpPluginPack/Utils/FormStyle.cs
+++ b/NppCSharpPluginPack/Utils/FormStyle.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Drawing;
-using System.Reflection;
+using System.Drawing;
using System.Windows.Forms;
namespace NppDemo.Utils
diff --git a/NppCSharpPluginPack/Utils/NanInf.cs b/NppCSharpPluginPack/Utils/NanInf.cs
index c356400..0397c55 100644
--- a/NppCSharpPluginPack/Utils/NanInf.cs
+++ b/NppCSharpPluginPack/Utils/NanInf.cs
@@ -6,7 +6,7 @@ public class NanInf
/// a/b
/// may be necessary to generate infinity or nan at runtime
/// to avoid the compiler pre-computing things
- /// since if the compiler sees literal 1d/0d in the code
+ /// since if the compiler sees literal division by 0d in the code
/// it just pre-computes it at compile time
///
///
diff --git a/NppCSharpPluginPack/Utils/Npp.cs b/NppCSharpPluginPack/Utils/Npp.cs
index 87584ed..90c998d 100644
--- a/NppCSharpPluginPack/Utils/Npp.cs
+++ b/NppCSharpPluginPack/Utils/Npp.cs
@@ -223,10 +223,8 @@ public static void CharToSb(StringBuilder sb, char c)
///
/// the string representation of a JSON string
- /// with or without the enclosing quotes a JSON string normally has
+ /// if not quoted, this will not have the enclosing quotes a JSON string normally has
///
- ///
- ///
public static string StrToString(string s, bool quoted)
{
int slen = s.Length;
diff --git a/NppCSharpPluginPack/Utils/SelectionManager.cs b/NppCSharpPluginPack/Utils/SelectionManager.cs
index c389976..f470b19 100644
--- a/NppCSharpPluginPack/Utils/SelectionManager.cs
+++ b/NppCSharpPluginPack/Utils/SelectionManager.cs
@@ -100,8 +100,8 @@ public static int StartEndCompareByStart((int start, int end) se1, (int start, i
/// Given selections (selstart1,selend1), (selstart2,selend2), ..., (selstartN,selendN)
/// returns a sep-separated list of "start,end" pairs.
/// EXAMPLE:
- /// * StartEndListToJsonString([(1, 2), (5, 7)], "], [") returns "1,2], [5,7"
- /// * StartEndListToJsonString([(1, 2), (9, 20), (30,45)], " ") returns "1,2 9,20 30,45"
+ /// * StartEndListToString([(1, 2), (5, 7)], "], [") returns "1,2], [5,7"
+ /// * StartEndListToString([(1, 2), (9, 20), (30,45)], " ") returns "1,2 9,20 30,45"
///
public static string StartEndListToString(IEnumerable<(int start, int end)> selections, string sep=" ")
{
diff --git a/README.md b/README.md
index 5fac0db..61919f1 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,12 @@
[![License](http://img.shields.io/badge/License-Apache_2-red.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
-This is a template for Notepad++ plugins written. The vast majority of the code (certainly all the parts that were really hard to implment) come from [kbilsted's now-archived `NotepadPlusPlusPluginPack.Net`](https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net), with some significant changes, including:
+This is a template for Notepad++ plugins written in C#. The vast majority of the code (certainly all the parts that were really hard to implement) come from [kbilsted's now-archived `NotepadPlusPlusPluginPack.Net`](https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net), with some significant changes, including:
-1. `NotepadPlusPlusPluginPack.Net` has an architecture that is (in my opinion) needlessly complicated, because it separates the `PluginInfrastructure` folder containing all the necessary code for connecting with Notepad++ in a completely different directory tree from the rest of the code.
-2. This plugin template includes an example of a [non-docking (pop-up) dialog](/docs/README.md#about-form) opened from the plugin menu, a [docking form](/docs/README.md#selections-remembering-form), and a [non-docking non-pop-up form](/docs/README.md#dark-mode-test-form).
-3. This plugin template includes a [settings form](/docs/README.md#settings-form) that makes it easy for the maintainer to add, remove or edit settings.
-4. This template has a template for [automated tests](/docs/README.md#running-tests) that can be run inside Notepad++, including a template for user interface tests that automatically test forms.
+1. A simpler architecture in which the [PluginInfrastructure folder](/NppCSharpPluginPack/PluginInfrastructure/) is side-by-side with the rest of the plugin's code, rather than in a separate directory tree.
+2. An example of a [non-docking (pop-up) dialog](/docs/README.md#about-form) opened from the plugin menu, a [docking form](/docs/README.md#selections-remembering-form), and a [non-docking non-pop-up form](/docs/README.md#dark-mode-test-form).
+3. A [settings form](/docs/README.md#settings-form) that makes it easy for the maintainer to add, remove or edit settings.
+4. A template for [automated tests](/docs/README.md#running-tests) that can be run inside Notepad++, including a template for user interface tests that automatically test forms.
If you have any issues, see if [updating to the latest release](https://github.com/molsonkiko/NppCSharpPluginPack/releases) helps, and then feel free to raise an [issue](https://github.com/molsonkiko/NppCSharpPluginPack/issues) on GitHub. Please be sure to include diagnostic information about your system, Notepad++ version, and plugin version (go to `?->Debug Info...` from the Notepad++ main menu).
diff --git a/ToolsForMaintainersOfTheProjectTemplate/Scintilla_iface_synchronizer/cs.py b/ToolsForMaintainersOfTheProjectTemplate/Scintilla_iface_synchronizer/cs.py
index 687e9e1..c5cea05 100644
--- a/ToolsForMaintainersOfTheProjectTemplate/Scintilla_iface_synchronizer/cs.py
+++ b/ToolsForMaintainersOfTheProjectTemplate/Scintilla_iface_synchronizer/cs.py
@@ -170,12 +170,16 @@ def printLexGatewayFile(f):
iindent = iindent + " "
if param2Type == "stringresult":
- bufferVariableName = param2Name + "Buffer"
- bufferSize = "length" if (param1Type == "int" and param1Name == "length") else "10000"
- out.append(iindent + "byte[] " + bufferVariableName +" = new byte["+bufferSize+"];")
- out.append(iindent + "fixed (byte* "+param2Name+"Ptr = " +bufferVariableName + ")" )
- out.append(iindent + "{")
- iindent = iindent + " "
+ # TODO: this is where I need to auto-generate calls to
+ # GetNullStrippedStringFromMessageThatReturnsLength(SciMsg msg, IntPtr wParam=default)
+ # THIS IS STILL NOT FINISHED
+ returnvalue = 'return GetNullStrippedStringFromMessageThatReturnsLength(' + featureConstant
+ # if param 1 is unused, don't pass a second arg
+ if param1Type != 'Unused':
+ returnvalue += ', (IntPtr)' + param1Name
+ returnvalue += ')'
+ out.append(returnvalue)
+
firstArg = translateVariableAccess(param1Name, param1Type)
seconArg = translateVariableAccess(param2Name, param2Type)
@@ -196,14 +200,14 @@ def printLexGatewayFile(f):
# out.append(iindent + "return new Position((int) " +res+ ");")
elif returnType == "string":
out.append(iindent + res + ";")
- out.append(iindent + "return Encoding.UTF8.GetString("+bufferVariableName+").TrimEnd('\\0');")
+ out.append(iindent + "return Utf8BytesToNullStrippedString("+bufferVariableName+");")
else:
out.append(iindent + "return (" +returnType+ ")" +res+ ";")
if param1Type in ["string", "Cells", "stringresult"]:
iindent = iindent[4:]
out.append(iindent + "}")
- if param2Type in ["string", "Cells", "stringresult"]:
+ if param2Type in ["string", "Cells"]:
iindent = iindent[4:]
out.append(iindent + "}")
diff --git a/docs/README.md b/docs/README.md
index 47ce056..43eb86e 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -86,7 +86,7 @@ One thing to note is that this form responds to keys in intuitive and useful way
This is all because I registered the controls in the form with the `KeyUp`, `KeyDown`, and `KeyPress` handlers in [NppCSharpPlugin/Forms/NppFormHelper.cs](/NppCSharpPluginPack/Forms/NppFormHelper.cs).
-You will notice that the DarkModeTestForm discussed below does not have these nice responses to keys, because I did not register those handlers for its controls.
+You will notice that the DarkModeTestForm discussed below *does not have these nice responses to keys*, because I did not register those handlers for its controls.
## Dark mode test form ##
diff --git a/most recent errors.txt b/most recent errors.txt
index 8e5cfb2..7185d3a 100644
--- a/most recent errors.txt
+++ b/most recent errors.txt
@@ -1,4 +1,4 @@
-Test results for CSharpPluginPack v0.0.1.3 on Notepad++ 8.5.8 64bit
+Test results for CSharpPluginPack v0.0.1.4 on Notepad++ 8.5.8 64bit
NOTE: Ctrl-F (regular expressions *on*) for "Failed [1-9]\d*" to find all failed tests
No tests failed
=========================
@@ -21,13 +21,13 @@ Testing Performance of something
Performance tests for My benchmarks (test1)
=========================
-To run query "foo" on file of size 7913 into took 0 +/- 0 ms over 32 trials
-Query times (ms): 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-Preview of result: Previow of result
+To run query "foo" on file of size 7913 into took 0 +/- 0.002 ms over 32 trials
+Query times (ms): 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+Preview of result: Preview of result
=========================
Performance tests for My benchmarks (test2)
=========================
To run query "bar" on file of size 7913 into took 0 +/- 0 ms over 32 trials
Query times (ms): 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-Preview of result: Previow of result
+Preview of result: Preview of result