Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Terminal.Gui/Drawing/Glyphs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public class Glyphs

/// <summary>Checked indicator (e.g. for <see cref="ListView"/> and <see cref="CheckBox"/>).</summary>
[ConfigurationProperty (Scope = typeof (ThemeScope))]
public static Rune CheckStateChecked { get; set; } = (Rune)'☒'; // '☑' is colored
public static Rune CheckStateChecked { get; set; } = (Rune)'☑';

/// <summary>Not Checked indicator (e.g. for <see cref="ListView"/> and <see cref="CheckBox"/>).</summary>
[ConfigurationProperty (Scope = typeof (ThemeScope))]
public static Rune CheckStateUnChecked { get; set; } = (Rune)'☐';

/// <summary>Null Checked indicator (e.g. for <see cref="ListView"/> and <see cref="CheckBox"/>).</summary>
[ConfigurationProperty (Scope = typeof (ThemeScope))]
public static Rune CheckStateNone { get; set; } = (Rune)'□'; // TODO: Verify this works as broadly as possible
public static Rune CheckStateNone { get; set; } = (Rune)'⬛';
Comment thread
tig marked this conversation as resolved.

/// <summary>Selected indicator (e.g. for <see cref="ListView"/> and <see cref="OptionSelector"/>).</summary>
[ConfigurationProperty (Scope = typeof (ThemeScope))]
Expand Down
8 changes: 4 additions & 4 deletions Terminal.Gui/Resources/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@
}
}
],
"Glyphs.CheckStateChecked": "",
"Glyphs.CheckStateNone": "",
"Glyphs.CheckStateChecked": "",
"Glyphs.CheckStateNone": "",
"Glyphs.CheckStateUnChecked": "☐",
"Glyphs.LeftBracket": "[",
"Glyphs.RightBracket": "]"
Expand Down Expand Up @@ -185,8 +185,8 @@
}
}
],
"Glyphs.CheckStateChecked": "",
"Glyphs.CheckStateNone": "",
"Glyphs.CheckStateChecked": "",
"Glyphs.CheckStateNone": "",
"Glyphs.CheckStateUnChecked": "☐",
"Glyphs.LeftBracket": "[",
"Glyphs.RightBracket": "]"
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/Views/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public bool AllowCheckStateNone
/// <para>
/// If <see cref="AllowCheckStateNone"/> is <see langword="true"/> and <see cref="CheckState.None"/>, the
/// <see cref="CheckBox"/>
/// will display the <c>Glyphs.CheckStateNone</c> character ().
/// will display the <c>Glyphs.CheckStateNone</c> character ().
/// </para>
/// <para>
/// If <see cref="CheckState.UnChecked"/>, the <see cref="CheckBox"/>
Expand Down
7 changes: 4 additions & 3 deletions Terminal.Gui/Views/ListView/ListView.Drawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ protected override bool OnDrawingContent (DrawContext? context)

var current = Attribute.Default;
int item = Viewport.Y;
int col = ShowMarks ? 2 : 0;
// Reserve mark glyph + separator column. If a configured mark glyph is wide, it can consume the separator.
int reservedMarkColumns = ShowMarks ? 2 : 0;
Move (0, 0);

for (var row = 0; row < Viewport.Height; row++, item++)
Expand Down Expand Up @@ -70,7 +71,7 @@ protected override bool OnDrawingContent (DrawContext? context)

default:
// Combination 4: Checkbox style
// Mark glyphs: Checkbox style ( marked, ☐ unmarked)
// Mark glyphs: Checkbox style ( marked, ☐ unmarked)
// Visual roles: Standard selection (mark glyphs provide visual indication)
role = isSelected ? HasFocus ? VisualRole.Focus : VisualRole.Active : VisualRole.Normal;

Expand Down Expand Up @@ -145,7 +146,7 @@ protected override bool OnDrawingContent (DrawContext? context)
}
}

int contentCol = col > 0 ? col : markWidth;
int contentCol = reservedMarkColumns > 0 ? reservedMarkColumns : markWidth;
Source.Render (this, isSelected, item, contentCol, row, Viewport.Width - contentCol, Viewport.X);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/Views/ListView/ListView.Selection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public bool MarkMultiple
/// <value>Set to <see langword="true"/> to show mark glyphs; <see langword="false"/> to hide them.</value>
/// <remarks>
/// <para>
/// When <see langword="true"/>, marks are rendered with glyphs: checkboxes (/☐) when
/// When <see langword="true"/>, marks are rendered with glyphs: checkboxes (/☐) when
/// <see cref="MarkMultiple"/> is <see langword="true"/>, or radio buttons (◉/○) when <see langword="false"/>.
/// </para>
/// <para>
Expand Down
5 changes: 4 additions & 1 deletion Terminal.Gui/Views/ListView/ListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ protected virtual void OnSourceChanged () { }
/// <inheritdoc/>
protected override void OnViewportChanged (DrawEventArgs e) => SetContentSize (new Size (EffectiveMaxItemLength, Source?.Count ?? Viewport.Height));

/// <summary>INTERNAL: Gets the width reserved for mark rendering (checkbox and space).</summary>
/// <summary>
/// INTERNAL: Gets the columns reserved for mark rendering (mark glyph + separator column). Wide glyphs may
/// consume the separator column.
/// </summary>
private int MarkWidth => ShowMarks ? 2 : 0;

/// <summary>INTERNAL: Gets the effective content width including mark columns when <see cref="ShowMarks"/> is true.</summary>
Expand Down
9 changes: 9 additions & 0 deletions Tests/UnitTestsParallelizable/Views/CheckBoxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ public void Constructors_Defaults ()
Assert.Equal (new Rectangle (3, 4, 6, 1), ckb.Frame);
}

// Copilot
[Fact]
public void Default_CheckState_Glyphs_Are_Distinct ()
{
Assert.Equal ((System.Text.Rune)'☑', Glyphs.CheckStateChecked);
Assert.Equal ((System.Text.Rune)'☐', Glyphs.CheckStateUnChecked);
Assert.Equal ((System.Text.Rune)'⬛', Glyphs.CheckStateNone);
}

[Fact]
public void LeftButtonReleased_Activates ()
{
Expand Down
Loading