Skip to content

Conversation

@theFox6
Copy link

@theFox6 theFox6 commented Sep 15, 2018

If keep_newlines is true, every new line given in the input text is also contained in the output text.

@theFox6
Copy link
Author

theFox6 commented Sep 15, 2018

Well this looks more clean than #7232

@paramat paramat added @ Script API Feature ✨ PRs that add or enhance a feature labels Sep 16, 2018
@rubenwardy rubenwardy force-pushed the master branch 2 times, most recently from 0e3b135 to 39c54e1 Compare June 21, 2019 00:46
@theFox6
Copy link
Author

theFox6 commented Jan 4, 2020

Can this be added please?

@SmallJoker
Copy link
Member

Testing mod:

local texts = {
--                                               | 50 is here
[[

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy]],

[[eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
dolores et ea rebum. Stet clita]]
}

print("core.line_break(text, 50)")
for i, text in ipairs(texts) do
	local lines = core.line_break(text, 50)
	print("\t" .. table.concat(lines, "\n\t"))
	print("")
end
print("core.wrap_text(text, 50, true, newlines)")
for i, text in ipairs(texts) do
	local lines = core.wrap_text(text, 50, true, true)
	print("\t" .. table.concat(lines, "\t")) -- new lines contained
	print("")
end

print("core.wrap_text(text, 50, true, no newlines)")
for i, text in ipairs(texts) do
	local lines = core.wrap_text(text, 50, true, false)
	print("\t" .. table.concat(lines, "\n\t"))
	print("")
end

But it does not contain new lines? This is the output:

core.wrap_text(text, 50, true, newlines)
		Lorem ipsum dolor sit amet, consetetur sadipscing	elitr, sed diam nonumy	

	eirmod tempor invidunt ut labore et dolore		magna aliquyam erat, sed diam voluptua. At vero	eos et accusam et justo duo		dolores et ea rebum. Stet clita	

@sfan5 sfan5 added the Rebase needed The PR needs to be rebased by its author label Jun 4, 2020
@theFox6
Copy link
Author

theFox6 commented Jun 7, 2020

The previously contained newlines were converted into table splits, I've added a note for that to the documentation. I can change the behavior so it wraps into table lines and puts the newlines in as characters if you want that.

@SmallJoker SmallJoker removed the Rebase needed The PR needs to be rebased by its author label Jun 7, 2020
@rubenwardy
Copy link
Contributor

rubenwardy commented Jun 21, 2021

It would be great to have some unit tests for this, see the tests folders in builtin

Also, this is yet another wrapping function in Minetest that #10853 could replace :'(

@rubenwardy rubenwardy added the Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand label Apr 25, 2022
@Zughy Zughy added the Rebase needed The PR needs to be rebased by its author label May 28, 2022
@rubenwardy rubenwardy removed the Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand label Jul 3, 2022
@rubenwardy rubenwardy added the Concept approved Approved by a core dev: PRs welcomed! label Jul 3, 2022
@SmallJoker SmallJoker added Rebase needed The PR needs to be rebased by its author and removed Rebase needed The PR needs to be rebased by its author labels Jul 3, 2022
@SmallJoker
Copy link
Member

@Zughy
Copy link
Contributor

Zughy commented Jul 3, 2022

Hello @theFox6 , sorry for the delay. Now that the PR has been conceptually approved, do you think you can take care of the rebase?

@Zughy Zughy added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Jul 3, 2022
@Zughy Zughy added the Adoption needed The pull request needs someone to adopt it. Adoption welcomed! label Aug 2, 2022
@Zughy Zughy closed this Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Action / change needed Code still needs changes (PR) / more information requested (Issues) Adoption needed The pull request needs someone to adopt it. Adoption welcomed! Concept approved Approved by a core dev: PRs welcomed! Feature ✨ PRs that add or enhance a feature Rebase needed The PR needs to be rebased by its author @ Script API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants