Add CodeEdit and TextEdit gutter system #40973
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continuing on with #31739
To start with, rather then sending in a giant PR with the complete overhaul, I figured it would be easier to PR in smaller chunks. Though am happy to change if one large PR is preferred. Secondly, if desired will squash the commits after review.
With that said the main focus of this PR is adding the initial
CodeEdit
class and extracting the gutters.In order to achieve this
TextEdit
now has a 'gutter system'. It's possible to add a new gutter by callingadd_gutter(int p_at =-1)
. Here on out it will be referred to via it's index position. Once added, you can set it's type (text, icon or custom), name and width etc. In the case of a text gutter, values can be set by callingset_line_gutter_text(int p_line, int p_gutter, const String &p_text)
with options to set colour, metadata etc. The gutters now have a small amount of padding between them and the text to make it a little easier to click.This also comes with 3 new signals:
gutter_added
gutter_removed
gutter_clicked(line, gutter)
The 'gutter system' is fully exposed to
GDScript
.Internally
CodeEdit
uses it forbreakpoints
,bookmarks
,execution lines
,line numbers,
andcode folding
. The editor gutters have also been extracted toscript_text_editor
using this for theConnection Gutter
andSafe Lines
. Given the easy expansion, should also make implementing VCS highlights (godotengine/godot-proposals/issues/1089) or error symbols straight forward.As part of the extraction, some of the gutters have been widened slightly and draw code cleaned up. Mainly for the breakpoint gutter a new bookmark icon has been added, and the graph connection icon has been reused for breakpoints. A full line now looks like the following:
Breakpoints require sending a signal whenever a placement is changed, to get the relevant information the
line_edited_from(p_from)
signal has been changed toline_edited_from(p_from, p_to)
. When lines are added,p_from
will be greater thenp_to
. On a removal vice versa,p_from
will be less thenp_to
.Finally, the breakpoints gutter for the editor as been made non-optional.
Handles #25279 for gutters.
Handles part of godotengine/godot-proposals/issues/873
Supersedes #40629
closes #32735
closes #30389