public void Emoji_() { WriteLine(Emoji.Get(":tada:").Raw); // 🎉 WriteLine(Emoji.Raw(":tada:")); // 🎉 WriteLine(Emoji.Emojify(":tada: initial commit")); // 🎉 initial commit WriteLine(Emoji.Find("party popper").First().Raw); // 🎉 }
public void Find() { Emoji.Find(":grinning:").Should().NotBeEmpty(); Emoji.Find("man: red hair").Should().NotBeEmpty(); Emoji.Find("face").Should().NotBeEmpty(); Emoji.Find("fail").Should().BeEmpty(); Action act = () => Emoji.Find(NullString); act.Should().Throw <ArgumentNullException>(); }
public void Find() { Emoji.Find("face").Should().NotBeEmpty(); Emoji.Find("fail").Should().BeEmpty(); }
/// <summary> /// Return a filtered list, based on the given query. /// </summary> /// <param name="query">The query to filter the list.</param> /// <returns>A filtered list, can be empty when nothing was found.</returns> public List <Result> Query(Query query) { if (query?.Search is null) { return(new List <Result>(0)); } var value = query.Search; if (string.IsNullOrEmpty(value)) { return(Emoji.All.Select(GetResult).ToList()); } var emojis = Emoji.Find(value); if (emojis.Any()) { return(emojis.Select(GetResult).ToList()); } var results = new List <Result>(); if (HasAlias(value)) { var result = Emoji.Emojify(value); results.Add( new Result { QueryTextDisplay = value, IcoPath = IconPath, Title = result, SubTitle = "Replace aliases in text with raw emojis", ToolTipData = new ToolTipData("Emojify", $"{value}\n{result}"), Action = _ => CopyToClipboard(result), ContextData = new EmojifiedString(result), }); } if (HasEmoji(value)) { var result = Emoji.Demojify(value); results.Add( new Result { QueryTextDisplay = value, IcoPath = IconPath, Title = result, SubTitle = "Replace raw emojis in text with aliases", ToolTipData = new ToolTipData("Demojify", $"{value}\n{result}"), Action = _ => CopyToClipboard(result), ContextData = new DemojifiedString(result), }); } return(results); Result GetResult(GEmoji emoji) => new() { QueryTextDisplay = value, IcoPath = IconPath, Title = emoji.Raw, SubTitle = string.Join(" ", emoji.Aliases.Select(x => x.PadAlias())), ToolTipData = new ToolTipData("GEmoji", $"Description: {emoji.Description}\nCategory: {emoji.Category}\nTags: {string.Join(", ", emoji.Tags ?? Enumerable.Empty<string>())}\n"), Action = _ => CopyToClipboard(emoji.Raw), ContextData = emoji, }; bool HasAlias(string value) { return(Regex.IsMatch(value, @":([\w+-]+):", RegexOptions.Compiled)); } bool HasEmoji(string value) { return(Regex.IsMatch(value, Emoji.RegexPattern, RegexOptions.Compiled)); } }