mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 05:18:16 +08:00
Add status support
This commit is contained in:

committed by
Patrik Svensson

parent
cbed41e637
commit
501db5d287
43
docs/input/appendix/spinners.md
Normal file
43
docs/input/appendix/spinners.md
Normal file
@ -0,0 +1,43 @@
|
||||
Title: Spinners
|
||||
Order: 4
|
||||
---
|
||||
|
||||
For all available spinners, see https://jsfiddle.net/sindresorhus/2eLtsbey/embedded/result/
|
||||
|
||||
# Usage
|
||||
|
||||
Spinners can be used with [Progress](xref:progress) and [Status](xref:status).
|
||||
|
||||
```csharp
|
||||
AnsiConsole.Status()
|
||||
.Spinner(Spinner.Known.Star)
|
||||
.Start("Thinking...", ctx => {
|
||||
// Omitted
|
||||
});
|
||||
```
|
||||
|
||||
# Implementing a spinner
|
||||
|
||||
To implement your own spinner, all you have to do is
|
||||
inherit from the `Spinner` base class.
|
||||
|
||||
In the example below, the spinner will alterate between
|
||||
the characters `A`, `B` and `C` every 100 ms.
|
||||
|
||||
```csharp
|
||||
public sealed class MySpinner : Spinner
|
||||
{
|
||||
// The interval for each frame
|
||||
public override TimeSpan Interval => TimeSpan.FromMilliseconds(100);
|
||||
|
||||
// Whether or not the spinner contains unicode characters
|
||||
public override bool IsUnicode => false;
|
||||
|
||||
// The individual frames of the spinner
|
||||
public override IReadOnlyList<string> Frames =>
|
||||
new List<string>
|
||||
{
|
||||
"A", "B", "C",
|
||||
};
|
||||
}
|
||||
```
|
Reference in New Issue
Block a user