Skip to content

Commit

Permalink
Merge pull request #38 from gandarez/master
Browse files Browse the repository at this point in the history
Update NPP plugin platform with latest version
  • Loading branch information
gandarez authored Oct 10, 2020
2 parents c2dcc92 + f54b6d4 commit bf3b494
Show file tree
Hide file tree
Showing 14 changed files with 3,087 additions and 1,942 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ History
-------


4.2.0 (2020-10-10)
++++++++++++++++++

- Update NPP plugin platform with latest version.


4.1.0 (2019-04-10)
++++++++++++++++++

Expand Down
27 changes: 18 additions & 9 deletions WakaTime/PluginInfrastructure/ClikeStringArray.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Kbg.NppPluginNET.PluginInfrastructure
{
Expand All @@ -18,10 +20,10 @@ public ClikeStringArray(int num, int stringCapacity)
for (int i = 0; i < num; i++)
{
IntPtr item = Marshal.AllocHGlobal(stringCapacity);
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (i * IntPtr.Size)), item);
Marshal.WriteIntPtr(_nativeArray + (i * IntPtr.Size), item);
_nativeItems.Add(item);
}
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (num * IntPtr.Size)), IntPtr.Zero);
Marshal.WriteIntPtr(_nativeArray + (num * IntPtr.Size), IntPtr.Zero);
}
public ClikeStringArray(List<string> lstStrings)
{
Expand All @@ -30,10 +32,10 @@ public ClikeStringArray(List<string> lstStrings)
for (int i = 0; i < lstStrings.Count; i++)
{
IntPtr item = Marshal.StringToHGlobalUni(lstStrings[i]);
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (i * IntPtr.Size)), item);
Marshal.WriteIntPtr(_nativeArray + (i * IntPtr.Size), item);
_nativeItems.Add(item);
}
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (lstStrings.Count * IntPtr.Size)), IntPtr.Zero);
Marshal.WriteIntPtr(_nativeArray + (lstStrings.Count * IntPtr.Size), IntPtr.Zero);
}

public IntPtr NativePointer { get { return _nativeArray; } }
Expand All @@ -52,12 +54,19 @@ List<string> _getManagedItems(bool unicode)

public void Dispose()
{
if (!_disposed)
try
{
for (int i = 0; i < _nativeItems.Count; i++)
if (_nativeItems[i] != IntPtr.Zero) Marshal.FreeHGlobal(_nativeItems[i]);
if (_nativeArray != IntPtr.Zero) Marshal.FreeHGlobal(_nativeArray);
_disposed = true;
if (!_disposed)
{
for (int i = 0; i < _nativeItems.Count; i++)
if (_nativeItems[i] != IntPtr.Zero) Marshal.FreeHGlobal(_nativeItems[i]);
if (_nativeArray != IntPtr.Zero) Marshal.FreeHGlobal(_nativeArray);
_disposed = true;
}
}
catch (Exception e)
{
MessageBox.Show(MethodBase.GetCurrentMethod().ToString() +": "+ e.Message, this.GetType().Name);
}
}
~ClikeStringArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@
On 32 bit windows usually C:\Program Files\
On 64 bit windows usually C:\Program Files (x86)\
$(ProgramW6432) points to the 64bit Program Files (on 32 bit windows it is blank) -->
<MakeDir
Directories="$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\"
Condition="Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\') AND !Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x86'" />
<MakeDir Directories="$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\" Condition="Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\') AND !Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x86'" />
<Copy
SourceFiles="$(TargetPath)"
DestinationFolder="$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\"
Condition="Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x86'"
ContinueOnError="false" />
<MakeDir
Directories="$(ProgramW6432)\Notepad++\plugins\$(TargetName)\"
Condition="Exists('$(ProgramW6432)\Notepad++\plugins\') AND !Exists('$(ProgramW6432)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x64'" />
ContinueOnError="false" />
<MakeDir Directories="$(ProgramW6432)\Notepad++\plugins\$(TargetName)\" Condition="Exists('$(ProgramW6432)\Notepad++\plugins\') AND !Exists('$(ProgramW6432)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x64'" />
<Copy
SourceFiles="$(TargetPath)"
DestinationFolder="$(ProgramW6432)\Notepad++\plugins\$(TargetName)\"
Expand Down
Loading

0 comments on commit bf3b494

Please sign in to comment.