godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Script Editor: Add RTL (Right to Left) support #10629

Open DexterFstone opened 2 months ago

DexterFstone commented 2 months ago

Describe the project you are working on

addon

Describe the problem or limitation you are having in your project

if I want to use RTL language for a comment, or document, the text direction is wrong

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

This can be done in 2 ways: auto detect language and change text direction to RTL or LTR shortcut: something like MWord (ctrl + shift)

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

shortcut: pressing the right ctrl + shift on the keyboard makes the direction of that line change to Right pressing the left ctrl + shift on the keyboard makes the direction of that line change to Left

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

No

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

I think it would be difficult and illogical to implement such a thing with a plugin

bruvzg commented 2 months ago

Please provide an example of incorrectly displayed text. Both RTL and mixed direction comments seems to work correctly (in 4.x, 3.x do not have any RTL/BiDi support).

DexterFstone commented 2 months ago

Please provide an example of incorrectly displayed text. Both RTL and mixed direction comments seems to work correctly (in 4.x, 3.x do not have any RTL/BiDi support).

image image

expected: image

bruvzg commented 2 months ago

I see, the main text looks fine, the rest is non-trivial to fix:

Ideally, we should have a structured text protocol for the script editor that is fully parsing script and using separate BiDi contexts for each script token (or at least for comments), but processing multiline comments still will be an issue.

DexterFstone commented 2 months ago

one more thing I tried is TextFile when using TextFile the text ordering is wrong image I need to add the # to keep text ordering right