mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-01 01:25:27 +08:00 
			
		
		
		
	Updating documentation output to match new Exception rendering.
This commit is contained in:
		 Phil Scott
					Phil Scott
				
			
				
					committed by
					
						 Patrik Svensson
						Patrik Svensson
					
				
			
			
				
	
			
			
			 Patrik Svensson
						Patrik Svensson
					
				
			
						parent
						
							78958aae27
						
					
				
				
					commit
					e8eb5b85b9
				
			| @@ -1,6 +1,7 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Threading; | ||||
| using System.Threading.Tasks; | ||||
| using Spectre.Console; | ||||
|  | ||||
| namespace Generator.Commands | ||||
| @@ -65,6 +66,11 @@ namespace Generator.Commands | ||||
|             _input.Enqueue((new ConsoleKeyInfo((char)input, input, false, false, false), delay)); | ||||
|         } | ||||
|  | ||||
|         public bool IsKeyAvailable() | ||||
|         { | ||||
|             return _input.Count > 0; | ||||
|         } | ||||
|  | ||||
|         public ConsoleKeyInfo? ReadKey(bool intercept) | ||||
|         { | ||||
|             if (_input.Count == 0) | ||||
| @@ -77,5 +83,10 @@ namespace Generator.Commands | ||||
|             Thread.Sleep(result.Item2); | ||||
|             return result.Item1; | ||||
|         } | ||||
|  | ||||
|         public Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken) | ||||
|         { | ||||
|             return Task.FromResult(ReadKey(intercept)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -9,7 +9,7 @@ namespace Generator.Commands.Samples | ||||
|     { | ||||
|         public abstract void Run(IAnsiConsole console); | ||||
|         public virtual string Name() => PascalToKebab(GetType().Name.Replace("Sample","")); | ||||
|         public virtual (int Cols, int Rows) ConsoleSize => (82, 24); | ||||
|         public virtual (int Cols, int Rows) ConsoleSize => (120, 24); | ||||
|         public virtual IEnumerable<(string Name, Action<Capabilities> CapabilitiesAction)> GetCapabilities() | ||||
|         { | ||||
|             return new (string Name, Action<Capabilities> CapabilitiesAction)[] | ||||
|   | ||||
| @@ -8,7 +8,7 @@ namespace Generator.Commands.Samples | ||||
|     { | ||||
|         internal abstract class BaseExceptionSample : BaseSample | ||||
|         { | ||||
|             public override (int Cols, int Rows) ConsoleSize => (base.ConsoleSize.Cols, 12); | ||||
|             public override (int Cols, int Rows) ConsoleSize => (120, 12); | ||||
|  | ||||
|             protected readonly Exception Exception = null!; | ||||
|  | ||||
| @@ -27,7 +27,7 @@ namespace Generator.Commands.Samples | ||||
|  | ||||
|         internal class DefaultExceptionSample : BaseExceptionSample | ||||
|         { | ||||
|             public override void Run(IAnsiConsole console) => console.WriteException(Exception); | ||||
|             public override void Run(IAnsiConsole console) => console.WriteException(Exception, ExceptionFormats.ShortenPaths); | ||||
|         } | ||||
|  | ||||
|         internal class ShortenedExceptionSample : BaseExceptionSample | ||||
|   | ||||
| @@ -19,8 +19,8 @@ namespace Generator.Commands.Samples | ||||
|             console.DisplayThenType(c => password = AskPassword(c), "hunter2↲"); | ||||
|             console.DisplayThenType(c => color = AskColor(c), "↲"); | ||||
|  | ||||
|             AnsiConsole.Render(new Rule("[yellow]Results[/]").RuleStyle("grey").LeftAligned()); | ||||
|             AnsiConsole.Render(new Table().AddColumns("[grey]Question[/]", "[grey]Answer[/]") | ||||
|             AnsiConsole.Write(new Rule("[yellow]Results[/]").RuleStyle("grey").LeftAligned()); | ||||
|             AnsiConsole.Write(new Table().AddColumns("[grey]Question[/]", "[grey]Answer[/]") | ||||
|                 .RoundedBorder() | ||||
|                 .BorderColor(Color.Grey) | ||||
|                 .AddRow("[grey]Name[/]", name) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user