Permalink
Browse files

Scroll to end of console when any text is output.

  • Loading branch information...
1 parent 9e873eb commit bf9e815a0f34e1dddbb596ce4b3a49a419f29725 @mrward mrward committed Mar 27, 2011
@@ -9,7 +9,7 @@ public interface IScriptingConsole : IDisposable
{
event EventHandler LineReceived;
- bool ScrollToEndWhenPromptWritten { get; set; }
+ bool ScrollToEndWhenTextWritten { get; set; }
void SendLine(string line);
void SendText(string text);
@@ -34,7 +34,7 @@ public ScriptingConsole(IScriptingConsoleTextEditor textEditor, ScriptingConsole
{
this.textEditor = textEditor;
this.unreadLines = unreadLines;
- this.ScrollToEndWhenPromptWritten = true;
+ this.ScrollToEndWhenTextWritten = true;
textEditor.PreviewKeyDown += ProcessPreviewKeyDown;
}
@@ -78,10 +78,10 @@ public void Write(string text, ScriptingStyle style)
WriteFirstLineOfSentText();
textEditor.MakeCurrentContentReadOnly();
-
- if (ScrollToEndWhenPromptWritten) {
- ScrollToEnd();
- }
+ }
+
+ if (ScrollToEndWhenTextWritten) {
+ ScrollToEnd();
}
}
@@ -346,7 +346,7 @@ public string ReadFirstUnreadLine()
return unreadLines.RemoveFirstLine();
}
- public bool ScrollToEndWhenPromptWritten { get; set; }
+ public bool ScrollToEndWhenTextWritten { get; set; }
void ScrollToEnd()
{
@@ -35,10 +35,9 @@ void NonThreadSafeScriptingConsoleLineReceived(object source, EventArgs e)
consoleEvents.SetLineReceivedEvent();
}
-
- public bool ScrollToEndWhenPromptWritten {
- get { return nonThreadSafeScriptingConsole.ScrollToEndWhenPromptWritten; }
- set { nonThreadSafeScriptingConsole.ScrollToEndWhenPromptWritten = value; }
+ public bool ScrollToEndWhenTextWritten {
+ get { return nonThreadSafeScriptingConsole.ScrollToEndWhenTextWritten; }
+ set { nonThreadSafeScriptingConsole.ScrollToEndWhenTextWritten = value; }
}
public void WriteLine()
@@ -52,36 +52,36 @@ public void Constructor_NewInstance_DoesNotHaveLinesWaitingToBeRead()
}
[Test]
- public void Write_WritePromptWhenScrollToPromptIsTrue_TextEditorIsScrolled()
+ public void Write_WritePromptWhenScrollToEndWhenTextWritten_TextEditorIsScrolled()
{
- TestableScriptingConsole.ScrollToEndWhenPromptWritten = true;
+ TestableScriptingConsole.ScrollToEndWhenTextWritten = true;
TestableScriptingConsole.Write("a", ScriptingStyle.Prompt);
Assert.IsTrue(FakeConsoleTextEditor.IsScrollToEndCalled);
}
[Test]
- public void Write_WritePromptWhenScrollToPromptIsFalse_TextEditorIsNotScrolled()
+ public void Write_WritePromptWhenScrollToEndWhenTextWrittenIsFalse_TextEditorIsNotScrolled()
{
- TestableScriptingConsole.ScrollToEndWhenPromptWritten = false;
+ TestableScriptingConsole.ScrollToEndWhenTextWritten = false;
TestableScriptingConsole.Write("a", ScriptingStyle.Prompt);
Assert.IsFalse(FakeConsoleTextEditor.IsScrollToEndCalled);
}
[Test]
- public void Write_WriteErrorWhenScrollToPromptIsTrue_TextEditorIsNotScrolled()
+ public void Write_WriteErrorWhenScrollToEndWhenTextWrittenIsTrue_TextEditorIsScrolled()
{
- TestableScriptingConsole.ScrollToEndWhenPromptWritten = true;
+ TestableScriptingConsole.ScrollToEndWhenTextWritten = true;
TestableScriptingConsole.Write("a", ScriptingStyle.Error);
- Assert.IsFalse(FakeConsoleTextEditor.IsScrollToEndCalled);
+ Assert.IsTrue(FakeConsoleTextEditor.IsScrollToEndCalled);
}
[Test]
- public void ScrollToEndWhenPromptWritten_NewInstance_IsTrue()
+ public void ScrollToEndWhenTextWritten_NewInstance_IsTrue()
{
- Assert.IsTrue(TestableScriptingConsole.ScrollToEndWhenPromptWritten);
+ Assert.IsTrue(TestableScriptingConsole.ScrollToEndWhenTextWritten);
}
}
}
@@ -355,21 +355,21 @@ public void ReadFirstUnreadLine_NonThreadSafeConsoleHasOneUnreadLine_ReturnsNonT
}
[Test]
- public void ScrollToEndWhenPromptWritten_NonThreadSafeConsoleScrollToEndWhenPromptWrittenIsTrue_ReturnsTrue()
+ public void ScrollToEndWhenTextWritten_NonThreadSafeConsoleScrollToEndWhenTextWrittenIsTrue_ReturnsTrue()
{
CreateThreadSafeScriptingConsole();
- nonThreadSafeScriptingConsole.ScrollToEndWhenPromptWritten = true;
+ nonThreadSafeScriptingConsole.ScrollToEndWhenTextWritten = true;
- Assert.IsTrue(threadSafeConsole.ScrollToEndWhenPromptWritten);
+ Assert.IsTrue(threadSafeConsole.ScrollToEndWhenTextWritten);
}
[Test]
- public void ScrollToEndWhenPromptWritten_NonThreadSafeConsoleScrollToEndWhenPromptWrittenIsFalse_ReturnsFalse()
+ public void ScrollToEndWhenTextWritten_NonThreadSafeConsoleScrollToEndWhenTextWrittenIsFalse_ReturnsFalse()
{
CreateThreadSafeScriptingConsole();
- nonThreadSafeScriptingConsole.ScrollToEndWhenPromptWritten = false;
+ nonThreadSafeScriptingConsole.ScrollToEndWhenTextWritten = false;
- Assert.IsFalse(threadSafeConsole.ScrollToEndWhenPromptWritten);
+ Assert.IsFalse(threadSafeConsole.ScrollToEndWhenTextWritten);
}
}
}
@@ -23,7 +23,7 @@ public class FakeScriptingConsole : IScriptingConsole
public string TextToReturnFromReadFirstUnreadLine;
public bool IsReadLineCalled;
public bool IsDisposeCalled;
- public bool ScrollToEndWhenPromptWritten { get; set; }
+ public bool ScrollToEndWhenTextWritten { get; set; }
public void SendLine(string text)
{
@@ -17,7 +17,6 @@ public PackageManagementConsole()
{
}
-
public PackageManagementConsole(TextEditor textEditor)
: this(new ScriptingConsoleTextEditor(textEditor), new ControlDispatcher(textEditor))
{

0 comments on commit bf9e815

Please sign in to comment.