Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/script/script_editor_plugin.h
9903 views
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 FindInFilesDialog;
253
class FindInFilesPanel;
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
uint64_t idle = 0;
331
332
PopupMenu *recent_scripts = nullptr;
333
PopupMenu *theme_submenu = nullptr;
334
335
Button *help_search = nullptr;
336
Button *site_search = nullptr;
337
Button *make_floating = nullptr;
338
bool is_floating = false;
339
EditorHelpSearch *help_search_dialog = nullptr;
340
341
ItemList *script_list = nullptr;
342
HSplitContainer *script_split = nullptr;
343
ItemList *members_overview = nullptr;
344
LineEdit *filter_scripts = nullptr;
345
LineEdit *filter_methods = nullptr;
346
VBoxContainer *scripts_vbox = nullptr;
347
VBoxContainer *overview_vbox = nullptr;
348
HBoxContainer *buttons_hbox = nullptr;
349
Label *filename = nullptr;
350
Button *members_overview_alphabeta_sort_button = nullptr;
351
bool members_overview_enabled;
352
ItemList *help_overview = nullptr;
353
bool help_overview_enabled;
354
VSplitContainer *list_split = nullptr;
355
TabContainer *tab_container = nullptr;
356
EditorFileDialog *file_dialog = nullptr;
357
AcceptDialog *error_dialog = nullptr;
358
ConfirmationDialog *erase_tab_confirm = nullptr;
359
ScriptCreateDialog *script_create_dialog = nullptr;
360
Button *scripts_visible = nullptr;
361
FindReplaceBar *find_replace_bar = nullptr;
362
363
float zoom_factor = 1.0f;
364
365
TextureRect *script_icon = nullptr;
366
Label *script_name_label = nullptr;
367
368
Button *script_back = nullptr;
369
Button *script_forward = nullptr;
370
371
FindInFilesDialog *find_in_files_dialog = nullptr;
372
FindInFilesPanel *find_in_files = nullptr;
373
Button *find_in_files_button = nullptr;
374
375
WindowWrapper *window_wrapper = nullptr;
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
415
void _add_recent_script(const String &p_path);
416
void _update_recent_scripts();
417
void _open_recent_script(int p_idx);
418
419
void _show_error_dialog(const String &p_path);
420
421
void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true);
422
void _update_find_replace_bar();
423
424
void _close_current_tab(bool p_save = true, bool p_history_back = true);
425
void _close_discard_current_tab(const String &p_str);
426
void _close_docs_tab();
427
void _close_other_tabs();
428
void _close_tabs_below();
429
void _close_all_tabs();
430
void _queue_close_tabs();
431
432
void _copy_script_path();
433
void _copy_script_uid();
434
435
void _ask_close_current_unsaved_tab(ScriptEditorBase *current);
436
437
bool grab_focus_block;
438
439
bool pending_auto_reload;
440
bool auto_reload_running_scripts;
441
bool reload_all_scripts = false;
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 open_textfile_after_create = true;
457
bool trim_trailing_whitespace_on_save;
458
bool trim_final_newlines_on_save;
459
bool convert_indent_on_save;
460
bool external_editor_active;
461
462
void _goto_script_line2(int p_line);
463
void _goto_script_line(Ref<RefCounted> p_script, int p_line);
464
void _set_execution(Ref<RefCounted> p_script, int p_line);
465
void _clear_execution(Ref<RefCounted> p_script);
466
String _get_debug_tooltip(const String &p_text, Node *p_se);
467
void _breaked(bool p_breaked, bool p_can_debug);
468
void _script_created(Ref<Script> p_script);
469
void _set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_enabled);
470
void _clear_breakpoints();
471
Array _get_cached_breakpoints_for_script(const String &p_path) const;
472
473
ScriptEditorBase *_get_current_editor() const;
474
TypedArray<ScriptEditorBase> _get_open_script_editors() const;
475
476
Ref<ConfigFile> script_editor_cache;
477
void _save_editor_state(ScriptEditorBase *p_editor);
478
void _save_layout();
479
void _editor_settings_changed();
480
void _apply_editor_settings();
481
void _filesystem_changed();
482
void _files_moved(const String &p_old_file, const String &p_new_file);
483
void _file_removed(const String &p_file);
484
void _autosave_scripts();
485
void _update_autosave_timer();
486
void _reload_scripts(bool p_refresh_only = false);
487
488
void _update_members_overview_visibility();
489
void _update_members_overview();
490
void _toggle_members_overview_alpha_sort(bool p_alphabetic_sort);
491
void _filter_scripts_text_changed(const String &p_newtext);
492
void _filter_methods_text_changed(const String &p_newtext);
493
void _update_script_names();
494
bool _sort_list_on_update;
495
496
void _members_overview_selected(int p_idx);
497
void _script_selected(int p_idx);
498
499
void _update_help_overview_visibility();
500
void _update_help_overview();
501
void _help_overview_selected(int p_idx);
502
503
void _update_online_doc();
504
505
void _find_scripts(Node *p_base, Node *p_current, HashSet<Ref<Script>> &used);
506
507
void _tree_changed();
508
509
void _split_dragged(float);
510
511
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
512
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
513
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
514
515
virtual void input(const Ref<InputEvent> &p_event) override;
516
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
517
518
void _script_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index);
519
void _make_script_list_context_menu();
520
521
void _help_search(const String &p_text);
522
523
void _history_forward();
524
void _history_back();
525
526
bool waiting_update_names;
527
bool lock_history = false;
528
529
void _help_class_open(const String &p_class);
530
void _help_class_goto(const String &p_desc);
531
bool _help_tab_goto(const String &p_name, const String &p_desc);
532
void _update_history_arrows();
533
void _save_history();
534
void _save_previous_state(Dictionary p_state);
535
void _go_to_tab(int p_idx);
536
void _update_history_pos(int p_new_pos);
537
void _update_script_colors();
538
void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script = Ref<Script>());
539
540
void _script_changed();
541
int file_dialog_option;
542
void _file_dialog_action(const String &p_file);
543
544
Ref<Script> _get_current_script();
545
TypedArray<Script> _get_open_scripts() const;
546
547
HashSet<String> textfile_extensions;
548
Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const;
549
Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path);
550
551
void _on_replace_in_files_requested(const String &text);
552
void _on_find_in_files_result_selected(const String &fpath, int line_number, int begin, int end);
553
void _start_find_in_files(bool with_replace);
554
void _on_find_in_files_modified_files(const PackedStringArray &paths);
555
void _on_find_in_files_close_button_clicked();
556
557
void _set_script_zoom_factor(float p_zoom_factor);
558
void _update_code_editor_zoom_factor(CodeTextEditor *p_code_text_editor);
559
560
void _window_changed(bool p_visible);
561
562
static void _open_script_request(const String &p_path);
563
void _close_builtin_scripts_from_scene(const String &p_scene);
564
565
static ScriptEditor *script_editor;
566
567
protected:
568
void _notification(int p_what);
569
static void _bind_methods();
570
571
public:
572
static ScriptEditor *get_singleton() { return script_editor; }
573
574
bool toggle_files_panel();
575
bool is_files_panel_toggled();
576
void apply_scripts() const;
577
void reload_scripts(bool p_refresh_only = false);
578
void open_find_in_files_dialog(const String &text);
579
void open_script_create_dialog(const String &p_base_name, const String &p_base_path);
580
void open_text_file_create_dialog(const String &p_base_path, const String &p_base_name = "");
581
Ref<Resource> open_file(const String &p_file);
582
583
void ensure_select_current();
584
585
bool is_editor_floating();
586
587
_FORCE_INLINE_ bool edit(const Ref<Resource> &p_resource, bool p_grab_focus = true) { return edit(p_resource, -1, 0, p_grab_focus); }
588
bool edit(const Ref<Resource> &p_resource, int p_line, int p_col, bool p_grab_focus = true);
589
590
Vector<String> _get_breakpoints();
591
void get_breakpoints(List<String> *p_breakpoints);
592
593
PackedStringArray get_unsaved_scripts() const;
594
void save_current_script();
595
void save_all_scripts();
596
void update_script_times();
597
598
void set_window_layout(Ref<ConfigFile> p_layout);
599
void get_window_layout(Ref<ConfigFile> p_layout);
600
601
void set_scene_root_script(Ref<Script> p_script);
602
Vector<Ref<Script>> get_open_scripts() const;
603
604
bool script_goto_method(Ref<Script> p_script, const String &p_method);
605
606
virtual void edited_scene_changed();
607
608
void notify_script_close(const Ref<Script> &p_script);
609
void notify_script_changed(const Ref<Script> &p_script);
610
611
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
612
void update_doc(const String &p_name);
613
void clear_docs_from_script(const Ref<Script> &p_script);
614
void update_docs_from_script(const Ref<Script> &p_script);
615
616
void trigger_live_script_reload(const String &p_script_path);
617
void trigger_live_script_reload_all();
618
619
VSplitContainer *get_left_list_split() { return list_split; }
620
621
void set_live_auto_reload_running_scripts(bool p_enabled);
622
623
void register_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
624
void unregister_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
625
626
static void register_create_script_editor_function(CreateScriptEditorFunc p_func);
627
628
ScriptEditor(WindowWrapper *p_wrapper);
629
};
630
631
class ScriptEditorPlugin : public EditorPlugin {
632
GDCLASS(ScriptEditorPlugin, EditorPlugin);
633
634
ScriptEditor *script_editor = nullptr;
635
WindowWrapper *window_wrapper = nullptr;
636
637
String last_editor;
638
639
void _focus_another_editor();
640
641
void _save_last_editor(const String &p_editor);
642
void _window_visibility_changed(bool p_visible);
643
644
protected:
645
void _notification(int p_what);
646
647
public:
648
virtual String get_plugin_name() const override { return TTRC("Script"); }
649
bool has_main_screen() const override { return true; }
650
virtual void edit(Object *p_object) override;
651
virtual bool handles(Object *p_object) const override;
652
virtual void make_visible(bool p_visible) override;
653
virtual void selected_notify() override;
654
655
virtual String get_unsaved_status(const String &p_for_scene) const override;
656
virtual void save_external_data() override;
657
virtual void apply_changes() override;
658
659
virtual void set_window_layout(Ref<ConfigFile> p_layout) override;
660
virtual void get_window_layout(Ref<ConfigFile> p_layout) override;
661
662
virtual void get_breakpoints(List<String> *p_breakpoints) override;
663
664
virtual void edited_scene_changed() override;
665
666
ScriptEditorPlugin();
667
};
668
669