Comments (35)
Is it just me or is vertical text with multiple lines, except when centered horiz, completely broken?
Note, to test this, you have to use this PR which fixes a crash in the scenario and updates the API per above:
from terminal.gui.
Only the ones in the middle vertically are correct. The ones on the sides are incorrect.
I was not setting tf.Size. Nevermind.
from terminal.gui.
Now, I really did find a bug in
TextAlignment.Right
whentf.AutoSize = true
:
(This is my bug. nevermind again... I can't repro it on v2_develop).
from terminal.gui.
Nevermind again and now mind...
It IS a bug in v2_develop. I just had the test disabled. This fails:
[InlineData ("AB", 1, true, "A")] // BUGBUG: This is wrong, it should be "A"
This works
[InlineData ("AB", 1, true, "")] // BUGBUG: This is wrong, it should be "A"
from terminal.gui.
Nevermind again and now mind...
It IS a bug in v2_develop. I just had the test disabled. This fails:
[InlineData ("AB", 1, true, "A")] // BUGBUG: This is wrong, it should be "A"
This works
[InlineData ("AB", 1, true, "")] // BUGBUG: This is wrong, it should be "A"
@BDisp since you wrote the TextFormatter.Draw code (?), could you look at this and see if you can see how to fix it?
from terminal.gui.
@BDisp since you wrote the TextFormatter.Draw code (?), could you look at this and see if you can see how to fix it?
If you don't mind, I'll look at it tomorrow. Thanks.
from terminal.gui.
A lot of this has already been fixed in code and documentation fixes I currently have outstanding.
I'd suggest not dealing with it right now, until that's done.
from terminal.gui.
I understand your doubt. Maybe you can improve the documentation for this method. In fact, in this case it should return 1, because this method is used for the vertical direction of the text, to obtain the maximum size that a column will occupy in a set of characters. If in a line there is a glyph that occupies two columns then it will return 2. Therefore, it does not return the sum of the column sizes but only the maximum size occupied by a character.
from terminal.gui.
I understand your doubt. Maybe you can improve the documentation for this method. In fact, in this case it should return 1, because this method is used for the vertical direction of the text, to obtain the maximum size that a column will occupy in a set of characters. If in a line there is a glyph that occupies two columns then it will return 2. Therefore, it does not return the sum of the column sizes but only the maximum size occupied by a character.
Yeah, I think I see it now. On it...
from terminal.gui.
This helped me fix issues here:
/// <summary>
/// Returns the number of columns required to render <paramref name="lines"/> oriented vertically.
/// </summary>
/// <remarks>
/// This API will return incorrect results if the text includes glyphs who's width is dependent on surrounding
/// glyphs (e.g. Arabic).
/// </remarks>
/// <param name="lines">The lines.</param>
/// <param name="startLine">The line in the list to start with (any lines before will be ignored).</param>
/// <param name="linesCount">The number of lines to process (if less than <c>lines.Count</c>, any lines after will be ignored).</param>
/// <param name="tabWidth">The number of columns used for a tab.</param>
/// <returns>The width required.</returns>
public static int GetColumnsRequiredForVerticalText (
List<string> lines,
int startLine = -1,
int linesCount = -1,
int tabWidth = 0
)
This was my bad. I renamed this method way back without really understanding what it did.
from terminal.gui.
Glad this helped fix the error. What matters is that now you know its purpose and it will certainly be well documented.
from terminal.gui.
While we're at it, perhaps you could help me understand why this test isn't working right
[SetupFakeDriver]
[Theory]
[InlineData ("A", 0, "")]
[InlineData ("A", 1, "A")]
[InlineData ("A", 2, "A")]
[InlineData ("A B", 3, "A B")]
[InlineData ("A B", 1, "A")]
[InlineData ("A B", 2, "A")]
[InlineData ("A B", 3, "A B")]
[InlineData ("A B", 4, "A B")] // BUGBUG: This should be "A B"
[InlineData ("A B", 5, "A B")]// BUGBUG: This should be "A B"
[InlineData ("A B", 6, "A B")]// BUGBUG: This should be "A B"
[InlineData ("A B", 10, "A B")]// BUGBUG: This should be "A B"
[InlineData ("ABC ABC", 10, "ABC ABC")] // BUGBUG: this is wrong
[InlineData ("ABC ABC", 12, "ABC ABC")] // BUGBUG: this is wrong
public void Draw_Horizontal_Justified (string text, int width, string expectedText)
{
TextFormatter tf = new ()
{
Text = text,
Alignment = TextAlignment.Justified,
};
tf.Draw (new Rectangle (0, 0, width, 1), Attribute.Default, Attribute.Default);
TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
}
from terminal.gui.
Only the ones in the middle vertically are correct. The ones on the sides are incorrect.
from terminal.gui.
Now, I really did find a bug in TextAlignment.Right
when tf.AutoSize = true
:
[SetupFakeDriver]
[Theory]
[InlineData ("A", 0, false, "")]
[InlineData ("A", 1, false, "A")]
[InlineData ("A", 2, false, " A")]
[InlineData ("AB", 1, false, "A")]
[InlineData ("AB", 2, false, "AB")]
[InlineData ("ABC", 3, false, "ABC")]
[InlineData ("ABC", 4, false, " ABC")]
[InlineData ("ABC", 6, false, " ABC")]
[InlineData ("A", 0, true, "")]
[InlineData ("A", 1, true, "A")]
[InlineData ("A", 2, true, " A")]
[InlineData ("AB", 1, true, "")] // BUGBUG: This is wrong, it should be "A"
[InlineData ("AB", 2, true, "AB")]
[InlineData ("ABC", 3, true, "ABC")]
[InlineData ("ABC", 4, true, " ABC")]
[InlineData ("ABC", 6, true, " ABC")]
public void Draw_Horizontal_Right (string text, int width, bool autoSize, string expectedText)
{
TextFormatter tf = new ()
{
Text = text,
Alignment = TextAlignment.Right,
AutoSize = autoSize,
};
if (!autoSize)
{
tf.Size = new Size (width, 1);
}
tf.Draw (new Rectangle (Point.Empty, new (width, 1)), Attribute.Default, Attribute.Default);
TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
}
from terminal.gui.
I've also seen that Button doesn't draw the right brackets in justified alignment in some situations. Have you ever noticed this?
from terminal.gui.
There were a few test cases that were very clearly explicitly defined incorrectly to ignore what were probably deemed minor issues when it was done. Some even had comments explicitly saying that. Those now are defined correctly and pass correctly in what I've got in progress.
from terminal.gui.
If you don't mind, I'll look at it tomorrow. Thanks.
My laptop is broken and only on Tuesday the SSD will be ready. Sorry.
from terminal.gui.
If you don't mind, I'll look at it tomorrow. Thanks.
My laptop is broken and only on Tuesday the SSD will be ready. Sorry.
Bummer!
from terminal.gui.
Luckily it was ready early. Both are not correct. In horizontal alignment to the right, it is always the last letter of a word that is always placed to the right, in the case of left-to-right direction. In this case it will be "B". The following change works:
In the case of the vertical direction of the text, it still seems like you are confusing the function that returns the maximum width of a rune, whose value should be 1, 2 or the tab width and not the sum of all runes. Remember that the Draw method already separates new lines and therefore these functions do not have to deal with them.
from terminal.gui.
Related Issues (20)
- Not always getting `Button1Clicked` events on `Netdriver` or `CursesDriver`
- NetDriver sometimes isn't decoding the correct color value HOT 2
- `Dialog` width sometimes increases before it close. HOT 3
- WindowsDriver is sending mouse button pressed only on moving. HOT 4
- `WindowsDriver` emits spurious Button press mouse events HOT 1
- `WindowsDriver` makes it impossible for an app to get fast mouse clicks HOT 1
- v2: Application.Top is null HOT 2
- Title Centering HOT 3
- Button clicked event is raised even with mouse button pressed on another view. HOT 3
- View.Dispose doen't call UngrabMouse if MouseGrabView is the view itself. HOT 6
- `ListViewWIthSelection` scenario does not show all rows and other issues HOT 1
- Does Terminal.GUI supports aarch64 arhitecture? HOT 3
- Mouse doubleclick stops continous pressed events. HOT 2
- Fix focus and keyboard nav with `Adornments`
- Refactor `Border` to use subviews for title, lines, and close button
- Long-standing repaint-flicker issue. HOT 8
- `Content Scrolling` Scenario doesn't illustrate `ClearContentOnly` properly
- Improve redraw performance by making `Clip` be a `Region` instead of `Rectangle` HOT 22
- Add internal analyzers and source generators HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terminal.gui.