diff --git a/OpenNest.Core/CNC/ProgramHighlighting.cs b/OpenNest.Core/CNC/ProgramHighlighting.cs index 1aeffe6..2fda4d7 100644 --- a/OpenNest.Core/CNC/ProgramHighlighting.cs +++ b/OpenNest.Core/CNC/ProgramHighlighting.cs @@ -4,6 +4,15 @@ using System.Text.RegularExpressions; namespace OpenNest.CNC; +/// +/// A character range in generated G-code assigned by one highlighting rule. +/// +/// Zero-based UTF-16 index of the first colored character. +/// Number of UTF-16 characters to color. +/// +/// Zero-based rule index: 0 comments, 1 motion modes (G90/G91), 2 rapid moves (G00), +/// 3 linear moves (G01), 4 arcs (G02/G03). +/// public readonly record struct HighlightSpan(int Index, int Length, int RuleIndex); /// Computes cosmetic G-code highlight spans without changing the generated text. diff --git a/OpenNest.Tests/CNC/ProgramHighlightingTests.cs b/OpenNest.Tests/CNC/ProgramHighlightingTests.cs index c142b55..ee1ebb4 100644 --- a/OpenNest.Tests/CNC/ProgramHighlightingTests.cs +++ b/OpenNest.Tests/CNC/ProgramHighlightingTests.cs @@ -9,6 +9,11 @@ namespace OpenNest.Tests.CNC; public class ProgramHighlightingTests { + [Fact] + public void ComputeSpans_RejectsNullText() + { + Assert.Throws(() => ProgramHighlighting.ComputeSpans(null)); + } [Theory] [InlineData("G00", 2, 3)] [InlineData("G000", -1, 0)] diff --git a/OpenNest.WinForms.Tests/Controls/ProgramEditorControlTests.cs b/OpenNest.WinForms.Tests/Controls/ProgramEditorControlTests.cs index 903a510..a37773b 100644 --- a/OpenNest.WinForms.Tests/Controls/ProgramEditorControlTests.cs +++ b/OpenNest.WinForms.Tests/Controls/ProgramEditorControlTests.cs @@ -44,8 +44,17 @@ public class ProgramEditorControlTests control.Dock = DockStyle.Fill; form.Controls.Add(control); form.Show(); + var status = GetControl