mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 07:56:41 +08:00
rename Lexer folder to match namespace, some cleanups and color adjustments
This commit is contained in:
32
src/UI/CSConsole/Lexers/NumberLexer.cs
Normal file
32
src/UI/CSConsole/Lexers/NumberLexer.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityExplorer.UI.CSharpConsole.Lexers
|
||||
{
|
||||
public class NumberLexer : Lexer
|
||||
{
|
||||
// Maroon
|
||||
protected override Color HighlightColor => new Color(0.58f, 0.33f, 0.33f, 1.0f);
|
||||
|
||||
private bool IsNumeric(char c) => char.IsNumber(c) || c == '.';
|
||||
|
||||
public override bool TryMatchCurrent(LexerBuilder lexer)
|
||||
{
|
||||
// previous character must be whitespace or delimiter
|
||||
if (!lexer.IsDelimiter(lexer.Previous, true))
|
||||
return false;
|
||||
|
||||
if (!IsNumeric(lexer.Current))
|
||||
return false;
|
||||
|
||||
while (!lexer.EndOfInput)
|
||||
{
|
||||
lexer.Commit();
|
||||
if (!IsNumeric(lexer.PeekNext()))
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user