-
Notifications
You must be signed in to change notification settings - Fork 41
Updated split_code_edit.gd to be editable and sync changes #166
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,16 +3,26 @@ | |
| extends CodeEdit | ||
|
|
||
| var last_v_scroll: float | ||
| var pause_text_changed = false | ||
|
|
||
| func _ready() -> void: | ||
| editable = false | ||
| editable = true | ||
| caret_draw_when_editable_disabled = true | ||
| set_v_scroll.call_deferred(last_v_scroll) | ||
| set_v_scroll.call_deferred(last_v_scroll) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty space at the end |
||
|
|
||
| static func new_from(from_code_edit: CodeEdit) -> CodeEdit: | ||
| var new_code_edit: CodeEdit = new() | ||
|
|
||
| if not from_code_edit.tree_exiting.is_connected(new_code_edit.exit_tree.bind(new_code_edit)): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the |
||
| from_code_edit.tree_exiting.connect(new_code_edit.exit_tree.bind(new_code_edit)) | ||
|
|
||
| new_code_edit.text = from_code_edit.text | ||
| new_code_edit.set_caret_line(from_code_edit.get_caret_line()) | ||
| if not new_code_edit.text_changed.is_connected(new_code_edit.to_changed.bind(from_code_edit,new_code_edit)): | ||
| new_code_edit.text_changed.connect(new_code_edit.to_changed.bind(from_code_edit,new_code_edit)) | ||
| if not from_code_edit.text_changed.is_connected(new_code_edit.from_changed.bind(from_code_edit,new_code_edit)): | ||
| from_code_edit.text_changed.connect(new_code_edit.from_changed.bind(from_code_edit,new_code_edit)) | ||
|
|
||
| new_code_edit.syntax_highlighter = from_code_edit.syntax_highlighter | ||
| new_code_edit.highlight_all_occurrences = from_code_edit.highlight_all_occurrences | ||
| new_code_edit.highlight_current_line = from_code_edit.highlight_current_line | ||
|
|
@@ -45,3 +55,28 @@ static func new_from(from_code_edit: CodeEdit) -> CodeEdit: | |
| new_code_edit.last_v_scroll = from_code_edit.scroll_vertical | ||
|
|
||
| return new_code_edit | ||
|
|
||
| func from_changed(from:CodeEdit,to:CodeEdit) -> void: | ||
| if not pause_text_changed: | ||
| pause_text_changed = true | ||
| var pos = to.get_caret_line() | ||
| var scroll = to.scroll_vertical | ||
| to.text = from.text | ||
| to.set_caret_line(pos) | ||
| to.scroll_vertical = scroll | ||
| pause_text_changed = false | ||
|
|
||
| func to_changed(from:CodeEdit,to:CodeEdit) -> void: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please always leave an empty space after the |
||
| if not pause_text_changed: | ||
| pause_text_changed = true | ||
| var pos = from.get_caret_line() | ||
| var scroll = from.scroll_vertical | ||
| from.text = to.text | ||
| from.set_caret_line(pos) | ||
| from.scroll_vertical = scroll | ||
| pause_text_changed = false | ||
|
|
||
| func exit_tree(to:CodeEdit) -> void: | ||
| if to: | ||
| to.get_parent().remove_child(to) | ||
| to.queue_free() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use types always.
: bool