Permalink
Browse files

Added AutoCompletion

  • Loading branch information...
cmrazek committed Jul 19, 2012
1 parent c259c28 commit a29293612d6ed81952a0a024fd855e0bd0c4a4ad
@@ -31,7 +31,7 @@ using namespace System::Security::Permissions;
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly:AssemblyVersionAttribute("1.0.3.3")];
+[assembly:AssemblyVersionAttribute("1.0.3.4")];
[assembly:ComVisible(false)];
View
@@ -192,6 +192,10 @@ namespace NppSharp
String^ BuildExtensionList(IEnumerable<String^>^ extList);
String^ ColorToWebHex(Color color);
Color WebHexToColor(String^ str);
+
+ // AutoCompletion
+ virtual void ShowAutoCompletion(int lengthEntered, IEnumerable<String^>^ list, bool ignoreCase);
+ virtual void CancelAutoCompletion();
private:
@@ -146,6 +146,7 @@
<ClCompile Include="AssemblyInfo.cpp" />
<ClCompile Include="ClrUtil.cpp" />
<ClCompile Include="Main.cpp" />
+ <ClCompile Include="Npp_AutoCompletion.cpp" />
<ClCompile Include="Npp_Editor.cpp" />
<ClCompile Include="NppInterface.cpp" />
<ClCompile Include="Stdafx.cpp">
@@ -20,6 +20,9 @@
<Filter Include="OutputWindow">
<UniqueIdentifier>{92131f8b-fdf9-478c-a11c-c013ea5e3f1f}</UniqueIdentifier>
</Filter>
+ <Filter Include="AutoCompletion">
+ <UniqueIdentifier>{fbfac5f8-97a5-4e2d-830d-6eefb299ab31}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<None Include="app.ico">
@@ -137,5 +140,8 @@
<ClCompile Include="OutputWindow.cpp">
<Filter>OutputWindow</Filter>
</ClCompile>
+ <ClCompile Include="Npp_AutoCompletion.cpp">
+ <Filter>AutoCompletion</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
@@ -0,0 +1,45 @@
+// NppSharp - C#/.NET Scripting Plugin for Notepad++
+// Copyright (C) 2012 Chris Mrazek
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "Stdafx.h"
+#include "NppInterface.h"
+#include "ClrUtil.h"
+
+using namespace System::Text;
+
+namespace NppSharp
+{
+ void NppInterface::ShowAutoCompletion(int lengthEntered, IEnumerable<String^>^ list, bool ignoreCase)
+ {
+ StringBuilder^ sb = gcnew StringBuilder();
+ for each (String^ word in list)
+ {
+ if (sb->Length > 0) sb->Append(" ");
+ sb->Append(word);
+ }
+
+ std::string listStr = ClrStringToAString(sb->ToString());
+
+ ::SendMessageA(_scHandle, SCI_AUTOCSETSEPARATOR, (WPARAM)' ', 0);
+ ::SendMessageA(_scHandle, SCI_AUTOCSETIGNORECASE, ignoreCase ? 1 : 0, 0);
+ ::SendMessageA(_scHandle, SCI_AUTOCSHOW, lengthEntered, (LPARAM)listStr.c_str());
+ }
+
+ void NppInterface::CancelAutoCompletion()
+ {
+ ::SendMessageA(_scHandle, SCI_AUTOCCANCEL, 0, 0);
+ }
+}
View
@@ -745,6 +745,21 @@ public interface INpp
/// </summary>
void RefreshCustomLexers();
#endregion
+
+ #region AutoCompletion
+ /// <summary>
+ /// Shows the AutoCompletion list.
+ /// </summary>
+ /// <param name="lengthEntered">The number of characters already entered by the user.</param>
+ /// <param name="list">The list of words.</param>
+ /// <param name="ignoreCase">Ignore case?</param>
+ void ShowAutoCompletion(int lengthEntered, IEnumerable<string> list, bool ignoreCase);
+
+ /// <summary>
+ /// Cancels any action auto-completion.
+ /// </summary>
+ void CancelAutoCompletion();
+ #endregion
}
#region Event Handlers
View
@@ -1070,5 +1070,36 @@ public void RefreshCustomLexers()
Plugin.NppIntf.RefreshCustomLexers();
}
#endregion
+
+ #region AutoCompletion
+ /// <summary>
+ /// Shows the AutoCompletion list.
+ /// </summary>
+ /// <param name="lengthEntered">The number of characters already entered by the user.</param>
+ /// <param name="list">The list of words.</param>
+ /// <param name="ignoreCase">Ignore case?</param>
+ public void ShowAutoCompletion(int lengthEntered, IEnumerable<string> list, bool ignoreCase)
+ {
+ Plugin.NppIntf.ShowAutoCompletion(lengthEntered, list, ignoreCase);
+ }
+
+ /// <summary>
+ /// Shows the AutoCompletion list.
+ /// </summary>
+ /// <param name="lengthEntered">The number of characters already entered by the user.</param>
+ /// <param name="list">The list of words.</param>
+ public void ShowAutoCompletion(int lengthEntered, IEnumerable<string> list)
+ {
+ Plugin.NppIntf.ShowAutoCompletion(lengthEntered, list, false);
+ }
+
+ /// <summary>
+ /// Cancels any active auto-completion.
+ /// </summary>
+ public void CancelAutoCompletion()
+ {
+ Plugin.NppIntf.CancelAutoCompletion();
+ }
+ #endregion
}
}
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.3.3")]
-[assembly: AssemblyFileVersion("1.0.3.3")]
+[assembly: AssemblyVersion("1.0.3.4")]
+[assembly: AssemblyFileVersion("1.0.3.4")]
View
@@ -3,7 +3,7 @@
;---------------------------------------------------------------------------------------------------
Name "NppSharp"
-OutFile "Output\NppSharp_Setup_1.0.3.3.exe"
+OutFile "Output\NppSharp_Setup_1.0.3.4.exe"
InstallDir "$PROGRAMFILES32\Notepad++"
;---------------------------------------------------------------------------------------------------

0 comments on commit a292936

Please sign in to comment.