-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for
TextPath
widget
- Loading branch information
1 parent
eb4a7d3
commit d5464d4
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Title: Text Path | ||
Order: 80 | ||
Description: "The **TextPath** class is used to render a horizontal rule (line) to the terminal." | ||
Highlights: | ||
- Automatically shrinks paths to fit. | ||
- Custom colors for segments of the path. | ||
- Specify left, center or right aligned paths. | ||
Reference: T:Spectre.Console.TextPath | ||
|
||
--- | ||
|
||
The `TextPath` class is used to render a Windows or Unix disk path. | ||
|
||
<?# Info ?> | ||
In the examples below, we wrap the paths in a `Panel` to emphasize | ||
what it does and how it behaves. | ||
<?#/ Info ?> | ||
|
||
## Usage | ||
|
||
To render a text path: | ||
|
||
```csharp | ||
var path = new TextPath("C:/This/Path/Is/Too/Long/To/Fit/In/The/Area.txt"); | ||
|
||
AnsiConsole.Write(new Panel(path)); | ||
``` | ||
|
||
```text | ||
┌────────────────────────────────────────────────┐ | ||
│ C:/…/Is/Too/Long/To/Fit/In/The/Area.txt │ | ||
└────────────────────────────────────────────────┘ | ||
``` | ||
|
||
## Alignment | ||
|
||
You can set the rule title markup text. | ||
|
||
```csharp | ||
var path = new TextPath("C:/This/Path/Is/Too/Long/To/Fit/In/The/Area.txt"); | ||
path.Alignment = Justify.Right; | ||
|
||
AnsiConsole.Write(new Panel(path)); | ||
``` | ||
|
||
```text | ||
┌────────────────────────────────────────────────┐ | ||
│ C:/…/Is/Too/Long/To/Fit/In/The/Area.txt │ | ||
└────────────────────────────────────────────────┘ | ||
``` | ||
|
||
You can also specify styles via extension methods: | ||
|
||
```csharp | ||
var path = new TextPath("C:/This/Path/Is/Too/Long/To/Fit/In/The/Area.txt") | ||
.RightAligned(); | ||
``` | ||
|
||
## Styling | ||
|
||
All the segments in the path can be customized to have different styles. | ||
|
||
```csharp | ||
var path = new TextPath("C:/This/Path/Is/Too/Long/To/Fit/In/The/Area.txt"); | ||
|
||
path.RootStyle = new Style(foreground: Color.Red); | ||
path.SeparatorStyle = new Style(foreground: Color.Green); | ||
path.StemStyle = new Style(foreground: Color.Blue); | ||
path.LeafStyle = new Style(foreground: Color.Yellow); | ||
``` | ||
|
||
You can also specify styles via extension methods: | ||
|
||
```csharp | ||
var path = new TextPath("C:/This/Path/Is/Too/Long/To/Fit/In/The/Area.txt") | ||
.RootStyle(new Style(foreground: Color.Red)) | ||
.SeparatorStyle(new Style(foreground: Color.Green)) | ||
.StemStyle(new Style(foreground: Color.Blue)) | ||
.LeafStyle(new Style(foreground: Color.Yellow)); | ||
``` | ||
|
||
Or just set the colors via extension methods: | ||
|
||
```text | ||
var path = new TextPath("C:/This/Path/Is/Too/Long/To/Fit/In/The/Area.txt") | ||
.RootColor(Color.Red) | ||
.SeparatorColor(Color.Green) | ||
.StemColor(Color.Blue) | ||
.LeafColor(Color.Yellow); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
using Statiq.Common; | ||
|
||
namespace Docs.Shortcodes | ||
{ | ||
public class InfoShortcode : SyncShortcode | ||
{ | ||
public override ShortcodeResult Execute(KeyValuePair<string, string>[] args, string content, IDocument document, IExecutionContext context) | ||
{ | ||
return $"<div class=\"alert-info\">{content}</div>"; | ||
} | ||
} | ||
} |