mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-06 04:28:15 +08:00
Add support for exclusive mode
This commit is contained in:

committed by
Phil Scott

parent
c2bab0ebf8
commit
7f6f2437b1
@ -9,12 +9,14 @@ namespace Spectre.Console.Testing
|
||||
{
|
||||
private readonly StringWriter _writer;
|
||||
private readonly IAnsiConsole _console;
|
||||
private readonly FakeExclusivityMode _exclusivityLock;
|
||||
|
||||
public string Output => _writer.ToString();
|
||||
|
||||
public Profile Profile => _console.Profile;
|
||||
public IAnsiConsoleCursor Cursor => _console.Cursor;
|
||||
public FakeConsoleInput Input { get; }
|
||||
public IExclusivityMode ExclusivityMode => _exclusivityLock;
|
||||
public RenderPipeline Pipeline => _console.Pipeline;
|
||||
|
||||
IAnsiConsoleInput IAnsiConsole.Input => Input;
|
||||
@ -24,6 +26,7 @@ namespace Spectre.Console.Testing
|
||||
AnsiSupport ansi = AnsiSupport.Yes,
|
||||
int width = 80)
|
||||
{
|
||||
_exclusivityLock = new FakeExclusivityMode();
|
||||
_writer = new StringWriter();
|
||||
|
||||
var factory = new AnsiConsoleFactory();
|
||||
|
@ -12,6 +12,7 @@ namespace Spectre.Console.Testing
|
||||
public Profile Profile { get; }
|
||||
public IAnsiConsoleCursor Cursor => new FakeAnsiConsoleCursor();
|
||||
IAnsiConsoleInput IAnsiConsole.Input => Input;
|
||||
public IExclusivityMode ExclusivityMode { get; }
|
||||
public RenderPipeline Pipeline { get; }
|
||||
|
||||
public FakeConsoleInput Input { get; }
|
||||
@ -24,6 +25,7 @@ namespace Spectre.Console.Testing
|
||||
bool legacyConsole = false, bool interactive = true)
|
||||
{
|
||||
Input = new FakeConsoleInput();
|
||||
ExclusivityMode = new FakeExclusivityMode();
|
||||
Pipeline = new RenderPipeline();
|
||||
|
||||
Profile = new Profile(new StringWriter(), encoding ?? Encoding.UTF8);
|
||||
|
18
src/Spectre.Console.Testing/Fakes/FakeExclusivityMode.cs
Normal file
18
src/Spectre.Console.Testing/Fakes/FakeExclusivityMode.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Spectre.Console.Testing
|
||||
{
|
||||
public sealed class FakeExclusivityMode : IExclusivityMode
|
||||
{
|
||||
public T Run<T>(Func<T> func)
|
||||
{
|
||||
return func();
|
||||
}
|
||||
|
||||
public async Task<T> Run<T>(Func<Task<T>> func)
|
||||
{
|
||||
return await func();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user