[Refactor] General reformat and clean-up.

This commit is contained in:
2025-11-24 20:12:10 +00:00
parent 8331fba1e4
commit a58f2e60e5
415 changed files with 4920 additions and 4829 deletions

View File

@@ -63,10 +63,7 @@ public static partial class AnsiColorParser
if(!m.Success) throw new ArgumentException("No ANSI SGR sequence found.", nameof(input));
int[] parts = m.Groups["params"]
.Value.Split([
';'
],
StringSplitOptions.RemoveEmptyEntries)
.Value.Split([';'], StringSplitOptions.RemoveEmptyEntries)
.Select(int.Parse)
.ToArray();
@@ -132,10 +129,7 @@ public static partial class AnsiColorParser
int ci = index - 16;
int r = ci / 36, g = ci / 6 % 6, b = ci % 6;
int[] levels =
[
0, 95, 135, 175, 215, 255
];
int[] levels = [0, 95, 135, 175, 215, 255];
return Color.FromArgb(levels[r], levels[g], levels[b]);
}

View File

@@ -82,17 +82,17 @@ public static class PrintHex
sb.Append(str);
sb.Append(" ");
for(int i = 0; i < width; i++) sb.Append($" {i:X2}");
for(var i = 0; i < width; i++) sb.Append($" {i:X2}");
if(color) sb.Append("\e[0m");
sb.AppendLine();
int b = 0;
var b = 0;
string format = $"{{0:X{offsetLength}}}";
var format = $"{{0:X{offsetLength}}}";
for(int i = 0; i < rows; i++)
for(var i = 0; i < rows; i++)
{
if(color) sb.Append("\e[36m");
@@ -104,18 +104,18 @@ public static class PrintHex
int lastBytes = i == rows - 1 ? last : width;
int lastSpaces = width - lastBytes;
for(int j = 0; j < lastBytes; j++)
for(var j = 0; j < lastBytes; j++)
{
sb.Append($" {array[b]:X2}");
b++;
}
for(int j = 0; j < lastSpaces; j++) sb.Append(" ");
for(var j = 0; j < lastSpaces; j++) sb.Append(" ");
b -= lastBytes;
sb.Append(" ");
for(int j = 0; j < lastBytes; j++)
for(var j = 0; j < lastBytes; j++)
{
int v = array[b];
sb.Append(v is > 31 and < 127 or > 159 ? (char)v : '.');