Browse Source

The home key moves the cursor to the start of the line after the prompt in the Python Console.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3618 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
3aef8c79fe
  1. 11
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
  2. 45
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHomeKeyTestFixture.cs
  3. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

11
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs

@ -226,6 +226,9 @@ namespace ICSharpCode.PythonBinding @@ -226,6 +226,9 @@ namespace ICSharpCode.PythonBinding
switch (keyData) {
case Keys.Back:
return !CanBackspace;
case Keys.Home:
MoveToHomePosition();
return true;
}
return false;
}
@ -283,5 +286,13 @@ namespace ICSharpCode.PythonBinding @@ -283,5 +286,13 @@ namespace ICSharpCode.PythonBinding
PythonConsoleCompletionDataProvider completionProvider = new PythonConsoleCompletionDataProvider(this);
textEditor.ShowCompletionWindow(completionProvider);
}
/// <summary>
/// The home position is at the start of the line after the prompt.
/// </summary>
void MoveToHomePosition()
{
textEditor.Column = promptLength;
}
}
}

45
src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHomeKeyTestFixture.cs

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;
using Microsoft.Scripting.Hosting.Shell;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Console
{
/// <summary>
/// The Home Key should return the user to the start of the line after the prompt.
/// </summary>
[TestFixture]
public class PythonConsoleHomeKeyTestFixture
{
MockTextEditor textEditor;
PythonConsole console;
string prompt = ">>> ";
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
console = new PythonConsole(textEditor, null);
console.Write(prompt, Style.Prompt);
}
[Test]
public void HomeKeyPressedWhenNoUserTextInConsole()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Home);
int expectedColumn = prompt.Length;
Assert.AreEqual(expectedColumn, textEditor.Column);
}
}
}

1
src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

@ -73,6 +73,7 @@ @@ -73,6 +73,7 @@
<Compile Include="Console\DerivedPythonConsoleHost.cs" />
<Compile Include="Console\DisposedPythonConsoleTestFixture.cs" />
<Compile Include="Console\CodeCompletionTests.cs" />
<Compile Include="Console\PythonConsoleHomeKeyTestFixture.cs" />
<Compile Include="Console\MockMemberProvider.cs" />
<Compile Include="Console\MockTextEditor.cs" />
<Compile Include="Console\PythonConsoleCodeCompletionTestFixture.cs" />

Loading…
Cancel
Save