2020-10-28 06:39:26 +11:00
|
|
|
|
using System.Collections.Generic;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
using UnityEngine;
|
2020-11-11 00:16:01 +11:00
|
|
|
|
using System.Linq;
|
2021-03-18 17:17:29 +11:00
|
|
|
|
using UnityExplorer.Core.Unity;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2021-03-18 18:52:30 +11:00
|
|
|
|
namespace UnityExplorer.UI.Main.CSConsole.Lexer
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
public abstract class Matcher
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
2020-10-26 01:07:59 +11:00
|
|
|
|
public abstract Color HighlightColor { get; }
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
public string HexColor => htmlColor ?? (htmlColor = "<color=#" + HighlightColor.ToHex() + ">");
|
2020-11-11 00:16:01 +11:00
|
|
|
|
private string htmlColor;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-11-11 00:16:01 +11:00
|
|
|
|
public virtual IEnumerable<char> StartChars => Enumerable.Empty<char>();
|
|
|
|
|
public virtual IEnumerable<char> EndChars => Enumerable.Empty<char>();
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2021-03-18 17:17:29 +11:00
|
|
|
|
public abstract bool IsImplicitMatch(CSLexerHighlighter lexer);
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2021-03-18 17:17:29 +11:00
|
|
|
|
public bool IsMatch(CSLexerHighlighter lexer)
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
2020-10-26 01:07:59 +11:00
|
|
|
|
if (IsImplicitMatch(lexer))
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
|
|
|
|
lexer.Commit();
|
2020-10-26 01:07:59 +11:00
|
|
|
|
return true;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-26 01:07:59 +11:00
|
|
|
|
lexer.Rollback();
|
|
|
|
|
return false;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|