mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Add link support for supported terminals
Also refactors the code quite a bit, to make it a bit more easier to add features like this in the future. Closes #75
This commit is contained in:

committed by
Patrik Svensson

parent
1601ef24b3
commit
504746c5dc
14
examples/Links/Links.csproj
Normal file
14
examples/Links/Links.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Description>Demonstrates how to render links in a console.</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Spectre.Console\Spectre.Console.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
22
examples/Links/Program.cs
Normal file
22
examples/Links/Program.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Links
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
if (AnsiConsole.Capabilities.SupportLinks)
|
||||
{
|
||||
AnsiConsole.MarkupLine("[link=https://patriksvensson.se]Click to visit my blog[/]!");
|
||||
}
|
||||
else
|
||||
{
|
||||
AnsiConsole.MarkupLine("[red]It looks like your terminal doesn't support links[/]");
|
||||
AnsiConsole.WriteLine();
|
||||
AnsiConsole.MarkupLine("[yellow](╯°□°)╯[/]︵ [blue]┻━┻[/]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user