Skip to content

Commit

Permalink
Merge pull request #9534 from rainersigwald/right-justify
Browse files Browse the repository at this point in the history
  • Loading branch information
rainersigwald authored Dec 13, 2023
2 parents 6257b8e + 8f8dd68 commit 16f6e5c
Show file tree
Hide file tree
Showing 29 changed files with 377 additions and 489 deletions.
9 changes: 9 additions & 0 deletions src/Framework/Logging/AnsiCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,13 @@ public static string MakeBold(string? s)

return $"{CSI}{SetBold}{s}{SetDefaultColor}";
}

public static string MoveCursorBackward(int count) => $"{CSI}{count}{MoveBackward}";

/// <summary>
/// Moves cursor to the specified column, or the rightmost column if <paramref name="column"/> is greater than the width of the terminal.
/// </summary>
/// <param name="column">Column index.</param>
/// <returns>Control codes to set the desired position.</returns>
public static string SetCursorHorizontal(int column) => $"{CSI}{column}G";
}
62 changes: 62 additions & 0 deletions src/MSBuild.UnitTests/NodeStatus_Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Build.Logging.TerminalLogger;

using VerifyTests;
using VerifyXunit;
using Xunit;

using static VerifyXunit.Verifier;


namespace Microsoft.Build.CommandLine.UnitTests;

[UsesVerify]
public class NodeStatus_Tests
{
private readonly NodeStatus _status = new("Namespace.Project", "TargetFramework", "Target", new());

public NodeStatus_Tests()
{
UseProjectRelativeDirectory("Snapshots");
}

[Fact]
public async Task EverythingFits()
{
NodesFrame frame = new(new[] { _status }, width: 80, height: 5);

await Verify(frame.RenderNodeStatus(_status).ToString());
}

[Fact]
public async Task TargetIsTruncatedFirst()
{
NodesFrame frame = new(new[] { _status }, width: 45, height: 5);

await Verify(frame.RenderNodeStatus(_status).ToString());
}

[Fact]
public async Task NamespaceIsTruncatedNext()
{
NodesFrame frame = new(new[] { _status }, width: 40, height: 5);

await Verify(frame.RenderNodeStatus(_status).ToString());
}

[Fact]
public async Task GoesToProject()
{
NodesFrame frame = new(new[] { _status }, width: 10, height: 5);

await Verify(frame.RenderNodeStatus(_status).ToString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
 Namespace.Project TargetFramework Target (0.0s)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
 Project TargetFramework  (0.0s)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
 Namespace.Project TargetFramework  (0.0s)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
]9;4;3;\[?25l
project tfName Build (0.0s)
project tfName Build (0.0s)
[?25h[?25l
project tf2 Build (0.0s)
 project tf2 Build (0.0s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[?25l
project tfName Build (0.0s)
project tfName Build (0.0s)
[?25h[?25l
project tf2 Build (0.0s)
 project tf2 Build (0.0s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
]9;4;3;\[?25l
project tfName Build (0.0s)
project tfName Build (0.0s)
[?25h[?25l
project tf2 Build (0.0s)
 project tf2 Build (0.0s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
]9;4;3;\[?25l
project Build (0.0s)
project Build (0.0s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[?25l
project Build (0.0s)
project Build (0.0s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
]9;4;3;\[?25l
project Build (0.0s)
project Build (0.0s)
[?25h
25 changes: 5 additions & 20 deletions src/MSBuild/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1536,26 +1536,11 @@
{0}: VT100 coded hyperlink to project output directory
</comment>
</data>
<data name="ProjectBuilding_NoTF" xml:space="preserve">
<value>{0}{1} {2} ({3}s)</value>
<comment>
Project building.
{0}: indentation - few spaces to visually indent row
{1}: project name
{2}: target
{3}: duration in seconds with 1 decimal point
</comment>
</data>
<data name="ProjectBuilding_WithTF" xml:space="preserve">
<value>{0}{1} {2} {3} ({4}s)</value>
<comment>
Project building including target framework information.
{0}: indentation - few spaces to visually indent row
{1}: project name
{2}: target framework
{3}: target
{4}: duration in seconds with 1 decimal point
</comment>
<data name="DurationDisplay">
<value>({0:F1}s)</value>
<comment>
{0}: duration in seconds with 1 decimal point
</comment>
</data>
<data name="BuildFailedWithPropertiesItemsOrTargetResultsRequested" xml:space="preserve">
<value>Build failed. Properties, Items, and Target results cannot be obtained. See details in stderr above.</value>
Expand Down
30 changes: 7 additions & 23 deletions src/MSBuild/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 7 additions & 23 deletions src/MSBuild/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 7 additions & 23 deletions src/MSBuild/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 7 additions & 23 deletions src/MSBuild/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 7 additions & 23 deletions src/MSBuild/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 16f6e5c

Please sign in to comment.