Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b0f050f
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 21, 2025
a64b4bc
touching publish.yml
tig Mar 21, 2025
320384e
Merge branch 'v2_release' into v2_develop
tig Mar 21, 2025
4048436
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Mar 29, 2025
3b0311d
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 29, 2025
ae79c48
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 30, 2025
1c39896
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 1, 2025
2cee67f
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 1, 2025
9560cf3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 2, 2025
0795dd1
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 2, 2025
4baccd7
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 3, 2025
7d7ffad
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 5, 2025
c37210a
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 5, 2025
680e5ae
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 16, 2025
3cba0a5
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 23, 2025
9bbec08
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 24, 2025
64403fa
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 24, 2025
5e1251c
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 24, 2025
49cd335
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 25, 2025
9a8e4e3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 25, 2025
ef6d193
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 25, 2025
4c0c504
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 25, 2025
4f5fca2
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 28, 2025
f8bfab8
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 28, 2025
898c2de
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 28, 2025
8f1fc33
TextStyle enum
Error-String-Expected-Got-Nil May 7, 2025
89033fc
CSI_AppendTextStyleChange
Error-String-Expected-Got-Nil May 7, 2025
0ca2fc0
Add TextStyle to Attribute
Error-String-Expected-Got-Nil May 7, 2025
9636e9c
Apply text style in NetOutput.Write()
Error-String-Expected-Got-Nil May 7, 2025
74e0ece
Don't append escape code if nothing to change
Error-String-Expected-Got-Nil May 7, 2025
6b24734
Make TextStyle an init property
Error-String-Expected-Got-Nil May 7, 2025
5a0fd0b
Apply TextStyle to OutputBuffer attributes
Error-String-Expected-Got-Nil May 7, 2025
aa660eb
Fix flag checking
Error-String-Expected-Got-Nil May 7, 2025
9bf39fd
Allow bold-faint text
Error-String-Expected-Got-Nil May 7, 2025
fd6e44d
Remove unnecessary check
Error-String-Expected-Got-Nil May 7, 2025
cd10bb3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig May 7, 2025
ce92023
Remove redundant check
Error-String-Expected-Got-Nil May 9, 2025
5884f8f
WindowsOutput support for text style
Error-String-Expected-Got-Nil May 9, 2025
d412c00
Merge branch 'gui-cs:v2_develop' into v2_develop
tig May 9, 2025
66f2c62
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig May 11, 2025
e967243
Merge branch 'v2_develop' into 4058-text-styles-basic-impl
tig May 11, 2025
a78ef9e
Merge branch '4058-text-styles-basic-impl' of github.com:Error-String…
tig May 11, 2025
dde50ce
Fixed Generic.cs.
tig May 11, 2025
92347b1
Code cleanup
tig May 11, 2025
58be13f
Code cleanup
tig May 11, 2025
8885f23
Tweaked Scenario to look more clear
tig May 11, 2025
abfa66a
Merge branch 'gui-cs:v2_develop' into v2_develop
tig May 11, 2025
d9dcca4
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig May 11, 2025
c533822
Merge branch 'gui-cs:v2_develop' into v2_develop
tig May 12, 2025
924112e
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig May 12, 2025
0c3c4b3
Merge branch 'Error-String-Expected-Got-Nil-4058-text-styles-basic-im…
tig May 12, 2025
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
15 changes: 2 additions & 13 deletions Examples/UICatalog/Scenarios/Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,12 @@ public override void Main ()
BorderStyle = LineStyle.None
};

var button = new Shortcut()
var button = new Button ()
{
CanFocus = true,
Id = "button",
X = Pos.Center (),
Y = 1,
ShadowStyle = ShadowStyle.None,
Text = "HelpText",
Title = "Command",
Key = Key.F10,
HighlightStyle = HighlightStyle.None
Title = "_Button",
};
button.ColorScheme = Colors.ColorSchemes ["Error"];

button.Padding!.Thickness = new (1);
button.Padding.ColorScheme = Colors.ColorSchemes ["Toplevel"];
button.Margin!.Thickness = new (1);

button.Accepting += (s, e) =>
{
Expand Down
123 changes: 123 additions & 0 deletions Examples/UICatalog/Scenarios/TextStyles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#nullable enable
using Terminal.Gui;

namespace UICatalog.Scenarios;

[ScenarioMetadata ("Text Styles", "Shows Attribute.TextStyles including bold, italic, etc...")]
[ScenarioCategory ("Text and Formatting")]
[ScenarioCategory ("Colors")]
public sealed class TestStyles : Scenario
{
public override void Main ()
{
// Init
Application.Init ();

// Setup - Create a top-level application window and configure it.
Window appWindow = new ()
{
Title = GetQuitKeyAndName (),
BorderStyle = LineStyle.None
};

appWindow.DrawingContent += OnAppWindowOnDrawingContent;

// Run - Start the application.
Application.Run (appWindow);
appWindow.Dispose ();

// Shutdown - Calling Application.Shutdown is required.
Application.Shutdown ();
}

private void OnAppWindowOnDrawingContent (object? sender, DrawEventArgs args)
{
if (sender is View { } sendingView)
{
var y = 0;
var x = 0;
int maxWidth = sendingView.Viewport.Width; // Get the available width of the view

TextStyle [] allStyles = Enum.GetValues (typeof (TextStyle))
.Cast<TextStyle> ()
.Where (style => style != TextStyle.None)
.ToArray ();

// Draw individual flags on the first line
foreach (TextStyle style in allStyles)
{
string text = Enum.GetName (typeof (TextStyle), style)!;
int textWidth = text.Length;

// Check if the text fits in the current line
if (x + textWidth >= maxWidth)
{
x = 0; // Move to the next line
y++;
}

sendingView.Move (x, y);

var attr = new Attribute (sendingView.GetNormalColor ())
{
TextStyle = style
};
sendingView.SetAttribute (attr);
sendingView.AddStr (text);

x += textWidth + 2; // Add spacing between entries
}

// Add a blank line
y += 2;
x = 0;

// Generate all combinations of TextStyle (excluding individual flags)
int totalCombinations = 1 << allStyles.Length; // 2^n combinations

for (var i = 1; i < totalCombinations; i++) // Start from 1 to skip "None"
{
var combination = (TextStyle)0;
List<string> styleNames = new ();

for (var bit = 0; bit < allStyles.Length; bit++)
{
if ((i & (1 << bit)) != 0)
{
combination |= allStyles [bit];
styleNames.Add (Enum.GetName (typeof (TextStyle), allStyles [bit])!);
}
}

// Skip individual flags
if (styleNames.Count == 1)
{
continue;
}

string text = $"[{string.Join (" | ", styleNames)}]";
int textWidth = text.Length;

// Check if the text fits in the current line
if (x + textWidth >= maxWidth)
{
x = 0; // Move to the next line
y++;
}

sendingView.Move (x, y);

var attr = new Attribute (sendingView.GetNormalColor ())
{
TextStyle = combination
};
sendingView.SetAttribute (attr);
sendingView.AddStr (text);

x += textWidth + 2; // Add spacing between entries
}

args.Cancel = true;
}
}
}
Loading