Skip to content

Fix: Wordwrap for MiniConsole and echo#7039

Merged
vadi2 merged 15 commits intoMudlet:developmentfrom
guhitb:miniconsole-indent
Dec 29, 2023
Merged

Fix: Wordwrap for MiniConsole and echo#7039
vadi2 merged 15 commits intoMudlet:developmentfrom
guhitb:miniconsole-indent

Conversation

@guhitb
Copy link
Copy Markdown
Contributor

@guhitb guhitb commented Dec 19, 2023

Brief overview of PR changes/additions

  • Added a TBuffer::wrapText. It takes a QString, and returns a wrapped and indented version of that QString.
  • Modified both TConsole::print functions to wrap the message before calling TBuffer::append.

Motivation for adding to Mudlet

MiniConsole output was not being intented. The following script did not work as expected:

Geyser.MiniConsole:new({name = "indent-test"})
setWindowWrapIndent("indent-test", 10)
echo("indent-test", "This is the song that doesn't end, yes it goes on and on my friend, some people started singing it not knowing what it was, and they'll continue singing it forever just because this is the song that doesn't end...")

/claim #5936
fixes #5936

Other info (issues closed, discussion etc)

Fixed for MiniConsole:
image

Fixed for echo:
image

@guhitb guhitb requested a review from a team as a code owner December 19, 2023 13:23
@guhitb guhitb requested a review from a team December 19, 2023 13:23
@add-deployment-links
Copy link
Copy Markdown

add-deployment-links bot commented Dec 19, 2023

Hey there! Thanks for helping Mudlet improve. 🌟

Test versions

You can directly test the changes here:

No need to install anything - just unzip and run.
Let us know if it works well, and if it doesn't, please give details.

@guhitb guhitb force-pushed the miniconsole-indent branch from 2b7a8da to 7685eda Compare December 19, 2023 13:29
@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Dec 19, 2023

Could you also add "fixes #5936" to the ticket, that way Github links the issue and PR together.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Dec 19, 2023

@demonnic mind testing this one?

@guhitb guhitb force-pushed the miniconsole-indent branch from 7685eda to a65cdac Compare December 19, 2023 14:47
@demonnic
Copy link
Copy Markdown
Member

So I ran this through the stressinator for 100k lines and the speeds are comparable, but I'm getting extra newlines in the PR version:

release

image

PR

image

@guhitb
Copy link
Copy Markdown
Contributor Author

guhitb commented Dec 24, 2023

Implemented the minor changes and removed the newlines added at the end of each echo. Text color changes seem to be a second source of newlines, so not 100% yet. I still need to update wrapText to use QTextBoundryFinder, hopefully that will also fix newlines from color changes.

image

@guhitb
Copy link
Copy Markdown
Contributor Author

guhitb commented Dec 25, 2023

Switched to using QTextBoundryFinder and it's working better.

image

image

@guhitb guhitb force-pushed the miniconsole-indent branch from 03ddae1 to 0d81bad Compare December 25, 2023 10:14
@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Dec 26, 2023

Cool! What is the before & after with 100,000 lines on your machine?

@guhitb
Copy link
Copy Markdown
Contributor Author

guhitb commented Dec 26, 2023

Running stresstest on 100,000 lines:

  • Before: 121 seconds
  • After: 124 seconds

image

image

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Dec 27, 2023

Did you also fix #5564 by accident with this?

@guhitb
Copy link
Copy Markdown
Contributor Author

guhitb commented Dec 27, 2023

This will wrap Chinese chacters, but the lines will be twice as long due to character width. These two examples were wrapped with the same settings:

image

@SlySven
Copy link
Copy Markdown
Member

SlySven commented Dec 29, 2023

This will wrap Chinese chacters, but the lines will be twice as long due to character width. ...

As a solution I think that initially this seems good enough to get the prize - I might fiddle with it later on so that it uses the widechar_width(...) function that we import from @ ridiculousFish 's widechar_width project (that we use elsewhere to work out how wide a grapheme is) to deduce whether the line of text passes the wrapping width in "normal" spaces - so that "wide" graphemes contribute 2 to the total compared to 1 for normal characters...

@vadi2 vadi2 merged commit 8d83f78 into Mudlet:development Dec 29, 2023
vadi2 pushed a commit to vadi2/Mudlet that referenced this pull request Jan 5, 2024
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
* Added a `TBuffer::wrapText`. It takes a QString, and returns a wrapped
and indented version of that QString.
* Modified both `TConsole::print` functions to wrap the message before
calling `TBuffer::append`.

#### Motivation for adding to Mudlet
MiniConsole output was not being intented. The following script did not
work as expected:
```lua
Geyser.MiniConsole:new({name = "indent-test"})
setWindowWrapIndent("indent-test", 10)
echo("indent-test", "This is the song that doesn't end, yes it goes on and on my friend, some people started singing it not knowing what it was, and they'll continue singing it forever just because this is the song that doesn't end...")
```
/claim Mudlet#5936
fixes Mudlet#5936
#### Other info (issues closed, discussion etc)
Fixed for MiniConsole:

![image](https://github.com/Mudlet/Mudlet/assets/147658676/38841017-1243-4fed-aa86-91cc5dd70e50)

Fixed for echo:

![image](https://github.com/Mudlet/Mudlet/assets/147658676/93b5ed64-b45d-44da-a0d5-7c282a323fec)
vadi2 added a commit that referenced this pull request Sep 16, 2024
vadi2 added a commit that referenced this pull request Oct 7, 2024
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This reverts commit 8d83f78 / PR
#7039.
#### Motivation for adding to Mudlet
Fixes #7316
#### Other info (issues closed, discussion etc)
This is a high-level issue that has been affecting many players for many
months now, and unfortunately it has no traction in getting fixed. It is
also holding up a release. Lets revert it so we can do a release with
all of the other fixes that have been done.

The bounty for the original issue was already paid out and unfortunately
the author is unresponsive in providing a fix, so we'll just deduct the
incorrectly paid out bounty amount in a future bounty.

Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setWindowWrapIndent not working except in main console

4 participants