Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll our own wrapping function for help #602

Merged
merged 3 commits into from
Dec 23, 2020

Conversation

SquidDev
Copy link
Member

@SquidDev SquidDev commented Dec 10, 2020

This saves us writing to a buffer multiple times, and so makes things much, much faster.

As in, it's actually usable on copy-cat now!


At this point, it might be worth the actual paginator into a separate utility module. Then we could deprecated textutils.pagedPrint and point towards that instead - sadly I don't think it's really possible to replicate the behaviour of _nFreeLines.

I'm not 100% sure how I feel about exposing entire UI interfaces from a module though. We'll have to see.

This saves us writing to a buffer multiple times, and so makes things
much, much faster.
@SquidDev SquidDev added enhancement An extension of a feature or a new feature. area-CraftOS This affects CraftOS, or any other Lua portions of the mod. labels Dec 10, 2020
@Lupus590
Copy link
Contributor

Lupus590 commented Dec 11, 2020

I was literally writing a word wrapper. I wasn't sure if I would make it a textutils thing or a cc.pretty thing or a new module.

I'll still make a PR and then maybe it can replace this.

(Now I'm glad that I didn't actually get anywhere because I was playing games with people.)

@Lupus590
Copy link
Contributor

Lupus590 commented Dec 11, 2020

So I copied the code from here and started writing tests. This one fails with ...got "test "

expect(textutils.wrap("test string is long", 11)[1]):eq("test string")

I would expect it to see the end of the word string with g as the 11th character and wrap it there. I'm investigating but I thought I'd give you a heads up.

end
else
-- Print a word normally
if width - #current_line - 1 < #word then push_line() end
Copy link
Contributor

@Lupus590 Lupus590 Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the -1 and then text wraps how I expect it to in the conversation tab.

@SquidDev SquidDev merged commit ed3913c into mc-1.15.x Dec 23, 2020
@SquidDev SquidDev deleted the feature/faster-pagination branch December 23, 2020 16:34
SquidDev pushed a commit that referenced this pull request Apr 29, 2022
This saves us writing to a buffer multiple times, and so makes things much,
much faster.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CraftOS This affects CraftOS, or any other Lua portions of the mod. enhancement An extension of a feature or a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants