Skip to content

Commit 5a6aae6

Browse files
committed
Fix warnings and tidup code
1 parent 64d286c commit 5a6aae6

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

Terminal.Gui/ConsoleDrivers/NetDriver.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,6 @@ private bool SetCursorPosition (int col, int row)
13391339
}
13401340

13411341
private CursorVisibility? _cachedCursorVisibility;
1342-
private static bool _supportsSixel;
13431342

13441343
public override void UpdateCursor ()
13451344
{

Terminal.Gui/Drawing/Quant/ColorQuantizer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public class ColorQuantizer
3232

3333
private readonly ConcurrentDictionary<Color, int> _nearestColorCache = new ();
3434

35+
/// <summary>
36+
/// Builds a <see cref="Palette"/> of colors that most represent the colors used in <paramref name="pixels"/> image.
37+
/// This is based on the currently configured <see cref="PaletteBuildingAlgorithm"/>.
38+
/// </summary>
39+
/// <param name="pixels"></param>
3540
public void BuildPalette (Color [,] pixels)
3641
{
3742
List<Color> allColors = new List<Color> ();

Terminal.Gui/Drawing/Quant/PopularityPaletteWithThreshold.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder
1212
private readonly IColorDistance _colorDistance;
1313
private readonly double _mergeThreshold;
1414

15+
/// <summary>
16+
/// Creates a new instance with the given color grouping parameters.
17+
/// </summary>
18+
/// <param name="colorDistance">Determines which different colors can be considered the same.</param>
19+
/// <param name="mergeThreshold">Threshold for merging two colors together.</param>
1520
public PopularityPaletteWithThreshold (IColorDistance colorDistance, double mergeThreshold)
1621
{
1722
_colorDistance = colorDistance;
@@ -62,6 +67,7 @@ public List<Color> BuildPalette (List<Color> colors, int maxColors)
6267
/// Merge colors in the histogram if they are within the threshold distance
6368
/// </summary>
6469
/// <param name="colorHistogram"></param>
70+
/// <param name="maxColors"></param>
6571
/// <returns></returns>
6672
private Dictionary<Color, int> MergeSimilarColors (Dictionary<Color, int> colorHistogram, int maxColors)
6773
{

Terminal.Gui/Drawing/SixelEncoder.cs

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ private string ProcessBand (Color [,] pixels, int startY, int bandHeight, int wi
114114
for (int x = 0; x < width; ++x)
115115
{
116116
Array.Clear (code, 0, usedColorIdx.Count);
117-
bool anyNonTransparentPixel = false; // Track if any non-transparent pixels are found in this column
118117

119118
// Process each row in the 6-pixel high band
120119
for (int row = 0; row < bandHeight; ++row)
@@ -127,10 +126,6 @@ private string ProcessBand (Color [,] pixels, int startY, int bandHeight, int wi
127126
{
128127
continue;
129128
}
130-
else
131-
{
132-
anyNonTransparentPixel = true;
133-
}
134129

135130
if (slots [colorIndex] == -1)
136131
{
@@ -147,27 +142,6 @@ private string ProcessBand (Color [,] pixels, int startY, int bandHeight, int wi
147142
code [slots [colorIndex]] |= (byte)(1 << row); // Accumulate SIXEL data
148143
}
149144

150-
/*
151-
// If no non-transparent pixels are found in the entire column, it's fully transparent
152-
if (!anyNonTransparentPixel)
153-
{
154-
// Emit fully transparent pixel data: #0!<width>?$
155-
result.Append ($"#0!{width}?");
156-
157-
// Add the line terminator: use "$-" if it's not the last line, "$" if it's the last line
158-
if (x < width - 1)
159-
{
160-
result.Append ("$-");
161-
}
162-
else
163-
{
164-
result.Append ("$");
165-
}
166-
167-
// Skip to the next column as we have already handled transparency
168-
continue;
169-
}*/
170-
171145
// Handle transitions between columns
172146
for (int j = 0; j < usedColorIdx.Count; ++j)
173147
{
@@ -209,9 +183,21 @@ private string ProcessBand (Color [,] pixels, int startY, int bandHeight, int wi
209183
private static string CodeToSixel (int code, int repeat)
210184
{
211185
char c = (char)(code + 63);
212-
if (repeat > 3) return "!" + repeat + c;
213-
if (repeat == 3) return c.ToString () + c + c;
214-
if (repeat == 2) return c.ToString () + c;
186+
if (repeat > 3)
187+
{
188+
return "!" + repeat + c;
189+
}
190+
191+
if (repeat == 3)
192+
{
193+
return c.ToString () + c + c;
194+
}
195+
196+
if (repeat == 2)
197+
{
198+
return c.ToString () + c;
199+
}
200+
215201
return c.ToString ();
216202
}
217203

Terminal.Gui/Drawing/SixelSupportResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/// <summary>
44
/// Describes the discovered state of sixel support and ancillary information
5-
/// e.g. <see cref="Resolution"/>. You can use <see cref="SixelSupportDetector"/>
5+
/// e.g. <see cref="Resolution"/>. You can use any <see cref="ISixelSupportDetector"/>
66
/// to discover this information.
77
/// </summary>
88
public class SixelSupportResult

0 commit comments

Comments
 (0)