| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // Copyright (c) The Avalonia Project. All rights reserved.
- // Licensed under the MIT license. See licence.md file in the project root for full license information.
- using Avalonia.Utility;
- namespace Avalonia.Media.TextFormatting.Unicode
- {
- internal ref struct CodepointEnumerator
- {
- private ReadOnlySlice<char> _text;
- public CodepointEnumerator(ReadOnlySlice<char> text)
- {
- _text = text;
- Current = Codepoint.ReplacementCodepoint;
- }
- /// <summary>
- /// Gets the current <see cref="Codepoint"/>.
- /// </summary>
- public Codepoint Current { get; private set; }
- /// <summary>
- /// Moves to the next <see cref="Codepoint"/>.
- /// </summary>
- /// <returns></returns>
- public bool MoveNext()
- {
- if (_text.IsEmpty)
- {
- Current = Codepoint.ReplacementCodepoint;
- return false;
- }
- Current = Codepoint.ReadAt(_text, 0, out var count);
- _text = _text.Skip(count);
- return true;
- }
- }
- }
|