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 BBCode Hotkeys for common typographic emphasis in RichText #10897

Open
ch0m5 opened this issue Oct 4, 2024 · 1 comment
Open

Add BBCode Hotkeys for common typographic emphasis in RichText #10897

ch0m5 opened this issue Oct 4, 2024 · 1 comment

Comments

@ch0m5
Copy link

ch0m5 commented Oct 4, 2024

Describe the project you are working on

A CRPG, where there's tons of Dialogue Text, usually with the need of typographic emphasis.

Describe the problem or limitation you are having in your project

When defining the text within a RichTextLabel through the Inspector or using a @tool script with TextEdit or LineEdit to define text that will be used in a RichTextLabel, it is considerably cumbersome to manually add all typographic emphasis wherever needed, as it involves several unusual keystrokes.

When writing tens of hundreds of paragraphs of dialogue, you strongly miss hotkeys that are commonplace in average text editors.

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

Adding the most common-use case BBCode snippets as hotkeys, which are available whenever an editable text in the Inspector is focused, such as when editing the contents of a RichTextLabel.

The most obvious candidates are Bold (CTRL+B), Italics (CTRL+I), and Underline (CTRL+U).

Other shortcuts could be considered, such as Strikethrough (CTRL+S) or even Paragraph (CTRL+P), although in these last two cases, they would conflict with existing engine hotkeys, Save and Quick Open, respectively. Imo, I think it would be acceptable (if possible at all) for this hotkeys to override generic engine hotkeys as long as a TextEdit where these hotkeys are relevant is focused, such as the Text property of a RichTextLabel in the Inspector, specially if the hotkey used is the same letter used on the BBCode (b in BBCode for Bold, so CTRL+B), which would make the system quite intuitive to use.

Nevertheless, the goal is to make writing with BBCode faster and easier, specially when dealing with large amounts of RichText.

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

Whenever a hotkey is pressed, text is modified based on the current edit state.

  1. No Selection, Caret is not under any word: The BBCode snippet is added and the caret placed in-between.
    E.g. CTRL+B -> [b]|[/b]

  2. No Selection, Caret is under a word: The BBCode snippet is added and the word placed in-between.
    E.g. "this is a |potato salad" -> CTRL+I -> "this is a [i]|potato[/i] salad"

  3. Text Selected: The BBCode snippet is added with the selection in-between. Selection remains.
    E.g. "I am considerably angry, Tim" -> CTRL+U -> "I am [u]considerably angry[/u], Tim"

(This sample below does not work exactly like it, but it shows the gist of it. Reference for proper implementation can be found in any decent text editor, even GitHub's text editor has this.)

EnhancedTextEdit.mp4

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

It can be bypassed easily by manually writing the BBCode snippets, the problem is the time it takes to do so when it is done very frequently.

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

Having a full "BBCode text editor" addon would be ideal, so that all these tools are available in a specialized text editor, rather than tuning Godot itself into implementing all of these shortcuts.

However, I think Godot itself integrating the "big 3" (B/I/U) would be an upgrade, specially given that there's no Godot generic hotkeys occupying these keys, and almost any software where you can write RichText accommodates them.

@Calinou
Copy link
Member

Calinou commented Oct 4, 2024

This is interesting, but we currently don't have a property hint that indicates that a multitext property expects BBCode. (We have one for Expressions, where a fixed-width font is used and generic syntax highlighting is applied.)

Such a property hint would need to be added first, and some buttons would also have to be added at the top of the LineEdit to ease discoverability.

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