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

Add an "Adaptive" line wrapping mode for TextEdit #6519

Closed
gelvinp opened this issue Mar 16, 2023 · 4 comments
Closed

Add an "Adaptive" line wrapping mode for TextEdit #6519

gelvinp opened this issue Mar 16, 2023 · 4 comments

Comments

@gelvinp
Copy link

gelvinp commented Mar 16, 2023

Describe the project you are working on

I am prototyping a notion-like text editor.

Describe the problem or limitation you are having in your project

I have an issue with the "Boundary" line wrapping mode. While it works for most reasonable lines with spaces in them, any lines that don't have spaces in them are simply cut off. See below:

boundary.mp4

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a new "Adaptive" case to the LineWrappingMode enum, and an if statement to the set_line_wrapping_mode function that checks for this adaptive case, and if found, uses the TextServer::BREAK_ADAPTIVE break flag on the contained TextParagraph. See below:

adaptive.mp4

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I have implemented it in this commit:
gelvinp/godot@e1ef595

If this enhancement will not be used often, can it be worked around with a few lines of script?

You can't access the TextParagraph to change the break flags from within GDScript.

Is there a reason why this should be core and not an add-on in the asset library?

The functionality to do this wrapping is already included in TextServer and used for RichTextLabel, it is just exposing that option to TextEdit.

@Calinou
Copy link
Member

Calinou commented Mar 16, 2023

cc @bruvzg

@gelvinp
Copy link
Author

gelvinp commented Mar 17, 2023

Forgot to propagate break flags to newly created lines within TextEdit, so I added a commit to fix that.

Here's a link to compare the combined change against master:
https://github.com/gelvinp/godot/compare/master...gelvinp:godot:linewrapping-character?expand=1

@bruvzg
Copy link
Member

bruvzg commented Mar 17, 2023

It's probably should use the same wrap modes as other controls - godotengine/godot#74813 (need more scrollbar / auto-scroll fixes).

@gelvinp
Copy link
Author

gelvinp commented Mar 17, 2023

👍 That probably works better, yeah

@gelvinp gelvinp closed this as completed Mar 17, 2023
@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants