-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix script popup #286
Merged
Merged
Fix script popup #286
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5ba3c30
Script Window: Use popup_dialog
manuq 8288b9b
Script Window: Remove background color
manuq fc523e5
Script Window: Improve layout
manuq 83b6cd2
Script Window: Change control type to CodeEdit
manuq b7568db
fixup! Script Window: Change control type to CodeEdit
wjt 527bc4b
Script Window: Attempt to match editor's syntax highlighting
wjt 778c8d7
Script Window: Don't clamp font color alpha channel to 0.65
wjt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,31 @@ extends Window | |
|
||
var script_content: String = "" | ||
|
||
@onready var script_label: TextEdit = $Margin/VBox/ColorRect/Scroll/Margin/Code | ||
@onready var script_label: CodeEdit = %Code | ||
|
||
|
||
## Attempts to match the syntax highlighting for some open script in the | ||
## editor, which is more likely to be appropriate for the editor theme | ||
## than our hardcoded default | ||
func _apply_editor_syntax_highlighter(): | ||
var script_editor: ScriptEditor = EditorInterface.get_script_editor() | ||
for x in script_editor.get_open_script_editors(): | ||
var control: Control = x.get_base_editor() | ||
if control is TextEdit: | ||
script_label.syntax_highlighter = control.syntax_highlighter | ||
break | ||
|
||
|
||
## Undoes the effect of the CodeEdit being read-only | ||
func _remove_font_color_alpha_clamp(): | ||
var font_readonly_color = script_label.get_theme_color("font_readonly_color") | ||
font_readonly_color.a = 1 | ||
script_label.add_theme_color_override("font_readonly_color", font_readonly_color) | ||
Comment on lines
+24
to
+25
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. Good finding, I didn't know the read-only was doing that. Thanks for digging the sourcecode. |
||
|
||
|
||
func _ready(): | ||
popup_centered() | ||
_apply_editor_syntax_highlighter() | ||
_remove_font_color_alpha_clamp() | ||
script_label.text = script_content.replace("\t", " ") | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Awesome!