mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-18 21:08:15 +08:00
Update emoji support
* Add constants for emojis * Move emoji shortcode rendering to Markup * Add documentation * Add example * Add tests
This commit is contained in:

committed by
Patrik Svensson

parent
090b30f731
commit
eeb3f967b6
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Generated {{ date.now | date.to_string `%Y-%m-%d %k:%M` }}
|
||||
// Generated {{ date.now | date.to_string `%F %R` }}
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Generated {{ date.now | date.to_string `%Y-%m-%d %k:%M` }}
|
||||
// Generated {{ date.now | date.to_string `%F %R` }}
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Generated {{ date.now | date.to_string `%Y-%m-%d %k:%M` }}
|
||||
// Generated {{ date.now | date.to_string `%F %R` }}
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Generated {{ date.now | date.to_string `%Y-%m-%d %k:%M` }}
|
||||
// Generated {{ date.now | date.to_string `%F %R` }}
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@ -10,20 +10,34 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class for working with emojis.
|
||||
/// Utility for working with emojis.
|
||||
/// </summary>
|
||||
internal static partial class Emoji
|
||||
public static partial class Emoji
|
||||
{
|
||||
private static readonly Dictionary<string, string> _emojis
|
||||
= new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase)
|
||||
{
|
||||
{{~ for emoji in emojis }} { "{{ emoji.name }}", "{{ emoji.code }}" },
|
||||
{{~ for emoji in emojis ~}}
|
||||
{ "{{ emoji.identifier }}", Emoji.Known.{{ emoji.name }} },
|
||||
{{~ end ~}}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Contains all predefined emojis.
|
||||
/// </summary>
|
||||
public static class Known
|
||||
{
|
||||
{{- for emoji in emojis }}
|
||||
/// <summary>
|
||||
/// Gets the "{{ emoji.identifier }}" emoji.
|
||||
/// Description: {{ emoji.description }}.
|
||||
/// </summary>
|
||||
public const string {{ emoji.name }} = "{{ emoji.code }}";
|
||||
{{~ end ~}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
resources/scripts/Generator/Templates/Emoji.Json.template
Normal file
10
resources/scripts/Generator/Templates/Emoji.Json.template
Normal file
@ -0,0 +1,10 @@
|
||||
[
|
||||
{{~ for x in 0..(emojis.size-1) ~}}
|
||||
{
|
||||
"id": "{{ emojis[x].identifier }}",
|
||||
"name": "{{ emojis[x].name }}",
|
||||
"description": "{{ emojis[x].description }}",
|
||||
"code": "{{ emojis[x].normalized_code }}"
|
||||
}{{ if x != (emojis.size-1) }},{{ end }}
|
||||
{{~ end ~}}
|
||||
]
|
Reference in New Issue
Block a user