Skip to content
Merged

#45 #46

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# nppGeneratePasswords
A plugin for the popular Notepad++ Editor. This plugin will generate any number of random passwords/strings to a new document, or to an existing document (think datafile)

# Currently in progress
Trying to massively increase generation speeds with the inline option. This is now very slow because of the jumping back and forth in the editor. No good solution yet.
## News
As of v1.9.5 it is now possible to generate strings inline just as fast as to a new document.
54 changes: 27 additions & 27 deletions nppRandomStringGenerator/Forms/About.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions nppRandomStringGenerator/Forms/ConfigAndGenerate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ private void SaveSettings()

private async void ButtonGenerate_Click(Object sender, EventArgs e)
{
if (this.RadioButtonInline.Checked && NumericUpDownQuantity.Value > 5000)
{
if (MessageBox.Show($"It will take allot of time to process {this.NumericUpDownQuantity.Value} lines and Notepad++ will be frozen until it is done.\nFor example it will take 20 seconds to process 5000 lines on a AMD Ryzen 9 5900. Are you sure you want to start this process?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
{
return;
}
}
//if (this.RadioButtonInline.Checked && NumericUpDownQuantity.Value > 5000)
//{
// if (MessageBox.Show($"It will take allot of time to process {this.NumericUpDownQuantity.Value} lines and Notepad++ will be frozen until it is done.\nFor example it will take 20 seconds to process 5000 lines on a AMD Ryzen 9 5900. Are you sure you want to start this process?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
// {
// return;
// }
//}

this.Cursor = Cursors.WaitCursor;

Expand Down
42 changes: 27 additions & 15 deletions nppRandomStringGenerator/Modules/StringGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public TimeSpan ProcessTime

public CancellationTokenSource CancelJob { get; set; }

private string[] AllLines;

public void GenerateStrings()
{

Expand All @@ -55,7 +57,6 @@ public void GenerateStrings()
MissingWorkload = this.GuidQuantity % cores;
}


CancelJob = new CancellationTokenSource();

ParallelOptions options = new ParallelOptions()
Expand All @@ -64,6 +65,11 @@ public void GenerateStrings()
MaxDegreeOfParallelism = cores
};

if (this.IsInline)
{
AllLines = this.Editor.GetText().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
}

Stopwatch sw = Stopwatch.StartNew();
try
{
Expand Down Expand Up @@ -106,15 +112,11 @@ public void GenerateStrings()

if (i > 0) line += MissingWorkload;

sb.Append(Guid.NewGuid().ToString(this.GuidFormat));
sb.Append(this.TextSeperator);

lock (this.LockingEditor)
{
sb.Append(Guid.NewGuid().ToString(this.GuidFormat));

this.Editor.GotoLine(line);
this.Editor.LineEnd();
this.Editor.AddText(sb.Length, sb.ToString());
}
AllLines[line] += sb.ToString();

sb.Clear();
}
Expand All @@ -124,7 +126,6 @@ public void GenerateStrings()

BufferCount++;


if (BufferCount >= 1024 || w + 1 == internalWorkload)
{
this.Editor.AddText(sb.Length, sb.ToString());
Expand Down Expand Up @@ -191,12 +192,7 @@ public void GenerateStrings()

if (i > 0) line += MissingWorkload;

lock (this.LockingEditor)
{
this.Editor.GotoLine(line);
this.Editor.LineEnd();
this.Editor.AddText(sb.Length, sb.ToString());
}
AllLines[line] += sb.ToString();

sb.Clear();
}
Expand All @@ -222,6 +218,22 @@ public void GenerateStrings()
Debug.WriteLine(oce.Message);
this.IsCancelled = true;
}


if (this.IsInline)
{
int totalLength = 0;
for (int i = 0; i < this.AllLines.Length; i++)
{
totalLength += this.AllLines[i].Length;
}

totalLength += (this.AllLines.Length * Environment.NewLine.Length) - Environment.NewLine.Length;

this.Editor.ClearAll();
this.Editor.AddText(totalLength, string.Join(Environment.NewLine, this.AllLines));
}

sw.Stop();

this.InternalProcessTime = sw.Elapsed;
Expand Down
4 changes: 2 additions & 2 deletions nppRandomStringGenerator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.9.4")]
[assembly: AssemblyFileVersion("1.9.4")]
[assembly: AssemblyVersion("1.9.5")]
[assembly: AssemblyFileVersion("1.9.5")]