Files
UnityExplorer_Fix/src/UI/Main/CSConsole/Lexer/Matcher.cs

33 lines
894 B
C#
Raw Normal View History

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