SupaLidlGame/Debug/CharIterator.cs

34 lines
564 B
C#
Raw Permalink Normal View History

2023-09-24 18:51:23 -07:00
namespace SupaLidlGame.Debug;
public class CharIterator : Iterator<char>
2023-09-24 18:51:23 -07:00
{
2023-09-29 11:32:15 -07:00
public int Line { get; protected set; } = 1;
public int Column { get; protected set; } = 0;
2023-09-24 18:51:23 -07:00
public CharIterator(string str) : base(str.ToCharArray())
{
}
public CharIterator(char[] chars) : base(chars)
{
}
public override char MoveNext()
{
char c = base.MoveNext();
if (c == '\n')
{
Line++;
2023-09-29 11:32:15 -07:00
Column = 1;
2023-09-24 18:51:23 -07:00
}
else
{
Column++;
}
return c;
}
}