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 CodeEdit and TextEdit gutter system #40973

Merged
merged 9 commits into from
Sep 10, 2020
Merged

Conversation

Paulb23
Copy link
Member

@Paulb23 Paulb23 commented Aug 2, 2020

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 calling add_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 calling set_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 for breakpoints, bookmarks, execution lines, line numbers, and code folding. The editor gutters have also been extracted to script_text_editor using this for the Connection Gutter and Safe 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:

image

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 to line_edited_from(p_from, p_to). When lines are added, p_from will be greater then p_to. On a removal vice versa, p_from will be less then p_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

@akien-mga
Copy link
Member

CC @bruvzg to review if there might be potential conflicts with upcoming CTL changes.

@akien-mga
Copy link
Member

Changes look good to me.

Secondly, if desired will squash the commits after review.

Some squashing might be useful, though maybe with more granularity than squash all 10 commits into one. I'll let you see if any grouping would make sense to reduce the number of commits (at least the first commits adding CodeEdit and refactoring the existing code to use it might be squashed - later commits that do actual logic changes/feature implementation might be good to keep separate).

@Paulb23
Copy link
Member Author

Paulb23 commented Sep 5, 2020

Squashed the first two commits.

Yeah was thinking about squashing the "add x gutter to CodeEdit" into a single one, but indeed, it might be useful to keep them as they are.

@akien-mga
Copy link
Member

Needs a rebase, otherwise it should be good to go.

@Paulb23
Copy link
Member Author

Paulb23 commented Sep 10, 2020

Rebased.

@akien-mga akien-mga merged commit beb9ebc into godotengine:master Sep 10, 2020
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The bookmark circle isn't drawn correctly. Cannot fold code if numbers are not showing.
3 participants