Browse Source

Allow CodeCompletionDataProvider to specify the chars that are allowed to be entered while the code completion window is opened.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1105 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
8c8f945005
  1. 11
      src/Libraries/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj
  2. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs
  3. 4
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/ICompletionDataProvider.cs
  4. 8
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs
  5. 11
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CachedCompletionDataProvider.cs
  6. 5
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs

11
src/Libraries/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj

@ -15,7 +15,6 @@
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Resources\ICSharpCode.TextEditor.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>Resources\ICSharpCode.TextEditor.snk</AssemblyOriginatorKeyFile>
<RootNamespace>ICSharpCode.TextEditor</RootNamespace> <RootNamespace>ICSharpCode.TextEditor</RootNamespace>
<DebugType>None</DebugType>
<RegisterForComInterop>False</RegisterForComInterop> <RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>134217728</BaseAddress> <BaseAddress>134217728</BaseAddress>
@ -23,7 +22,6 @@
<FileAlignment>4096</FileAlignment> <FileAlignment>4096</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
@ -32,13 +30,20 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>False</DebugSymbols>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\bin\</OutputPath> <OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>Full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs

@ -151,7 +151,7 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
public override bool ProcessKeyEvent(char ch) public override bool ProcessKeyEvent(char ch)
{ {
if (!Char.IsLetterOrDigit(ch) && ch != '_') { if (dataProvider.IsInsertionKey(ch)) {
if (ch == ' ' && dataProvider.InsertSpace) { if (ch == ' ' && dataProvider.InsertSpace) {
// increment start + end and process as normal space // increment start + end and process as normal space
++startOffset; ++startOffset;

4
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/ICompletionDataProvider.cs

@ -36,6 +36,10 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
get; get;
set; set;
} }
/// <summary>
/// Gets if pressing 'key' should trigger the insertion of the currently selected element.
/// </summary>
bool IsInsertionKey(char key);
/// <summary> /// <summary>
/// Generates the completion data. This method is called by the text editor control. /// Generates the completion data. This method is called by the text editor control.

8
src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs

@ -62,6 +62,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
} }
} }
/// <summary>
/// Gets if pressing 'key' should trigger the insertion of the currently selected element.
/// </summary>
public virtual bool IsInsertionKey(char key)
{
return !char.IsLetterOrDigit(key) && key != '_';
}
/// <summary> /// <summary>
/// Generates the completion data. This method is called by the text editor control. /// Generates the completion data. This method is called by the text editor control.
/// </summary> /// </summary>

11
src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CachedCompletionDataProvider.cs

@ -38,6 +38,17 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
} }
} }
public override ImageList ImageList {
get {
return baseProvider.ImageList;
}
}
public override bool IsInsertionKey(char key)
{
return baseProvider.IsInsertionKey(key);
}
public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
{ {
if (completionData == null) { if (completionData == null) {

5
src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs

@ -244,6 +244,11 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
if (codeCompletionWindow.ProcessKeyEvent(ch)) { if (codeCompletionWindow.ProcessKeyEvent(ch)) {
return true; return true;
} }
if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed) {
// code-completion window is still opened but did not want to handle
// the keypress -> don't try to restart code-completion
return false;
}
} }
try { try {

Loading…
Cancel
Save