Debian Codegraph @

editor/script/script_editor_plugin.h

raw symbols SCIP
1 /**************************************************************************/
2 /* script_editor_plugin.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "core/object/script_language.h"
34 #include "editor/plugins/editor_plugin.h"
35 #include "scene/gui/dialogs.h"
36 #include "scene/gui/panel_container.h"
37 #include "scene/resources/syntax_highlighter.h"
38 #include "scene/resources/text_file.h"
39
40 class CodeTextEditor;
41 class EditorFileDialog;
42 class EditorHelpSearch;
43 class FindReplaceBar;
44 class HSplitContainer;
45 class ItemList;
46 class MenuButton;
47 class TabContainer;
48 class TextureRect;
49 class Tree;
50 class VSplitContainer;
51 class WindowWrapper;
52
53 class EditorSyntaxHighlighter : public SyntaxHighlighter {
54 GDCLASS(EditorSyntaxHighlighter, SyntaxHighlighter)
55
56 private:
57 Ref<RefCounted> edited_resource;
58
59 protected:
60 static void _bind_methods();
61
62 GDVIRTUAL0RC(String, _get_name)
63 GDVIRTUAL0RC(PackedStringArray, _get_supported_languages)
64 GDVIRTUAL0RC(Ref<EditorSyntaxHighlighter>, _create)
65
66 public:
67 virtual String _get_name() const;
68 virtual PackedStringArray _get_supported_languages() const;
69
70 void _set_edited_resource(const Ref<Resource> &p_res) { edited_resource = p_res; }
71 Ref<RefCounted> _get_edited_resource() { return edited_resource; }
72
73 virtual Ref<EditorSyntaxHighlighter> _create() const;
74 };
75
76 class EditorStandardSyntaxHighlighter : public EditorSyntaxHighlighter {
77 GDCLASS(EditorStandardSyntaxHighlighter, EditorSyntaxHighlighter)
78
79 private:
80 Ref<CodeHighlighter> highlighter;
81 ScriptLanguage *script_language = nullptr; // See GH-89610.
82
83 public:
84 virtual void _update_cache() override;
85 virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
86
87 virtual String _get_name() const override { return TTR("Standard"); }
88
89 virtual Ref<EditorSyntaxHighlighter> _create() const override;
90
91 void _set_script_language(ScriptLanguage *p_script_language) { script_language = p_script_language; }
92
93 EditorStandardSyntaxHighlighter() { highlighter.instantiate(); }
94 };
95
96 class EditorPlainTextSyntaxHighlighter : public EditorSyntaxHighlighter {
97 GDCLASS(EditorPlainTextSyntaxHighlighter, EditorSyntaxHighlighter)
98
99 public:
100 virtual String _get_name() const override { return TTR("Plain Text"); }
101
102 virtual Ref<EditorSyntaxHighlighter> _create() const override;
103 };
104
105 class EditorJSONSyntaxHighlighter : public EditorSyntaxHighlighter {
106 GDCLASS(EditorJSONSyntaxHighlighter, EditorSyntaxHighlighter)
107
108 private:
109 Ref<CodeHighlighter> highlighter;
110
111 public:
112 virtual void _update_cache() override;
113 virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
114
115 virtual PackedStringArray _get_supported_languages() const override { return PackedStringArray{ "json" }; }
116 virtual String _get_name() const override { return TTR("JSON"); }
117
118 virtual Ref<EditorSyntaxHighlighter> _create() const override;
119
120 EditorJSONSyntaxHighlighter() { highlighter.instantiate(); }
121 };
122
123 class EditorMarkdownSyntaxHighlighter : public EditorSyntaxHighlighter {
124 GDCLASS(EditorMarkdownSyntaxHighlighter, EditorSyntaxHighlighter)
125
126 private:
127 Ref<CodeHighlighter> highlighter;
128
129 public:
130 virtual void _update_cache() override;
131 virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
132
133 virtual PackedStringArray _get_supported_languages() const override { return PackedStringArray{ "md", "markdown" }; }
134 virtual String _get_name() const override { return TTR("Markdown"); }
135
136 virtual Ref<EditorSyntaxHighlighter> _create() const override;
137
138 EditorMarkdownSyntaxHighlighter() { highlighter.instantiate(); }
139 };
140
141 class EditorConfigFileSyntaxHighlighter : public EditorSyntaxHighlighter {
142 GDCLASS(EditorConfigFileSyntaxHighlighter, EditorSyntaxHighlighter)
143
144 private:
145 Ref<CodeHighlighter> highlighter;
146
147 public:
148 virtual void _update_cache() override;
149 virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
150
151 // While not explicitly designed for those formats, this highlighter happens
152 // to handle TSCN, TRES, `project.godot` well. We can expose it in case the
153 // user opens one of these using the script editor (which can be done using
154 // the All Files filter).
155 virtual PackedStringArray _get_supported_languages() const override { return PackedStringArray{ "ini", "cfg", "tscn", "tres", "godot" }; }
156 virtual String _get_name() const override { return TTR("ConfigFile"); }
157
158 virtual Ref<EditorSyntaxHighlighter> _create() const override;
159
160 EditorConfigFileSyntaxHighlighter() { highlighter.instantiate(); }
161 };
162
163 ///////////////////////////////////////////////////////////////////////////////
164
165 class ScriptEditorQuickOpen : public ConfirmationDialog {
166 GDCLASS(ScriptEditorQuickOpen, ConfirmationDialog);
167
168 LineEdit *search_box = nullptr;
169 Tree *search_options = nullptr;
170 String function;
171
172 void _update_search();
173
174 void _sbox_input(const Ref<InputEvent> &p_event);
175 Vector<String> functions;
176
177 void _confirmed();
178 void _text_changed(const String &p_newtext);
179
180 protected:
181 void _notification(int p_what);
182 static void _bind_methods();
183
184 public:
185 void popup_dialog(const Vector<String> &p_functions, bool p_dontclear = false);
186 ScriptEditorQuickOpen();
187 };
188
189 class EditorDebuggerNode;
190
191 class ScriptEditorBase : public VBoxContainer {
192 GDCLASS(ScriptEditorBase, VBoxContainer);
193
194 protected:
195 static void _bind_methods();
196
197 public:
198 struct EditedFileData {
199 String path;
200 uint64_t last_modified_time = -1;
201 } edited_file_data;
202
203 virtual void add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
204 virtual void set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
205
206 virtual void apply_code() = 0;
207 virtual Ref<Resource> get_edited_resource() const = 0;
208 virtual Vector<String> get_functions() = 0;
209 virtual void set_edited_resource(const Ref<Resource> &p_res) = 0;
210 virtual void enable_editor(Control *p_shortcut_context = nullptr) = 0;
211 virtual void reload_text() = 0;
212 virtual String get_name() = 0;
213 virtual Ref<Texture2D> get_theme_icon() = 0;
214 virtual bool is_unsaved() = 0;
215 virtual Variant get_edit_state() = 0;
216 virtual void set_edit_state(const Variant &p_state) = 0;
217 virtual Variant get_navigation_state() = 0;
218 virtual void goto_line(int p_line, int p_column = 0) = 0;
219 virtual void set_executing_line(int p_line) = 0;
220 virtual void clear_executing_line() = 0;
221 virtual void trim_trailing_whitespace() = 0;
222 virtual void trim_final_newlines() = 0;
223 virtual void insert_final_newline() = 0;
224 virtual void convert_indent() = 0;
225 virtual void ensure_focus() = 0;
226 virtual void tag_saved_version() = 0;
227 virtual void reload(bool p_soft) {}
228 virtual PackedInt32Array get_breakpoints() = 0;
229 virtual void set_breakpoint(int p_line, bool p_enabled) = 0;
230 virtual void clear_breakpoints() = 0;
231 virtual void add_callback(const String &p_function, const PackedStringArray &p_args) = 0;
232 virtual void update_settings() = 0;
233 virtual void set_debugger_active(bool p_active) = 0;
234 virtual void update_toggle_files_button() {}
235
236 virtual bool show_members_overview() = 0;
237
238 virtual void set_tooltip_request_func(const Callable &p_toolip_callback) = 0;
239 virtual Control *get_edit_menu() = 0;
240 virtual void clear_edit_menu() = 0;
241 virtual void set_find_replace_bar(FindReplaceBar *p_bar) = 0;
242
243 virtual Control *get_base_editor() const = 0;
244 virtual CodeTextEditor *get_code_editor() const = 0;
245
246 virtual void validate() = 0;
247 };
248
249 typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const Ref<Resource> &p_resource);
250
251 class EditorScriptCodeCompletionCache;
252 class FindInFilesContainer;
253 class FindInFilesDialog;
254
255 class ScriptEditor : public PanelContainer {
256 GDCLASS(ScriptEditor, PanelContainer);
257
258 enum MenuOptions {
259 // File.
260 FILE_MENU_NEW,
261 FILE_MENU_NEW_TEXTFILE,
262 FILE_MENU_OPEN,
263 FILE_MENU_REOPEN_CLOSED,
264 FILE_MENU_OPEN_RECENT,
265
266 FILE_MENU_SAVE,
267 FILE_MENU_SAVE_AS,
268 FILE_MENU_SAVE_ALL,
269
270 FILE_MENU_SOFT_RELOAD_TOOL,
271 FILE_MENU_COPY_PATH,
272 FILE_MENU_COPY_UID,
273 FILE_MENU_SHOW_IN_FILE_SYSTEM,
274
275 FILE_MENU_HISTORY_PREV,
276 FILE_MENU_HISTORY_NEXT,
277
278 FILE_MENU_THEME_SUBMENU,
279
280 FILE_MENU_CLOSE,
281 FILE_MENU_CLOSE_ALL,
282 FILE_MENU_CLOSE_OTHER_TABS,
283 FILE_MENU_CLOSE_TABS_BELOW,
284 FILE_MENU_CLOSE_DOCS,
285
286 FILE_MENU_RUN,
287
288 FILE_MENU_TOGGLE_FILES_PANEL,
289
290 FILE_MENU_MOVE_UP,
291 FILE_MENU_MOVE_DOWN,
292 FILE_MENU_SORT,
293
294 // Search.
295 HELP_SEARCH_FIND,
296 HELP_SEARCH_FIND_NEXT,
297 HELP_SEARCH_FIND_PREVIOUS,
298
299 SEARCH_IN_FILES,
300 REPLACE_IN_FILES,
301
302 SEARCH_HELP,
303 SEARCH_WEBSITE,
304
305 // Theme.
306 THEME_IMPORT,
307 THEME_RELOAD,
308 THEME_SAVE_AS,
309 };
310
311 enum ScriptSortBy {
312 SORT_BY_NAME,
313 SORT_BY_PATH,
314 SORT_BY_NONE,
315 };
316
317 enum ScriptListName {
318 DISPLAY_NAME,
319 DISPLAY_DIR_AND_NAME,
320 DISPLAY_FULL_PATH,
321 };
322
323 HBoxContainer *menu_hb = nullptr;
324 MenuButton *file_menu = nullptr;
325 MenuButton *edit_menu = nullptr;
326 MenuButton *script_search_menu = nullptr;
327 MenuButton *debug_menu = nullptr;
328 PopupMenu *context_menu = nullptr;
329 Timer *autosave_timer = nullptr;
330
331 PopupMenu *recent_scripts = nullptr;
332 PopupMenu *theme_submenu = nullptr;
333
334 Button *help_search = nullptr;
335 Button *site_search = nullptr;
336 Button *make_floating = nullptr;
337 bool is_floating = false;
338 EditorHelpSearch *help_search_dialog = nullptr;
339
340 ItemList *script_list = nullptr;
341 HSplitContainer *script_split = nullptr;
342 ItemList *members_overview = nullptr;
343 LineEdit *filter_scripts = nullptr;
344 LineEdit *filter_methods = nullptr;
345 VBoxContainer *scripts_vbox = nullptr;
346 VBoxContainer *overview_vbox = nullptr;
347 HBoxContainer *buttons_hbox = nullptr;
348 Button *members_overview_alphabeta_sort_button = nullptr;
349 bool members_overview_enabled;
350 ItemList *help_overview = nullptr;
351 bool help_overview_enabled;
352 VSplitContainer *list_split = nullptr;
353 TabContainer *tab_container = nullptr;
354 EditorFileDialog *file_dialog = nullptr;
355 AcceptDialog *error_dialog = nullptr;
356 ConfirmationDialog *erase_tab_confirm = nullptr;
357 ScriptCreateDialog *script_create_dialog = nullptr;
358 FindReplaceBar *find_replace_bar = nullptr;
359
360 float zoom_factor = 1.0f;
361
362 Label *script_name_label = nullptr;
363
364 Button *script_back = nullptr;
365 Button *script_forward = nullptr;
366
367 FindInFilesDialog *find_in_files_dialog = nullptr;
368 FindInFilesContainer *find_in_files = nullptr;
369
370 WindowWrapper *window_wrapper = nullptr;
371
372 #ifdef ANDROID_ENABLED
373 Control *virtual_keyboard_spacer = nullptr;
374 int last_kb_height = -1;
375 #endif
376
377 enum {
378 SCRIPT_EDITOR_FUNC_MAX = 32,
379 };
380
381 static int script_editor_func_count;
382 static CreateScriptEditorFunc script_editor_funcs[SCRIPT_EDITOR_FUNC_MAX];
383
384 Vector<Ref<EditorSyntaxHighlighter>> syntax_highlighters;
385
386 struct ScriptHistory {
387 Control *control = nullptr;
388 Variant state;
389 };
390
391 Vector<ScriptHistory> history;
392 int history_pos;
393
394 List<String> previous_scripts;
395 List<int> script_close_queue;
396
397 void _tab_changed(int p_which);
398 void _menu_option(int p_option);
399 void _theme_option(int p_option);
400 void _show_save_theme_as_dialog();
401 bool _has_docs_tab() const;
402 bool _has_script_tab() const;
403 void _prepare_file_menu();
404 void _file_menu_closed();
405
406 Tree *disk_changed_list = nullptr;
407 ConfirmationDialog *disk_changed = nullptr;
408
409 bool restoring_layout;
410
411 void _resave_scripts(const String &p_str);
412
413 bool _test_script_times_on_disk(Ref<Resource> p_for_script = Ref<Resource>());
414 bool _script_exists(const String &p_path) const;
415
416 void _add_recent_script(const String &p_path);
417 void _update_recent_scripts();
418 void _open_recent_script(int p_idx);
419
420 void _show_error_dialog(const String &p_path);
421
422 void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true);
423 void _update_find_replace_bar();
424
425 void _close_current_tab(bool p_save = true, bool p_history_back = true);
426 void _close_discard_current_tab(const String &p_str);
427 void _close_docs_tab();
428 void _close_other_tabs();
429 void _close_tabs_below();
430 void _close_all_tabs();
431 void _queue_close_tabs();
432
433 void _copy_script_path();
434 void _copy_script_uid();
435
436 void _ask_close_current_unsaved_tab(ScriptEditorBase *current);
437
438 bool grab_focus_block;
439
440 bool pending_auto_reload;
441 bool auto_reload_running_scripts;
442 Vector<String> script_paths_to_reload;
443 void _live_auto_reload_running_scripts();
444
445 void _update_selected_editor_menu();
446
447 void _editor_stop();
448
449 int edit_pass;
450
451 void _add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args);
452 void _res_saved_callback(const Ref<Resource> &p_res);
453 void _scene_saved_callback(const String &p_path);
454 void _mark_built_in_scripts_as_saved(const String &p_parent_path);
455
456 bool trim_trailing_whitespace_on_save;
457 bool trim_final_newlines_on_save;
458 bool convert_indent_on_save;
459 bool external_editor_active;
460
461 void _goto_script_line2(int p_line);
462 void _goto_script_line(Ref<RefCounted> p_script, int p_line);
463 void _set_execution(Ref<RefCounted> p_script, int p_line);
464 void _clear_execution(Ref<RefCounted> p_script);
465 String _get_debug_tooltip(const String &p_text, Node *p_se);
466 void _breaked(bool p_breaked, bool p_can_debug);
467 void _script_created(Ref<Script> p_script);
468 void _set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_enabled);
469 void _clear_breakpoints();
470 Array _get_cached_breakpoints_for_script(const String &p_path) const;
471
472 ScriptEditorBase *_get_current_editor() const;
473 TypedArray<ScriptEditorBase> _get_open_script_editors() const;
474
475 Ref<ConfigFile> script_editor_cache;
476 void _save_editor_state(ScriptEditorBase *p_editor);
477 void _save_layout();
478 void _apply_editor_settings();
479 void _filesystem_changed();
480 void _files_moved(const String &p_old_file, const String &p_new_file);
481 void _file_removed(const String &p_file);
482 void _autosave_scripts();
483 void _update_autosave_timer();
484 void _reload_scripts(bool p_refresh_only = false);
485
486 void _update_members_overview_visibility();
487 void _update_members_overview();
488 void _toggle_members_overview_alpha_sort(bool p_alphabetic_sort);
489 void _filter_scripts_text_changed(const String &p_newtext);
490 void _filter_methods_text_changed(const String &p_newtext);
491 void _update_script_names();
492 bool _sort_list_on_update;
493
494 void _members_overview_selected(int p_idx);
495 void _script_selected(int p_idx);
496
497 void _update_help_overview_visibility();
498 void _update_help_overview();
499 void _help_overview_selected(int p_idx);
500
501 void _update_online_doc();
502
503 void _find_scripts(Node *p_base, Node *p_current, HashSet<Ref<Script>> &used);
504
505 void _tree_changed();
506
507 void _split_dragged(float);
508
509 Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
510 bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
511 void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
512
513 virtual void input(const Ref<InputEvent> &p_event) override;
514 virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
515
516 void _script_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index);
517 void _make_script_list_context_menu();
518
519 void _help_search(const String &p_text);
520
521 void _history_forward();
522 void _history_back();
523
524 bool waiting_update_names;
525 bool lock_history = false;
526 void _unlock_history();
527
528 void _help_class_open(const String &p_class);
529 void _help_class_goto(const String &p_desc);
530 bool _help_tab_goto(const String &p_name, const String &p_desc);
531 void _update_history_arrows();
532 void _save_history();
533 void _save_previous_state(Dictionary p_state);
534 void _go_to_tab(int p_idx);
535 void _update_history_pos(int p_new_pos);
536 void _update_script_colors();
537 void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script = Ref<Script>());
538
539 void _script_changed();
540 int file_dialog_option;
541 void _file_dialog_action(const String &p_file);
542
543 Ref<Script> _get_current_script();
544 TypedArray<Script> _get_open_scripts() const;
545
546 HashSet<String> textfile_extensions;
547 Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const;
548 Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path);
549
550 void _on_replace_in_files_requested(const String &text);
551 void _on_find_in_files_result_selected(const String &fpath, int line_number, int begin, int end);
552 void _start_find_in_files(bool with_replace);
553 void _on_find_in_files_modified_files(const PackedStringArray &paths);
554
555 void _set_script_zoom_factor(float p_zoom_factor);
556 void _update_code_editor_zoom_factor(CodeTextEditor *p_code_text_editor);
557
558 void _window_changed(bool p_visible);
559
560 static void _open_script_request(const String &p_path);
561 void _close_builtin_scripts_from_scene(const String &p_scene);
562
563 static ScriptEditor *script_editor;
564
565 protected:
566 void _notification(int p_what);
567 static void _bind_methods();
568
569 public:
570 static ScriptEditor *get_singleton() { return script_editor; }
571
572 bool toggle_files_panel();
573 bool is_files_panel_toggled();
574 void apply_scripts() const;
575 void reload_scripts(bool p_refresh_only = false);
576 void open_find_in_files_dialog(const String &text);
577 void open_script_create_dialog(const String &p_base_name, const String &p_base_path);
578 void open_text_file_create_dialog(const String &p_base_path, const String &p_base_name = "");
579 Ref<Resource> open_file(const String &p_file);
580
581 void ensure_select_current();
582
583 bool is_editor_floating();
584
585 _FORCE_INLINE_ bool edit(const Ref<Resource> &p_resource, bool p_grab_focus = true) { return edit(p_resource, -1, 0, p_grab_focus); }
586 bool edit(const Ref<Resource> &p_resource, int p_line, int p_col, bool p_grab_focus = true);
587
588 Vector<String> _get_breakpoints();
589 void get_breakpoints(List<String> *p_breakpoints);
590
591 PackedStringArray get_unsaved_scripts() const;
592 void save_current_script();
593 void save_all_scripts();
594 void update_script_times();
595
596 void set_window_layout(Ref<ConfigFile> p_layout);
597 void get_window_layout(Ref<ConfigFile> p_layout);
598
599 void set_scene_root_script(Ref<Script> p_script);
600 Vector<Ref<Script>> get_open_scripts() const;
601
602 bool script_goto_method(Ref<Script> p_script, const String &p_method);
603
604 virtual void edited_scene_changed();
605
606 void notify_script_close(const Ref<Script> &p_script);
607 void notify_script_changed(const Ref<Script> &p_script);
608
609 void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
610 void update_doc(const String &p_name);
611 void clear_docs_from_script(const Ref<Script> &p_script);
612 void update_docs_from_script(const Ref<Script> &p_script);
613
614 void trigger_live_script_reload(const String &p_script_path);
615
616 VSplitContainer *get_left_list_split() { return list_split; }
617
618 void set_live_auto_reload_running_scripts(bool p_enabled);
619
620 void register_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
621 void unregister_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
622
623 static void register_create_script_editor_function(CreateScriptEditorFunc p_func);
624
625 ScriptEditor(WindowWrapper *p_wrapper);
626 };
627
628 class ScriptEditorPlugin : public EditorPlugin {
629 GDCLASS(ScriptEditorPlugin, EditorPlugin);
630
631 ScriptEditor *script_editor = nullptr;
632 WindowWrapper *window_wrapper = nullptr;
633
634 String last_editor;
635
636 void _focus_another_editor();
637
638 void _save_last_editor(const String &p_editor);
639 void _window_visibility_changed(bool p_visible);
640
641 protected:
642 void _notification(int p_what);
643
644 public:
645 static bool open_in_external_editor(const String &p_path, int p_line, int p_col, bool p_ignore_project = false);
646
647 virtual String get_plugin_name() const override { return TTRC("Script"); }
648 bool has_main_screen() const override { return true; }
649 virtual void edit(Object *p_object) override;
650 virtual bool handles(Object *p_object) const override;
651 virtual void make_visible(bool p_visible) override;
652 virtual void selected_notify() override;
653
654 virtual String get_unsaved_status(const String &p_for_scene) const override;
655 virtual void save_external_data() override;
656 virtual void apply_changes() override;
657
658 virtual void set_window_layout(Ref<ConfigFile> p_layout) override;
659 virtual void get_window_layout(Ref<ConfigFile> p_layout) override;
660
661 virtual void get_breakpoints(List<String> *p_breakpoints) override;
662
663 virtual void edited_scene_changed() override;
664
665 ScriptEditorPlugin();
666 };