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

TextEdit cleanup and refactoring #50371

Merged
merged 11 commits into from
Aug 12, 2021
Merged

Conversation

Paulb23
Copy link
Member

@Paulb23 Paulb23 commented Jul 11, 2021

Continuation of #31739

Builds on #50122


This PR seems larger then it is, mainly moving around code and renames, rather then any changes.

The main aim of this PR is to cleanup after extracting features into CodeEdit and to prepare the API going forward. Will do EditorSettings as a separate PR.

Given TextEdit has organically grown rather large it became a bit of mess, so I took the time here to reorganise the methods; hopefully will made it easier to browse.

With that said, the three main API changes are:

  • Block caret no longer exists and is now an enum CaretType, currently with Line and Block as the options. The methods have been renamed appropriately:
    • cursor_set_block_mode --> set_caret_type
    • cursor_is_block_mode --> get_caret_type
  • Line wrapping has now been changed from enable / disable to an enum LineWrappingMode, with None and Boundary meaning the control boundary as it currently works. Similarly the methods have been renamed:
    • set_wrap_enabled --> set_line_wrapping_mode
    • is_wrap_enabled --> get_line_wrapping_mode
  • Cut, copy and paste are now overrideable with:
    • _cut
    • _copy
    • _paste

Otherwise bedsides exposing many new methods, the following renames have taken place:

Caret:

  • cursor_get_blink_enabled --> set_caret_blink_enabled
  • cursor_set_blink_enabled --> is_caret_blink_enabled
  • cursor_set_blink_speed --> set_caret_blink_speed
  • cursor_get_blink_speed --> get_caret_blink_speed
  • set_right_click_moves_caret --> set_move_caret_on_right_click_enabled
  • is_right_click_moving_caret --> is_move_caret_on_right_click_enabled
  • set_mid_grapheme_caret_enabled --> set_caret_mid_grapheme_enabled
  • get_mid_grapheme_caret_enabled --> is_caret_mid_grapheme_enabled
  • cursor_set_line --> set_caret_line
  • cursor_get_line --> get_caret_line
  • cursor_set_column --> set_caret_column
  • cursor_get_column --> get_caret_column
  • adjust_viewport_to_cursor --> adjust_viewport_to_caret
  • insert_text_at_cursor --> insert_text_at_caret
  • get_word_under_cursor --> get_word_under_caret

Selection:

  • is_selection_active --> has_selection
  • get_selection_text --> get_selected_text

Insert Mode:

  • set_insert_mode --> set_overtype_mode_enabled
  • is_insert_mode --> is_overtype_mode_enabled

Read only:

  • set_readonly --> set_editable
  • is_readonly --> is_editable

Signals:

  • cursor_changed --> caret_changed

Properties:

  • caret_block_mode --> caret_type
  • caret_enabled --> wrap_mode
  • caret_moving_by_right_click --> caret_move_on_right_click

Supersedes #47548

Apart from the couple features that need a little more work, after this I'm happy to close #31739

editor/code_editor.cpp Outdated Show resolved Hide resolved
scene/gui/text_edit.h Outdated Show resolved Hide resolved
@Paulb23 Paulb23 force-pushed the text_edit_cleanup branch from aef07cf to 487c332 Compare July 12, 2021 21:28
@Paulb23 Paulb23 force-pushed the text_edit_cleanup branch 2 times, most recently from 8a72573 to 92bb862 Compare August 6, 2021 13:03
@akien-mga akien-mga requested a review from a team August 6, 2021 13:12
doc/classes/CodeEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
doc/classes/TextEdit.xml Outdated Show resolved Hide resolved
@Paulb23 Paulb23 force-pushed the text_edit_cleanup branch from da2b063 to 1b482d9 Compare August 11, 2021 17:19
@Paulb23 Paulb23 force-pushed the text_edit_cleanup branch from 1b482d9 to a4606c2 Compare August 12, 2021 12:24
@akien-mga akien-mga changed the title TextEdit Cleanup TextEdit cleanup and refactoring Aug 12, 2021
@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.

Refactor TextEdit into two classes (text and code focused)
5 participants